How do GameShark codes work?

[BACK]
How do GameShark codes work?
Posted On: July 22, 2013

This has always boggled me. Obviously GameShark and Game Genie never got inside access to place their own cheats into every game. I don't think any developers gave them the source code to pour over for codes. And I don't think the original development process for these games included placing any of these codes themselves. So, what is a GameShark or Game Genie code, really?


Both of them usually take the form of a relatively short hexadecimal string (or multiple if that is the case) so my intuition tells me they use the same principle. But are they just memory addresses to flip a bit? Or lock it? Or XOR a series of bits with something? What is the code, and what does it do?


Question from user LoveAndCoding at gaming.stackexchange.com.


Answer:

How it works.


When GameShark (and other game enhancer products/homebrew) gets loaded by the console, the enhancer is what launches the actual game. In doing so, it leaves behind a Code Handler in the system RAM and "hooks" the game's programming.


Specific locations in a game's programming that get executed roughly every frame (like reading the controller data) are where "hooks" will be placed. (because SDKs are used, this makes finding hooks that work in all games for a system much easier).


What the hook actually does is redirect the flow of programming to the Code Handler the enhancer left behind. Once the Code Handler is finished executing, it returns the flow of programming back to the point of hijacking.


If you are familiar with GameShark's "Master Code", that is what sets the hook.


(other enhancers - like Gecko OS for Wii - don't need master codes because the enhancer itself has a handful of SDK-based hooks that it can "find" in the game while it loads.).


Structure of codes.


Now a code itself is separated into THREE parts:.


The CodeType (this is USUALLY the first byte of the code-- the first 2 Hex Characters). CodeTypes are specific to the enhancer.


The address in ram that the CodeType will use.


The value the codetype will use at the specified address.


The most common CodeTypes are:.


RAM Writes (typical options are 8bit, 16bit, or 32bit).


With RAM Write, the CodeHandler will take the value and place it at the address. (changing whatever was there, like setting your health to 100!).


Conditionals (typical options are >, <, =, !=).


With Conditionals, the CodeHander reads the value at the code's address and compares it to the value in the code. IF the comparison returns true, then the CodeHander will execute the next line in the code. (how many lines it executes is up to the enhancer and often is an option in the codetype itself!).


There is plenty more info we could dive into, but that should give you a good basis for understanding. =).


Source: Game hacker since 1999, founder of http://GeckoCodes.org.


Answer from user James0x57 at gaming.stackexchange.com.



[BACK]
How do GameShark codes work?
Posted On: July 22, 2013

This has always boggled me. Obviously GameShark and Game Genie never got inside access to place their own cheats into every game. I don't think any developers gave them the source code to pour over for codes. And I don't think the original development process for these games included placing any of these codes themselves. So, what is a GameShark or Game Genie code, really?


Both of them usually take the form of a relatively short hexadecimal string (or multiple if that is the case) so my intuition tells me they use the same principle. But are they just memory addresses to flip a bit? Or lock it? Or XOR a series of bits with something? What is the code, and what does it do?


Question from user LoveAndCoding at gaming.stackexchange.com.


Answer:

How it works.


When GameShark (and other game enhancer products/homebrew) gets loaded by the console, the enhancer is what launches the actual game. In doing so, it leaves behind a Code Handler in the system RAM and "hooks" the game's programming.


Specific locations in a game's programming that get executed roughly every frame (like reading the controller data) are where "hooks" will be placed. (because SDKs are used, this makes finding hooks that work in all games for a system much easier).


What the hook actually does is redirect the flow of programming to the Code Handler the enhancer left behind. Once the Code Handler is finished executing, it returns the flow of programming back to the point of hijacking.


If you are familiar with GameShark's "Master Code", that is what sets the hook.


