Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

Manipulating memory


james227uk
 Share

Recommended Posts

I've done basic scripts for a long time (1-2 years?). Cool, now I want to do something more challenging. I noticed memory opcodes, and found an address for weapons set one to see if I get using them right. This is what I made

 

 

{$CLEO .cs}thread 'FUNC':1wait 0if   Player.Defined($PLAYER_CHAR)jf @1if   00E1: 0 11jf @10A8C: write_memory 0x969130 size 4 value 1 virtual_protect 0wait 1000jump @1

 

 

However, nothing happened. Can someone write me a sample script on using a mem address please?

Link to comment
Share on other sites

Horny Quintus

This is something I have just started getting to grips with as well.

 

According to the GTA modding page, the memory address for that weapon cheat code is one byte. So instead of size 4, you need size 1:

 

 

0A8C: write_memory 0x969130 size 1 value 1 virtual_protect 0

 

 

The size is size in bytes. For future reference, float and dword are 4 bytes.

Link to comment
Share on other sites

Thanks for the help. Size 1 was my original number and that didnt work either

Link to comment
Share on other sites

Well, 24 hours. Thanks for all your help guys, really, your help has meant alot [/sarcasm]

Link to comment
Share on other sites

Horny Quintus

Unfortunately I am running v1.01 so the memory addresses listed for v1.0 do not work for me and I was unable to run your script and see how it worked out for me. I had a look at finding the v1.01 addresses for cheat codes but was unable to.

 

Link to comment
Share on other sites

Unfortunately I am running v1.01 so the memory addresses listed for v1.0 do not work for me and I was unable to run your script and see how it worked out for me. I had a look at finding the v1.01 addresses for cheat codes but was unable to.

I've got 1.01 but as long as you have a V1 EXE it doesnt matter

Link to comment
Share on other sites

No need for sarcasm. Memory manipulating is not an easy area of modding where everyone could give you advices, so be patient. About your problem, you're doing almost everything right (except wrong size, there actually must be 1 instead of 4, because you were set a cheat flag, which is one byte in length). But sadly you misunderstood the whole thing: not an every cheat could be activated by setting its flag to 1. Yes, some of them could work so if you set a flag to 1, the game begins to think the cheat was typed so it does something new. But for some cheats the game should perform specific actions before. For example, for the weapon cheat the game must load proper models, give weapons to player, set its ammo and so on. Only then the flag is set to 1, indicating that the cheat was there (actually it does not really matter for these kind of cheats is the flag set or not, they are executed once and that's it - like cheat that clear your wanted level, the game clears it and does nothing with the flag).

 

So, for the cheats to work, you should not set the flags, but should call proper functions from the exe file, which makes actual changes in game. Addresses of these functions are located at 0x008A5B58 and further.

Link to comment
Share on other sites

Thanks Seemann,

 

So I need the call_function opcode and a function memory address?

Link to comment
Share on other sites

Hm... I guess it's just as well that I didn't read Seemann's notes earlier. I was poking around with the write memory codes and found some interesting results. Only some of the flags will work. I found some cheats I didn't know existed, but that's not saying much since I seldom use cheats. I found Recruit Anyone and they get an AK-47. I also found Cars Drive on Water flags, but two flags need to be set to get it to work (oh, it looks like there is a PS2 version of this cheat). Anyway, here's a set of flags that had an apparent effect. Occasionally I went with the flag definition that was triggered in SACC and didn't investigate much further.

 

 

