 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dave_Scream Cheater
Reputation: 0
Joined: 06 Dec 2009 Posts: 36
|
Posted: Sun May 05, 2024 1:46 pm Post subject: {$ccode} compilation failed:undefined '__chkstk' if too big |
|
|
When press OK, CE accept all code. But when trying to activate, it looks like okay, but dont work.
After activate, I press right key and upper line show error message:
| Code: | | <<ccode section compilation failed:tcc: error: undefined symbol '__chkstk'>> |
I found that its happening if im using array with too much elements:
| Code: |
typedef struct {
int id;
float damage_mult;
int damage_value;
int armor_damage_value;
int penetration1_no_angle_value;
int penetration2_angle_value;
int penetration3_unknown_value;
int penetration4_unknown_value;
char* weapon_name;
} Weapon;
Weapon weapons[72] = {
{326, 1.0f, -1, -1, -1, -1, -1, -1, "Helldiver melee:50 5 1 0 0 0"},
// Assault rifle
{ 51, 10.0f, -1, -1, -1, -1, -1, -1, "AR-22C Patriot / AR-23 Liberator / AR-48 Truth Whisperer / AX/AR-23 Guard Dog (w Liberator AR) / Stalwart / Polar Patriots Warbond - AR-61 Tenderizer:60 6 2 2 2 0"},
{ 50, 1.0f, -1, -1, -1, -1, -1, -1, "AR-23C Liberator Concussive:65 15 2 2 2 2"},
{ 48, 1.0f, -1, -1, -1, -1, -1, -1, "AR-23P Liberator Penetrator:45 15 3 3 3 0"},
// Marksman rifle
{ 65, 1.0f, -1, -1, -1, -1, -1, -1, "AR-20L Justice / BR-14 Adjudicator / Machine Gun / Gatling Sentry / Machine Gun Sentry:80 8 3 3 3 1"},
{ 73, 1.0f, -1, -1, -1, -1, -1, -1, "R-63 Diligence:125 13 2 2 2 0"},
{ 74, 1.0f, -1, -1, -1, -1, -1, -1, "R-63CS Diligence Counter Sniper:140 14 3 3 3 0"},
// Submachine gun
{ 26, 1.0f, -1, -1, -1, -1, -1, -1, "MP-98 Knight:50 5 2 2 2 0"},
{ 41, 1.0f, -1, -1, -1, -1, -1, -1, "Polar Patriots Warbond - SMG-72 Pummeler:65 7 2 2 2 0"},
{ 34, 1.0f, -1, -1, -1, -1, -1, -1, "SG-8S / SMG-37 Defender:70 7 2 2 2 0"} |
for example
Weapon weapons[72] is okay. But 150 will be not.
So the problem is not in code, but in size of array.
I increased memory size by allocating 20000. It should be more than enough, but still getting the same error:
| Code: | aobscanmodule(damage_inject,game.dll,66 0F 6E 59 04 66 0F 6E 49 08 0F 5B C9 0F 5B DB)
alloc(damage_newmem,[b]$20000[/b]) |
Also I tryed to split 1 big array in two smaller like this:
| Code: | Weapon weapons[72];
Weapon weapons2[72];
...
// changed code to work with both arrays |
but this dont work.
Last edited by Dave_Scream on Mon May 06, 2024 5:38 am; edited 2 times in total |
|
| Back to top |
|
 |
Dave_Scream Cheater
Reputation: 0
Joined: 06 Dec 2009 Posts: 36
|
Posted: Mon May 06, 2024 12:35 am Post subject: |
|
|
It looks like it is not important how you allocate: alloc(damage_newmem,$20000)
{$ccode} section have its own unvisible limit...
Maybe I should use {$c} section to specify array1 and another {$c} section to specify array2 and then in {$ccode} section write code that will use these arrays?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25819 Location: The netherlands
|
Posted: Mon May 06, 2024 6:48 am Post subject: |
|
|
__chkstk is called when you have more than 4KB of local variable storage in a function, it's to trigger the guard page in case the first local var byte is before the guard page and thus causes a crash
it's better to define it in a global c variable instead (also faster)
Not sure why the symbol lookup fails for you though. The symbols aren't being loaded ?
(if you have to do it as local vars in the stack, you can implement your own chkstk function in assembler, which reads all the bytes from the BP down to the current SP)
_________________
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 |
|
 |
Dave_Scream Cheater
Reputation: 0
Joined: 06 Dec 2009 Posts: 36
|
Posted: Mon May 06, 2024 10:18 am Post subject: |
|
|
| Dark Byte wrote: | | it's better to define it in a global c variable instead (also faster) |
It should be faster because will not define every run?
Can you please explain how to create global c variable?
I saw somewhere in tutorials, you used {$c} block to define function. And then you used it in {$ccode} but it is not transparent for me global it or not. And not transparent will {$c} block call only 1 time or not.
Maybe global variables should be declared before [Enable] and [Disable] ?
UPD. I think its working. Does definition of struct is global and work only 1 time so faster?
| Code: |
alloc(weapons, 20000)
registersymbol(weapons)
{$c}
typedef struct {
int id;
float damage_mult;
int damage_value;
int armor_damage_value;
int penetration1_no_angle_value;
int penetration2_angle_value;
int penetration3_unknown_value;
int penetration4_unknown_value;
char* weapon_name;
} Weapon;
Weapon weapons[1000] = {
{326, 1.0f, -1, -1, -1, -1, -1, -1, "Helldiver melee:50 5 1 0 0 0"}
};
{$asm}
[ENABLE]
{$ccode}
// extern Weapon weapons[]; // no need
// just use
for (int i = 0; i < sizeof(weapons) / sizeof(weapons[0]); ++i) {
// weapons[i].id
}
{$asm}
[DISABLE]
|
|
|
| Back to top |
|
 |
|
|
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
|
|