Solved

Calling a 16 bit DLL from a 32 bit

Posted on 1997-09-09
9
385 Views
Last Modified: 2008-02-26
            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
Comment
Question by:cyberdude
  • 5
  • 3
9 Comments
 
LVL 3

Accepted Solution

by:
msmits earned 200 total points
ID: 1169337
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
 

Author Comment

by:cyberdude
ID: 1169338
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
 
LVL 3

Expert Comment

by:msmits
ID: 1169339
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
 

Author Comment

by:cyberdude
ID: 1169340
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:cyberdude
ID: 1169341
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
 
LVL 3

Expert Comment

by:msmits
ID: 1169342
I believe that is not the way to do it. I will check my code and post the relevant parts here.

0
 
LVL 3

Expert Comment

by:msmits
ID: 1169343
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1169344
Bought This Question.
0
 
LVL 3

Expert Comment

by:msmits
ID: 1169345
Mirkwood: I hope it is of some use to you...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now