简体   繁体   中英

Access 64 bit ODBC from 32 bit Process

I would like to access a 64 bit dll from a 32 bit application. Due to propitiatory third party lock-in, we do not have a suitable port of the 32 bit application. Creating 2 different versions of the 64 bit dll is practically not feasible as to meet the dependencies we might have to end up building almost the entire application in both bitness which would nullify the entire porting purpose. To amplify further, we would like to access 64 bit ODBC from the 32 bit application.

I came across two propritory solution in this regard

ODBC-ODBC Bridge - Easysoft

Openlink Software

Both are propitiatory solution but am looking for some open source or an in house implementation

A little research in this area made me believe that it might be possible if we can load the dll as a separate process and using IPC to communicate as mentioned in Interprocess Communication Between 32-bit and 64-bit Applications . The challenge here is marshaling and unmarshalling the data typically when it involves reference data type.

In this regard, I came across a SO answer Is it possible to access a 64-bit dll from a 32-bit application? which links to a solution in Code Central . This is a delphi solution and a similar solution I would like to peruse for Visual C++.

Is there any open source implementation which tries to address the issue?

You can't access a 64-bit DLL from a 32-bit application - or a 32-bit DLL from a 64-bit application. That's because there is no way for the processor to switch modes like that - when a 64-bit OS is running a 32-bit applicaiton, the processor is in "compatibility mode", and you'd have to change the mode to enter the DLL. Although it's technically possible to achieve the mode-switch, there are numerous other problems - such as "what happens when a 32-bit app receives a 64-bit value in a single register.".

The solution in the Delphi model is to start another application that is 64-bit and just a thin shim to the DLL itself - I haven't downloaded the source-code to look at it, but it does from the description sound like it is an IPC to call a function in the 64-bit process and return the results via IPC to the 32-bit process. This is certainly a plausible solution for any language. It does however involve an extra IPC stage (which of course does involve a marshalling problem - although databases tend to supply the result as text, so you could possibly get away with it fairly well in that respect), which could be costly in a database application due to the double copying of the data.

I'm not at all convinced it is not worth the effort of compiling your application as a 64-bit application - if the application is well-written, it wouldn't be much more than switching the switch over. And 64-bit applications tend to run a little faster than the same application in 32-bit thanks to the extra registers available.

Sorry if this isn't the "Here's a link ..." answer you were looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM