Quantcast

Jump to content

» «
Photo

TestCheatString

5 replies to this topic
fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#1

Posted 10 February 2012 - 11:13 AM Edited by fastman92, 10 February 2012 - 11:16 AM.

For GTA VC:
CODE
:TestCheatString
{
Description:
   Compares typed string against passed string
Type: IF

Parameters:
  Passed:
    0@ - 1th part of cheat string
    1@ - 2nd optional part of cheat sting
    2@ - 3th optional part of cheat string
    3@ - 4th optional part of cheat string
     
     (0@v together)  
  Result:
    none
      Returns true or false.

Example:
 if                                                                                                    
 05F5: call_scm_func @TestCheatString 2 STRING 0x454D4954 0x435943   // TIMECYC
}
{   ///////////////
0@v - cheat string to check
4@v - copied cheat string
8@ - static adress of _cheatString
9@ - ending of merged _cheatString: _cheatString + strlen(0@v) - 1    
10@ - adress of _gtaStrlen / read character from _cheatString
11@ - adress of 4@v, increased dynamically
   \\\\\\\\\\\\\\\
}
8@ = 0xA10942   // _cheatString

05EC: 9@ = current_thread_pointer
0085: 11@ = 9@ // integer values and handles
11@ += 64       // 4@ pointer
9@ += 48        // 0@ pointer

0085: 12@ = 9@ // integer values and handles
0085: 13@ = 11@ // integer values and handles
     
05E2: call_function 0x00642540 num_params 1 pop 1 get_string 9@ length_to 9@

005A: 9@ += 8@  // (int)
9@ -= 1

   while 002D:   9@ >= 8@  // (int)
   05E0: 10@ = read_memory 9@ size 1 virtual_protect 0
   05DF: write_memory 11@ size 1 value 10@ virtual_protect 0

   9@ -= 1
   11@ += 1
   end
   
05DF: write_memory 11@ size 1 value 0x00 virtual_protect 0  // NULL termination

05E2: call_function 0x00642620 _strcmp num_params 2 pop 2 STRING2 13@ STRING1 12@ RESULT_TO 9@
     
if
9@ == false
else_jump @TestCheatString_return_false      
05DF: write_memory 8@ size 1 value 0x00 virtual_protect false  // NULL termination    
return_true
05F6: ret 0
   
:TestCheatString_return_false
return_false
05F6: ret 0

Works with: gta-vc.exe, 2,94 MB (3 088 896 bytes)


Remember there are no string variables in GTA VC. You can`t put 6@v or 6@s = "CHEAT" and pass it to function.
It will be compiled mistakenly by SB, there`s no such opcode to handle string type of variables.
You must write integers instead of strings.

For GTA SA find it within In-game Timecyc Editor source. It uses many dependencies.

Swoorup
  • Swoorup

    innovator

  • Feroci
  • Joined: 28 Oct 2008
  • Nepal

#2

Posted 11 February 2012 - 05:03 PM Edited by Swoorup, 11 February 2012 - 05:23 PM.

All of your findings should be pinned. Fastman92 you should set up a site or something and put up all your works.

I hate it when it takes too much of my time going through the forums looking for something useful. Most of the modding section topics contains bulk, unwanted posts

spaceeinstein
  • spaceeinstein

    巧克力

  • Members
  • Joined: 17 Jul 2003
  • None

#3

Posted 11 February 2012 - 09:38 PM

That's what the wiki is for.

DK22Pac
  • DK22Pac

    Playing SA on my lovely PS2. Y'all bums.

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine

#4

Posted 11 February 2012 - 10:19 PM

