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]

In Yakuza0, What does divine intervention mean on the Sacred Wooden Katana? In Yakuza0, What does divine intervention mean on the Sacred Wooden Katana?

Posted On: March 20, 2023
The description of the Sacred Wooden Katana states:. This wooden sword is protected by the gods, and legend has it that divine intervention will occur when your health is low. What does "di...[More]


Defeating the helicopter in Split Second Defeating the helicopter in Split Second

Posted On: January 24, 2023
I'm having some trouble in the episode where you're supposed to defeat the helicopter. I do pretty well in the episodes where you're supposed to avoid the helicopter fire. I must be missing a power ...[More]


Can I tell if an enemy is out of range in Elden Ring? Can I tell if an enemy is out of range in Elden Ring?

Posted On: August 10, 2023
I'm playing as an Astrologer, so my main means of attack is to cast spells from a distance, as I barely do any physical damage. However, I noticed that my spells have a certain range, and firin...[More]


Where are all the Daedalian Key locations in Hogwarts Legacy? Where are all the Daedalian Key locations in Hogwarts Legacy?

Posted On: July 20, 2023
I'm trying to find all the Daedalian Keys to put onto the chest cabinet thing in my common room, but I'm struggling to find all of them. Where can I find all of them? Does someone have a li...[More]


How much health does an Apple heal? How much health does an Apple heal?

Posted On: January 20, 2023
How much HP does an apple heal? Whenever I pick up an apple the amount healed seems to vary. Does the amount healed scale with my character's maximum HP? Question from user Stevoisiak at gaming...[More]


Where is the last red coin in Motos Factory? Where is the last red coin in Motos Factory?

Posted On: March 29, 2024
I am trying to collect the 8 red coins for Motos Factory in B3313 v1.0, but I have only been able to find 7. I've found the following red coins:.At the start of the level behind where you spawn.In the...[More]


How to pick up the walkie talkie in Walking Dead Season 2: Episode 3? How to pick up the walkie talkie in Walking Dead Season 2: Episode 3?

Posted On: March 25, 2023
I am stuck at the quick time event where Clem has to pick up the walkie talkie. I see two brackets moving towards each other, yet I forgot what to do for those quick time events. How to pick up the...[More]


Help with Shadowheart approval. Help with Shadowheart approval.

Posted On: September 19, 2024
I am in Act 3 and trying to get Shadowhearts approval high enough to where i can romance, but i’m wondering if me long resting will make it so I cant have the romance scene? ive seen people say that...[More]


Are there American cars faster than NASCAR cars in GT5? Are there American cars faster than NASCAR cars in GT5?

Posted On: May 26, 2023
In B specs I'm trying to win an American championship that only allows American cars. I've tried with a Pilot Level 30 and a NASCAR car, but he can't win. . I'm wondering if ther...[More]


In YuGiOh, How to verify if a card is banned, limited, semi-limited for an event festival In YuGiOh, How to verify if a card is banned, limited, semi-limited for an event festival

Posted On: February 16, 2023
There are two events coming soon in Yu-Gi-Oh! Master Duel, the Legends Anthology, and the XYZ Festival.If I were to pre-build decks for those events, how do I verify if the card I want to use can be u...[More]