c++winapisyntax

Why does this c++ syntax with WINAPI mean?


BOOL (WINAPI *ZTSQueryUserToken)(ULONG SessionId, PHANDLE phToken) = NULL;

To me it looks like a variable being created for a struct or something but I've never seen this type of syntax so can someone break it down for me?


Solution

  • WINAPI convention is usually used to call Win32 API functions.

    WINAPI is simply __stdcall:

    #define WINAPI __stdcall
    

    The __stdcall calling convention has following characteristics in general:

    So leaving behind __stdcall, use the "Spiral Rule" to get

                +----------------------+
                |   +----------------+ |
                |   |                | |
                |   ^                | |
    BOOL (WINAPI* ZTSQueryUserToken  ) ( ULONG SessionId, PHANDLE phToken) 
     ^          ^                    | |
     |          +--------------------+ |
     +---------------------------------+   
    

    Thus, Identifier:

    And the pointer is assigned to NULL in your case.