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 


Unable to call the C function.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
CookiesHax
How do I cheat?
Reputation: 0

Joined: 25 Jul 2024
Posts: 1

PostPosted: Thu Jul 25, 2024 5:41 am    Post subject: Unable to call the C function. Reply with quote

Hello everyone.
I am trying to use the C function in AA, but it doesnt work. This is my script

Code:
[ENABLE]
registersymbol(newmem)
alloc(newmem,$100)
createthread(newmem)

registersymbol(math)
alloc(math,$10)

math+0:
dd (float)3
math+4:
dd (float)7

newmem:
  pushad
  movss xmm0,[math+0]
  movss xmm1,[math+4]

{$c}
float addf(float x, float y)
{
    return x + y;
}

{$ccode xmmReg0=xmm0 xmmReg1=xmm1}
xmmReg0.f0 = addf(xmmReg0.f0, xmmReg1.f0);

{$asm}
  //movss xmm0,[math+0]
  //addss xmm0,[math+4]
  movss [math+8],xmm0

  popad
  jmp newmem

[DISABLE]

newmem:
  ret

unregistersymbol(*)
dealloc(*)


This is the error message:
Code:
Not all code is injectable.
(C Error Error at line 25: error: declaration
expected
)
Are you sure you want to edit it to this?


However, when I do not use the function and perform the calculation directly, it executes correctly.

Code:
[ENABLE]
registersymbol(newmem)
alloc(newmem,$100)
createthread(newmem)

registersymbol(math)
alloc(math,$10)

math+0:
dd (float)3
math+4:
dd (float)7

newmem:
  pushad
  movss xmm0,[math+0]
  movss xmm1,[math+4]

{$ccode xmmReg0=xmm0 xmmReg1=xmm1}
xmmReg0.f0 = xmmReg0.f0 + xmmReg1.f0;

{$asm}
  //movss xmm0,[math+0]
  //addss xmm0,[math+4]
  movss [math+8],xmm0

  popad
  jmp newmem

[DISABLE]

newmem:
  ret

unregistersymbol(*)
dealloc(*)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Thu Jul 25, 2024 9:27 am    Post subject: Reply with quote

{$c} blocks need a terminating {$asm}; you can't just go directly into a {$ccode} block

Move the {$c} block above newmem

Code:
{$c}
...
{$asm}

...
newmem:
  ...
{$ccode ...}
...
{$asm}

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Thu Jul 25, 2024 2:45 pm    Post subject: Reply with quote

Moved from Auto Assembler Tutorials as this is not a tutorial.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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