JFLib

plat/win_lib.rs (Windows)#

Source: lib/plat/win_lib.rs

win_lib -- plugin libraries and the crash guard: the Windows part
                                        [src/plat/win/win_lib.s; docs/modules/PLUGIN_LOADER.md]

  lib_open(path) -> Lib / Err(LIBE_*)   LoadLibraryExW(DONT_RESOLVE_DLL_REFERENCES): the
       image is mapped and relocated, but DllMain / TLS callbacks never run and no import
       is bound -- a plugin with an import, delay-import or TLS directory is rejected
       (LIBE_DEPS / LIBE_INIT); only DLLs of this processor (LIBE_FORMAT; the other: LIBE_ARCH).  Hard-error dialogs are
       suppressed (SetThreadErrorMode).  Segments: headers + every section.
  lib_sym(h, name) -> address | 0       own export-directory lookup (bounds checked against
       SizeOfImage, every table / name inside a readable section -- a section without
       MEM_READ is PAGE_NOACCESS; forwarders -> 0, so no other DLL is ever loaded)
  (crate) lib_unload(h)                 FreeLibrary (lib_close / drop)
  (crate) plat_tid() -> u64             thread id (TEB ClientId, gs:[0x48]; ARM64: x18 + 0x48)
  (crate) guard_thread()                nothing on Windows
  (crate) guard_os_install()            AddVectoredExceptionHandler(first, guard_veh)

guard_veh handles access violations, in-page errors, illegal / privileged instructions,
integer and FP traps, misalignment, breakpoints and stack overflow -- only while the
faulting thread has an active guard (plib.rs); everything else goes on to the next
handler (win_crash.rs).
  • fn lib_open(path: &str) -> Result<Lib, u32> open a plugin DLL (see the file header) [plat_lib_open]

  • fn lib_sym(h: &Lib, name: &str) -> usize the address of the export name, 0 when missing / forwarded [plat_lib_sym]

Source: docs/API.md in the JFLib repository.