I wrote a small procedure to load a file into memory. Why does this not work? I get a GPF every time i try it. I set a up a prototype too.

FileToBuffer proc lpszFileName:DWORD, lpBuffer:DWORD

invoke CreateFile, lpszFileName,
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_ARCHIVE,
NULL

mov hFile, eax

invoke GetFileSize, hFile, NULL
mov FileSize, eax

invoke GlobalAlloc, GMEM_FIXED or GMEM_ZEROINIT, FileSize
mov lpBuffer, eax

;invoke ReadFile, hFile, lpBuffer, FileSize, addr SizeReadWrite, NULL
invoke CloseHandle, hFile

FileToBuffer Endp
Posted on 2002-01-11 02:54:11 by Asm_Freak
Hossa

sorry im a newbie.......but possible you need to free the mem after ?
if i use GlobalAlloc firsttime i get crash solong if i free the mem after :-)
Posted on 2002-01-11 02:59:58 by Max
my guess would be no ret. :rolleyes: :grin:
Posted on 2002-01-11 03:00:45 by fresh
Max, that's in another proc, called DestroyBuffer.

Anyways... How could i be so dumb, no ret solved the prolbem.

Thanks fresh.

JP
Posted on 2002-01-11 03:07:10 by Asm_Freak
Anyways... How could i be so dumb, no ret solved the prolbem.

Heh, i've made the same mistake myself in the past. What i do now is as soon as i have typed the <funcName> proc and <funcName> endp lines, i immediately put in the ret before anything else. That way i never forget ;)
Posted on 2002-01-11 03:18:08 by sluggy