Skip to content

Commit 18ace52

Browse files
DaLynXfancycode
authored andcommitted
Added x64 exception handling
1 parent 5f83e41 commit 18ace52

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

MemoryModule.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,15 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
435435
return TRUE;
436436
}
437437

438+
static BOOL
439+
RegisterExceptionHandling(PMEMORYMODULE module)
440+
{
441+
PIMAGE_DATA_DIRECTORY pDir = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION);
442+
PIMAGE_RUNTIME_FUNCTION_ENTRY pEntry = (PIMAGE_RUNTIME_FUNCTION_ENTRY)(module->codeBase + pDir->VirtualAddress);
443+
UINT count = (pDir->Size / sizeof(IMAGE_RUNTIME_FUNCTION_ENTRY)) - 1;
444+
return RtlAddFunctionTable(pEntry, count, (DWORD64)module->codeBase);
445+
}
446+
438447
static BOOL
439448
BuildImportTable(PMEMORYMODULE module)
440449
{
@@ -725,6 +734,10 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, size_t size,
725734
goto error;
726735
}
727736

737+
if (!RegisterExceptionHandling(result)) {
738+
goto error;
739+
}
740+
728741
// mark memory pages depending on section headers and release
729742
// sections that are marked as "discardable"
730743
if (!FinalizeSections(result)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy