How to push a 64bit int in NASM?
17,480
There is no push imm64
instruction. As a workaround you can do one of the following:
- go through a register:
mov rax, 0xACEACEACACEACEAC; push rax
- go through memory:
push qword [rel foo]
- write it in two parts:
push dword low32; mov dword [rsp+4], high32
orsub rsp,8; mov dword [rsp], low32; mov dword [rsp+4], high32
- use sign-extension if your immediate allows it
Author by
user2272296
A lot of things happened, this was preceeded by my birth. After my birth, things continued to happen. Coincidence??? I think not.
Updated on June 04, 2022Comments
-
user2272296 almost 2 years
I'm trying to push a 64bit integer but when assembling NASM seems to want to see it as a DWORD not a QWORD.
I'm using ASM to create the shellcode I need to inject a 64bit DLL into a 64bit process. The first QWORD is the old instruction pointer, the second is the address containing the address of the DLL, the third is the address of LoadLibrary. The placeholders are filled in at runtime.
section .text global _start _start: BITS 64 PUSH QWORD 0xACEACEACACEACEAC PUSHFQ push rax PUSH QWORD 0xACEACEACACEACEAC MOV RAX, 0xACEACEACACEACEAC CALL RAX pop RAX POPFQ RETN