cs: support raco exe --embed-dlls
on Windows
Uses a MemoryModule PR by @DaLynX to fix a setjmp/longjmp interaction with embedded DLLs.
This commit is contained in:
parent
fffdeeddd2
commit
61cefe693a
|
@ -1563,7 +1563,6 @@
|
|||
dest
|
||||
mred?))))))
|
||||
(define embed-dlls? (and (eq? 'windows (cross-system-type))
|
||||
(eq? 'racket (cross-system-type 'vm))
|
||||
(let ([m (assq 'embed-dlls? aux)])
|
||||
(and m (cdr m)))))
|
||||
(define embedded-dlls-box (and embed-dlls? (box null)))
|
||||
|
|
|
@ -435,6 +435,17 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
static BOOL
|
||||
RegisterExceptionHandling(PMEMORYMODULE module)
|
||||
{
|
||||
PIMAGE_DATA_DIRECTORY pDir = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION);
|
||||
PIMAGE_RUNTIME_FUNCTION_ENTRY pEntry = (PIMAGE_RUNTIME_FUNCTION_ENTRY)(module->codeBase + pDir->VirtualAddress);
|
||||
UINT count = (pDir->Size / sizeof(IMAGE_RUNTIME_FUNCTION_ENTRY)) - 1;
|
||||
return RtlAddFunctionTable(pEntry, count, (DWORD64)module->codeBase);
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL
|
||||
BuildImportTable(PMEMORYMODULE module)
|
||||
{
|
||||
|
@ -725,6 +736,12 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, size_t size,
|
|||
goto error;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
if (!RegisterExceptionHandling(result)) {
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
// mark memory pages depending on section headers and release
|
||||
// sections that are marked as "discardable"
|
||||
if (!FinalizeSections(result)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user