2024-01-12 21:37:22 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2024-01-13 03:29:00 +08:00
|
|
|
#include <winternl.h>
|
2024-01-12 21:37:22 +08:00
|
|
|
|
|
|
|
#include <string>
|
2024-05-08 05:30:23 +08:00
|
|
|
#include <string_view>
|
2024-05-24 11:22:14 +08:00
|
|
|
#include <cstdint>
|
2024-01-12 21:37:22 +08:00
|
|
|
|
|
|
|
namespace pe_helpers
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef struct SectionHeadersResult
|
|
|
|
{
|
|
|
|
WORD count;
|
|
|
|
PIMAGE_SECTION_HEADER ptr;
|
|
|
|
} SectionHeadersResult_t;
|
|
|
|
|
|
|
|
|
2024-01-14 08:29:02 +08:00
|
|
|
PIMAGE_NT_HEADERS get_nt_header(HMODULE hModule);
|
|
|
|
|
|
|
|
PIMAGE_FILE_HEADER get_file_header(HMODULE hModule);
|
|
|
|
|
|
|
|
PIMAGE_OPTIONAL_HEADER get_optional_header(HMODULE hModule);
|
|
|
|
|
2024-01-12 21:37:22 +08:00
|
|
|
uint8_t* search_memory(uint8_t *mem, size_t size, const std::string &search_patt);
|
|
|
|
|
|
|
|
bool replace_memory(uint8_t *mem, size_t size, const std::string &replace_patt, HANDLE hProcess);
|
|
|
|
|
|
|
|
std::string get_err_string(DWORD code);
|
|
|
|
|
|
|
|
bool is_module_64(HMODULE hModule);
|
|
|
|
|
|
|
|
bool is_module_32(HMODULE hModule);
|
|
|
|
|
|
|
|
SectionHeadersResult get_section_headers(HMODULE hModule);
|
|
|
|
|
|
|
|
PIMAGE_SECTION_HEADER get_section_header_with_name(HMODULE hModule, const char* name);
|
|
|
|
|
2024-06-29 08:56:40 +08:00
|
|
|
DWORD loadlib_remote(HANDLE hProcess, const std::string &fullpath, const char** err_reason = nullptr);
|
2024-01-12 21:37:22 +08:00
|
|
|
|
|
|
|
size_t get_pe_size(HMODULE hModule);
|
|
|
|
|
2024-04-13 23:35:10 +08:00
|
|
|
const std::string& get_current_exe_path();
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-05-08 05:30:23 +08:00
|
|
|
const std::string& get_current_exe_name();
|
|
|
|
|
2024-06-27 04:13:43 +08:00
|
|
|
bool ends_with_i(PUNICODE_STRING target, std::wstring_view query);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-01-14 08:29:02 +08:00
|
|
|
MEMORY_BASIC_INFORMATION get_mem_page_details(const void* mem);
|
|
|
|
|
|
|
|
size_t get_current_exe_mem_size();
|
|
|
|
|
2024-01-12 21:37:22 +08:00
|
|
|
}
|