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 I use N.E.I. every time i play? Can I use N.E.I. every time i play?

Posted On: September 19, 2023
Is it possible to always have Not Enough Items set up every time I play Minecraft even without Forge? Can I for example open Minecraft and choose my normal profile not Forge, and when I play have Forg...[More]


Build the greatest possible sleight of hand. Build the greatest possible sleight of hand.

Posted On: December 14, 2025
I'm looking to start a new campaign in honor mode for myself. In my current campaign, I'm having a lot of trouble buying items from merchants, even though I'm collecting everything in the world to sel...[More]


How do I use Triple Notch without triggering High Volley in Horizon Forbidden West How do I use Triple Notch without triggering High Volley in Horizon Forbidden West

Posted On: April 21, 2023
I have two skills from the Hunter tree: Triple Notch and High Volley. The weird thing is that as far as I can tell both are triggered by the same buttons, holding L2 and pressing R1. Sometimes when...[More]


Would the companion talk to each other about Tav - Durge? Would the companion talk to each other about Tav - Durge?

Posted On: November 8, 2023
Specifically if you manage to romance nearly all of them, do they just sit around the campfire and talk to each other about it, like it's the Bachelor/Bachelorette - Faerun edition? Or do they ...[More]


How do I get the star behind the gate in The City? How do I get the star behind the gate in The City?

Posted On: March 29, 2024
Near the start of The City, there is a star behind a gate down in the water. The B3313 wiki says I can bypass the gate with a vanish cap, but I'm not able to find it. Where can I find the vanish cap t...[More]


How do I transfer the Militech Datashard eddies to myself? How do I transfer the Militech Datashard eddies to myself?

Posted On: December 19, 2023
During one of the early missions in the game, you are tasked with collecting a Flathead robot from a Maelstrom hideout. I resolved the optional objective to chat to Militech about it, and received the...[More]


Can I hide the Currently In game from Steam? Can I hide the Currently In game from Steam?

Posted On: February 3, 2023
I don't want to hide my online status.I want to hide the currently in-game which appears on a game on my profile page.Any way to do that?Question from user KeyC0de at gaming.stackexchange.com.Answer:Y...[More]


Why are my Dungeon Crawl items losing points? Why are my Dungeon Crawl items losing points?

Posted On: May 8, 2023
I started a new game playing Crawl Stone Soup and have noticed that my weapons and armor get weaker over time. My weapon started at +2/+2 and is now at +2/-4. My armor went from +1 to -1. Wha...[More]


How do I reach these isolated graffiti spots in Versum Hill? How do I reach these isolated graffiti spots in Versum Hill?

Posted On: August 29, 2023
In Versum Hill there's an underground area with several graffiti spots seemingly isolated from the rest of the map. There's a long hallway leading to it that I can't find any way to reach....[More]


Is it just me or is there something wrong with Professor Garlick? Is it just me or is there something wrong with Professor Garlick?

Posted On: September 5, 2023
Is it just me or is there something wrong with Professor Garlick? Was it really just accidents her former herbalism teacher suffered, or did Garlick have something to do with it? I mean, she fel...[More]