Ive made someth when I worked on MagicSpawner for GTA3.
CODE
{$CLEO}
{$I scmfuncs.txt}
05E5: 8@ = game_version
while true
   wait 0
   if
       player.Defined($PLAYER_CHAR)
   then
       for 0@ = 90 to 150
           05F5: call_scm_func @getCarModelName 1 model 0@ get_string_offset_to 10@
           05F5: call_scm_func @getStringNumChars 2 string_offset 10@ include_null_terminator 0 get_num_chars_to 9@
           if
               9@ <> 0
           then
               05F5: call_scm_func @testCheat 2 string_offset 10@ num_chars 9@ get_result_to 3@
               if
                   3@ == 1
               then
                   0054: store_player $PLAYER_CHAR position_to 1@ 2@ 3@
                   02C1: set 4@ 5@ 6@ to_car_path_coords_closest_to 1@ 2@ 3@
                   05F5: call_scm_func @getDistanceBetweenPoints 6 XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@ to 7@
                   if
                       7@ > 15.0
                   then
                       05F5: call_scm_func @getCoordsFromActor 4 actor $PLAYER_ACTOR offset 0.0 3.0 0.0 store_to 4@ 5@ 6@
                   end
                   05F5: call_scm_func @spawnCar 4 model 0@ XYZ 4@ 5@ 6@
                   9@ *= 2
                   if
                       8@ == 0
                   then
                       9@ += 0x95CCB6
                       13@ = 0x95CCB6
                       14@ = 0x5051E0
                   else
                       9@ += 0x95CE6E
                       13@ = 0x95CE6E
                       14@ = 0x5052C0
                   end
                   0085: 7@ = 13@
                   0085: 11@ = 10@
                   for 15@ = 0 to 19
                       05E0: 12@ = read_memory 11@ size 1 virtual_protect 0
                       05DF: write_memory 13@ size 2 value 12@ virtual_protect 0
                       inc(11@)
                       13@ += 2
                   end
                   05DF: write_memory 9@ size 2 value 0x20 virtual_protect 0 //
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x73 virtual_protect 0 // s
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x70 virtual_protect 0 // p
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x61 virtual_protect 0 // a
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x77 virtual_protect 0 // w
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x6E virtual_protect 0 // n
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x65 virtual_protect 0 // e
                   9@ += 2
                   05DF: write_memory 9@ size 2 value 0x64 virtual_protect 0 // d
                   05E1: call 14@ num_params 2 pop 2 0 7@
               end
           end
       end
   end
end

CODE
//-----------------------------------------------------------------------------------
{
eNums bodyparts
}
const
   SLOWERLEGL = 0
   SMID       = 1
   SHEAD      = 2
   SUPPERARML = 3
   SUPPERARMR = 4
   SLHAND     = 5
   SRHAND     = 6
   SUPPERLEGL = 7
   SUPPERLEGR = 8
   SFOOTL     = 9
   SFOOTR     = 10
   SLOWERLEGR = 11
   var_0      = 0@
   var_1      = 1@
   var_2      = 2@
   var_3      = 3@
   var_4      = 4@
   var_5      = 5@
   var_6      = 6@
   var_7      = 7@
   var_8      = 8@
   var_9      = 9@
   var_10     = 10@
   var_11     = 11@
   var_12     = 12@
   var_13     = 13@
   var_14     = 14@
   var_15     = 15@
   timer1     = 16@
   timer2     = 17@    
end

goto @end

//-----------------------------------------------------------------------------------
:getCoordsFromActor
{
05F5: call_scm_func @getCoordsFromActor 4 actor $PLAYER_ACTOR offset 0.0 2.0 0.0 store_to 0@ 1@ 2@
}
05E6: 0@ = actor 0@ struct
0@ += 4
05E5: 5@ = game_version
05EC: 6@ = current_thread_pointer
6@ += 0x34
if
   5@ == 0
then    
   05E1: call 0x5A37D0 num_params 4 pop 4 0@ 1 6@ 6@
else
   05E1: call 0x5A3A90 num_params 4 pop 4 0@ 1 6@ 6@
end
05F6: ret 3 1@ 2@ 3@

//-----------------------------------------------------------------------------------
:getCoordsFromCar
{
05F5: call_scm_func @getCoordsFromCar 4 car 3@ offset 0.0 2.0 0.0 store_to 0@ 1@ 2@
}
05E7: 0@ = car 0@ struct
0@ += 4
05E5: 5@ = game_version
05EC: 6@ = current_thread_pointer
6@ += 0x34
if
   5@ == 0
then    
   05E1: call 0x5A37D0 num_params 4 pop 4 0@ 1 6@ 6@
else
   05E1: call 0x5A3A90 num_params 4 pop 4 0@ 1 6@ 6@
end
05F6: ret 3 1@ 2@ 3@

//-----------------------------------------------------------------------------------
:getCoordsFromObject
{
05F5: call_scm_func @getCoordsFromObject 4 object 3@ offset 0.0 2.0 0.0 store_to 0@ 1@ 2@
}
05E8: 0@ = object 0@ struct
0@ += 4
05E5: 5@ = game_version
05EC: 6@ = current_thread_pointer
6@ += 0x34
if
   5@ == 0
then    
   05E1: call 0x5A37D0 num_params 4 pop 4 0@ 1 6@ 6@
else
   05E1: call 0x5A3A90 num_params 4 pop 4 0@ 1 6@ 6@
