Questions tagged [heapalloc]

28 questions
1
vote
1 answer

MASM dll memory allocation

I need help with my MASM dll. I'm counting elements in array then I want to allocate memory for another array, in C I'm using vector. I tried to use: invoe GetProcessHeap invoke HeapAlloc, eax, HEAP_NO_SERIALIZE + HEAP_ZERO_MEMORY,…
Asker
  • 93
  • 7
1
vote
1 answer

HeapCreate and HeapAlloc Confuse

I am doing a project on dynamic memory management. I run into a confuse about the HeapCreate and HeapAlloc functions. For the HeapCreate() function, we can create a heap and the function will return a HANDLE. We can initialize the size of heap.…
satellite
  • 13
  • 1
  • 6
0
votes
1 answer

how to catch or __except when double free runtime error (HeapAlloc)

HANDLE h = HeapCreate(HEAP_GENERATE_EXCEPTIONS, 1024, 4096); int* test = (int*)HeapAlloc(h, HEAP_GENERATE_EXCEPTIONS, sizeof(int)); __try { HeapFree(h, 0, ((char*)test)); HeapFree(h, 0, ((char*)test)); } __except…
YU lee
  • 13
  • 2
0
votes
1 answer

ReadFile buffer output is weird (prints content + some more)

I am trying to open a file and read its content using the Win32 API: HANDLE hFileRead = CreateFileA(FilePath, GENERIC_READ, 0, NULL, …
B00t
  • 9
  • 3
0
votes
1 answer

Why hooking HeapFree with Detours not working for delete/free?

I'm trying to write a memory tracker for my Windows app. I've already finished a prototype using Detours. I hooked HeapAlloc, HeapReAlloc, HeapFree, HeapDestroy and output some logs for me to check. However there's something wrong. Here's my sample…
Zimian
  • 1
  • 1
0
votes
1 answer

Does a call to HeapAlloc with Assembly require deallocation?

At the beginning of my program I allocate memory using HeapAlloc. Is it neccessary to deallocate it or is that done by the system, when the program ends? start: call GetProcessHeap mov r11, rax ; r11 contains handle …
jso
  • 11
  • 2
0
votes
4 answers

Searching for a safe magic number for in-memory data structure

I'm implementing a heap allocator (malloc), and I need to choose a magic number to check if a given pointer point to a data structure I allocated. It seems obvious to me that no magic number can be considered completely safe (if the number is…
fokenrute
  • 739
  • 6
  • 17
0
votes
1 answer

MASM vector like array dynamic allocation

I need help with my MASM code. When I'm using dynamic allocation for arrays my other variables change values after adding few elements to array. .686 .387 .model flat, stdcall .xmm include include\kernel32.inc includelib…
Asker
  • 93
  • 7
0
votes
1 answer

MASM - HeapAlloc throws exception

I'm here again. I'm using masm .dll in c# application, but now my code throws 'System.AccessViolationException' in line: INVOKE HeapAlloc, edx, 0, Can you tell me what cause problem? Here is my ASM code: invoke GetProcessHeap mov edx,…
Asker
  • 93
  • 7
0
votes
1 answer

"LPVOID" can not be assigned to an entity of the type X

I am dealing with a function that deals with USB devices. But I am already having a problem at something simple: I am getting the compiler error A value of the type "LPVOID" can not be assigned to an entity of the type…
tmighty
  • 10,734
  • 21
  • 104
  • 218
0
votes
2 answers

VC++ HeapAlloc inside function gives null pointer

I am trying to use HeapAlloc() to allocate a buffer used by SetupDiGetDeviceRegistryProperty(). Inside GetDeviceInformation() I have: HANDLE hHeap = GetProcessHeap(); while (SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex++, DeviceInfoData)) { …
nckturner
  • 1,266
  • 1
  • 15
  • 19
-2
votes
1 answer

Why does HeapFree() not working as it should?

I created implementation in MVS without using CRT. I use HeapAlloc() and HeapFree() for allocating memory. My example should work without memory leak. Here is my code: LPCSTR byte2ch(BYTE* data, int size) { char* datas =…
korozya
  • 17
  • 6
-3
votes
1 answer

Why heap memory still accessible after HeapFree

I wrote a simple C program which creates a singly linked list. It works; for instance, I pushed a few numbers to a list and the function print_list(...) prints the numbers to the console. However, I then added a clear_list(...) function and called…
Anfield
  • 27
  • 4
1
2