-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpthread.cpp
70 lines (57 loc) · 1.87 KB
/
dumpthread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "dumpthread.h"
#include "vdskapi.h"
#include "functions.h"
#include <stdio.h>
#include "main.h"
#pragma package(smart_init)
extern TForm1 *Form1;
extern bool ramdisk;
extern unsigned long curdisksize, disksize;
extern LPVOID memory;
extern char savefile[128];
// ---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(&UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall dumpthread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
// ---------------------------------------------------------------------------
__fastcall dumpthread::dumpthread(bool CreateSuspended):TThread(CreateSuspended)
{
}
// ---------------------------------------------------------------------------
void __fastcall dumpthread::Execute()
{
NameThreadForDebugging("dumpthread");
// ---- Place thread code here ----
Form1->current->Text = "ñîçäàíèå îáðàçà ...";
deb("ñîõðàíÿåì â ôàéë %s ...\r\n \r\n", savefile);
Application->ProcessMessages();
char *b = new char[curdisksize];
if (!ramdisk)
nread((unsigned long)b, 0, curdisksize, 0);
else
memcpy(b, memory, curdisksize);
unlink(savefile);
dump(b, curdisksize, savefile);
int crc = checksum((unsigned short*)b, curdisksize);
char temp[129];
sprintf(temp, " * Îáðàç ñîõðàí¸í, CRC=0x%04X\r\n \r\n", crc);
deb(temp);
Form1->current->Text = temp;
delete[]b;
Form1->Button4->Enabled = true;
Application->ProcessMessages();
if (!ramdisk)
Form1->Button5Click(NULL);
}
// ---------------------------------------------------------------------------