end
05F6: ret 3 1@ 2@ 3@

//-----------------------------------------------------------------------------------
:getLocalVarOffset
{
05F5: call_scm_func @getLocalVarOffset 1 var 0 store_to 1@
}
05EC: 1@ = current_thread_pointer
0@ *= 4
1@ += 0x30
005A: 1@ += 0@
05F6: ret 1 1@

//-----------------------------------------------------------------------------------
:getActorBodypartPosition
{
05F5: call_scm_func @getActorBodypartPosition 2 actor $PLAYER_ACTOR bodypart SUPPERARML store_to 0@ 1@ 2@
}
05E6: 0@ = actor 0@ struct
0@ += 0x1A4
1@ *= 4
005A: 0@ += 1@
05E0: 0@ = read_memory 0@ size 4 virtual_protect 0
0@ += 0x10
05E0: 0@ = read_memory 0@ size 4 virtual_protect 0
0@ += 0x80
05E0: 1@ = read_memory 0@ size 4 virtual_protect 0
0@ += 4
05E0: 2@ = read_memory 0@ size 4 virtual_protect 0
0@ += 4
05E0: 3@ = read_memory 0@ size 4 virtual_protect 0
05F6: ret 3 1@ 2@ 3@

//-----------------------------------------------------------------------------------
:ActorRemoveBodypart
{
05F5: call_scm_func @ActorRemoveBodypart 2 actor $PLAYER_ACTOR bodypart SUPPERARML
}
05E6: 0@ = actor 0@ struct
05E5: 2@ = game_version
if
   2@ == 0
then
   05E3: call_method 0x4EAEE0 struct 0@ num_params 2 pop 0 0 1@
else
   05E3: call_method 0x4EAF90 struct 0@ num_params 2 pop 0 0 1@
end
05F6: ret 0

//-----------------------------------------------------------------------------------
:spawnCar
{
05F5: call_scm_func @spawnCar 4 model 0@ XYZ 4@ 5@ 6@
}
model.Load(0@)
038B: load_requested_models
car.Create(4@, 0@, 1@, 2@, 3@)
model.Destroy(0@)
car.RemoveReferences(4@)
05F6: ret 0

//-----------------------------------------------------------------------------------
:showTextBox
{
05F5: call_scm_func @showTextBox 1 string_offset 0@
}
05E5: 1@ = game_version
if
   1@ == 0
then
   3@ = 0x95CCB6
   4@ = 0x5051E0
else
   3@ = 0x95CE6E
   4@ = 0x5052C0
end
for 1@ = 0 to 19
   05E0: 2@ = read_memory 0@ size 1 virtual_protect 0
   05DF: write_memory 3@ size 2 value 2@ virtual_protect 0
   inc(0@)
   3@ += 2
end
05E1: call 4@ num_params 2 pop 2 0 3@
05F6: ret 0

//-----------------------------------------------------------------------------------
:getDistanceBetweenPoints
{
05F5: call_scm_func @getDistanceBetweenPoints XYZ 1@ 2@ 3@ and 4@ 5@ 6@ to 7@
}
0087: 6@ = 0@
0087: 7@ = 1@
0087: 8@ = 2@
0063: 6@ -= 3@
0063: 7@ -= 4@
0063: 8@ -= 5@
006B: 6@ *= 6@
006B: 7@ *= 7@
006B: 8@ *= 8@
005B: 6@ += 7@
005B: 6@ += 8@
01FB: 6@ = square_root 6@
if
   6@ < 0.0
then
   0097: absf 6@
end
05F6: ret 1 6@    

//-----------------------------------------------------------------------------------
:getCarModelName
{
05F5: call_scm_func @getCarModelName 1 model 90 get_string_offset_to 1@
}
0@ *= 4
0@ += 0x83D408
05E0: 0@ = read_memory 0@ size 4 virtual_protect 0
0@ += 0x4
05F6: ret 1 0@

//-----------------------------------------------------------------------------------
:getStringNumChars
{
05F5: call_scm_func @getStringNumChars 2 string_offset 1@ include_null_terminator 1 get_num_chars_to 2@
}
for 2@ = 0 to 99
   05E0: 3@ = read_memory 0@ size 1 virtual_protect 0
   if
       3@ == 0
   then
       if
           1@ == 1
       then
           inc(2@)
       end
       05F6: ret 1 2@
   end
   inc(0@)
end
05F6: ret 1 0

