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 access AutoAssemble variables in C?

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

Joined: 09 Sep 2023
Posts: 5

PostPosted: Fri Sep 22, 2023 8:15 am    Post subject: How to access AutoAssemble variables in C? Reply with quote

Wiki told me to properly use 'extern' keyword,but idk how to do it.
My codes:
Code:

{$asm}
define(test_hp_ptr,[Base]+40)
registersymbol(test_hp_ptr)
{$C}
#include <stdint.h>
extern uintptr_t test_hp_ptr;
*test_hp_ptr = 1;

the codes above can't be compiled.Error:test_hp_ptr declaration expected.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4307

PostPosted: Fri Sep 22, 2023 10:06 am    Post subject: Reply with quote

Error4ever wrote:
Code:
*test_hp_ptr = 1;
This isn't inside a function. Put it in a function then call the function.
You could leave it outside a function with {$ccode}, but that can only be used in an injection.

With the way that code is written, the last offset in that pointer path is 0, not 40. This is probably unintended.

Use extern to get Base and traverse that path in C.
Example:
Code:
[ENABLE]
globalalloc(foo,1024)
foo:
  dq foo+100

{$C}
// the value at the address "foo" is a void*
extern void *foo;

int myThreadProc() {
  // increases foo+180
  *(int *)(foo + 0x80) += 1;
  return 0;
}
{$asm}

createthreadandwait(myThreadProc, 1000)

[DISABLE]

_________________
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
Error4ever
How do I cheat?
Reputation: 0

Joined: 09 Sep 2023
Posts: 5

PostPosted: Wed Mar 20, 2024 8:47 am    Post subject: thank you Reply with quote

it works well
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