Error compile with "libloaderapi.h" library in Visual studio

Nguyen Ba Quan (GAM.DAP) 6 Reputation points
2022-01-19T08:52:13.433+00:00

Hi,
I would like to using "libloaderapi.h" library that allocated in "Kernel32.lib" Library and "Kernel32.dll" DLL
https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress

But when I compiled the program with visual studio 2019, there is an error with the library "minwinbase.h"

typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;

typedef RTL_CRITICAL_SECTION_DEBUG CRITICAL_SECTION_DEBUG;
typedef PRTL_CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG;
typedef PRTL_CRITICAL_SECTION_DEBUG LPCRITICAL_SECTION_DEBUG;

Error: identifier is undefined.
these are declared in "winnt.h"

166248-1.png

I have added the links to the libraries: libloaderapi.h, minwinbase.h, winnt.h in VC++ directories, C/C++/General, Linker/input. But it's still fail
Please help me
Thanks

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,526 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 81,636 Reputation points
    2022-01-19T09:05:41.297+00:00

    You don't need to include it
    As the doc says, just

    #include <windows.h>
    

  2. Nguyen Ba Quan (GAM.DAP) 6 Reputation points
    2022-01-19T09:30:45.837+00:00

    currently, I'm working on windows driver framework(WDF) with kernel mode driver(KMDF), can this library work in this mode?