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 


$c how to implement common c headers?

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

Joined: 23 Apr 2015
Posts: 33

PostPosted: Tue Mar 22, 2022 2:53 am    Post subject: $c how to implement common c headers? Reply with quote

Is there any way to keep {$c} block features and use common headers?

addCIncludePath(path) doc say it only applies to compile().

If I use to {$lua} to return {$c}, then all source line info seems lost.
In addition, CE seems to reject multiple {$c} blocks, so non-header {$c} must also becomes part of lua string and thus lost syntax highlighting.
(lua must return a {$c} prefixed block, plus another non-header {$c} block)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Mar 22, 2022 3:28 am    Post subject: Reply with quote

addCIncludePath functions for all c-code. Just keep in mind it's a path, not an auto include, so you still need to add the #include <xxx> yourself

CE has no issue with multiple {$C} blocks

e.g:
Code:



{$c}

typedef int myintegertype;

{$asm}

alloc(script,1024)


{$c}
myintegertype bla(myintegertype x)
{
  return x+12;
}
{$asm}


script:
mov rcx,10
call long bla //I know its within 2GB

{$ccode result=rax}
  myintegertype r=result;
  result=bla(r);
{$asm}

ret


and if you wish to use lua to output c-blocks, do NOT define them inside the auto assembler using multiline blocks [[xxx]], as {$asm} will conflict. So you will have to use a different way to define the script. E.g from another lua script, or using another method

e.g:
Code:


{$lua}
s=createStringList()
s.add('{$c}')
s.add('typedef int myintegertype;')
s.add('{$asm}')
local r=s.text
s.destroy()

return r
{$asm}


alloc(script,1024)

{$lua}
s=createStringList()
s.add('{$c}')
s.add('myintegertype bla(myintegertype x)')
s.add('{');
s.add('  return x+12;')
s.add('}')
s.add('{$asm}')
{$asm}



script:
mov rcx,10
call long bla //I know its within 2GB

{$ccode result=rax}
  myintegertype r=result;
  result=bla(r);
{$asm}

ret


though I recommend using a initial script that sets up a global var with the c script and then just let the lua block return that string

e.g:
tablescript lua:
Code:

script1=[[{$c}
typedef int myintegertype;
{$asm}
]]

script2=[[{$c}
myintegertype bla(myintegertype x)
{
  return x+12;
}
{$asm}
]]


and then have aa script as

Code:


{$lua}
return script1
{$asm}


alloc(script,1024)

{$lua}
return script2
{$asm}



script:
mov rcx,10
call long bla //I know its within 2GB

{$ccode result=rax}
  myintegertype r=result;
  result=bla(r);
{$asm}

ret

_________________
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
myocytebd2
Cheater
Reputation: 0

Joined: 23 Apr 2015
Posts: 33

PostPosted: Tue Mar 22, 2022 6:49 am    Post subject: Reply with quote

Thanks.
Dark Byte wrote:
CE has no issue with multiple {$C} blocks

I see, the problem for me is due to some minor bugs of the parser.
This is OK
Code:
{$c}
typedef int myintegertype;
{$asm}
// Error if this line is deleted or {$asm} is deleted
{$c}
myintegertype bla(myintegertype x) { return x+12; }

But these two are rejected:
(I expected empty blocks to work because mixing empty {$lua}/{$asm} is fine)
Code:
{$c}
typedef int myintegertype;
{$asm}
{$c}
myintegertype bla(myintegertype x) { return x+12; }

Code:
{$c}
typedef int myintegertype;
{$c}
myintegertype bla(myintegertype x) { return x+12; }
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