GameMaker Objects and Instances

Post here (make sure thread doesn't exist first) any type of tutorials: text, images, videos or oriented discussions on specific games. No online-related discussions/posts OR warez!
Post Reply
aSwedishMagyar
Table Makers
Table Makers
Posts: 690
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1262

GameMaker Objects and Instances

Post by aSwedishMagyar »

Next on the chopping block of Gamemaker hacking is Object Instances!

I have seen in various tables that some people are unknowingly getting the instance bases for certain object types but I have a good way to quickly get all object types and their bases/instances.

Similar to the CScripts in the other post, you can iterate through all of the objects when you find their base using the following template table:
Gamemaker_Object_Template.CT
03-05-2021
(7.49 KiB) Downloaded 1832 times
Once Enabled, you can use the object name as the indexer in your pointers like so:

Image

From the base there are two important parts that need addressing, one is the associated events (step, create, destroy, alarms etc.) and the other is the instances which is what I will be focusing on in this post. Once you get to the base of the object, the number of current instances is located +0x8 from the base of the instance array (which is a linked list by the looks of it) and you index through them by driving down into offset 0x0 as you can see here:

Image
Image

In this case the head of that linked list is at 0xD0 and the tail is at 0xD4 but in other games it could be at 0x38/0x3C. It depends on what the object properties offset is (0x2C or 0x60 for instances at 0x38 and 0xD0 respectively). This means to get to instance 1 you only go down 1 level into 0xD0, for instance 2 you go 2 levels down into 0xD0 and so on.

For games that use multiple instances of the same object (Such as Grim Night which I have posted table for here), you can quickly iterate through the list and set stats or generate records using the following getObjectBase(objName) and getObjectInstance(base,instNum) functions I made:

Code: Select all

function registerObjects(base)
	local base = readPointer(base)
    local numObjects = readInteger(base+8)-1
    if numObjects > 511 then numObjects = 511 end
    base = readPointer(base)
    local offset = 0
    local check = readString(readPointer(readPointer(readPointer(base)+0xC)+offset),100)
    if check == nil or ((not check:find("obj_")) and (not check:find("o"))) then offset = 0x14 end
    for i = 0,numObjects do
    	local name = readString(readPointer(readPointer(readPointer(base+i*8)+0xC)+offset),100)
		if name then _G[name]=i end
    end
end
function getObjectBase(objName)
	if _G[objName] == nil then return nil end
	local off = string.format('%X',_G[objName]*8)
	local base = getAddressSafe('[[[[baseObjects]]+'..off..']+C]')
    return base
end
function getObjectInstance(base,instNum)
	local instMax = readInteger(base+0xD8)--You may have to change this offset depending on the game
    if instNum > instMax or instNum <= 0 then return nil end
    base = base+0xD0	--You may have to change this offset depending on the game
    for i = 1,instNum do
    	base = readPointer(base)
        if (not base) or base == 0 then return nil end
    end
    return readPointer(base+0x8)
end
Register Objects allows you to use the object name in your pointer for the offset (multiply it by 8).

When you have the object instance base, you can dive down into its properties array by (in this case) going to 0x60 and then 0x10 where all of the associated stats are (for a player or unit it would contains things like health, max health, damage, and so on).

Once you have a pointer to that array (see first picture) you can place that header under Query Object Properties to get either 'All' of the properties with their respective offsets or just a particular value (which can be helpful if you have to sift through a bunch).

Image

Hope someone finds this interesting and helpful.

Happy Hacking,
aSwedishMagyar

BHNHAT
What is cheating?
What is cheating?
Posts: 2
Joined: Wed May 05, 2021 10:33 am
Reputation: 0

Re: GameMaker Objects and Instances

Post by BHNHAT »

Why the max objects can be found is 511 ?

3qalves3
Novice Cheater
Novice Cheater
Posts: 18
Joined: Tue Sep 28, 2021 4:40 pm
Reputation: 1

Re: GameMaker Objects and Instances

Post by 3qalves3 »

is Hero Siege not compatible with this table? I'm asking it because hero sieage was made with gamemaker

Post Reply

Who is online

Users browsing this forum: No registered users