macro Msg t { invoke MessageBox,0,t,0,0 }
macro opnFile f,b {
	mov eax,f
        mov edx,b
        call pc@LoadFile
	mov dword [b+edx],0
	}

rbait       	dd 0
flen        	dd 0,0,0,0
filename    	dd 0
fhand       	dd 0
load.allocMode  db 0
dataAllocPtr@	dd 0

proc    pc@LoadFile
             push    edx
             mov     [rbait],0
             mov     [filename],eax
             invoke CreateFile,eax,GENERIC_READ,3,0,OPEN_EXISTING,FILE_ATTRIBUTE_READONLY,0 ;NORMAL,0
             mov    [fhand],eax
             invoke GetFileSizeEx,[fhand],flen
		cmp byte [load.allocMode],1
		jnz @f
		invoke  VirtualAlloc,0,dword [flen],MEM_COMMIT,PAGE_READWRITE
                mov     dword [dataAllocPtr@],eax
		mov dword [esp],eax
@@:
             pop    edx
             invoke ReadFile,[fhand],edx,[flen],rbait,0 ;nelza pisat 290_000_000 ! nade [flen] kernell 
             invoke CloseHandle,[fhand]
             mov    eax,[rbait]
             test    eax,eax
             jnz    pc@PLoadFileOK
             mov     eax,[filename]
             invoke  MessageBox, 0, eax, fileErrorMsg,MB_OK or MB_ICONERROR
pc@PLoadFileOK: mov edx,[flen]
	cmp edx,[rbait]
	jz  @f
	;PrintValue 'LoadFile size error = %d',dword [rbait]
@@:
		ret
fileErrorMsg db "Fille not found.",0
endp