WINDOWS HELLO WORLD (scuffed)

This commit is contained in:
2026-06-09 01:02:40 -04:00
parent e4acaf40aa
commit ea305909a0
6 changed files with 58 additions and 8 deletions
+24 -1
View File
@@ -79,10 +79,33 @@ fn windows() {
let mut program = Program::<X86_64>::default();
let [get_std_handle, write_file, exit_process] =
program.external("KERNEL32.dll", ["GetStdHandle", "WriteFile", "ExitProcess"]);
let text = b"Hello world!\n";
let text_sym = program.ro_data("hello_en", text);
let written = program.ro_data("written", [0; 4]);
let entry = program.func(
"main",
[BInstr::Asm(Asm {
instrs: vec![Instr::Sub, mov(ecx, 40), Instr::CallMem(exit_process)],
instrs: vec![
Instr::Sub,
// stdout
mov(ecx, -11),
Instr::CallMem(get_std_handle),
// write
mov(rcx, rax),
lea(rdx, text_sym),
mov(r8d, text.len() as u64),
lea(r9, written),
Instr::MemMov {
reg: rsp,
offset: 0x20,
val: 0,
},
// mov qword [rsp+32], 0
Instr::CallMem(write_file),
// exit
mov(ecx, 39),
Instr::CallMem(exit_process),
],
})],
);
program.entry = Some(entry);