[ Home | Optimize | Current | Project | Tools | Made in France | F.A.Q | Forums | Links | Sources Codes ]

5 - FREEING MEMORY

For freeing memory I use the VirtualFree  function. This function frees a block allocated with VirtualAlloc.

Here is an example of what such a function could be :

FreeMemory        PROC  __lpBuffer:DWord

                  mov    eax,__lpBuffer

                  test   eax,eax
                  jz     @Exit

                  push   MEM_RELEASE
                  push   NULL
                  push   eax
                  push   OFFSET @Exit
                  jmp    VirtualFree

@Error :          xor    eax,eax

@Exit :

                  test   eax,eax
                  ret
FreeMemory        ENDP

This function returns TRUE if the free 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 Free Memory ,4096
jz     @Error

<Return>

 

[ Home | Optimize | Current | Project | Tools | Made in France | F.A.Q | Forums | Links | Sources Codes ]