flat assembler
Message board for the users of flat assembler.
Index
> Windows > How can I modify a heap? |
Author |
|
AsmGuru62 15 Jul 2013, 22:34
HeapCreate will return a handle to the heap object.
To allocate memory from that heap object you must call HeapAlloc. |
|||
15 Jul 2013, 22:34 |
|
Picnic 15 Jul 2013, 23:07
hi d0mek,
hHeap is a label say at address 0x401000 which holds a 32-bit value (memory pointer) you destroy the high bits of pointer by storing a 0 dword at address 0x401002 it makes more sense like this Code: mov esi, [hHeap] mov eax, [lpBytesRead] move byte [esi+eax], 0 |
|||
15 Jul 2013, 23:07 |
|
d0mek 17 Jul 2013, 00:08
AsmGuru64:
Value 8 in: invoke HeapCreate, HEAP_NO_SERIALIZE, 8, 0 means- set size to 8 bytes. Plus it works without HeapAlloc. |
|||
17 Jul 2013, 00:08 |
|
d0mek 17 Jul 2013, 00:21
Picnic:
Thank you, this works. But I can do this without esi? If hHeap is a "variable" and "esi" is a variable- why do I have to copy from hHeap to esi? |
|||
17 Jul 2013, 00:21 |
|
AsmGuru62 17 Jul 2013, 12:50
MSDN says that you must use HeapAlloc to get blocks from heap created by HeapCreate.
|
|||
17 Jul 2013, 12:50 |
|
JohnFound 17 Jul 2013, 21:56
d0mek, you simply don't understand what the "heap" actually is. It is not one block of memory, but a special memory object from where you can dynamically allocate one or many memory blocks depending of your needs. The heap has special structure and contains not only memory you use, but also memory that describes what memory is allocated and what memory is free. As long the exact structure of the heap is unknown and can be changed from version to version, the only legal way to allocate memory from the heap is to use heap functions of Windows.
BTW, there is no need to create a heap with HeapCreate. Every Windows application already have one. Get its handle with "GetProcessHeap" and then use it to allocate one or many blocks of memory with HeapAlloc. Don't forget to free these memory blocks when not needed with "HeapFree". |
|||
17 Jul 2013, 21:56 |
|
Picnic 17 Jul 2013, 22:41
d0mek wrote: If hHeap is a "variable" and "esi" is a variable- why do I have to copy from hHeap to esi? [hHeap+2] refers at address 0x401000+2 [esi+2] refers at memory block start address+2 Not the same thing, debug your code and trace values to see what's happening. I too suggest to use HeapAlloc. |
|||
17 Jul 2013, 22:41 |
|
baldr 18 Jul 2013, 07:57
Picnic wrote: I too suggest to use HeapAlloc. |
|||
18 Jul 2013, 07:57 |
|
d0mek 18 Jul 2013, 13:31
AsmGuru62, JohnFound, Picnic, baldr: Thank you guys! I will use HeapAlloc then.
I mostly code in PHP, Javascript, Delphi and C# and I don't even need pointers there. I just specify a variable has to be passed by reference and don't need to care any more about it. |
|||
18 Jul 2013, 13:31 |
|
JohnFound 18 Jul 2013, 23:04
d0mek, so it is time to make some real programming then. Try some web programming in assembly. It is a big fun.
|
|||
18 Jul 2013, 23:04 |
|
alessandro95 19 Jul 2013, 12:52
JohnFound wrote: d0mek, so it is time to make some real programming then. Try some web programming in assembly. It is a big fun. Web programming in assembly? That does sound interesting, how do you do that? Can you link any docs/forum/site or whatever? |
|||
19 Jul 2013, 12:52 |
|
JohnFound 19 Jul 2013, 13:46
alessandro95 wrote: Web programming in assembly? That does sound interesting, how do you do that? Can you link any docs/forum/site or whatever? It is open source. You can read and download the sources in the repository. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
19 Jul 2013, 13:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.