|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
flarn2006 Advanced Cheater Reputation: 1
Joined: 27 Nov 2012 Posts: 73
|
Posted: Sun Dec 30, 2012 3:26 am Post subject: How do I force allocateSharedMemory to allocate a new block? |
|
|
Why is allocateSharedMemory sometimes returning the address to memory that was already allocated in a previous call? How do I prevent it from doing so and force it to allocate a new block of memory, even if one was previously allocated with the same size?
I remember once I was allocating memory for some ASM code that's run every frame, and in another part of my Lua script I allocated some memory for storing strings. As soon as I tried to write a string to the memory I allocated for that purpose, the program crashed. What happened? It had returned the address of the memory block I allocated for code, and it just wrote the strings right over the code. Of course, it then tried to execute the string as code and promptly crashed.
How do I prevent this? On the wiki article for allocateSharedMemory it mentions something about "if it doesn't exist yet" and "if there is no shared region with this name", but I don't see anywhere to specify a name.
All I want to do is allocate some memory that's guaranteed not to already be used by something else. Is there something I'm missing?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Sun Dec 30, 2012 3:49 am Post subject: |
|
|
The function declaration in the wiki was wrong, it's allocateSharedMemory(name, size)
Where name is a unique name
Anyhow, shared memory is probably not what you want, unless you're debugging. (Shared memory retains the contents even if the game has crashed to desktop, so if you reopen the game, allocate the same name again, the original contents will be there)
currently there isn't a lua specific allocation method, but you can use this function
Code: |
function alloc(size)
autoAssemble([[
alloc(luatemp, ]]..size..[[)
registersymbol(luatemp)
]])
return getAddress("luatemp")
end
|
Also, make sure your asm code does not read strings while they are being written (so make sure it doesn't execute at the wrong time)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
flarn2006 Advanced Cheater Reputation: 1
Joined: 27 Nov 2012 Posts: 73
|
Posted: Sun Dec 30, 2012 3:30 pm Post subject: |
|
|
Well actually allocateSharedMemory sounds like it would be perfect for what I need. Thanks!
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|