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]

How do I reset my sensor to track Shrines in Zelda Tears Of The Kingdom? How do I reset my sensor to track Shrines in Zelda Tears Of The Kingdom?

Posted On: May 31, 2023
I set my sensor to track the location of an item from the Hyrule Compendium. How do I reset it to start tracking Shrines again? Question from user Stevoisiak at gaming.stackexchange.com. Answer:...[More]


Does anyone know how to get up these stairs in the Gryffindor common room? I’ve completed the entire story. Thanks! Does anyone know how to get up these stairs in the Gryffindor common room? I’ve completed the entire story. Thanks!

Posted On: March 22, 2023
Does anyone know how to get up these stairs in the Gryffindor common room? I’ve completed the entire story. Question from user ash_5512 at HogwartsLegacyGaming at reddit.com. Answer: Th...[More]


How do I make food in Planet Crafter? How do I make food in Planet Crafter?

Posted On: April 29, 2024
In The Planet Crafter, I'm building my base, and I have enough food for now. I don't have any machines to make food, but I know I'm going to eventually run out. I guess that, like with water, I'm goin...[More]


Why are Fallouts computers so backwards? Why are Fallouts computers so backwards?

Posted On: April 16, 2024
The games are set in the future right? Circa 2077. But the terminals look like the computers back in the 1950's. When we actually had to type commands to get things done. Why is this? Im assuming it h...[More]


Damp wall ignored in Dwarf Fortress why? Damp wall ignored in Dwarf Fortress why?

Posted On: April 26, 2023
I took as granted that Miners always detected damp walls and stopped mining in these cases. But a miner did not detect, or just decided to ignore, an obvious damp wall, and created a leak that led ...[More]


Whats the games equivalent of the force Whats the games equivalent of the force

Posted On: June 10, 2024
Not Jedi per se, but the power of that world, like Destiny 2 has light and dark, Star Wars has the Force, Harry Potter Just has magic, etc.I like playing tanky characters that use whatever the primary...[More]


I don't like Gale I don't like Gale

Posted On: April 7, 2026
I know I'm not alone in this opinion either, but there's also a shocking amount of people who love Gale so I'm trying to understand the appeal. .Please understand, I have used Gale in my party all the...[More]


Will I still get weapon discounts in Ratchet & Clank 3 with a Ratchet & Clank 1 new game+ save? Will I still get weapon discounts in Ratchet & Clank 3 with a Ratchet & Clank 1 new game+ save?

Posted On: March 8, 2024
In Ratchet and Clank 3: Up your Arsenal, it's possible to get an "employee discount" at Gadgetron weapons vendors if you have a save file from Ratchet & Clank 1 present on the memory card.The save fil...[More]


How do I backup my Minecraft world on Xbox to a flash drive without realms? How do I backup my Minecraft world on Xbox to a flash drive without realms?

Posted On: June 10, 2023
How do I backup my Minecraft Bedrock world from my Xbox to a flash drive?. I don’t have realms and don’t want to get realms to backup my world. I want to keep it on a drive separate ...[More]


How do I continue downloading a game in Steam while playing? How do I continue downloading a game in Steam while playing?

Posted On: May 28, 2015
I have many games on Steam and many more I will buy, but I have a problem and I hope you can point me a solution.When I download a game, is it possible to launch and play a single player game under St...[More]