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 


Write to location 00004080 caused an access violation.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
wazlord
Expert Cheater
Reputation: 4

Joined: 17 Sep 2012
Posts: 208

PostPosted: Wed May 06, 2015 9:10 am    Post subject: Write to location 00004080 caused an access violation. Reply with quote

Hi,

I am not able to locate why the code would cause the game to crash when i press the hotkey that i set to change the EnVar to 1.
It seems that when i try to write a 1 to any of the declared EnVars the game would crash out.

It was working fine but suddenly start crashing the game...
Anyone could help me with what i am doing wrong?

ps: It doesnt crash when enabling the script.
It only crash when i go and enable any of the EnVariables... Sad

thanks

Code:

[ENABLE]
aobscan(getDust,48 8B C1 F3 0F 10 40 38 F3 0F 5A C0 F2 0F 5A C0 48 83 C4 08)
alloc(newmemD,$2048,getDust)

label(getDustR)
label(getBoostC)
label(_getEnCheck)
label(_getBoost)
label(_getBoostR)

label(EnBoost)

newmemD:
 _getEnCheck:                               //check if any cheat EnVar is 1b
  cmp byte ptr [EnBoost],1
  je _getBoost
  _getBoostR:
  movss xmm0,[rax+38]
  jmp getDustR

 _getBoost:
  cmp dword ptr [r8+434],(float)1 //434    //compare if the value is float 1
  jne getBoostC
  cmp byte ptr [r8+B00],1 //B00            //compare if the value is 1
  jne getBoostC
  getBoostC:
  jmp _getBoostR

EnBoost:
 dw 0

getDust+3:
  jmp _getEnCheck
getDustR:
registersymbol(getDust)
registersymbol(EnBoost)

[DISABLE]
getDust+3:
  db F3 0F 10 40 38
unregistersymbol(getDust)
unregistersymbol(EnBoost)
dealloc(newmemD)




Last edited by wazlord on Wed May 06, 2015 8:59 pm; edited 4 times in total
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Wed May 06, 2015 10:30 am    Post subject: Reply with quote

Your script is long and I am lazy to check everything since you didn't put in any comments, but I have noticed that you have used a jmp to make the hook and you are using a ret, so unless the original code would end the function anyway, it's obvious why would this cause a crash.
_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Wed May 06, 2015 10:33 am    Post subject: Reply with quote

You use ret without a call
_________________
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
wazlord
Expert Cheater
Reputation: 4

Joined: 17 Sep 2012
Posts: 208

PostPosted: Wed May 06, 2015 9:03 pm    Post subject: Reply with quote

Geri wrote:
Your script is long and I am lazy to check everything since you didn't put in any comments, but I have noticed that you have used a jmp to make the hook and you are using a ret, so unless the original code would end the function anyway, it's obvious why would this cause a crash.


Dark Byte wrote:
You use ret without a call


Thanks Embarassed

Made some changes to the code and the actual cause of the crash is pointing to this part of the code...

Code:

  cmp dword ptr [r8+434],(float)1 //434    //compare if the value is float 1
  jne getBoostC
  cmp byte ptr [r8+B00],1 //B00            //compare if the value is 1
  jne getBoostC


am i doing something wrong with comparison code?
seems if i remove this line the crash went away Sad

I tried comparing to rbp register and it still crashes
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed May 06, 2015 9:12 pm    Post subject: Reply with quote

Looks like the original code is:
movss xmm0,[rax+38]

Are you sure you shouldn't be using:
cmp dword ptr [rax+434],(float)1
cmp byte ptr [rax+B00],1

You're probably crashing because 'r8' isn't a pointer.

Note: Although the current code will work because you're comparing equality,
you cannot compare greater than/less than with floats using CMP.
Back to top
View user's profile Send private message
wazlord
Expert Cheater
Reputation: 4

Joined: 17 Sep 2012
Posts: 208

PostPosted: Wed May 06, 2015 9:19 pm    Post subject: Reply with quote

Zanzer wrote:
Looks like the original code is:
movss xmm0,[rax+38]

Yup thats the original code, which seems to be a generic function used for doing everything in the game

Zanzer wrote:

Are you sure you shouldn't be using:
cmp dword ptr [rax+434],(float)1
cmp byte ptr [rax+B00],1

You're probably crashing because 'r8' isn't a pointer.

Well i would need to check if i could use rax, but from what i checked, r8 is a pointer and seems to have the values i am checking when i was tracing the register values
changing to rbp instead of r8 also causing the crash

i am not sure what happen, as the code was working at one point.

But the thing is the crash happens before coming to the code above as it didnt trip the breakpoints i set the jmp code from the EnCheck, will try and look into it.

Zanzer wrote:

Note: Although the current code will work because you're comparing equality,
you cannot compare greater than/less than with floats using CMP.


I just want to check if the value is equal float 1, i dont care of the greater/less, not sure if this is the cause as well.
maybe ill try and use the other comparison method for the float and see if it solve the problem

This is from the error log, R8/RBP is the pointers as far as i have checked
Code:

Read from location 00000435 caused an access violation.

Context:
RDI:    0x20498888  RSI: 0x2470b100  RAX:   0x2470b100
RBX:    0x00000001  RCX: 0x2470b100  RDX:   0x0000421e
RIP:    0x13d60021  RBP: 0x0029e890  SegCs: 0x00000033
EFlags: 0x00010246  RSP: 0x0029e850  SegSs: 0x0000002b
R8:    0x0029e5d0  R9: 0x00000001  R10:   0x00000000
R11:    0x137dd150  R12: 0x21c279c0  R13:   0x2e908400
R14:    0x4a12c700  R15: 0x23492600
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed May 06, 2015 9:42 pm    Post subject: Reply with quote

Those appear to be local temporary addresses and certainly not something that is going to have an offset of 434 and B00.

What makes you think those are the correct pointers and offsets for the values you're trying to use?

If you simply remove the +434 and +B00, does your script no longer crash?

According to your error log, it almost appears like it is trying to read [r9+434]
Since the error said it tried to read 00000435, which is r9+434.
Curious if CE has a bug that wrote the wrong opcode?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu May 07, 2015 3:19 am    Post subject: Reply with quote

It's possible r8 is part of a previous function call from a different location and the function you're in only takes 2 parameters
So, if the function is called from a different location where r8 isn't setup, then r8 will be wrong{you could use RSP instead)

As for ce assembler errors, ce might have issues with the Rex prefix, but that would cause r8 to turn into rax, not r9

_________________
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
wazlord
Expert Cheater
Reputation: 4

Joined: 17 Sep 2012
Posts: 208

PostPosted: Thu May 07, 2015 8:34 am    Post subject: Reply with quote

Zanzer wrote:
Those appear to be local temporary addresses and certainly not something that is going to have an offset of 434 and B00.

What makes you think those are the correct pointers and offsets for the values you're trying to use?

If you simply remove the +434 and +B00, does your script no longer crash?


hmm, i guess the issue is really due to R8.
when i change the address to RBP, it no longer crash.

It seems there are times when R8 do not have those addresses. Hence causing the crash when it hit into that point which isn't meeting my criteria Evil or Very Mad
guess should have checked this rather than made that assumption.

When i tested earlier i always get the exact amount of register count when checking against R8 offsets, hence using it as hack point.
will have to find another unique combinations then Sad

thx all for helping Very Happy
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