none
User mode function typedef error in driver code RRS feed

  • Question

  • I need to do the following typedef in a wdm driver. It's not clear how I can do this. Anyone knows? Thanks.

    typedef BOOL (WINAPI *PDLL_MAIN) (HMODULE,DWORD,LPVOID);

    The following does not produce a VS IDE error. But I am not sure if it's equivalent to what I want.

    typedef NTSTATUS (*PDLL_MAIN) (HANDLE,UINT32,PVOID);



    • Edited by Dev10110110 Monday, August 27, 2018 12:53 PM
    Monday, August 27, 2018 12:41 PM

Answers

  • Well, from a user mode perspective they are not equivalent due to the difference in the calling convention.

    Edit:

    In user mode WINAPI resolves to the __stdcall calling convention.  The default calling convention used by VS would otherwise be __cdecl.

    • Edited by RLWA32 Monday, August 27, 2018 1:17 PM clarified comment
    • Marked as answer by Dev10110110 Monday, August 27, 2018 1:35 PM
    Monday, August 27, 2018 12:58 PM

All replies

  • Well, from a user mode perspective they are not equivalent due to the difference in the calling convention.

    Edit:

    In user mode WINAPI resolves to the __stdcall calling convention.  The default calling convention used by VS would otherwise be __cdecl.

    • Edited by RLWA32 Monday, August 27, 2018 1:17 PM clarified comment
    • Marked as answer by Dev10110110 Monday, August 27, 2018 1:35 PM
    Monday, August 27, 2018 12:58 PM
  • Thank you RLWA32. I looked around in the driver includes and found no __stdcall. I just assumed __stdcall was not available in a driver. Now that I try it, the compilation succeeds:

    typedef NTSTATUS (__stdcall *PDLL_MAIN) (HANDLE,UINT32,PVOID);

    Please let me know if this is still not equivalent.


    • Edited by Dev10110110 Monday, August 27, 2018 1:35 PM
    Monday, August 27, 2018 1:34 PM
  • I don't see any other real differences.
    Monday, August 27, 2018 1:40 PM