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]

Why do Pokemon sometimes have dark stripes in Pokemon Go? Why do Pokemon sometimes have dark stripes in Pokemon Go?

Posted On: February 5, 2023
Occasionally I'll face a Charizard or Venusaur in GBL that has dark striping like this:.How do they get those markings, or what is the significance of them?Question from user Lysander at gaming.stacke...[More]


How do I solve level 7 category normal on Lineum? How do I solve level 7 category normal on Lineum?

Posted On: April 14, 2023
All the stone going around the green and the blue has uneven amount. Plus I keep getting bored trying to figure it out but keep getting the same thing over and over. Question from user Hunter Jason...[More]


How many types of charging ports do Nintendo handhelds have? How many types of charging ports do Nintendo handhelds have?

Posted On: June 17, 2023
I'm sorting through my old Nintendo handhelds and have found that many of them use different charging cables. I've seen at least four different types:. Nintendo Switch & Switch Lite. ...[More]


Dead or Alive: Dimensions Control Mechanism Dead or Alive: Dimensions Control Mechanism

Posted On: March 24, 2023
In the recently released title for the Nintendo 3DS, some of the video previews seem to suggest that the characters are controlled by "selecting" combinations on the touch screen, rather tha...[More]


New player in Hogwarts Legacy!! New player in Hogwarts Legacy!!

Posted On: June 25, 2023
Currently downloading the game on steam, anybody have any tips or anything for my first time ever playing the game? All advice welcome! Thanks :D. Question from user sullydtd at HogwartsLegacyGamin...[More]


How do damage upgrades of the same type stack in Dead Cells? How do damage upgrades of the same type stack in Dead Cells?

Posted On: April 13, 2023
When I pick up an upgrade scroll I can increase my attack power for brutality, tactic, or survival objects by 15%. How do damage increases of the same type stack with each other? Are they additive or ...[More]


How do I complete a Cargo Link quest? How do I complete a Cargo Link quest?

Posted On: October 28, 2023
One of my quests is to establish a Cargo Link for Uranium at Akila. (I can't find any further information in my mission logfile how to do that.). I have found the console near the landing zo...[More]


What Hogwarts House Did You Pick and Why? What Hogwarts House Did You Pick and Why?

Posted On: June 16, 2023
In the movies, (I didn’t read the books) it only really shows Gryffindor and Slytherin, Ravenclaw and Hufflepuff houses aren’t mentioned that much. . Primarily the ones who picked Huffl...[More]


How to quit an online match? How to quit an online match?

Posted On: March 6, 2024
I'm trying to run for the Platinum trophy before the server closure, so I'll soon start to get game modes I don't need anymore, and I don't want to waste my time.Is there a way to leave an online matc...[More]


Can’t use - get rid of these. Can’t use - get rid of these.

Posted On: December 9, 2024
Playing on ps5. Can’t hit X or square to move/examine. They have been stuck in my inventory since act 1. .Am I supposed to keep hold of them for an interaction or is something bugged out?(Clean play...[More]