qWord has the right idea, Jack
here is what i suggest
first, let's create a couple message strings
.DATA
SuccessMessage db 'Success',0
FailureMessage db 'Failure',0
use global variables for hHeap and PtrMem
.DATA?
hHeap dq ?
PtrMem dq ?
during program initialization, get and store the process heap
INVOKE GetProcessHeap
mov [hHeap],rax
now, when you want to allocate and free memory, use hHeap, HeapAlloc, and HeapFree
INVOKE HeapAlloc,[hHeap],NULL,120000 ;replace NULL with HEAP_ZERO_MEMORY if needed
mov [PtrMem],rax
or rax,rax
jz Allocation_Error
;your "file read" code, here
push rbx
mov rbx,[PtrMem]
;let's test it
mov al,[rbx]
;other code, here
pop rbx
;free the allocated block, when done using it
INVOKE HeapFree,[hHeap],NULL,[PtrMem]
INVOKE MessageBox,0,addr SuccessMessage,addr SuccessMessage,MB_OK
jmp Done
Allocation_Error:
INVOKE MessageBox,0,addr FailureMessage,addr FailureMessage,MB_OK
Done: