Okay. So I have this code in intel syntax.
BITS 64
section .text
global asm_proc
asm_proc:
jmp program
section .data
; b8 - mov rax, <32bit immediate>
; 64 00 00 00 - The number 100 decimal
; C3 - ret
program db 0b8h, 064h, 000h, 000h, 000h, 0c3h
I have the opcodes documented there so you don't have to look them up.
The above code actually does work with a slight modification (moving program
to the the .text
section).
BITS 64
section .text
global asm_proc
asm_proc:
jmp program
; b8 - mov rax, <32bit immediate>
; 64 00 00 00 - The number 100 decimal
; C3 - ret
program db 0b8h, 064h, 000h, 000h, 000h, 0c3h
I have this declared in a C file extern uint64_t asm_proc();
and it returns 100
when program
is in the .text.
section, but Windows crashed the application when program
is in the .data
section.
Could anyone explain this to me? Maybe a solution to what I am trying to do?
Also is this information correct?
.text
- Flags: read
& exec
.data
- Flags: read
| (read
& write
).bss
- Flags: Not sure, but I think just read
Heap - Flags: read
& write
Stack - Flags: read
& write
THANKS! :D