(other enhancers - like Gecko OS for Wii - don't need master codes because the enhancer itself has a handful of SDK-based hooks that it can "find" in the game while it loads.).


Structure of codes.


Now a code itself is separated into THREE parts:.


The CodeType (this is USUALLY the first byte of the code-- the first 2 Hex Characters). CodeTypes are specific to the enhancer.


The address in ram that the CodeType will use.


The value the codetype will use at the specified address.


The most common CodeTypes are:.


RAM Writes (typical options are 8bit, 16bit, or 32bit).


With RAM Write, the CodeHandler will take the value and place it at the address. (changing whatever was there, like setting your health to 100!).


Conditionals (typical options are >, <, =, !=).


With Conditionals, the CodeHander reads the value at the code's address and compares it to the value in the code. IF the comparison returns true, then the CodeHander will execute the next line in the code. (how many lines it executes is up to the enhancer and often is an option in the codetype itself!).


There is plenty more info we could dive into, but that should give you a good basis for understanding. =).


Source: Game hacker since 1999, founder of http://GeckoCodes.org.


Answer from user James0x57 at gaming.stackexchange.com.



[BACK]

Is there a secret way to get some character skins in Soul Knight? Is there a secret way to get some character skins in Soul Knight?

Posted On: August 19, 2023
I'm quite new to playing Soul Knight, and I find it quite enjoyable and entertaining. I see that there are skins in the game, but I just can't afford to buy one. Is there a secret thing o...[More]


Hogwarts Legacy is Excellent but lacking? Hogwarts Legacy is Excellent but lacking?

Posted On: April 17, 2023
Anyone else love the game but just feel they could have expanded on a lot of things? Beast taming could have been a proper side thing yet I'm just feeding them for materials, once I've gott...[More]


How can I activate an area of redstone all at once? How can I activate an area of redstone all at once?

Posted On: February 6, 2023
The idea behind my contraption is to trap players in lava by deactivating an area of fence gates under some carpet. This pushes the players upwards into the lava and there items fall onto the carpet. ...[More]


Is it possible to see what of my content received awards? Is it possible to see what of my content received awards?

Posted On: March 16, 2024
My Steam profile has a couple of awards, but I'm not sure where they came from. I remember receiving an email about this, but it's gone now.Is it possible to find which of my content (comments, review...[More]


How to join Minecraft servers? How to join Minecraft servers?

Posted On: August 24, 2023
My son wants to join a server on Minecraft (Wii U Edition), but we don't know how. How can he join a server? Question from user Tomás at stackexchange. Answer: You can only join...[More]


How many Pokémon were available at the release of Pokémon Go? How many Pokémon were available at the release of Pokémon Go?

Posted On: January 20, 2023
I have googled for this, but can't really put the proper terms to find an answer. At the initial release of Pokémon Go, how many Pokémon were available? I seem to remember legenda...[More]


Can a War Caster use Shocking Gasp as a reaction without having it as a Cantrip? Can a War Caster use Shocking Gasp as a reaction without having it as a Cantrip?

Posted On: October 22, 2023
When leveling up my character, I have the option to take the War Caster feat which says I can use a reaction to cast Shocking Grasp at a target moving out of melee range. However, my character does no...[More]


How can you be immune to damage from bed explosions in the nether? How can you be immune to damage from bed explosions in the nether?

Posted On: April 11, 2023
In Minecraft, everyone seems to able to use beds for mining or killing the Ender Dragon, but whenever I use it I blow up instantly. Is this a bug, or how can I be immune to this damage? Question...[More]


What are the black bugs that come from defeated enemies? What are the black bugs that come from defeated enemies?

Posted On: January 31, 2023
Sometimes when I defeat an enemy a small black bug will appear and start flying away from me. What are these black bugs? Is there something I can do with them? Question from user Stevoisiak at gami...[More]


Dueling in Hogwarts Legacy Dueling in Hogwarts Legacy

Posted On: August 28, 2023
EDIT Thank you to everyone who commented with your advice! I admit I started getting frustrated and my bf had to take over as PVP isn't usually my thing in video games! (I usually do Minecraft, st...[More]