Change pe_find_section interface again, add error handling

This commit is contained in:
mkrsym1 2023-08-04 14:28:30 +03:00
parent dcb482ab8e
commit 970561afb9
3 changed files with 5 additions and 10 deletions

Binary file not shown.

View File

@ -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);

View File

@ -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) {