IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


Pages: (2) 1 [2]   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

 Store variable value to memory

 how to ?
 
Ify24  
Posted: Tuesday, Aug 7 2012, 18:00
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (Deji @ Tuesday, Aug 7 2012, 17:22)
QUOTE (fastman92 @ Tuesday, Aug 7 2012, 15:16)
You can use additional variables in a read context, not write to them.

You especially shouldn't local vars for offsets... the pointer of the script data can sometimes be placed before the script and it doesn't seem to quite like using negative indexes. Global offsets were better, because they are statically allocated and will always result in a positive index.

However, I got crashes simply comparing the value of one in a very rare case. The rest of the script ran fine with them, but comparing one to a normal local var somehow started causing a crash, precisely after the array var was parsed. It didn't even matter if I switched the order of the local and global array, it would crash after the global array was parsed, getting an incorrect pointer overall (I calculated the array info myself and it was conclusive).

A remedy was placing 0000: (or anything) before this check. That seemed to change where the data was allocated and resulted in a good pointer when the array was calculated. Maybe something to do with the fact I used it in a SCM Function? Not sure, but a crash that occurs 'sometimes' is hard to pinpoint, so I wouldn't feel good recommending this as a solution to lack of vars, knowing modders may end up spending ages puzzled about why their mod is crashing so randomly.

But fear not, because this unfortunate discovery encouraged me to come up with a much better solution which has plenty of perks to come soon. It requires an ASI, however...


@Ify24
In coding terms, an offset is the name of the difference between too memory locations.
So 4 would be the offset of 2 and 6.

Here we're writing to offset 0x598 of the ped struct:
CODE
0A96: 0@ = actor $PLAYER_ACTOR struct
0@ += 0x598
0A8C: write_memory 0@ size 4 value 0 virtual_protect 0

So in this example the offset is this?:
0@ + 0x598 = offset ?

And is this:
CODE

0A96: 0@ = actor $PLAYER_ACTOR struct
0@ += 0x598
0A8C: write_memory 0@ size 4 value 0 virtual_protect 0


and this

CODE

0A96: 0@ = 0xB6F5F0 //- Player pointer (CPed)
0@ += 0x598
0A8C: write_memory 0@ size 4 value 0 virtual_protect 0

the same thing ?
PM
  Top
 

 
Wesser  
Posted: Tuesday, Aug 7 2012, 18:06
Quote Post


The complexity simplifier, the efficiency optimizer
Group Icon
Group: Members
Joined: Aug 19, 2006

eu.gif

Member Award




QUOTE (fastman92 @ Tuesday, Aug 7 2012, 16:52)
While coder sees a label in the source project, labels are simply negative offsets of different codes compiled somewhere else.

It isn't that correct. Offsets of the main part are relative to the beginning of the main script and they are positive. Those of missions and allocating scripts (also known as externals) point to their beginning and they are negative. That's because main script, missions and allocating scripts are stored into different buffers. Plus, the last 2 don't start from a 0-based offset.

Ify24, the offset is 0x598 in your example. Moreover, both of your codes does the same thing, except that 0xB6F5F0 is the pointer to the first player struct whose first member contains a pointer to CPed. You should read its pointer in the second sample.
PMMSNPlayStation Network
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 18:21
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE
CODE
hex
04 00 02 0800 04 01
end


It will be compiled as
CODE
0004: $2 = 1



hmmm dozingoff.gif
How do sanny builder compile
04 00 02 0800 04 01 to 0004: $2 = 1 ???
Does it first convert to binary and then to ''sanny language''?

Oh, and this:

QUOTE

CODE
:get_offset
hex
04 00 02 $PLAYER_CHAR 01 @get_offset
end


It will be compiled as 0004: $PLAYER_CHAR = @get_offset


I don't understand this.
PM
  Top
 

 
fastman92  
Posted: Tuesday, Aug 7 2012, 18:43
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



.scm is one and possibilities may be only changed by modification of hardcoded gta_sa.exe code, while there may be many programming languages compiled into the .scm following the same rules.
Sanny language is one of them to use in source.
Similarly there are many programming languages to create EXEs - C++, Pascal, D, but all of them must follow Assembler's standards to produce code

04 00 02 0800 04 01 to 0004: $2 = 1 ???

04 00 - command ID, WORD taking 2-bytes, number 4
02 - data type, meant to be global integer/float variable + 0800 aligned, but not divided offset.
Global variable offsets are not divided, integer/float vars take 4-byte, therefore $2 will be on offset 8. 2*4 = 8, right or not?

04 - data type of second argument, meant to be static integer value taking 1-byte, char from C++
01 - value for the data type of 1-byte

This post has been edited by fastman92 on Tuesday, Aug 7 2012, 18:46
Users WebsitePMMSN
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 18:56
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (fastman92 @ Tuesday, Aug 7 2012, 18:43)
04 00 - command ID, WORD taking 2-bytes, number 4
02 - data type, meant to be global integer/float variable + 0800 aligned, but not divided offset.
Global variable offsets are not divided, integer/float vars take 4-byte, therefore $2 will be on offset 8. 2*4 = 8, right or not?

04 - data type of second argument, meant to be static integer value taking 1-byte, char from C++
01 - value for the data type of 1-byte

Where did you learn this stuff?
Where can I learn it?
PM
  Top
 

 
fastman92  
Posted: Tuesday, Aug 7 2012, 18:59
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



Read: http://www.mediafire.com/?6j6prenz7v47tnh
Please note that commands with variable amount of arguments have one more byte at the end - 00.
It ends up list of arguments.

These commands have -1 undefined amount of arguments in Sanny Builder.

This post has been edited by fastman92 on Tuesday, Aug 7 2012, 19:02
Users WebsitePMMSN
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 19:05
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



