Advertisement
MichaelPetch

SO79498852

Mar 10th, 2025 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. section .text
  2. extern GetStdHandle
  3. extern WriteFile
  4. ;extern ExitProcess
  5. global hw
  6. hw:
  7. push rbp ; Align stack back on 16 byte boundary
  8. mov rbp, rsp
  9. sub rsp, 32+8+8 ; Allocate space on stack for maximum number
  10. ; of stack based variables used to call Windows functions
  11. ; which is 1 argument in this case (total 8 bytes).
  12. ; Subtract 32 bytes for the shadow space. Subtract additional
  13. ; 8 bytes to maintain 16 byte alignment
  14. mov rcx,-11
  15. call GetStdHandle
  16.  
  17. mov rcx,rax ; No need to use R12 and if we had we would have to preserve it
  18. ; as it is a nonvolatile register
  19. lea rdx,[rel msg]
  20. mov r8,16
  21. mov r9,rsp
  22. mov qword [rsp+32], 0 ; RSP+0 to RSP+31 are the shadow space.
  23. ; First stack based parameter (5th argument to WriteFile) is at RSP+32
  24. call WriteFile
  25.  
  26. leave
  27. ret
  28.  
  29. section .data
  30. msg: db "hello"
  31. msglen: equ $-msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement