簡體   English   中英

Nasm - Crinkler 不導入 winapi 函數

[英]Nasm - Crinkler not importing winapi functions

我一直在嘗試用NasmCrinkler組裝這個codeproject 程序,但是每次我嘗試將 object 文件與 kernel32.lib 和 user32.lib 鏈接時,它都會給我以下 output:

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

當我在 linker 上刪除 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 output 而失敗:

error: parser: instruction expected

關於它為什么發生以及如何解決它的任何想法? 謝謝。

解決它!

只需用我必須通過查看 kernel32.lib 和 user32.lib 獲得的extern _"name"@"number"替換每個extern "name"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM