// test_version.cpp : Test for RtlGetNtVersionNumbers() API // #include #include #include #include using namespace std; typedef VOID (NTAPI* PRTL_GET_NT_VERSION_NUMBERS)(OUT LPDWORD pdwMajorVersion, OUT LPDWORD pdwMinorVersion, OUT LPDWORD pdwBuildNumber); int _tmain(int argc, _TCHAR* argv[]) { HMODULE hNTDLL = LoadLibrary(TEXT("ntdll.dll")); if (hNTDLL) { PRTL_GET_NT_VERSION_NUMBERS pRtlGetVersionNumbers = (PRTL_GET_NT_VERSION_NUMBERS)GetProcAddress(hNTDLL, "RtlGetNtVersionNumbers"); if (pRtlGetVersionNumbers) { DWORD Major, Minor, Build; pRtlGetVersionNumbers(&Major, &Minor, &Build); cout << "RtlGetNtVersionNumbers() called successfully" << endl << "\tMajor = " << Major << " ; 0x" << hex << Major << dec << endl << "\tMinor = " << Minor << " ; 0x" << hex << Minor << dec << endl << "\tBuild = " << Build << " ; 0x" << hex << Build << dec << endl; } else { cout << "ERROR: The RtlGetNtVersionNumbers() API doesn't exist in your version of NTDLL.DLL" << endl; } FreeLibrary(hNTDLL); } else { cout << "ERROR: Cannot load NTDLL.DLL" << endl; } _getch(); return 0; }