-
Notifications
You must be signed in to change notification settings - Fork 1
/
ROMCheck.cpp
29 lines (25 loc) · 960 Bytes
/
ROMCheck.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
#include "ROMCheck.h"
ROMStatus CheckOriginalROM(std::fstream &ROMFile) {
unsigned char FileStartSample[5];
ROMFile.seekg(0, std::ios::beg);
ROMFile.read((char*)(&(FileStartSample[0])), 1);
ROMFile.read((char*)(&(FileStartSample[1])), 1);
ROMFile.read((char*)(&(FileStartSample[2])), 1);
ROMFile.read((char*)(&(FileStartSample[3])), 1);
FileStartSample[4] = '\0';
/* Read first bytes to identify if this ROM is the headered or the un-headered one.
I should do this with an actual hash or checksum later. */
if (FileStartSample[0] == 0x78 &&
FileStartSample[1] == 0xD8 &&
FileStartSample[2] == 0x18 &&
FileStartSample[3] == 0xFB) {
return UNHEADERED;
}
else if (FileStartSample[0] == 0x80 &&
FileStartSample[1] == 0x00 &&
FileStartSample[2] == 0x00 &&
FileStartSample[3] == 0x00) {
return HEADERED;
}
return UNKNOWN;
}