我试图在winApi函数IsWindows10OrGreater中调用Masm32,但得到了错误LNK2001:未解析的外部符号_IsWindows10OrGreater@0。我还试图在visual .asm中调用此函数,但结果是相等的。为什么masm不认识这个函数?我试着用C代码调用这个函数,它可以工作。这是我的代码:
.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 发布于 2022-10-12 18:09:21
查看文档 for IsWindows10OrGreater,我们看到函数是在versionhelpers.h中定义的。在versionhelpers.h中,我们看到函数不是在库中定义的。它就写在versionhelpers.h中,其中IsWindows10OrGreater调用了IsWindowsVersionOrGreater,而后者又调用了VerifyVersionInfoW。
因此,在任何名为IsWindows10OrGreater的库中都没有符号,这就解释了为什么链接器没有找到它。您应该能够从这些函数中重新创建逻辑,并直接调用VerifyVersionInfoW,这是导出的(来自Kernel32.lib)。
https://stackoverflow.com/questions/74045729
复制相似问题