Quantcast

Jump to content

» «
Photo

TestCheatString

5 replies to this topic
fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • Poland
  • Best Conversion 2016 [GTA: Underground] [Contribution]
    Contribution Award [Mods]

#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:
    [email protected] - 1th part of cheat string
    [email protected] - 2nd optional part of cheat sting
    [email protected] - 3th optional part of cheat string
    [email protected] - 4th optional part of cheat string
     
     ([email protected] together)  
  Result:
    none
      Returns true or false.

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

05EC: [email protected] = current_thread_pointer
0085: [email protected] = [email protected] // integer values and handles
[email protected] += 64       // [email protected] pointer
[email protected] += 48        // [email protected] pointer

0085: [email protected] = [email protected] // integer values and handles
0085: [email protected] = [email protected] // integer values and handles
     
05E2: call_function 0x00642540 num_params 1 pop 1 get_string [email protected] length_to [email protected]

005A: [email protected] += [email protected]  // (int)
[email protected] -= 1

   while 002D:   [email protected] >= [email protected]  // (int)
   05E0: [email protected] = read_memory [email protected] size 1 virtual_protect 0
   05DF: write_memory [email protected] size 1 value [email protected] virtual_protect 0

   [email protected] -= 1
   [email protected] += 1
   end
   
05DF: write_memory [email protected] size 1 value 0x00 virtual_protect 0  // NULL termination

05E2: call_function 0x00642620 _strcmp num_params 2 pop 2 STRING2 [email protected] STRING1 [email protected] RESULT_TO [email protected]
     
if
[email protected] == false
else_jump @TestCheatString_return_false      
05DF: write_memory [email protected] 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 [email protected] or [email protected] = "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

    Foot Soldier

  • 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

    Chocolate

  • GTA Mods Staff
  • Joined: 17 Jul 2003
  • Hong-Kong
  • Major Contribution Award [Mods]
    Helpfulness Awards [Mods]

#3

Posted 11 February 2012 - 09:38 PM

That's what the wiki is for.

DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#4

Posted 11 February 2012 - 10:19 PM

Ive made someth when I worked on MagicSpawner for GTA3.
CODE
{$CLEO}
{$I scmfuncs.txt}
05E5: [email protected] = game_version
while true
   wait 0
   if
       player.Defined($PLAYER_CHAR)
   then
       for [email protected] = 90 to 150
           05F5: call_scm_func @getCarModelName 1 model [email protected] get_string_offset_to [email protected]
           05F5: call_scm_func @getStringNumChars 2 string_offset [email protected] include_null_terminator 0 get_num_chars_to [email protected]
           if
               [email protected] <> 0
           then
               05F5: call_scm_func @testCheat 2 string_offset [email protected] num_chars [email protected] get_result_to [email protected]
               if
                   [email protected] == 1
               then
                   0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]
                   02C1: set [email protected] [email protected] [email protected] to_car_path_coords_closest_to [email protected] [email protected] [email protected]
                   05F5: call_scm_func @getDistanceBetweenPoints 6 XYZ [email protected] [email protected] [email protected] and_XYZ [email protected] [email protected] [email protected] to [email protected]
                   if
                       [email protected] > 15.0
                   then
                       05F5: call_scm_func @getCoordsFromActor 4 actor $PLAYER_ACTOR offset 0.0 3.0 0.0 store_to [email protected] [email protected] [email protected]
                   end
                   05F5: call_scm_func @spawnCar 4 model [email protected] XYZ [email protected] [email protected] [email protected]
                   [email protected] *= 2
                   if
                       [email protected] == 0
                   then
                       [email protected] += 0x95CCB6
                       [email protected] = 0x95CCB6
                       [email protected] = 0x5051E0
                   else
                       [email protected] += 0x95CE6E
                       [email protected] = 0x95CE6E
                       [email protected] = 0x5052C0
                   end
                   0085: [email protected] = [email protected]
                   0085: [email protected] = [email protected]
                   for [email protected] = 0 to 19
                       05E0: [email protected] = read_memory [email protected] size 1 virtual_protect 0
                       05DF: write_memory [email protected] size 2 value [email protected] virtual_protect 0
                       inc([email protected])
                       [email protected] += 2
                   end
                   05DF: write_memory [email protected] size 2 value 0x20 virtual_protect 0 //
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x73 virtual_protect 0 // s
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x70 virtual_protect 0 // p
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x61 virtual_protect 0 // a
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x77 virtual_protect 0 // w
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x6E virtual_protect 0 // n
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x65 virtual_protect 0 // e
                   [email protected] += 2
                   05DF: write_memory [email protected] size 2 value 0x64 virtual_protect 0 // d
                   05E1: call [email protected] num_params 2 pop 2 0 [email protected]
               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      = [email protected]
   var_1      = [email protected]
   var_2      = [email protected]
   var_3      = [email protected]
   var_4      = [email protected]
   var_5      = [email protected]
   var_6      = [email protected]
   var_7      = [email protected]
   var_8      = [email protected]
   var_9      = [email protected]
   var_10     = [email protected]
   var_11     = [email protected]
   var_12     = [email protected]
   var_13     = [email protected]
   var_14     = [email protected]
   var_15     = [email protected]
   timer1     = [email protected]
   timer2     = [email protected]    
