| 3 | #include <Phobos.h> |
| 4 | |
| 5 | int GetSection(const char* sectionName, void** pVirtualAddress) |
| 6 | { |
| 7 | auto hInstance = Phobos::hInstance; |
| 8 | auto pHeader = reinterpret_cast<PIMAGE_NT_HEADERS>(((PIMAGE_DOS_HEADER)hInstance)->e_lfanew + (long)hInstance); |
| 9 | |
| 10 | for (int i = 0; i < pHeader->FileHeader.NumberOfSections; i++) |
| 11 | { |
| 12 | auto sct_hdr = IMAGE_FIRST_SECTION(pHeader) + i; |
| 13 | |
| 14 | if (strncmp(sectionName, (char*)sct_hdr->Name, 8) == 0) |
| 15 | { |
| 16 | *pVirtualAddress = (void*)((DWORD)hInstance + sct_hdr->VirtualAddress); |
| 17 | return sct_hdr->Misc.VirtualSize; |
| 18 | } |
| 19 | } |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | void Patch::ApplyStatic() |
| 24 | { |