PDA

View Full Version : Calling 16bit NE DLL from 32bit PE executable


johnny
March 3rd, 2010, 05:27
I have an old 16bit NE DLL. I want to call the exports from a 32bit PE executable. Anyone knows a solution?

disavowed
March 3rd, 2010, 11:37
Though I don't know for sure that it can't be done, I would guess it's not possible since 64-bit EXEs can't load 32-bit DLLs.

Maximus
March 3rd, 2010, 13:46
well, win95/98 was doing it with kernel32, which was FLAT thunked to 16 bit dll kernel. So yes, it is possible, and was widely used by M$ for making an OS.
It caused alot of problems (you need to enforce serialization etc.).

see http://support.microsoft.com/?scid=kb%3Ben-us%3B125710&x=10&y=12

If you feel very bold, you can find somewhere a detailed article on how the cool (and absurd) win95 flat thunking works, and its secret trickeries, and try redo it by yourself. Good luck if you select this way.

I'd rather suggest you to write a NE EXE wrapper, and use the intercommunication features to make the exe and DLL works.

But recreating Win95 flat thunk is way more cool...

Kayaker
March 3rd, 2010, 13:54
Quote:
[Originally Posted by Maximus;85552]
If you feel very bold, you can find somewhere a detailed article on how the cool (and absurd) win95 flat thunking works, and its secret trickeries, and try redo it by yourself.


I thunk we already did that
The K32lib example code and refs might help.

GetProcAddress by ordinal problem
http://www.woodmann.com/forum/showthread.php?t=4210

Maximus
March 3rd, 2010, 14:49
hmm I do not think that it works


the thunk mechanics existed in win95/98, not in NT family (as far as I know). I fear he has to reimplement the thunk trick manually, by (re)implementing the same selector tricks MS used for that, which was not trivial but rather a little mine field, as I remember.

ooh, yes, that article on DDJ! But I wonder if it works in Win32... let me think

edit----
hmmm..... we need to have a 16 bit selector for stack ( MOV SS,DX ), and LoadLibrary16 does not exist in NT. so the pietrek solution will not work.
edit 2---
as I see it, he needs to load a 16 bit app into a shared workspace, get its selector via driver call, and enfo... no. It wouldnt work.
hmmm... meh, tougher than it seems...