end

goto @end

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

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

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

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

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

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

//-----------------------------------------------------------------------------------
:spawnCar
{
05F5: call_scm_func @spawnCar 4 model [email protected] XYZ [email protected] [email protected] [email protected]
}
model.Load([email protected])
038B: load_requested_models
car.Create([email protected], [email protected], [email protected], [email protected], [email protected])
model.Destroy([email protected])
car.RemoveReferences([email protected])
05F6: ret 0

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

//-----------------------------------------------------------------------------------
:getDistanceBetweenPoints
{
05F5: call_scm_func @getDistanceBetweenPoints XYZ [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] to [email protected]
}
0087: [email protected] = [email protected]
0087: [email protected] = [email protected]
0087: [email protected] = [email protected]
0063: [email protected] -= [email protected]
0063: [email protected] -= [email protected]
0063: [email protected] -= [email protected]
006B: [email protected] *= [email protected]
006B: [email protected] *= [email protected]
006B: [email protected] *= [email protected]
005B: [email protected] += [email protected]
005B: [email protected] += [email protected]
01FB: [email protected] = square_root [email protected]
if
   [email protected] < 0.0
then
   0097: absf [email protected]
end
05F6: ret 1 [email protected]    

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

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

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

//-----------------------------------------------------------------------------------
:testCheat
{
05F5: call_scm_func @testCheat 2 string_offset [email protected] num_chars [email protected] get_result_to [email protected]
}
05E5: [email protected] = game_version
if
   [email protected] == 0
then
   05F5: call_scm_func @stringReverse 4 string_offset 0x885B90 num_chars [email protected] store_to 0x5F7650 skip_null_terminator 1
   05E2: call_function 0x5A08B0 num_params 2 pop 2 [email protected] 0x5F7650 [email protected]
else
   05F5: call_scm_func @stringReverse 4 string_offset 0x885B40 num_chars [email protected] store_to 0x5F7438 skip_null_terminator 1
   05E2: call_function 0x5A0B70 num_params 2 pop 2 [email protected] 0x5F7438 [email protected]
end                                                        
if
   [email protected] == 0
then
   if
       [email protected] == 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

    VICE

  • Members
  • Joined: 28 Oct 2011
  • None

#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
  • Poland
  • Best Conversion 2016 [GTA: Underground] [Contribution]
    Contribution Award [Mods]

#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 [email protected]

// you can do
// [email protected] -= @label
// to get memory address to @label

   while true
   wait 0
   01E5: show_text_1number_highpriority GXT 'NUMBER' number [email protected] 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 [email protected]
05EC: [email protected] = current_thread_pointer
[email protected] += 0x10
05E0: [email protected] = read_memory [email protected] size 4 virtual_protect false

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users