//0A8C: write_memory 0x96913B size 1 value 1 virtual_protect 0 // Speed up Clock
//0A8C: write_memory 0x96913E size 1 value 1 virtual_protect 0 // Peds Rioting
//0A8C: write_memory 0x96913F size 1 value 1 virtual_protect 0 // Everyone Attacks CJ
//0A8C: write_memory 0x969140 size 1 value 1 virtual_protect 0 // Peds have Weapons
//0A8C: write_memory 0x96914B size 1 value 1 virtual_protect 0 // Invisible Cars
//0A8C: write_memory 0x96914C size 1 value 1 virtual_protect 0 // Perfect Handling
//0A8C: write_memory 0x96914E size 1 value 1 virtual_protect 0 // All green lights
//0A8C: write_memory 0x96914F size 1 value 1 virtual_protect 0 // Aggressive Drivers
//0A8C: write_memory 0x969150 size 1 value 1 virtual_protect 0 // Pink Traffic
//0A8C: write_memory 0x969151 size 1 value 1 virtual_protect 0 // Black Traffic 
//0A8C: write_memory 0x969152 size 1 value 1 virtual_protect 0 // Cars Drive On Water
//0A8C: write_memory 0x969153 size 1 value 1 virtual_protect 0 // Boats Can Fly
//0A8C: write_memory 0x969154 size 1 value 1 virtual_protect 0 // unknown (was Cars Drive On Water part 2)
//0A8C: write_memory 0x969159 size 1 value 1 virtual_protect 0 // Beach Traffic
//0A8C: write_memory 0x96915B size 1 value 1 virtual_protect 0 // No Traffic 
//0A8C: write_memory 0x96915C size 1 value 1 virtual_protect 0 // Motorcycle Traffic (Ninja?)
//0A8C: write_memory 0x96915E size 1 value 1 virtual_protect 0 // Crappy Car Traffic
//0A8C: write_memory 0x96915F size 1 value 1 virtual_protect 0 // Fast Car Traffic
//0A8C: write_memory 0x969160 size 1 value 1 virtual_protect 0 // Cars Can Fly 
//0A8C: write_memory 0x969161 size 1 value 1 virtual_protect 0 // Huge Bunnyhop 
//0A8C: write_memory 0x969164 size 1 value 1 virtual_protect 0 // Tank Mode
//0A8C: write_memory 0x969165 size 1 value 1 virtual_protect 0 // Cars Have Nitro
//0A8C: write_memory 0x969166 size 1 value 1 virtual_protect 0 // Bubble Cars
//0A8C: write_memory 0x969167 size 1 value 1 virtual_protect 0 // Stop Game Clock
//0A8C: write_memory 0x969168 size 1 value 1 virtual_protect 0 // Stop Game Clock
//0A8C: write_memory 0x96916C size 1 value 1 virtual_protect 0 // Mega Jump
//0A8C: write_memory 0x96916D size 1 value 1 virtual_protect 0 // Infinite Health
//0A8C: write_memory 0x96916E size 1 value 1 virtual_protect 0 // Infinite Oxygen
//0A8C: write_memory 0x969171 size 1 value 1 virtual_protect 0 // Never Wanted
//0A8C: write_memory 0x969173 size 1 value 1 virtual_protect 0 // Mega Punch
//0A8C: write_memory 0x969174 size 1 value 1 virtual_protect 0 // Never Hungry
//0A8C: write_memory 0x969175 size 1 value 1 virtual_protect 0 // Riot Mode
//0A8C: write_memory 0x969176 size 1 value 1 virtual_protect 0 // Funhouse Traffic
//0A8C: write_memory 0x969178 size 1 value 1 virtual_protect 0 // Infinite Ammo
//0A8C: write_memory 0x969179 size 1 value 1 virtual_protect 0 // Full Aim Driving
//0A8C: write_memory 0x96917A size 1 value 1 virtual_protect 0 // Decreased Traffic
//0A8C: write_memory 0x96917B size 1 value 1 virtual_protect 0 // Farm Traffic 
//0A8C: write_memory 0x96917C size 1 value 1 virtual_protect 0 // Recruit Anyone w/Pistol
//0A8C: write_memory 0x96917D size 1 value 1 virtual_protect 0 // Recruit Anyone w/AK-47
//0A8C: write_memory 0x96917E size 1 value 1 virtual_protect 0 // Recruit Anyone w/Rockets
//0A8C: write_memory 0x96917F size 1 value 1 virtual_protect 0 // Max Respect 
//0A8C: write_memory 0x969180 size 1 value 1 virtual_protect 0 // Max Sex Appeal 
 

 

 

I find it very helpful to use Tsearch to make memory dumps so I can examine the data I intend to edit with memory writes. Perhaps that's because I got started with save editing and I'm mostly trying to recreate those types of modifications. I've got some examples but most of them are subroutines and I'm not sure they'll make any sense out of context.

Edited by OrionSR
Code Tags
Link to comment
Share on other sites

Thanks Orion. So would value 0 for a cheat turn it off?

 

EDIT: Thanks again Orion. You've proved my theory. Cars drive on water is apparently not in the PC version, yet I tried the mem address and it worked perfect.

Edited by james227uk
Link to comment
Share on other sites

