Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

hx+win32+fpc 2.4.0 vs loadlibrary+dll (DOSX)

posted by Japheth(R) Homepage, Germany (South), 04.01.2010, 10:02

> 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:

Back to the forum
Board view  Mix view
15276 Postings in 1373 Threads, 253 registered users, 13 users online (0 registered, 13 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum