mirror of
https://github.com/QuasarApp/pe-parse.git
synced 2025-04-26 12:24:32 +00:00
.
This commit is contained in:
parent
83c258e202
commit
faf770c598
@ -82,6 +82,9 @@ bounded_buffer *readFileToFileBuffer(const char *filePath) {
|
||||
//split buffer inclusively from from to to by offset
|
||||
bounded_buffer *splitBuffer(bounded_buffer *b, ::uint32_t from, ::uint32_t to) {
|
||||
//safety checks
|
||||
if(to < from || to >= b->bufLen) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//make a new buffer
|
||||
bounded_buffer *newBuff = new bounded_buffer();
|
||||
@ -91,9 +94,9 @@ bounded_buffer *splitBuffer(bounded_buffer *b, ::uint32_t from, ::uint32_t to) {
|
||||
}
|
||||
|
||||
newBuff->copy = true;
|
||||
|
||||
::uint8_t *curPtr = b->buf;
|
||||
::uint8_t *newPtr = curPtr+from;
|
||||
::uint8_t *newPtr = b->buf+from;
|
||||
newBuff->buf = newPtr;
|
||||
newBuff->bufLen = b->bufLen-(to-from);
|
||||
|
||||
return newBuff;
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ list<section> getSections(bounded_buffer *file) {
|
||||
}
|
||||
|
||||
bool readNtHeader(bounded_buffer *b, nt_header_32 &header) {
|
||||
if(b == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -34,6 +37,10 @@ bool readNtHeader(bounded_buffer *b, nt_header_32 &header) {
|
||||
bool getHeader(bounded_buffer *file) {
|
||||
pe_header p;
|
||||
|
||||
if(file == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//start by reading MZ
|
||||
::uint16_t tmp = 0;
|
||||
::uint32_t curOffset = 0;
|
||||
@ -51,8 +58,8 @@ bool getHeader(bounded_buffer *file) {
|
||||
curOffset += offset;
|
||||
|
||||
//now, we can read out the fields of the NT headers
|
||||
nt_header_32 nthdr;
|
||||
if(readNtHeader(splitBuffer(file, curOffset, file->bufLen), nthdr) == false) {
|
||||
nt_header_32 nt;
|
||||
if(readNtHeader(splitBuffer(file, curOffset, file->bufLen-1), nt) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user