Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      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. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Memory handling


BnB
 Share

Recommended Posts

My skills in SA memory handling are low and I need

a little help

 

I cannot understand this

 

0A9F: [email protected] = current_thread_pointer000A: [email protected] += 0x10

 

how do I know which number I have to use like 0x10. It would be helpful if you help me understand this and please give me an example of his usage.

 

 

0AB1: call_scm_func @GetSQR 1 10 $result

 

What does this and when we use it?

 

 

 

const  NUM       = [email protected] end

 

What exactly does this ?

I understand that it constructs a variable and instead of using [email protected] we use NUM is this right ?

 

Thanks

Link to comment
Share on other sites

 

My skills in SA memory handling are low and I need

a little help

 

I cannot understand this

 

0A9F: [email protected] = current_thread_pointer000A: [email protected] += 0x10

 

how do I know which number I have to use like 0x10. It would be helpful if you help me understand this and please give me an example of his usage.

 

0A9F returns an address of the current thread (script) struct at the game memory. What this struct holds you can read there

http://www.gtamodding.com/index.php?title=...Block_1:_Script

Scroll down till words Thread Memory Dump:

 

 

  0x00  dword                     Next Pointer

  0x04  dword                     Previous Pointer

  0x08  char[8]                   Thread Name

  0x10  dword                     Absolute Base Address

  0x14  dword                     Absolute IP

  0x18  dword[8]                  Absolute Return Stack

  0x38  word                      Stack Pointer

  0x3A  byte[2]                   (Align)

  0x3C  dword[32]                 Local Variables

  0xBC  dword[2]                  Local Timers

  0xC4  byte                      (Unknown)

  0xC5  byte                      'if' statement result

  0xC6  byte                      (Unknown)

  0xC7  byte                      Is External Script

  0xC8  byte                      (Unknown)

  0xC9  byte                      (Unknown)

  0xCA  byte[2]                   (Align)

  0xCC  dword                     Wakeup Time

  0xD0  word                      'if' parameter

  0xD2  byte                      'not' flag

  0xD3  byte                      'wb_check' flag

  0xD4  byte[4]                   (Unknown)

  0xD8  dword                     Skip Scene Pos (opcode 0707)

  0xDC  byte                      Is Mission

  0xDD  byte[3]                   (Align)

  0xE0                            end

 

By adding +10 you get address of the 'Absolute Base Address' value. So, after using

0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0

[email protected] will hold this value. It's useful to know actual script location in the game memory for some advanced coding tricks.

Link to comment
Share on other sites

@Jerry123 I already have read it and I want to know more.

@Adler Thanks!

@Seemann Thanks your post was really helpful can you post an example

script with explanation.

 

So, if I use this 0x08 I can get the thread name and change it.

 

 

Edited by BnB
Link to comment
Share on other sites

 

{$CLEO}thread 'test'0A9F: [email protected] = current_thread_pointer000A: [email protected] += 0x080A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 00ADF: add_dynamic_GXT_entry "_TEST" text [email protected]: set_draw_text_position 250.0 40.0 GXT "_TEST"0A93: end_custom_thread

 

 

Only works with CLEO 4.

 

Also, size of 0A8D could be 8, since that's the maximum thread name length... Which is why I can't understand how people get away with really long thread names...

 

 

@Seemann

By the way, thanks for the list.. I've not been able to find a full one anywhere smile.gif

Edited by Deji
Link to comment
Share on other sites

If you add that offset to the thread pointer you obtain the thread name address which is read/write. Unfortunately, GTA cannot store more than 4 bytes per var so you should use 0A8D twice, once to get the first 4 bytes and once for getting the last 3 bytes (7 chars + null-terminator). Here is the workable script:

 

{$CLEO}thread 'test' 0A9F: [email protected] = [email protected] += 0x8 0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0 [email protected] += 0x4 0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0 033E: set_draw_text_position 250.0 40.0 GXT [email protected] 0A93: end_custom_thread

 

012          345
678   9A   BCD
EFG HIJK LMN
OPQR  STUV
WX    YZ

Link to comment
Share on other sites

This is helping me too, but what is a real genuine reason for using the current_thread_pointer opcode in a proper script?

Link to comment
Share on other sites

It was used mostly to get a label address (see example in CLEO3's test_example.cs). But after CLEO 4 indroduced opcode 0AC6, it becomes almost unnecessary. Still, you can change the thread's name with 0A9F.

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.