我相信这对大多数人来说非常简单,但我对 x86 汇编语言不是很熟悉。我只是想自学。

我在 window 里。在我阅读的任何地方,我都被告知使用 INT 21 返回操作系统。这退出了程序,但我收到一条错误消息,说 Unhandled exception at 0x003d1313 in Assignment1.exe: 0xC0000005: Access violation reading location 0xffffffff

谢谢!

最佳答案

在 Windows 上,如果您使用的是正式的汇编程序(例如 MASM),您可以简单地调用以下代码:

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
.code
start:
        invoke ExitProcess,0
end start

如果您不使用任何汇编程序并且只想执行一段二进制代码,请执行以下操作:
push xxx
push -1
push 0
mov eax, yyy
mov edx, 7FFE0300
call dword ptr ds:[edx]

其中 xxx 是进程的退出代码,yyy 是 NtTerminateProcess 的系统调用号(使用 http://www.pediy.com/document/Windows_System_Call_Table/Windows_System_Call_Table.htm 确定适当操作系统的调用号。Windows 7 为 0x172)

关于x86 汇编语言 - 终止程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8085414/

10-15 01:38