[Misc] Moved pe_image to base from 3pp and cut unnecessary parts

This commit is contained in:
Gliniak
2025-05-29 21:06:00 +02:00
committed by Radosław Gliński
parent 31ce3e0c71
commit 50492a951e
4 changed files with 213 additions and 1066 deletions

View File

@@ -12,10 +12,10 @@
#include <algorithm>
#include <string>
#include "third_party/pe/pe_image.h"
#include "xenia/base/atomic.h"
#include "xenia/base/chrono.h"
#include "xenia/base/logging.h"
#include "xenia/base/pe_image.h"
#include "xenia/base/string.h"
#include "xenia/base/threading.h"
#include "xenia/kernel/kernel_state.h"
@@ -400,7 +400,7 @@ DECLARE_XBOXKRNL_EXPORT3(RtlUnicodeToMultiByteN, kNone, kImplemented,
kHighFrequency, kSketchy);
// https://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Executable%20Images/RtlImageNtHeader.html
static IMAGE_NT_HEADERS32* ImageNtHeader(uint8_t* module) {
static XIMAGE_NT_HEADERS32* ImageNtHeader(uint8_t* module) {
if (!module) {
return 0;
}
@@ -419,7 +419,7 @@ static IMAGE_NT_HEADERS32* ImageNtHeader(uint8_t* module) {
if (nt_magic != 0x4550) { // 'PE'
return 0;
}
return reinterpret_cast<IMAGE_NT_HEADERS32*>(nt_header);
return reinterpret_cast<XIMAGE_NT_HEADERS32*>(nt_header);
}
pointer_result_t RtlImageNtHeader_entry(lpvoid_t module) {
@@ -443,13 +443,13 @@ dword_result_t RtlImageDirectoryEntryToData_entry(dword_t Base,
aligned_base = Base & 0xFFFFFFFE;
MappedAsImage = false;
}
IMAGE_NT_HEADERS32* nt_header =
XIMAGE_NT_HEADERS32* nt_header =
ImageNtHeader(ctx->TranslateVirtual<uint8_t*>(aligned_base));
if (!nt_header) {
return 0;
}
if (nt_header->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
if (nt_header->OptionalHeader.Magic != XIMAGE_NT_OPTIONAL_HDR32_MAGIC) {
return 0;
}
if (DirectoryEntry >= nt_header->OptionalHeader.NumberOfRvaAndSizes) {
@@ -468,7 +468,7 @@ dword_result_t RtlImageDirectoryEntryToData_entry(dword_t Base,
}
uint32_t n_sections = nt_header->FileHeader.NumberOfSections;
IMAGE_SECTION_HEADER* v8 = reinterpret_cast<IMAGE_SECTION_HEADER*>(
XIMAGE_SECTION_HEADER* v8 = reinterpret_cast<XIMAGE_SECTION_HEADER*>(
reinterpret_cast<char*>(&nt_header->OptionalHeader) +
nt_header->FileHeader.SizeOfOptionalHeader);
if (!n_sections) {