thanks

EDIT:
It's very useful, but there are only data types.
Where can I found command IDs ?

QUOTE
04 00 - command ID, WORD taking 2-bytes, number 4


This post has been edited by Ify24 on Tuesday, Aug 7 2012, 19:10
PM
  Top
 

 
fastman92  
Posted: Tuesday, Aug 7 2012, 19:31
Quote Post


фастман92 | ف
Group Icon
Group: Members
Joined: Jul 28, 2009

pl.gif

XXXXX



QUOTE (Ify24 @ Tuesday, Aug 7 2012, 20:05)
thanks

EDIT:
It's very useful, but there are only data types.
Where can I found command IDs ?

QUOTE
04 00 - command ID, WORD taking 2-bytes, number 4

What's your native language?

Command ID? It's the first thing processed.
There is:
command ID + appropriate amount of arguments.
next command ID + appropriate amount of arguments.
next command ID + appropriate amount of arguments.
next command ID + appropriate amount of arguments.

Amount of arguments depends on commands.

I use term "command" since there were no "opcodes" at R*.
They had commands, opcode term was invented by modding community.
CODE
   * ProcessCommands1000To1099 (i)

   * ProcessCommands900To999 (i)

   * ProcessCommands800To899 (i)

   * ProcessCommands700To799 (i)

   * ProcessCommands600To699 (i)

   * ProcessCommands500To599 (i)

   * ProcessCommands400To499 (i)

   * ProcessCommands300To399 (i)


GTA VC: "Processing command"
GTA SA command 2083 (0x823): COMMAND_TASK_GREET_PARTNER

What's your native language?
Users WebsitePMMSN
  Top
 

 
Bad.boy!  
Posted: Tuesday, Aug 7 2012, 20:00
Quote Post


SA modder
Group Icon
Group: Members
Joined: Jun 20, 2010

nl.gif

XXXXX



Read this topic if you want to know more about cleo files.

This is a file in hex:
CODE
00 00
06 00 03 01 00 04 03
06 00 03 02 00 04 05
02 00 01 FE FF FF FF


2 hexadecimals are 1 byte. The offset is the position in bytes. The hex value "02 00" at the end means opcode 0002 (jump). The next 01 says that the next 4 bytes are an integer. FE FF FF FF is -2 in decimals (see previous post why it's a -). So we have start reading at the end of the second byte.

CODE
00 00
|!START HERE!| 06 00 03 01 00 04 03
06 00 03 02 00 04 05
02 00 01 FE FF FF FF


As you can see there is nothing like a label name. It's just a number, and if you decompile the code you'll see this:
CODE
0000: NOP

:NONAME_2
0006: 1@ = 3
0006: 2@ = 5
0002: jump @NONAME_2


As you can see the 2 returns. Sanny Builder converts it into a name to make it more readable.

EDIT: About the compiler it's sort of finished, the for loop is buggy but I barely use it.
PM
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 20:46
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (fastman92 @ Tuesday, Aug 7 2012, 19:31)
What's your native language?

What's your native language?

Croatian.
PM
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 20:50
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (Bad.boy! @ Tuesday, Aug 7 2012, 20:00)
Read this topic if you want to know more about cleo files.

This is a file in hex:
CODE
00 00
06 00 03 01 00 04 03
06 00 03 02 00 04 05
02 00 01 FE FF FF FF


2 hexadecimals are 1 byte. The offset is the position in bytes. The hex value "02 00" at the end means opcode 0002 (jump). The next 01 says that the next 4 bytes are an integer. FE FF FF FF is -2 in decimals (see previous post why it's a -). So we have start reading at the end of the second byte.

CODE
00 00
|!START HERE!| 06 00 03 01 00 04 03
06 00 03 02 00 04 05
02 00 01 FE FF FF FF


As you can see there is nothing like a label name. It's just a number, and if you decompile the code you'll see this:
CODE
0000: NOP

:NONAME_2
0006: 1@ = 3
0006: 2@ = 5
0002: jump @NONAME_2


As you can see the 2 returns. Sanny Builder converts it into a name to make it more readable.

EDIT: About the compiler it's sort of finished, the for loop is buggy but I barely use it.

So you can make a whole script using just hex?

EDIT:Uh, I doubleposted
PM
  Top
 

 
Wesser  
Posted: Tuesday, Aug 7 2012, 21:03
Quote Post


The complexity simplifier, the efficiency optimizer
Group Icon
Group: Members
Joined: Aug 19, 2006

eu.gif

Member Award




QUOTE (fastman92 @ Tuesday, Aug 7 2012, 19:59)
Read: http://www.mediafire.com/?6j6prenz7v47tnh

Although you're posting at GTAForums, link the article found on the community wiki here. It's a lie to say you didn't learn from there.

Ify24, yep. Your code will be decompiled with Sanny's sintax yet.
PMMSNPlayStation Network
  Top
 

 
Ify24  
Posted: Tuesday, Aug 7 2012, 21:15
Quote Post


0x00000000 --> invisible
Group Icon
Group: Members
Joined: Aug 17, 2011

yu.gif

XXXXX



QUOTE (Wesser @ Tuesday, Aug 7 2012, 21:03)
QUOTE (fastman92 @ Tuesday, Aug 7 2012, 19:59)
Read: http://www.mediafire.com/?6j6prenz7v47tnh

Although you're posting at GTAForums, link the article found on the community wiki here. It's a lie to say you didn't learn from there.

Ify24, yep. Your code will be decompiled with Sanny's sintax yet.

Alright, thanks for http://www.gtamodding.com/index.php?title=..._%28Overview%29 link
PM
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Pages: (2) 1 [2] 

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG