winapi - Nasm - Crinkler 不导入 winapi 函数
问题描述
我一直在尝试用Nasm和Crinkler组装这个codeproject 程序,但是每次我尝试将目标文件与 kernel32.lib 和 user32.lib 链接时,它都会给我以下输出:
Crinkler 2.3 (Jul 21 2020) (c) 2005-2020 Aske Simon Christensen & Rune Stubbe
Target: out.exe
Tiny compressor: YES
Tiny import: NO
Subsystem type: WINDOWS
Large address aware: NO
Compression mode: SLOW
Saturate counters: NO
Hash size: 500 MB
Hash tries: 100
Order tries: 0
Reuse mode: OFF (no file specified)
Report: NONE
Transforms: NONE
Replace DLLs: NONE
Fallback DLLs: NONE
Range DLLs: NONE
Exports: NONE
Loading window.obj...
Loading kernel32.lib...
Loading user32.lib...
Linking...
Forced alignment of 1 code hunk to 1 (including entry point).
WINDOW.OBJ: START: error LNK: Cannot find symbol 'GetModuleHandleA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'LoadIconA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'LoadCursorA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'RegisterClassExA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'MessageBoxA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'CreateWindowExA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'ShowWindow'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'UpdateWindow'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'PeekMessageA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'TranslateMessage'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'DispatchMessageA'
WINDOW.OBJ: START: error LNK: Cannot find symbol 'ExitProcess'
WINDOW.OBJ: WindowProc: error LNK: Cannot find symbol 'PostQuitMessage'
WINDOW.OBJ: WindowProc: error LNK: Cannot find symbol 'DefWindowProcA'
我也尝试将它与golink链接,它在格式上给了我同样的错误:
GoLink.Exe Version 1.0.3.0 Copyright Jeremy Gordon 2002-2018 info@goprog.com
Error!
The following symbols were not defined in the object file or files:-
ExitProcess
RegisterClassExA
CreateWindowExA
MessageBoxA
GetModuleHandleA
PeekMessageA
TranslateMessage
DispatchMessageA
PostQuitMessage
DefWindowProcA
ShowWindow
UpdateWindow
LoadIconA
LoadCursorA
Output file not made
命令行是:
nasm window.asm -f win32
crinkler /NODEFAULTLIB /ENTRY:START /SUBSYSTEM:WINDOWS /TINYHEADER window.obj kernel32.lib user32.lib
golink window.obj kernel32.lib user32.lib
在我的代码中:
extern printf
extern ExitProcess
;all other externs
;more code
START:
push 0
call GetModuleHandleA
;more code
当我在链接器上删除 kernel32.lib 和 user32.lib 时,我注意到的另一件奇怪的事情发生了,我遇到了新错误:
Crinkler import: _Import: error LNK: Cannot find symbol '__imp__MessageBoxA@16'
Crinkler import: _Import: error LNK: Cannot find symbol '__imp__LoadLibraryA@4'
这是我通常对失败的导入所期望的,通常它们在名称前有“ imp ”,在其后有“@number”。
另外,我尝试导入 win32n.inc 并使用:
import ExitProcess kernel32.dll
nasm 输出失败:
error: parser: instruction expected
关于它为什么发生以及如何解决它的任何想法?谢谢。
解决方案
修复!
只需用我必须通过查看 kernel32.lib 和 user32.lib 获得的extern "name"
一个替换每个。extern _"name"@"number"
推荐阅读
- ios - 使用 Swift 解析 @odata 值的问题
- c++11 - 将原始指针重叠到 unique_ptr 并再次将其分配给 unique_ptr
- autocomplete - 根据 tcsh 中的命令和子命令自动完成命令行参数
- kubernetes - Kubernetes 中没有发生 DNS 名称解析
- ionic4 - 键盘覆盖离子 4 中的输入字段
- java - 将多边形和 Jbutton 打包到 Tile 中
- c++ - C++ 如何制作一个 std::list 的数组?
- r - 重新排列山脊线图中的面板
- c++ - qt opengl stl 用法线向量渲染错误
- database - 没有主键的 Cassandra 排序查询(或自动更新记录)