![](/img/trans.png)
[英]x86 assembly - how to use Windows API _WriteConsole@4 - masm32 syntax
[英]x86 assembly - GetStdHandle & WriteConsole
在回答我關於Windows API的問題時,我已經成功地使用了它。 我的問題是關於這段代碼:
push STD_OUTPUT_HANDLE
call GetStdHandle
push NULL
push offset other
push mlen
push offset msg
push eax
call WriteConsole
push 0
call ExitProcess
此代碼應該打印msg
的值。 為什么需要做:
一種)
push STD_OUTPUT_HANDLE
call GetStdHandle
push NULL
和:
b)
push offset other
push mlen
push offset msg
push eax
我只是想知道需要什么來獲得StdHandle
並推動抵消。
提前致謝,
Progrmr
看看WriteConsole的定義 。 NULL是函數的最后一個參數,即lpReserved參數。 參數按從右到左的順序推送。 第一個函數參數是控制台句柄,你從GetStdHandle得到的那個,你通過推送eax傳遞。
所以正確評論匯編代碼:
push STD_OUTPUT_HANDLE ; GetStdHandle nStdHandle argument
call GetStdHandle ; eax = Console handle
push NULL ; lpReserved = null
push offset other ; lpNumberOfCharsWritten = pointer to "other"
push mlen ; nNumberOfCharsToWrite = length of "msg"
push offset msg ; lpBuffer = pointer to "msg"
push eax ; hConsoleOutput = console handle from GetStdHandle
call WriteConsole ; Write string
push 0 ; exit code = 0
call ExitProcess ; terminate program
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.