I cannot load a KBD layout from wow64 (returning Null)

답변됨 I cannot load a KBD layout from wow64 (returning Null)

  • 2011년 11월 21일 월요일 오후 9:25
     
     

    Hi,

    I am trying to obtain a pointer to the descriptor of my current keyboard layout in \Windows\syswow64\kbdsp.dll. All this through an unmanaged 32bits dll loaded by a x86 .net application in a x64 windows 7 installation.

    In a brief, I do:


    kbdLibrary = LoadLibrary(getLayoutFilename());
    pKbdLayerDescriptor = (KbdLayerDescriptor)GetProcAddress(kbdLibrary, "KbdLayerDescriptor");
    pKbd = pKbdLayerDescriptor();


    But pKbd->pVkToWcharTable is null after the last call in x64 architectures. However, if I run the same application in a x86 Windows installation then it works fine....

     

    I can figure out that the pointer returned is out of the wow64 mapped memory, but is there any approach to deal with this problem?

     

    Thanks

     

     

모든 응답

  • 2011년 11월 22일 화요일 오전 11:28
     
     
    ok, the returned layer descriptor is a 64bits pointers even if it's in WoW64. Problem solved.
  • 2012년 1월 16일 월요일 오후 8:38
     
     

    Edit:

    Ahh, I finally got it work.
    Is it possible to define at runtime, based on if the application is runned on x86 or x64?

     

    ----

     

    Hi LQBWEB, I've been twisting my mind around the same problem.

    Could you post a solution here?

    I check the:

    #if defined(BUILD_WOW6432)
        #define KBD_LONG_POINTER __ptr64
    #else
        #define KBD_LONG_POINTER
    #endif

    Then..

    typedef struct _VK_TO_WCHAR_TABLE {
        PVK_TO_WCHARS1 pVkToWchars;
        BYTE           nModifications;
        BYTE           cbSize;
    } VK_TO_WCHAR_TABLE, *KBD_LONG_POINTER PVK_TO_WCHAR_TABLE;

    Isn't PVK_TO_WCHAR_TABLE a __ptr64?


    • 편집됨 Mr. Werner 2012년 1월 16일 월요일 오후 10:31
    •  
  • 2012년 8월 6일 월요일 오후 3:08
     
      코드 있음

    Hi,

    I'm using the same piece of code and I'm still having some problems.

    Can anyone of you post the final answer ?

    This is what I have :

    if(pKbdLayerDescriptor != NULL) { int * __ptr64 pPtr64; pKbd = pKbdLayerDescriptor();

    printf("Size pVkToWcharTable : %d Size PVK_TO_WCHAR_TABLE : %d Size__ptr64 : %d 0x%X\n", sizeof(pKbd->pVkToWcharTable), sizeof(PVK_TO_WCHAR_TABLE), sizeof(pPtr64), pKbd->pVkToWcharTable); }

    And the result :

    Size pVkToWcharTable : 4 Size PVK_TO_WCHAR_TABLE : 4 Size__ptr64 : 4  0x0

    As you can see, it keeps dealing with 32 bits pointers...

    I'm using Code Blocks with GNU GCC compiler, i have set #define BUILD_WOW6432 before any includes.

    Thanks for any help!

    Regards


    N'hésitez pas à poser des questions si un problème subsiste ou quelque chose n'est pas clair. Dans l'autre cas, veuillez indiquer que le problème est résolu. Cordialement - Best Regards. Contact

  • 2012년 8월 6일 월요일 오후 5:18
     
     답변됨

    For a 32-bit app, __ptr64 has no effect -  it is truncated to 32 bits . See here.

    So the solution found by the OP probably was just to compile in x64 mode.

    Also, not sure that we can help with the GCC.

    -- pa