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]

Can you cast Avada Kedavra on students and teachers? Can you cast Avada Kedavra on students and teachers?

Posted On: July 22, 2023
I haven't unlocked the killing curse (Avada Kedevra) yet, but I have seen and used it in one of the battle arenas. But now I am wondering: When you eventually unlock it later in the game as a n...[More]


Any useful strategies for finding a Nether Fortress in Minecraft? Any useful strategies for finding a Nether Fortress in Minecraft?

Posted On: June 20, 2023
Anyone have useful strategies for finding a Nether Fortress in Minecraft's Nether? I got into the nether and wandered around for quite a while, but didn't find anything. I'm not sure if...[More]


Hogwarts Legacy Was So Much Fun Hogwarts Legacy Was So Much Fun

Posted On: June 10, 2023
I am now the proud owner of a shop in Hogsmeade, and that quest was way more involved than I expected. Question from user Street-Comparison-45 at HogwartsLegacyGaming at reddit.com. Answer: T...[More]


Resistance 3, unable to delete game data, and installation of trophies freezing Resistance 3, unable to delete game data, and installation of trophies freezing

Posted On: March 25, 2023
Bought Resistance 3, popped it into the PS3 and the first thing that came up was an update. So I wait the 2 hours to download the 696 MB update, then let it install. The entire PS3 freezes at installi...[More]


What does Ominis mean when he says Imelda's quick and not just on a broom? What does Ominis mean when he says Imelda's quick and not just on a broom?

Posted On: July 19, 2023
he says it so cheeky as if it's an insult but the only insulting meaning for quick really only applies to guys and even then generally quick means witty and/or smart. am I misreading his voice or ...[More]


Is GoldenEye Source free? Is GoldenEye Source free?

Posted On: March 23, 2023
I can't tell if you have to buy anything to play GoldenEye: Source. Is it free? Are there any good tutorials on getting this up and running? Question from user slim at gaming.stackexchange.com....[More]


Who picks your locks and disarms your traps... Who picks your locks and disarms your traps...

Posted On: May 18, 2024
. if not Astarion? I'm considering ditching him for the first time in my second run, but he is my lockpicker and trap disarmer, and Act 3 has many areas full of traps and locks. Of course, I could mak...[More]


What is the best class to RP as a doctor? What is the best class to RP as a doctor?

Posted On: May 7, 2025
So, I want to try and play as a doctor character but don't know what class would fit them best. Armor wise, I feel like they would only wear clothing and wield a staff. I was thinking cleric could fit...[More]


What was the first game to show toilets? What was the first game to show toilets?

Posted On: November 20, 2023
And by "toilets" I mean the actual thing you sit on, not just "restrooms". Not trying to be weird, I just remember I first saw them in Fallout 3 (2008) and suddenly realized tho...[More]


Donkey Kong 64 - What do the Chimpy Cam options do? Donkey Kong 64 - What do the Chimpy Cam options do?

Posted On: March 17, 2023
In the options for Donkey Kong 64 I can set Chimpy Cam to either Free or Follow. What's the difference between Free and Follow? Question from user Stevoisiak at gaming.stackexchange.com. Ans...[More]