hx+win32+fpc 2.4.0 vs loadlibrary+dll (DOSX)
> WIN32-programs, compiled with FPC 2.4.0 and loaded with HX are not able to
> handle dynamic libraries (dll) anymore. I tried HXRT217 and 216 with the
> same result.
>
> I tried to do this under FreeDOS in qemu, bochs and dosemu and got no
> positive result.
>
> Using FPC 2.2.4 everything works, but I'm not sure that this is FPC
> trouble, because Linux target does things well even compiled by FPC
> 2.4.0.
I ran your test app under a debugger. AFAICS the problem is that your dll's DllMain function ( sometimes also called LibMain ) returns -1. HX's DPMILD32 expects this function to return 1 on success.
This is what MSDN says about DllMain's return value:
-------------------------------------------------------------
When the system calls the DllMain function with the DLL_PROCESS_ATTACH value, the function returns TRUE if it succeeds or FALSE if initialization fails. If the return value is FALSE when DllMain is called because the process uses the LoadLibrary function, LoadLibrary returns NULL. (The system immediately calls your entry-point function with DLL_PROCESS_DETACH and unloads the DLL.) If the return value is FALSE when DllMain is called during process initialization, the process terminates with
-------------------------------------------------------------
It seems that DPMILD32 is slightly more picky than Windows.
Btw., the DllMain function inside lib.dll calls LoadLibrary() on its own, which - according to MSDN - is an error:
-------------------------------------------------------------
Warning On attach, the body of your DLL entry-point function should perform only simple initialization tasks, such as setting up thread local storage (TLS), creating objects, and opening files. You must not call LoadLibrary in the entry-point function, because you may create dependency loops in the DLL load order. This can result in a DLL being used before the system
-------------------------------------------------------------
---
MS-DOS forever!
Complete thread:
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 02.01.2010, 13:29
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - marcov, 02.01.2010, 21:21
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 02.01.2010, 22:11
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Rugxulo, 02.01.2010, 23:23
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 03.01.2010, 11:33
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Rugxulo, 03.01.2010, 15:12
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 03.01.2010, 22:46
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Rugxulo, 03.01.2010, 15:12
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 03.01.2010, 11:33
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Rugxulo, 02.01.2010, 23:23
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 02.01.2010, 22:11
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Japheth, 04.01.2010, 10:02
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 12:01
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Khusraw, 04.01.2010, 13:51
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 13:55
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Khusraw, 04.01.2010, 14:25
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 14:31
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Japheth, 04.01.2010, 14:42
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 15:52
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Rugxulo, 06.01.2010, 18:42
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 15:52
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Japheth, 04.01.2010, 14:42
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 14:31
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Khusraw, 04.01.2010, 14:25
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 13:55
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - Khusraw, 04.01.2010, 13:51
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - post-factum, 04.01.2010, 12:01
- hx+win32+fpc 2.4.0 vs loadlibrary+dll - marcov, 02.01.2010, 21:21