Created
March 25, 2017 17:51
-
-
Save AaronC81/aafe36aca2e3e9502c8a3799c001b4d6 to your computer and use it in GitHub Desktop.
Allocating Memory in NASM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global _main | |
extern _ExitProcess@4 | |
extern _MessageBoxA@16 | |
extern _GetProcessHeap@0 | |
extern _HeapAlloc@12 | |
section .text | |
_main: | |
; Place heap in eax | |
call _GetProcessHeap@0 | |
; Allocate 5 bytes and point to eax | |
push 5 | |
push 8 | |
push eax | |
call _HeapAlloc@12 | |
mov byte [eax], 65 | |
mov byte [eax+1], 66 | |
mov byte [eax+2], 67 | |
mov byte [eax+3], 68 | |
mov byte [eax+4], 0 | |
; Display message | |
push 0 | |
push _title | |
push _msg | |
push 0 | |
call _MessageBoxA@16 | |
push 0 | |
call _ExitProcess@4 | |
_msg: db "Hello", 0 | |
_title: db "Title", 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment