Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with enumMemoryRegions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
daninthemix
Cheater
Reputation: 0

Joined: 29 Jul 2013
Posts: 39

PostPosted: Sun Jun 28, 2020 12:48 am    Post subject: Help with enumMemoryRegions Reply with quote

This very helpful script gives you the base address of DOSBOX's virtual memory:

Code:
[ENABLE]
for i,v in ipairs(enumMemoryRegions()) do
  if v.RegionSize==0x1001000 and v.AllocationProtect==4 then
    unregisterSymbol('GameMemoryStart') registerSymbol('GameMemoryStart',v.BaseAddress+0x20)
  end
end


But it only works when
Code:
memsize=16
in the dosbox.conf.

If
Code:
memsize=32
it doesn't work, and I've tried using
Code:
v.RegionSize==0x2002000
but to no avail.

How can I figure out what memory region size I want to be searching for, when DOSbox is using a particular amount of virtual memory?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25287
Location: The netherlands

PostPosted: Sun Jun 28, 2020 1:32 am    Post subject: Reply with quote

try 2001000

anyhow, instead of checking the size you could change the check to v.RegionSize>=0x1001000

and then check each result if it's a valid dosbox memory region

e.g at GameMemoryStart+7e is likely the 2 byte value 0xc000 (int1f default points to a graphics card bios rom area which is at c000)

_________________
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
View user's profile Send private message MSN Messenger
daninthemix
Cheater
Reputation: 0

Joined: 29 Jul 2013
Posts: 39

PostPosted: Sun Jun 28, 2020 3:04 am    Post subject: Reply with quote

v.RegionSize>=0x1001000 works great - tested on 32MB and 64MB mem sizes, so thanks a million for that.

In the case of games with changing values (for example Fade to Black - the health value is in a different location every time you run the game), would I just follow the standard process of trying to find the pointer, and then when I do make that pointer relative to GameMemoryStart right at the end?

I always get very confused when it comes to finding pointers in emulators.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25287
Location: The netherlands

PostPosted: Sun Jun 28, 2020 8:43 am    Post subject: Reply with quote

no, pointers are very different in emulators, and in realmode it's just a nightmare
in realmode (dos) a pointer exists out of segment and offset
segment specifies the address*0x10 and offset adds to it

e.g
0x1000:0x30 would end up at 0x10000+0x30=0x10030
0x1002:0x10 would end up at 0x10020+0x10=0x10030
0x1003:0x0 would end up at 0x10030+0=0x10030

_________________
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
View user's profile Send private message MSN Messenger
daninthemix
Cheater
Reputation: 0

Joined: 29 Jul 2013
Posts: 39

PostPosted: Sun Jun 28, 2020 9:07 am    Post subject: Reply with quote

Thanks a million for your help.

Luckily most DOS games seem to use static addresses. So with the above method, you can just find the right address once, then add it with GameMemoryStart+offset and it works across all versions of DOSBox, which is great.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Jul 13, 2020 11:27 am    Post subject: Reply with quote


Left window = dosbox with memsize=16
Right window = dosbox with memsize=32

This should work for memsize=32
Code:
for i,v in ipairs(enumMemoryRegions()) do
  if v.RegionSize==0x2001000 and v.AllocationProtect==4 then
    unregisterSymbol('GameMemoryStart') registerSymbol('GameMemoryStart',v.BaseAddress+0x20)
  end

end

What games are using more than 16MB under DOS?

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites