在 2025-3-7 06:51, Jeremy Drake via Mingw-w64-public 写道:
Actaully, the test case I was starting with was delay loading from a
non-existant module, and using the failure hook to load it.  In the case
of the ResolveDelayLoadedAPI function, it does not seem to save the
function returned from the failure hook back to the delay IAT.  Doing a
more "normal" delay load of a function/module that *does* exist does
result in a segfault with current binutils and ResolveDelayLoadedAPI.

Ahh right. I have found my issue now. I was using a patched binutils like in Wine [1]. It produced delay-import data which somehow worked if passed to `ResolveDelayLoadedAPI()`, but the mingw-w64 implementation didn't like it. It was not modifying the IAT that caused the fault; it was earlier than that:

   ```
   Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff6ff0c280a in __delayLoadHelper2 (pidd=0x7ff6ff0c30a0 <__DELAY_IMPORT_DESCRIPTOR_delay_ws2_32_a>,
       ppfnIATEntry=0x7ff6ff0c40b0 <__imp_WSAGetLastError>)
at D:/lh_mouse/GitHub/MINGW-packages/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/misc/delayimp.c:161
   161       dli.dlp.fImportByName = !IMAGE_SNAP_BY_ORDINAL(pitd->u1.Ordinal);
   (gdb)
   ```


[1] https://gitlab.winehq.org/wine/wine/-/merge_requests/7328/diffs?commit_id=c9519f68ea04915a60704534ab3afec5ec1b8fd7


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to