Lateloading of x86 / x64 bit DLL keyboard files and init defines
Hi
I currently have an issue with the init of lateloading DLLs (keyboard files) that is compiled either with x86 or x64. The app is a simple C++ MFC application (32-bit)
First, here is a summary of the lateloading of the keyboard files:
Now here is the mainissue, program is compiled with x86 but executed on a x64-system.
* All keyboard files in %windir%\system32\ is x64 DLLs files and failes (because BUILD_WOW6432 doesn't exist)
* Struct is partly filled, possible corrupt
Same app running on a x86-system:
* All keyboard files are loaded ok, because the keyboardfiles in %windir%\system32\ is x86.
Taking a x86 KBDxx.DLL to a x64-system:
* Loaded ok, without a problem
Forcing the KBD_LONG_POINTER as __ptr64 on a x32-system:
* All keyboard files fails to load (as expected)
Forcing the KBD_LONG_POINTER as __ptr64 on a x64-system:
* All keyboard files are loaded ok (as expected).
Any tips on how to get this to work, without creating a kbd64.h containing the "same" defines?
Is it possible to "redefine" during runtime?
==========================
Lars Werner aka Large http://lars.werner.no/
==========================
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
VictorN:
That isn't really an option, since I want to use the already installed keyboard layouts that is available in the %windir%\system32\ directory.
But it would "solve" the problem if I distributed the dlls with the installation.
Not any other nifty solutions though?
I guess I'll have to create a kbd64.h that manage the structs for x64 bit and do a x86/x64 check on the dll-files before loading.
==========================
Lars Werner aka Large http://lars.werner.no/
==========================
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
Originally Posted by Large
VictorN:
That isn't really an option, since I want to use the already installed keyboard layouts that is available in the %windir%\system32\ directory.
But it would "solve" the problem if I distributed the dlls with the installation.
Not any other nifty solutions though?
I guess I'll have to create a kbd64.h that manage the structs for x64 bit and do a x86/x64 check on the dll-files before loading.
Where you ever able to resolve this issue? I am having the exact same problem.
I wonder, is this a problem to detect running on x64? In case it is x64, the path to load from must be just C:\Windows\SysWOW64 instead of system32. That's it.
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
Originally Posted by Igor Vartanov
I wonder, is this a problem to detect running on x64? In case it is x64, the path to load from must be just C:\Windows\SysWOW64 instead of system32. That's it.
That's what you would think to be the case but from what I have gathered SysWOW64/KBDUS.DLL is not purely 32 bit. I think my problem is that mingw __ptr64 doesnt do what it should be doing so I am going to test with msvc.
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
kwhat:
I used the solution described from Igor by loading x86-dlls on a 64bit-system from the %windir%\SysWOW64 directory.
On x86-systems I load them from the %windir%\system32.
I seems to work on every layout, just not KBDKOR.dll nor KBDJPN.DLL.
==========================
Lars Werner aka Large http://lars.werner.no/
==========================
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
Originally Posted by Large
kwhat:
I used the solution described from Igor by loading x86-dlls on a 64bit-system from the %windir%\SysWOW64 directory.
On x86-systems I load them from the %windir%\system32.
I seems to work on every layout, just not KBDKOR.dll nor KBDJPN.DLL.
Thanks for the reply. After spending most of the day trying to wrap my brain around why this wasn't working for me I finally figured out what the problem was. As it turns out GCC and subsequently MinGW do not support __ptr64 and simply ignore it. This turns out to be a problem when working with Wow64 libraries as they appear to be 64-bit aligned 32-bit pointers. I have been experimenting with __attribute__((mode(DI))) and __attribute__ ((aligned(8))). Both show promise however I cant seem to get mode(DI) working directly with pointers. Hopefully this will save someone a huge headache down the line as there is almost no information on the topic.
Re: Lateloading of x86 / x64 bit DLL keyboard files and init defines
I solved this issue very differently due to the GCC compatibility requirement of my project. Its not pretty, but it uses the same binary code for both native 32-bit and wow64 environments. I haven't tested it with the MSVC compiler, but there shouldn't be any reason it wouldn't work.
Bookmarks