AllocMemory
PROC __dwRequestedSize:DWord
mov eax,__dwRequestedSize
test eax,eax
jz @Exit
add eax,4095
shr
eax,12
; Requested Size / 4096
shl
eax,12 ;
Requested Size * 4096
push PAGE_EXECUTE_READWRITE
push MEM_COMMIT or MEM_RESERVE
push
eax
push NULL
push OFFSET @Exit
jmp
VirtualAlloc
@Error
: xor
eax,eax
@Exit :
test eax,eax
ret
AllocMemory ENDP
This function returns TRUE if the alloc operation
returns successfully.
The function return FALSE if an error occured.
At the end of the function the ZERO flag is set if an error occured.
INVOKE AllocMemory ,4096
jz @Error