//-----------------------------------------------------------------------------------
:stringReverse
{
05F5: call_scm_func @stringReverse 4 string_offset 0x885B90 num_chars 1@ store_to 0x5F7650 skip_null_terminator 1
}
if
   3@ == 0
then
   1@ -= 2
else
   dec(1@)
end
005A: 2@ += 1@
0085: 6@ = 2@
for 4@ = 0 to 1@
   05E0: 5@ = read_memory 0@ size 1 virtual_protect 0
   05DF: write_memory 2@ size 1 value 5@ virtual_protect 0
   dec(2@)
   inc(0@)
end
inc(6@)
05DF: write_memory 6@ size 1 value 0 virtual_protect 0
05F6: 0

//-----------------------------------------------------------------------------------
:testCheat
{
05F5: call_scm_func @testCheat 2 string_offset 1@ num_chars 2@ get_result_to 3@
}
05E5: 3@ = game_version
if
   3@ == 0
then
   05F5: call_scm_func @stringReverse 4 string_offset 0x885B90 num_chars 1@ store_to 0x5F7650 skip_null_terminator 1
   05E2: call_function 0x5A08B0 num_params 2 pop 2 0@ 0x5F7650 2@
else
   05F5: call_scm_func @stringReverse 4 string_offset 0x885B40 num_chars 1@ store_to 0x5F7438 skip_null_terminator 1
   05E2: call_function 0x5A0B70 num_params 2 pop 2 0@ 0x5F7438 2@
end                                                        
if
   2@ == 0
then
   if
       3@ == 0
   then
       05DF: write_memory 0x885B90 size 1 value 0 virtual_protect 0
   else
       05DF: write_memory 0x885B40 size 1 value 0 virtual_protect 0
   end
   05F6: ret 1 1
else
   05F6: ret 1 0
end

:end

ThePrince
  • ThePrince

    Moroccan Modder

  • Members
  • Joined: 28 Oct 2011

#5

Posted 29 June 2012 - 06:29 PM

I'm not good in Coding, but i want to change VC Cheat codes,

Let say for Exemple: i want to change ASPIRINE to ASPRO.
how do i write the Cheat String ? smile.gif

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#6

Posted 05 July 2012 - 03:01 PM Edited by fastman92, 05 July 2012 - 03:46 PM.

QUOTE (ThePrince @ Friday, Jun 29 2012, 19:29)
I'm not good in Coding, but i want to change VC Cheat codes,

Let say for Exemple: i want to change ASPIRINE to ASPRO.
how do i write the Cheat String ? smile.gif

Replacing standard cheats is bit tricky for newbies. I described it here:
http://www.gtaforums...st&p=1060723183

006D8624 ASPIRINE db 'HSPSVkVH',0

Encrypted ASPIRINE becomes HSPSVkVH and I shared function to decrypt and encrypt strings using GTA VC cheat algorithm.

Encrypted ASPRO becomes RWWTN

To replace cheat string we need to write into memory address of that cheat.
The code will work assuming that your gta_vc.exe has 3 088 896 bytes.

CODE
{$CLEO}
// Author: fastman92
// Description: ASPIRINE cheat code is replaced into ASPRO code

05DF: write_memory 0x6D8624 size 4 value 0x54575752 virtual_protect false   // "RWWT"
05DF: write_memory 0x6D8628 size 2 value 0x004E virtual_protect false       // "N" and NULL

05DC: end_custom_thread


Must be compiled as CLEO script.

You can cheat strings if you happen to know the details of simple GTA VC IDB reengineering till the plugin to change the cheat strings comes out.

-------------------------------

Today i created a very useful SCM function GetBaseIP for GTA VC.
It gets memory address to beginning of script content.

The code will work assuming that your gta_vc.exe has 3 088 896 bytes.
CODE

{$CLEO}
05F5: call_scm_func @GetBaseIP 0 store_to 3@

// you can do
// 3@ -= @label
// to get memory address to @label

   while true
   wait 0
   01E5: show_text_1number_highpriority GXT 'NUMBER' number 3@ time 5000 flag 1  // See the address of script content in decimal format
   end

05DC: end_custom_thread

:GetBaseIP
// Example: 05F5: call_scm_func @GetBaseIP 0 store_to 3@
05EC: 0@ = current_thread_pointer
0@ += 0x10
05E0: 0@ = read_memory 0@ size 4 virtual_protect false

:GetBasePastTheReadMemory
0@ += 0x821280  // _scmBlock
0@ += 3         // size of (03 00 00,  0@ = )
0@ += @GetBasePastTheReadMemory
05F6: ret 1 0@




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users