Calling a 16 bit DLL from a 32 bit

            I am trying to call a 16 bit DLL from 32 bit Appication. I have read the HELP pages in Win32 SDK. As instructed I have created two objs using the thunk compiler and MSDN assembler. Now I am having a problem in linking the objs to the 32 bit DLL and 16 bit DLL.

             I created a project file for 32 bit DLL in MS Developer Studio Ver 4.2 in Windows 95 and 16 bit DLL in MS VC++ Ver 1.5 in Windows 3.11. The HELP pages says you have to add EXPORT thk_ThunkData32 in the def files for 32 bit DLL. But when I Build it , it fails to Link exactly that place. The same happens in 16 bit DLL.
cyberdudeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
msmitsCommented:
In my 32bit app I export dllthunk_ThunkData32, which you can find back in the asm file that is generated by the thunk-compiler.

EXPORTS
      dllthunk_ThunkData32

For my 16bit dll I export DLLTHUNK_THUNKDATA16, which you can also find back in the asm file that is generated by the thunk-compiler. It is only in the 16-bit section of the file.

EXPORTS
      DLLENTRYPOINT            @1      RESIDENTNAME
      DLLTHUNK_THUNKDATA16      @2

There are also lots of imports the 32bit and only 2 in the 16bit def file.

0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
cyberdudeAuthor Commented:
Thanks a lot !!, I really appreciate your effort though it did not solve my problem.

 The functions dllthunk_ThunkData32 ,DLLTHUNK_THUNKDATA16 are not present in the asm file generated by the thunk compiler. The functions thk_ThunkData32 and thk_Thunkdata16 are present in it though. Although they are present in the asm file, I am not able to export them.

Do you think the problem is in some compiler or linker settings ?


0
 
msmitsCommented:
Do you assemble the asm file with the correct defines to include the correct sections in the 32bit and 16bit version of the generated object?
The thunk compiler generates one assembler file with two different sections, one with the 32bit code and one with the 16bit code. You must assemble this file twice, once with the define for the 32bit section and once with the define for the 16bit section. Also take care that the obj output files are named differently for the two assembler calls.
I don't know the exact names of the defines and as the thunk compilers we use seem to be different they may differ anyway, so look in the asm file or the documentation for the correct naming.

I would also appreciate to know which version of the thunk compiler you are using. I am using the compiler that came with Turbo assembler 5.0 from Borland. I am also using the Borland C++ 5.02 environment, which can generate 32bit and 16bit code from the same IDE.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
cyberdudeAuthor Commented:
Thanks Again !!

I can understand the difference in the EXPORT functions as we are
using different assemblers. My 32 bit DLL is working fine now after a lot of trail and error. I am still strugging with the
16 bit DLL being developed in VC++ ver1.52 in Windows 3.11
I am crystal clear as far generating the thunk objs for 16bit &
32 bit. It is just that I am not able to link the objs to the 16 bit DLL properly.

I really want you to know that I appreciate every bit effort you
have taken for my problem. Thanks.

Bye
   Satya (CyberDude)

-------------
SOFTWARE USED
-------------

Well my assembler is ml
MS Macro Assembler Professional Development System, Version 6.0
The thunk compiler I am using is of MS Win32 SDK.
I am using MS Developer Studio (VC++) Ver 4.2 for building the
32 bit DLL.
The 16 bit DLL is build using MS VC++ ver 1.52 in Windows 3.11


0
 
cyberdudeAuthor Commented:
Hi
  I have successfully created two DLL for 16 bit and 32
bit using thunk compiler and assembler. Now I am having
a problem in loading the DLL in an application.

  I am using MS VC++ ver4.2. I am using the LoadLibrary
function to load the DLL. The appication fails to load
the DLL though.

Can you help ?
Thanks
0
 
msmitsCommented:
I believe that is not the way to do it. I will check my code and post the relevant parts here.

0
 
msmitsCommented:
In my 16-bit DLL I have the standard DllEntryPoint with the following code:

  if (dllthunk_ThunkConnect16("setupnet.dll", "iaewiz.exe",
                               hInst, dwReason)) {
    return TRUE;
  }
  else
  {
    return FALSE;
  }

In the 32-bit exe I have the following code:

  result = dllthunk_ThunkConnect32("setupnet.dll", "iaewiz.exe",
                              hInstance, DLL_PROCESS_ATTACH);


  dllthunk_ThunkConnect32("setupnet.dll", "iaewiz.exe",
                          hInstance, DLL_PROCESS_DETACH);

Between these calls I just call the functions from the DLL as if they were normally linked function. They are included via a header file and linked via the obj from the thunk compiler.
I use no LoadLibrary.

0
 
MirkwoodCommented:
Bought This Question.
0
 
msmitsCommented:
Mirkwood: I hope it is of some use to you...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.