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 


CE 7.3 AA edit "access violation" with c code

 
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: Sun Oct 31, 2021 11:23 pm    Post subject: CE 7.3 AA edit "access violation" with c code Reply with quote

CE 7.3 AA edit UI often prompt "access violation" with c code.
It usually triggers randomly when moving cursor or scrolling.

Here is one case that always trigger "access violation" for me.
AA edit "access violation":
1. Add bug.CEA to table and open;
2. Move cursor to end of this line , by up/down or mouse click;
Code:
label*(

3. "access violation" dialog prompts.

Code:
// Common functions
[ENABLE]
alloc(cCommonCode, 409600)

label(ctCheckDefs)
label*(

registerSymbol(cCommonCode)

registerSymbol(ctCheck)
registerSymbol(ctLog)
registerSymbol(ctInfo)
registerSymbol(ctError)

registerSymbol(ctCheckDefs)

cCommonCode:
  db CC CC CC

ctCheck:
{$luacode cond=eax, msgAddr=edx}
  cCheck(cond, msgAddr)
{$asm}
  ret
  db CC CC CC

ctLog:
{$luacode msgAddr=eax}
  cLog(msgAddr)
{$asm}
  ret
  db CC CC CC

ctInfo:
{$luacode msgAddr=eax}
  cInfo(msgAddr)
{$asm}
  ret
  db CC CC CC

ctError:
{$luacode msgAddr=eax}
  cError(msgAddr)
{$asm}
  ret
  db CC CC CC

{$c}
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#define FALSE 0
#define TRUE 1

__attribute__((regparm(2))) void ctCheck(int cond, const char *msg);
__attribute__((regparm(2))) void ctLog(const char *msg);
__attribute__((regparm(2))) void ctInfo(const char *msg);
__attribute__((regparm(2))) void ctError(const char *msg);

#define STR(__arg) #__arg

#define CHECK_SIZE(__theStructType, __sizeExpr) \
  if (sizeof(__theStructType) != (__sizeExpr)) { \
    char buf[256]; \
    snprintf(buf, sizeof(buf), "%s expected size: %u, actual: %u", STR(__theStructType), (__sizeExpr), sizeof(__theStructType)); \
    ctCheck(FALSE, buf); \
  }

#define CHECK_OFFSET(__theStructType, __m, __offsetExpr) \
  if (offsetof(__theStructType, __m) != (__offsetExpr)) { \
    char buf[256]; \
    snprintf(buf, sizeof(buf), "%s.%s expected offset: %u, actual: %u", STR(__theStructType), STR(__m), (__offsetExpr), offsetof(__theStructType, __m)); \
    ctCheck(FALSE, buf); \
  }

typedef struct { int a; void *vtable; } DisputationState;

void checkDisputationDefs() {
  log("aaaaa");
  CHECK_SIZE(DisputationState, 0x4990);
  CHECK_OFFSET(DisputationState, vtable, 0);
}

void checkDefs() {
  checkDisputationDefs();
}

{$asm}
ctCheckDefs:
{$ccode var=eax}
  checkDefs();
{$asm}
  ret 4

[DISABLE]
unregisterSymbol(cCommonCode)

unregisterSymbol(ctCheck)
unregisterSymbol(ctLog)
unregisterSymbol(ctInfo)
unregisterSymbol(ctError)

unregisterSymbol(ctCheckDefs)

dealloc(cCommonCode, 409600)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Nov 01, 2021 1:09 am    Post subject: Reply with quote

thanks. it should be fixed on github. (any error, usually lua though, combined with ccode could cause the error)


(also, dealloc doesn't need the size)

_________________
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: Mon Nov 01, 2021 2:43 am    Post subject: Reply with quote

Dark Byte wrote:
(also, dealloc doesn't need the size)

(the usual consequence of paste alloc to dealloc, lol)

One more question, does x64 c code supports microsoft calling convention?
Tiny cc docs does not mention ms_abi/sysv_abi (and CE does not warn on unsupported attribute, so the situation is not clear to me).
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Nov 01, 2021 5:51 am    Post subject: Reply with quote

it uses the microsoft calling convention when using the windows version
_________________
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
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