I was able to get something to build and run without installing MASM.
In this, VirtualAlloc returns EAX=0, so of course VirtualProtect will also not be successful.
; TEST program
; ---------------------------------------------------------------------------------------------------------
.686P
.model flat, stdcall
.stack 4096
; ---------------------------------------------------------------------------------------------------------
; Constants
memorySize EQU 1024*8
PAGE_READWRITE EQU 0004h
PAGE_EXECUTE EQU 0010h
PAGE_EXECUTE_READWRITE EQU 0040h
MEM_COMMIT EQU 010000h
; ---------------------------------------------------------------------------------------------------------
.data
hHeap DWORD ?
theMem DWORD ?
; ---------------------------------------------------------------------------------------------------------
.code
ExitProcess PROTO, dwExitCode:dword
GetProcessHeap PROTO ; Get the current process heap handle
HeapAlloc PROTO,
hHeap:DWORD, ; handle to private heap block
dwFlags:DWORD, ; heap allocation control flags
dwBytes:DWORD ; number of bytes to allocate
HeapFree PROTO,
hHeap:DWORD, ; handle to heap with memory block
dwFlags:DWORD, ; heap free options
lpMem:DWORD ; pointer to block to be freed
VirtualProtect PROTO,
pMem:DWORD, ; pointer to the memory
dwSize:DWORD, ; size of area to protect
fNewProtect:DWORD, ; new protection
pOldProtect:DWORD ; pointer to storage for old protection value
VirtualAlloc PROTO,
pMem:DWORD, ; optional, NULL lets the system figure it out
dwSize:DWORD, ; requested size
fAllocType:DWORD, ; allocation type
fProtect:DWORD ; protection flags
; ---------------------------------------------------------------------------------------------------------
main proc
; call GetProcessHeap
; mov hHeap, eax
; invoke HeapAlloc, hHeap, 0, memorySize
; invoke HeapFree, hHeap, 0, theMem
invoke VirtualAlloc, 0, memorySize, MEM_COMMIT, PAGE_READWRITE
mov theMem, eax
invoke VirtualProtect, theMem, memorySize, PAGE_EXECUTE, 0
invoke ExitProcess,0
main endp
end main
; ---------------------------------------------------------------------------------------------------------