Menu ▾ ▴

#29 TdzResourceDllLoader: load DLLs from a resource in 64 bit programs

unread
nobody
2026-10-12
2026-10-12
No

Since [bugs:#56] was fixed, TdzResourceDllLoader looks up entry points in 64 bit programs too, but Create(DllName) raises EDllLoadError there: loading a DLL from a RESOURCEDLL resource is only supported in 32 bit programs. TDzDllApi then falls back to the DLL file.

Loading a 64 bit DLL from a resource would need, in LoadDll and UnloadDll:

  • relocations of type IMAGE_REL_BASED_DIR64; only IMAGE_REL_BASED_HIGHLOW is handled now
  • 64 bit import thunks, with IMAGE_ORDINAL_FLAG64 for imports by ordinal; they are read and written as PDWORD now
  • the import descriptor laid out with 32 bit RVAs; the local record has a Pointer field, which is 8 bytes on Win64
  • address arithmetic without DWORD/Cardinal/Integer casts, and DllMain called with a pointer sized handle
  • the exception tables (.pdata) registered with RtlAddFunctionTable and removed again on unload; without that, an exception raised inside the DLL cannot be handled

Testing it needs a small 32 bit and a 64 bit DLL embedded as RESOURCEDLL in the test program, so either checked in binaries or a build step in the test set.

Related

Bug Reports: #56

Discussion


Log in to post a comment.