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
|
dest
|
||||||
mred?))))))
|
mred?))))))
|
||||||
(define embed-dlls? (and (eq? 'windows (cross-system-type))
|
(define embed-dlls? (and (eq? 'windows (cross-system-type))
|
||||||
(eq? 'racket (cross-system-type 'vm))
|
|
||||||
(let ([m (assq 'embed-dlls? aux)])
|
(let ([m (assq 'embed-dlls? aux)])
|
||||||
(and m (cdr m)))))
|
(and m (cdr m)))))
|
||||||
(define embedded-dlls-box (and embed-dlls? (box null)))
|
(define embedded-dlls-box (and embed-dlls? (box null)))
|
||||||
|
|
|
@ -435,6 +435,17 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
|
||||||
return TRUE;
|
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
|
static BOOL
|
||||||
BuildImportTable(PMEMORYMODULE module)
|
BuildImportTable(PMEMORYMODULE module)
|
||||||
{
|
{
|
||||||
|
@ -725,6 +736,12 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, size_t size,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
if (!RegisterExceptionHandling(result)) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// mark memory pages depending on section headers and release
|
// mark memory pages depending on section headers and release
|
||||||
// sections that are marked as "discardable"
|
// sections that are marked as "discardable"
|
||||||
if (!FinalizeSections(result)) {
|
if (!FinalizeSections(result)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user