Solved

Thunking 16Bits dll's to 32Bits Project

Posted on 1998-05-21
7
326 Views
Last Modified: 2012-06-27
How can I use a 16 Bits dll in my 32 Bits App using Borland C++ 5.02?
0
Comment
Question by:nosredna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1164448
You'll have to use the "Flat thunks" mechanism.  Use the thunk compiler (thunk.exe).
The process is explained in KB articles Q125715 and Q142564.  Also see the Borland help about "flat thunks" and "thunk compiler"



0
 

Author Comment

by:nosredna
ID: 1164449
alexo's, thanks for your answer, but
I would like a response step by step how to proceed. I've tried some times to use
Thunk.exe with a script file .thk but there was some error messages.


Thanks.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1164450
Never used it myself.  If you reopen the question somebody else may give you a better answer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
abesoft earned 200 total points
ID: 1164451
Well, this is a complex problem.

There are no truly portable thunking mechanisms available under Win32.  There are "Universal thunks", "Flat thunks", and one other one that I can't remember at the moment, but none of them are available under 95, NT, and Win32s.  (I am assuming that you only care about Intel chips for NT, right?  Otherwise, I think you're completely out of luck, since Alpha etc doesn't run 16 bit apps...)  Also, under NT, there are no MS-provided thunks that will let a 32-bit process call a 16-bit DLL.

When I had to solve this problem, I used DDE in a C++ class provide thunks across all win32 platforms.  It wasn't exactly pretty, but here's the general gist:
1) The main entry point of the app was a 16-bit executable, and it would first detect that you had Win32s or a real 32 bit platform to run on.  (This was a nice side-effect of the solution...)  It would then exec the real 32-bit app, and open a connection to it.
2) Whenever a 32-bit routine wanted to call a thunked routine, it would call it via a class that I had written.
3) The class would take the function parameters, convert them into a portable format (in this case, text... watch out for pointers...) and pass them via DDE to the 16-bit executable.
4) The 16-bit executable would decode the parameters, dynamically load the DLL, and call the function.  It would then encode the result and pass it back....

Obviously, adding a new routine involved writing a fair amount of code, but it is mostly cookie-cutter stuff if you design your class nicely.

Other options avaialble are wrapping the whole thing in OLE (which was not an option for us since we wanted to support early Win32s which didn't do OLE), use WM_COPYDATA instead of DDE (not available on all platforms) or, well, there are a LOT of options here... but they all come down to the same kind of approach.
0
 
LVL 2

Expert Comment

by:abesoft
ID: 1164452
Just remembered it: The other thunk mechanism is "Generic Thunk".  (And all none of the MS-thunks are generic or universal, regardless of the neames... ;)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1164453
There are "flat", "generic" and "universal" thunks.  Some are Win95 specific, some are for NT and some work with Win32s.  Check the KB articles I mentioned in my rejected answer.
0
 

Author Comment

by:nosredna
ID: 1164454
It seems very easy and I will try.
Thanks for your answer.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

615 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