Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to change actual parameters?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 51

PostPosted: Sun May 14, 2023 2:16 am    Post subject: How to change actual parameters? Reply with quote

The game is 32-bit.

view game code by dnSpyEx

Code:

   public static CrewMember CreateCrewMember(int level, int minRarity, int maxRarity, int factionIndex, bool allowSpecial, Random rand)
   {
      CrewDB.Validate();
      CrewMember crewMember = null;
      if (allowSpecial)
      {
         List<CrewMember> availableSpecialCrewMember = CrewDB.GetAvailableSpecialCrewMember();
         int num = 8 - GameData.data.specialCrewUsed.Count;
         if (num < 4)
         {
            num = 4;
         }
         if (availableSpecialCrewMember.Count != 0 && Random.Range(1, 0x65) <= num)
         {
            crewMember = availableSpecialCrewMember[Random.Range(0, availableSpecialCrewMember.Count)];
            GameData.data.specialCrewUsed.Add(crewMember.id);
         }
      }
      if (crewMember == null)
      {
         level = Mathf.Clamp(level, 1, PChar.maxLevel);
         crewMember = new CrewMember(level, minRarity, maxRarity, factionIndex, rand);
         crewMember.id = CrewDB.GetNextCrewMemberID();
         crewMember.aiChar.name = CrewDB.GenerateCrewMemberName(rand);
         crewMember.aiChar.imgIndex = rand.Next(0x3E8, 0x3E8 + PortraitDB.getCrewPortraitsCount);
         CrewDB.crewList.Add(crewMember);
      }
      return crewMember;
   }





I want to set

level = 0x63
minRarity = 0x4
maxRarity = 0x4





Code:

[ENABLE]

aobscanregion(hook_CreateCrew_INJECT,CrewDB:CreateCrewMember,CrewDB:CreateCrewMember+30,83 EC 4C 8B C0 E8 D0)
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  sub esp,4C
  mov eax,eax

  mov [ebp+?],63 //level
  mov [ebp+?],04 //minRarity
  mov [ebp+?],04 //maxRarity

  jmp return

hook_CreateCrew_INJECT:
  jmp newmem
return:
registersymbol(hook_CreateCrew_INJECT)

[DISABLE]

hook_CreateCrew_INJECT:
  db 83 EC 4C 8B C0

unregistersymbol(hook_CreateCrew_INJECT)
dealloc(newmem)




Screenshot 2023-05-14 161610.png
 Description:
 Filesize:  77.55 KB
 Viewed:  475 Time(s)

Screenshot 2023-05-14 161610.png


Back to top
View user's profile Send private message
Bloodybone
Newbie cheater
Reputation: 0

Joined: 07 Dec 2016
Posts: 20
Location: Germany

PostPosted: Sun May 14, 2023 4:21 am    Post subject: Reply with quote

Looking at the code snippet the method is either using stdcall or cdecl in which case the parameters are pushed from right to left, which means that:
[ebp+8] == level
[ebp+C] == minRarity
[ebp+10] == maxRarity
[ebp+14] == factionIndex
[ebp+18] == allowSpecial
[ebp+1C] == rand

Though you could also inject at the Top of the Method and use
[esp+4] == level
[esp+8] == minRarity
...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites