Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
post-factum

Homepage

/ukraine/kyiv,
02.01.2010, 13:29
(edited by post-factum, 02.01.2010, 14:44)
 

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.

Sources and binaries are available via this link:

http://postfactum.pl.ua/nebula3/download.php?q=da17c1e60708fabbd4984a7b00cd0178

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

marcov

02.01.2010, 21:21
(edited by marcov, 03.01.2010, 13:17)

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> 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'm not entirely sure, but it might be that FPC 2.4.0 uses some -W bits here and there, and afaik now requires MSLU (on w9x. I don't know if HX emulates the -W stuff/MSLU)

> Sources and binaries are available via this link:
>
> http://postfactum.pl.ua/nebula3/download.php?q=da17c1e60708fabbd4984a7b00cd0178

Binary works fine under XP.


* added later: the stuff between parentheses.

post-factum

Homepage

/ukraine/kyiv,
02.01.2010, 22:11

@ marcov
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> I'm not entirely sure, but it might be that FPC 2.4.0 uses some -W bits
> here and there, and afaik now requires MSLU.

First of all, I tried to play with fpc -W switches, but got no result.

Putting MSLU files (unicows.dll and unicows.pdb) into testing folder didn't help as well.

What should I do?

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Rugxulo

Homepage

Usono,
02.01.2010, 23:23

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> > I'm not entirely sure, but it might be that FPC 2.4.0 uses some -W bits
> > here and there, and afaik now requires MSLU.
>
> First of all, I tried to play with fpc -W switches, but got no result.
>
> Putting MSLU files (unicows.dll and unicows.pdb) into testing folder
> didn't help as well.
>
> What should I do?

Dunno, but here's a informative link (esp. about the partial Mozilla reimplementation):

http://en.wikipedia.org/wiki/Microsoft_Layer_for_Unicode

post-factum

Homepage

/ukraine/kyiv,
03.01.2010, 11:33

@ Rugxulo
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> Dunno, but here's a informative link (esp. about the partial Mozilla
> reimplementation):
>
> http://en.wikipedia.org/wiki/Microsoft_Layer_for_Unicode

I have no idea how to apply this to fixing the issue :(.

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Rugxulo

Homepage

Usono,
03.01.2010, 15:12

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> > Dunno, but here's a informative link (esp. about the partial Mozilla
> > reimplementation):
> >
> > http://en.wikipedia.org/wiki/Microsoft_Layer_for_Unicode
>
> I have no idea how to apply this to fixing the issue :(.

Sorry, not sure it will. But can you at least try OpenCow? Or try WDOSX, there is some minimal support for that in FPC too (or at least used to be).

post-factum

Homepage

/ukraine/kyiv,
03.01.2010, 22:46

@ Rugxulo
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> Sorry, not sure it will. But can you at least try OpenCow?

How? And why should it help?

> Or try WDOSX,
> there is some minimal support for that in FPC too (or at least used to
> be).

I tried WDOSX, it has no threads support.

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Japheth

Homepage

Germany (South),
04.01.2010, 10:02

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

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

post-factum

Homepage

/ukraine/kyiv,
04.01.2010, 12:01

@ Japheth
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

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

As I understand from Google, there's no way to set up returning 1 from DllMain in FPC :(.

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Khusraw

E-mail

Bucharest, Romania,
04.01.2010, 13:51

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> > 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.
>
> As I understand from Google, there's no way to set up returning 1 from
> DllMain in FPC :(.

Doesn't it have to do with the new implementation of TRUE in FPC?

---
Glory to God for all things

post-factum

Homepage

/ukraine/kyiv,
04.01.2010, 13:55

@ Khusraw
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> Doesn't it have to do with the new implementation of TRUE and FALSE in
> FPC?

http://wiki.freepascal.org/User_Changes_2.4.0#Byte.2FWord.2FLong.2FQwordbool_types

This one? But, in such case, who is right ? HX, WinAPI or FPC?

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Khusraw

E-mail

Bucharest, Romania,
04.01.2010, 14:25

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> http://wiki.freepascal.org/User_Changes_2.4.0#Byte.2FWord.2FLong.2FQwordbool_types
>
> This one? But, in such case, who is right — HX, WinAPI or FPC?

Be aware that various compilers for different programming languages have different definitions for TRUE (AFAIK FALSE is always 0). So it is better to check for 1 or -1 when it is the case, instead of TRUE. Certainly not your fault, but they missed it.

---
Glory to God for all things

post-factum

Homepage

/ukraine/kyiv,
04.01.2010, 14:31

@ Khusraw
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> Be aware that various compilers for different programming languages have
> different definitions for TRUE (AFAIK FALSE is always 0). So it is better
> to check for 1 or -1 when it is the case, instead of TRUE. Certainly not
> your fault, but they missed it.

So to fix this, I have to recompile FPC?

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Japheth

Homepage

Germany (South),
04.01.2010, 14:42

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> So to fix this, I have to recompile FPC?

It's rather trivial to fix in DPMILD32. So I did a small update to HXRT217.ZIP, which then hopefully works with fpc 2.4.

---
MS-DOS forever!

post-factum

Homepage

/ukraine/kyiv,
04.01.2010, 15:52

@ Japheth
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> It's rather trivial to fix in DPMILD32. So I did a small update to
> HXRT217.ZIP, which then hopefully works with fpc 2.4.

Yes, it works. Thanks a lot.

---
% uname -a
Linux eternity 3.0.1-pf #1 SMP PREEMPT Fri Aug 5 21:45:05 EEST 2011 i686 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux

Rugxulo

Homepage

Usono,
06.01.2010, 18:42

@ post-factum
 

hx+win32+fpc 2.4.0 vs loadlibrary+dll

> > It's rather trivial to fix in DPMILD32. So I did a small update to
> > HXRT217.ZIP, which then hopefully works with fpc 2.4.
>
> Yes, it works. Thanks a lot.

Yes, big thanks!

Back to index page
Thread view  Board view
22049 Postings in 2034 Threads, 396 registered users, 265 users online (0 registered, 265 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum