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 


ccode crashing but luacode works

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Tue Nov 01, 2022 2:38 am    Post subject: ccode crashing but luacode works Reply with quote

I have made two script to fetch address of hunger rate, first in luacode but it works but game lag a lot and become unplayable. So I have decided to make it in ccode but it crashes instantly on activation. Below are my findings.

My luacode script:

Code:


{$luacode xBase=ebp}
if readPointer(xBase+0x10) > 0 then
if readString(readPointer(xBase+0x10)+0x10) == 'hungerrate' then
registerSymbol('hungerr',xBase)
end
end
{$asm}



My ccode script:
Code:


{$ccode xBase=ebp}
extern long hngrrt;
 if (*(unsigned long *)(xBase+0x10) > 0)
 {
   char str =(char)(*(unsigned long *)(xBase+0x10)+0x10);
   if (strcmp(str,"hungerrate"))
   {
   hngrrt=xBase;
   }
 }
{$asm}





[/img]
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Nov 01, 2022 4:35 am    Post subject: Reply with quote

Perhaps it's to do with the variable assignment. Maybe something like this? I didn't test it.
Code:

{$ccode xBase=ebp}
extern long hngrrt;
 if (*(unsigned long *)(xBase+0x10) > 0)
 {
   char str[] =(char)(*(unsigned long *)(xBase+0x10)+0x10);
   char res[] = "hungerrate"
   if (strcmp(str,res))
   {
   hngrrt=xBase;
   }
 }
{$asm}
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Tue Nov 01, 2022 6:15 am    Post subject: Reply with quote

LeFiXER wrote:
Perhaps it's to do with the variable assignment. Maybe something like this? I didn't test it.

Thank you for reply I have tried it at first it shows syntax error but I have managed to fix it with this.

Code:
char str[] ={(char)(*(unsigned long *)(xBase+0x10)+0x10)}


This time it works a bit long but it crashes too and also does not fetch hunger rate. May be there is a little mistake occurs.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25813
Location: The netherlands

PostPosted: Tue Nov 01, 2022 6:42 am    Post subject: Reply with quote

try something like this:
Code:

push eax
{$try}
mov eax,[ebp+10] //if this fails, the except will catch it
add eax,10
cmp [eax],0 //if eax is an invalid address, except will catch it

{$ccode xBase=ebp str=eax}
 extern long hngrrt;
 if (strcmp(str,"hungerrate")==0)
   hngrrt=xBase;
{$asm}

{$except}
invalid:
//skip the ccode block on error


pop eax

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Thu Nov 03, 2022 3:37 am    Post subject: Reply with quote

Dark Byte wrote:
try something like this:

Thank you very much for reply.
I have tried it and now game is not crashing but it does not fetch address also.
I have tried another slower opcode and injecting luacode works and game is hanging less but still ccode can not fetch address. I think I am doing some mistake in defining [[xBase+0x10]+0x10] location.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25813
Location: The netherlands

PostPosted: Thu Nov 03, 2022 5:39 am    Post subject: Reply with quote

perhaps the ccode is never executed at all

Try adding counters
And yes, likely the address is wrong

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Wed Nov 09, 2022 6:58 am    Post subject: Reply with quote

Here this works

Code:
mov ecx,[ebp+10]
test ecx,ecx
je code

{$ccode xBase=ecx iBase=ebp}
extern long op1;
char *str = (char *)(xBase+0x10);
char *str2 = "currenthealth";
  if (strcmp(str,str2)==0)
{
 op1 = iBase;
}
{$asm}
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 Lua Scripting 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