winapimasm32

Masm32 winApi function IsWindows10OrGreater isn't recognized


I am trying to call winApi function IsWindows10OrGreater in Masm32 but i get error LNK2001: unresolved external symbol _IsWindows10OrGreater@0. I also tried to call this function in visual studio .asm, but the result is equal. Why masm doesnt recognize this function?I tried to call this function in C code and it works. Here is my code:

.686 
.model flat, STDCALL
option casemap :none 
include D:\masm32\include\windows.inc 
include D:\masm32\macros\macros.asm 


include D:\masm32\include\masm32.inc
include D:\masm32\include\gdi32.inc
include D:\masm32\include\user32.inc
include D:\masm32\include\kernel32.inc
include D:\masm32\include\ntdll.inc


includelib D:\masm32\lib\masm32.lib
includelib D:\masm32\lib\gdi32.lib
includelib D:\masm32\lib\user32.lib
includelib D:\masm32\lib\kernel32.lib
includelib D:\masm32\lib\ntdll.lib

IsWindows10OrGreater proto STDCALL
MessageBoxA proto STDCALL, h : DWORD, lpText : DWORD, LPCSTR : DWORD, UINT : DWORD
ExitProcess proto STDCALL, uExitCode : DWORD
.data 
buflen dd 256
hello_title db ' Lab ', 0
hello_message db 'IsWindows10OrGreater: '
.code 
Start:


call IsWindows10OrGreater 
push 40h 
push offset hello_title 
push offset hello_message 

push 0 
call MessageBoxA 
push 0
call ExitProcess 
end Start 

Solution

  • Looking at the docs for IsWindows10OrGreater, we see that the function is defined in versionhelpers.h. Looking in versionhelpers.h, we see that the function is not defined in a library. It's written right there in versionhelpers.h, where IsWindows10OrGreater calls IsWindowsVersionOrGreater, which in turn calls VerifyVersionInfoW.

    So there is no symbol in any library named IsWindows10OrGreater, which explains why the linker isn't finding it. You should be able to recreate the logic from those functions and call VerifyVersionInfoW directly, which is exported (from Kernel32.lib).