MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / FillNtDllLUTs

Function FillNtDllLUTs

Source/Windows/ARM64EC/Module.cpp:163–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161
162
163void FillNtDllLUTs(HMODULE NtDll) {
164 ULONG Size;
165 const auto* LoadConfig =
166 reinterpret_cast<_IMAGE_LOAD_CONFIG_DIRECTORY64*>(RtlImageDirectoryEntryToData(NtDll, true, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, &Size));
167 const auto* CHPEMetadata = reinterpret_cast<IMAGE_ARM64EC_METADATA*>(LoadConfig->CHPEMetadataPointer);
168 const auto* RedirectionTableBegin = reinterpret_cast<IMAGE_ARM64EC_REDIRECTION_ENTRY*>(NtDllBase + CHPEMetadata->RedirectionMetadata);
169 const auto* RedirectionTableEnd = RedirectionTableBegin + CHPEMetadata->RedirectionMetadataCount;
170
171 NtDllRedirectionLUTSize = std::prev(RedirectionTableEnd)->Source + 1;
172
173 SIZE_T AllocSize = NtDllRedirectionLUTSize * sizeof(uint32_t);
174 NtAllocateVirtualMemoryNative(NtCurrentProcess(), reinterpret_cast<void**>(&NtDllRedirectionLUT), 0, &AllocSize, MEM_COMMIT | MEM_RESERVE,
175 PAGE_READWRITE);
176 for (auto It = RedirectionTableBegin; It != RedirectionTableEnd; It++) {
177 NtDllRedirectionLUT[It->Source] = It->Destination;
178 }
179}
180
181template<typename T>
182void WriteModuleRVA(HMODULE Module, LONG RVA, T Data) {

Callers 1

InitSyscallsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected