• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

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.
0
cyberdude
Asked:
cyberdude
  • 5
  • 3
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now