64 位中的程序集系统调用 Windows
Assembly Syscalls in 64-bit Windows
我在 windows 10,安装了 Cygwin。我一直将 Cygwin 用于 compilation/assembly of c 和使用 Cygwin 安装的 "gcc" 和 "nasm" 的汇编程序。据我所知,nasm 有一个 -f win64 模式,所以它可以 assemble 64 位程序。现在,windows 上的x64 汇编编程,youtube 似乎缺少教程。 youtube 上的大多数汇编编程教程都是针对 x64 linux 或 x32 windows,我需要能够在 x64 windows 上将字符串打印到控制台,而无需使用任何外部工具函数,例如 C 的 "printf".
Whosebug link对我不起作用的:
64-bit windows assembler
据我所知,nasm 使用 -f win64 扩展支持 64 位 windows。此外,答案与如何在 x64 位汇编中编写实际程序无关 windows
How to write hello world in assembler under Windows?
所有提供代码的答案都只提供过时 windows 版本(32 位)的代码,一个除外。我试过适用于 64 位的一个答案,但是 link 目标文件的命令给我一个错误,系统找不到指定的路径。
windows x64 assembler?
本站不包含任何代码,这正是我需要的。另外,我正在尝试在 nasm.
中编写 Hello World 程序
64 bit assembly, when to use smaller size registers
这个问题实际上包含一个 hello world 程序的代码,但是当在 windows 10(我的设备)上的 cygwin 下执行时,我遇到了分段错误。
Why does Windows64 use a different calling convention from all other OSes on x86-64?
我曾尝试使用 objdump -d 反汇编 C Hello World 程序,但这会调用预构建的 C 函数 printf,我正在努力避免使用外部函数。
我试过其他外部函数(例如 Messagebox),但它们 return 错误,因为某些东西无法识别这些函数。另外,如果可能的话,我尽量不使用任何外部函数,只使用系统调用、sysenter 或中断。
代码:
尝试 #1:
section .data
msg db "Hello, World!", 10, 0
section .text
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 14
syscall
mov rax, 60
mov rdi, 0
syscall
问题:正确组装和 links,但在 运行.
时抛出分段错误
尝试 #2:
section .text
mov ah, 0eh
mov al, '!', 0
mov bh, 0
mov bl, 0
int 10h
问题:assemble 不正确;说 "test.asm:3: error: invalid combination of opcode and operands"
尝试 #3:
section .text
msg db 'test', 10, 0
mov rdi, 1
mov rsi, 1
mov rdx, msg
mov rcx, 5
syscall
mov rdi, 60
mov rsi, 0
syscall
问题:正确组装和 links,但在 运行.
时抛出分段错误
尝试 #4:
section .text
mov ah, 0eh
mov al, '!'
mov bh, 0
mov bl, 0
int 10h
问题:正确组装和 links,但在 运行.
时抛出分段错误
我只需要一个在 64 位上运行的 hello world 汇编程序的示例 Windows10。当我 运行 32 位程序时,它们似乎 return 出错。如果不使用外部函数就无法将字符串打印到控制台,那么使用外部函数并在 64 位 Windows 10 上运行的程序示例会很好。
我听说 windows 中的系统调用地址与 linux 中的地址大不相同。
Attempt #1:
Attempt #2:
内部Windows使用中断或系统调用。但是它们没有正式记录,它们可能会更改 Microsoft 想要更改它们的任何时候:
只有少数.dll
个文件直接使用了系统调用指令;所有程序都直接或间接访问这些 .dll
文件。
某个序列(例如 mov rax, 5
、syscall
)在 Windows 更新之前可能具有“打印文本”的含义,Microsoft 可能会更改此序列的含义Windows 更新后“删除文件”。
为此,Microsoft 只需更换内核和正式“允许”使用 syscall
指令的 .dll
文件。
调用 Windows 操作系统函数以保证您的程序在下一次 Windows 更新后仍然工作的唯一方法是调用 [=11] 中的函数=] 文件 - 与在 C 程序中执行此操作的方式相同。
示例(32 位代码):
push 1
push msg
push 14
call _write
mov dword [esp], 0
call _exit
我在 windows 10,安装了 Cygwin。我一直将 Cygwin 用于 compilation/assembly of c 和使用 Cygwin 安装的 "gcc" 和 "nasm" 的汇编程序。据我所知,nasm 有一个 -f win64 模式,所以它可以 assemble 64 位程序。现在,windows 上的x64 汇编编程,youtube 似乎缺少教程。 youtube 上的大多数汇编编程教程都是针对 x64 linux 或 x32 windows,我需要能够在 x64 windows 上将字符串打印到控制台,而无需使用任何外部工具函数,例如 C 的 "printf".
Whosebug link对我不起作用的:
64-bit windows assembler
据我所知,nasm 使用 -f win64 扩展支持 64 位 windows。此外,答案与如何在 x64 位汇编中编写实际程序无关 windows
How to write hello world in assembler under Windows?
所有提供代码的答案都只提供过时 windows 版本(32 位)的代码,一个除外。我试过适用于 64 位的一个答案,但是 link 目标文件的命令给我一个错误,系统找不到指定的路径。
windows x64 assembler?
本站不包含任何代码,这正是我需要的。另外,我正在尝试在 nasm.
中编写 Hello World 程序64 bit assembly, when to use smaller size registers
这个问题实际上包含一个 hello world 程序的代码,但是当在 windows 10(我的设备)上的 cygwin 下执行时,我遇到了分段错误。
Why does Windows64 use a different calling convention from all other OSes on x86-64?
我曾尝试使用 objdump -d 反汇编 C Hello World 程序,但这会调用预构建的 C 函数 printf,我正在努力避免使用外部函数。
我试过其他外部函数(例如 Messagebox),但它们 return 错误,因为某些东西无法识别这些函数。另外,如果可能的话,我尽量不使用任何外部函数,只使用系统调用、sysenter 或中断。
代码:
尝试 #1:
section .data
msg db "Hello, World!", 10, 0
section .text
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 14
syscall
mov rax, 60
mov rdi, 0
syscall
问题:正确组装和 links,但在 运行.
时抛出分段错误尝试 #2:
section .text
mov ah, 0eh
mov al, '!', 0
mov bh, 0
mov bl, 0
int 10h
问题:assemble 不正确;说 "test.asm:3: error: invalid combination of opcode and operands"
尝试 #3:
section .text
msg db 'test', 10, 0
mov rdi, 1
mov rsi, 1
mov rdx, msg
mov rcx, 5
syscall
mov rdi, 60
mov rsi, 0
syscall
问题:正确组装和 links,但在 运行.
时抛出分段错误尝试 #4:
section .text
mov ah, 0eh
mov al, '!'
mov bh, 0
mov bl, 0
int 10h
问题:正确组装和 links,但在 运行.
时抛出分段错误我只需要一个在 64 位上运行的 hello world 汇编程序的示例 Windows10。当我 运行 32 位程序时,它们似乎 return 出错。如果不使用外部函数就无法将字符串打印到控制台,那么使用外部函数并在 64 位 Windows 10 上运行的程序示例会很好。
我听说 windows 中的系统调用地址与 linux 中的地址大不相同。
Attempt #1:
Attempt #2:
内部Windows使用中断或系统调用。但是它们没有正式记录,它们可能会更改 Microsoft 想要更改它们的任何时候:
只有少数.dll
个文件直接使用了系统调用指令;所有程序都直接或间接访问这些 .dll
文件。
某个序列(例如 mov rax, 5
、syscall
)在 Windows 更新之前可能具有“打印文本”的含义,Microsoft 可能会更改此序列的含义Windows 更新后“删除文件”。
为此,Microsoft 只需更换内核和正式“允许”使用 syscall
指令的 .dll
文件。
调用 Windows 操作系统函数以保证您的程序在下一次 Windows 更新后仍然工作的唯一方法是调用 [=11] 中的函数=] 文件 - 与在 C 程序中执行此操作的方式相同。
示例(32 位代码):
push 1
push msg
push 14
call _write
mov dword [esp], 0
call _exit