Yeah, hardly anyone knows much about memory here. Since your getting started there are a few of those basic things you should know (if you don't already know them)...

 

 

Hex Numbers

 

GTA stores memory as hex. In fact, the whole .scm file is originally written in hex. Notice how opcodes are often typed: 03F9.

 

Now memory is read and written in hex, although Sanny does indeed support converting to decimal, it's handy to know the basic hex numbering system. Basically, it's just like the normal numbers except with 6 extra 1-digit numbers which are defined as letters...

 

Hex

0 1 2 3 4 5 6 7 8 9 A B C D E F

 

(Remember that in Sanny, hex numbers are usually identified by having 0x in front of them. Example: 0x2A)

 

Decimal

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

 

F is the hex number for 15, but just imagine it as the new limit for your count to 2-digit numbers. Usually it ends at 9, but now we go to a whole new number, F.

 

F is 15, so what is 16?

 

10!

 

Hex numbers go up to F before adding or changing a digit to the start of a number and resetting the last number back to 0. Just like counting to 10 in decimal.

 

10 = 16

11 = 17

12 = 18

13 = 19

14 = 20

15 = 21

16 = 22

17 = 23

18 = 24

19 = 25

1A = 26

1B = 27

1C = 28

1D = 29

1E = 30

1F = 31

20 = 32

[...]

AA = 170

FF = 255

100 = 256

 

Just some examples of hex numbers and what they equal in decimal.

 

 

But note that you can also spell letters in hex, which only works for some techniques for San Andreas (ones that use this lettering system)... Let's play a game!

 

A = 41

Z = 5A

 

Remembering that these hex numbers are just going up by 1 hex number per letter (so B is 42 and Y is 59) try and figure out the rest of the alphabet... Then decode the message below:

 

4D 59 20 53 45 43 52 45 54 20 4D 45 53 53 41 47 45

 

Answer:

MY SECRET MESSAGE

 

 

Ever notice how the keycodes for 0AB0 are simply the same as the letters? So keypress "A" is simply letter "A".

 

 

Lowercase letters are different:

 

61 = a

7a = z

 

 

Although often aren't used in San Andreas. Keypresses are always uppercase.

 

 

By the way, you can also spell words in decimal. Simply the same operation of converting letters to numbers.

 

 

Memory/Function

 

Memory addresses and function addresses are different things... Although commonly classed under the same thing.

 

 

Memory addresses are usually for settings and generally stuff to remember. Variables are also stored in these addresses.

 

 

0A8D: $result = read_memory [email protected] size 4 virtual_protect 00A8C: write_memory 0xC0BC15 size 1 value 1 virtual_protect 0

 

 

Addresses are different sizes and some are "read only". If you ever find an address that cant be written or read, try changing the size or switching the virtual protect flag on.

 

I'm not too sure about this, but I believe these are the sizes of different things:

 

Boolean (1 or 0 / true or false): 1

Number (Float/Integer): 4

Short string: 8

Long string: 16

 

I believe I missed out 2 as I'm not too sure whether there is a specific type assigned with it. I just remember using 2 for making cheat codes.

 

 

 

That's all I can be bothered to type at the moment, but if you have a question... Feel free to ask.

 

Hopefully someone can help me with some sort of address to completely freeze the game... Like when you press Esc...

Edited by Deji
Link to comment
Share on other sites

 

Thanks Orion. So would value 0 for a cheat turn it off?

I didn't test setting a value of 0 very often, but in the few cases where I did try it worked to disable the effects of setting a value of 1. I suspect that due to the nature of these flags this should always be the case, but didn't test the idea so I can't know for sure.

 

I suspect that more experimentation with the addresses in the range 0x969130 to 0x969189 not included in my previous post might result in additional cheat type effects. 0x96915A or 0x96915D seems to alter the ped group information enough to have reduced peds and traffic, but I couldn't isolate the effects. It was similar to setting gangs in a zone where they don't below without altering the mysterious ped group (0874:) information or 0767: popcycle. (Hm... didn't 076A: ped wealth ever get updated to dealer density?) Anyway, frequently the effects are a bit subtle so I would not be surprised if more interesting information could be discovered.

 

james227uk, do you have enough examples of memory writes to get started, or do you need more sample code?

Edited by OrionSR
Link to comment
Share on other sites

Enough to get started, thanks. cookie.gifcookie.gifcookie.gif

 

EDIT: Saw Deji's post. WOW. Still having a good read through. Thanks colgate.gif

Edited by james227uk
Link to comment
Share on other sites

spaceeinstein
user posted image
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.