Change pe_find_section interface again, add error handling
This commit is contained in:
parent
dcb482ab8e
commit
970561afb9
Binary file not shown.
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
struct pe_section_info {
|
IMAGE_SECTION_HEADER *pe_find_section(HMODULE module, const char *section);
|
||||||
void *base_address;
|
|
||||||
size_t initialized_size;
|
|
||||||
};
|
|
||||||
|
|
||||||
void pe_find_section(HMODULE module, const char *section, struct pe_section_info *buf);
|
|
||||||
void *pe_find_entry_point(HMODULE module);
|
void *pe_find_entry_point(HMODULE module);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
|
|
||||||
void pe_find_section(HMODULE module, const char *section, struct pe_section_info *buf) {
|
IMAGE_SECTION_HEADER *pe_find_section(HMODULE module, const char *section) {
|
||||||
char *cModule = (char*)module;
|
char *cModule = (char*)module;
|
||||||
|
|
||||||
IMAGE_DOS_HEADER* dosHeader = (IMAGE_DOS_HEADER*)module;
|
IMAGE_DOS_HEADER* dosHeader = (IMAGE_DOS_HEADER*)module;
|
||||||
@ -11,14 +11,13 @@ void pe_find_section(HMODULE module, const char *section, struct pe_section_info
|
|||||||
|
|
||||||
for (WORD i = 0; i < sectionCount; i++) {
|
for (WORD i = 0; i < sectionCount; i++) {
|
||||||
if (strncmp((char*)sectionHeader->Name, section, 8) == 0) {
|
if (strncmp((char*)sectionHeader->Name, section, 8) == 0) {
|
||||||
break;
|
return sectionHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionHeader++;
|
sectionHeader++;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->base_address = cModule + sectionHeader->VirtualAddress;
|
return NULL;
|
||||||
buf->initialized_size = sectionHeader->SizeOfRawData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pe_find_entry_point(HMODULE module) {
|
void *pe_find_entry_point(HMODULE module) {
|
||||||
|
Loading…
Reference in New Issue
Block a user