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>
|
||||
|
||||
struct pe_section_info {
|
||||
void *base_address;
|
||||
size_t initialized_size;
|
||||
};
|
||||
IMAGE_SECTION_HEADER *pe_find_section(HMODULE module, const char *section);
|
||||
|
||||
void pe_find_section(HMODULE module, const char *section, struct pe_section_info *buf);
|
||||
void *pe_find_entry_point(HMODULE module);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#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;
|
||||
|
||||
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++) {
|
||||
if (strncmp((char*)sectionHeader->Name, section, 8) == 0) {
|
||||
break;
|
||||
return sectionHeader;
|
||||
}
|
||||
|
||||
sectionHeader++;
|
||||
}
|
||||
|
||||
buf->base_address = cModule + sectionHeader->VirtualAddress;
|
||||
buf->initialized_size = sectionHeader->SizeOfRawData;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *pe_find_entry_point(HMODULE module) {
|
||||
|
Loading…
Reference in New Issue
Block a user