From 89e02fcd9edc6bfb82890757d4269d3fb5ec2186 Mon Sep 17 00:00:00 2001 From: Fr0sT-Brutal Date: Thu, 12 Mar 2015 20:11:05 +0300 Subject: [PATCH] Zero the memory allocated in the heap Using HEAP_ZERO_MEMORY parameter of HeapAlloc function we can fill all the struct contents with zeros thus removing possible bugs with uninitialized members and slightly shortening/speeding up the code --- MemoryModule.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MemoryModule.c b/MemoryModule.c index 8a348a1..682b95d 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -496,7 +496,7 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, } } - result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE)); + result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MEMORYMODULE)); if (result == NULL) { SetLastError(ERROR_OUTOFMEMORY); VirtualFree(code, 0, MEM_RELEASE); @@ -504,9 +504,6 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, } result->codeBase = code; - result->numModules = 0; - result->modules = NULL; - result->initialized = FALSE; result->isDLL = (old_header->FileHeader.Characteristics & IMAGE_FILE_DLL) != 0; result->loadLibrary = loadLibrary; result->getProcAddress = getProcAddress;