Change pe_find_section interface
This commit is contained in:
parent
5e2b015cc0
commit
dcb482ab8e
Binary file not shown.
@ -2,5 +2,10 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
void pe_find_section(HMODULE module, const char *section, MEMORY_BASIC_INFORMATION *buf);
|
struct pe_section_info {
|
||||||
|
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, MEMORY_BASIC_INFORMATION *buf) {
|
void pe_find_section(HMODULE module, const char *section, struct pe_section_info *buf) {
|
||||||
char *cModule = (char*)module;
|
char *cModule = (char*)module;
|
||||||
|
|
||||||
IMAGE_DOS_HEADER* dosHeader = (IMAGE_DOS_HEADER*)module;
|
IMAGE_DOS_HEADER* dosHeader = (IMAGE_DOS_HEADER*)module;
|
||||||
@ -9,17 +9,16 @@ void pe_find_section(HMODULE module, const char *section, MEMORY_BASIC_INFORMATI
|
|||||||
WORD sectionCount = ntHeaders->FileHeader.NumberOfSections;
|
WORD sectionCount = ntHeaders->FileHeader.NumberOfSections;
|
||||||
IMAGE_SECTION_HEADER* sectionHeader = (IMAGE_SECTION_HEADER*)(ntHeaders + 1);
|
IMAGE_SECTION_HEADER* sectionHeader = (IMAGE_SECTION_HEADER*)(ntHeaders + 1);
|
||||||
|
|
||||||
void* targetAddress = 0x0;
|
|
||||||
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) {
|
||||||
targetAddress = (void*)(cModule + sectionHeader->VirtualAddress);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionHeader++;
|
sectionHeader++;
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualQuery(targetAddress, buf, sizeof(MEMORY_BASIC_INFORMATION));
|
buf->base_address = cModule + sectionHeader->VirtualAddress;
|
||||||
|
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