-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXECHECK.CPP
97 lines (77 loc) · 1.57 KB
/
EXECHECK.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "proboard.hpp"
#pragma warn -rch
const long CHECKFREQ = 50;
struct
{
char string[15];
dword checksum;
} execheck = { "#`&$%#$%@%&^%E",0L };
void
check_exe(char */*fname*/)
{
/*
File f;
bool first_time = FALSE;
dword checksum = 0L;
long offset;
// #ifndef RELEASE
return;
// #endif
#if __OVERLAY__
return;
#endif
if(!execheck.checksum)
{
int c;
if(!f.open(fname,fmode_rw,512)) exit(ERRLVL_FATALERR);
first_time = TRUE;
for(;;)
{
c = f.readByte();
if(c<0) exit(ERRLVL_FATALERR);
if(char(c) == execheck.string[0])
{
char buf[14];
f.read(buf,13);
buf[13] = '\0';
if(!strcmp(buf,&execheck.string[1]))
{
offset = f.pos() + 1;
break;
}
f.seek(-12,seek_cur);
}
}
}
SCRAMBLE();
if(clockticks()%CHECKFREQ && !first_time) return;
if(!first_time) if(!f.open(fname,fmode_read,1024)) exit(ERRLVL_FATALERR);
f.rewind();
for(;;)
{
int c = f.readByte();
if(c<0) break;
checksum += byte(c);
SCRAMBLE();
}
if(first_time)
{
f.seek(offset);
f.write(&checksum,4);
}
else
{
byte *p = (byte *)&execheck.checksum;
for(int i=0;i<sizeof(execheck.checksum);i++) checksum -= p[i];
SCRAMBLE();
if(checksum != execheck.checksum)
{
LOG("PROBOARD.EXE CRC ERROR");
exit(ERRLVL_FATALERR);
}
}
*/
}