-
Notifications
You must be signed in to change notification settings - Fork 0
/
PLD.cpp
49 lines (29 loc) · 810 Bytes
/
PLD.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
#include "PLD.h"
PLD::PLD () {
}
PLD::~PLD() {
delete [] pldBuffer;
pldBuffer = NULL;
}
bool PLD::PLD_LoadFile(std::string fileName) {
FILE *pld = NULL;
pld = fopen(fileName.c_str(), "rb");
if (pld == NULL) {
std::cout << "Nao foi possivel encontrar o PDL !" << std::endl;
return false;
}
fseek(pld, 0, SEEK_END);
pldSize = ftell(pld);
rewind(pld);
pldBuffer = new unsigned char[pldSize];
fread(pldBuffer, pldSize, 0, pld);
// PLD HEADER
pldHeader = *(PLD_HEADER_T*)&(pldBuffer[0]);
pldFileSection = new unsigned int [pldHeader.dirCount];
for (unsigned int i = 0; i < (pldHeader.dirCount); i++) {
pldFileSection[i] = *(unsigned int*)(pldBuffer+pldHeader.dirOffset+(i*4));
printf("Section: %d - Offset: 0x%X\n", i, pldFileSection[i]);
}
fclose(pld);
return true;
}