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 


Code injection crashes app

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

Joined: 28 Aug 2016
Posts: 2

PostPosted: Sun Aug 28, 2016 11:38 am    Post subject: Code injection crashes app Reply with quote

Hello, I'm trying to inject some code to an application, I've found an address that I want to take over (unfortunately it's not static and finding a pointer is probably impossible - anyway, I can't), and I know what instructions are writing to the address, but every time I do an injection, the app crashes as soon as I switch the window and select the app's one. Even if I don't add any instructions, for example
Code:
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
mov [edi+ecx*4-10],eax
mov eax,[esi+ecx*4-0C]

exit:
jmp returnhere

"MSVCR80.dll"+150F4:
jmp newmem
nop
nop
nop
returnhere:

if I execute that, the app crashes.
Of course I know that the code is copying memory, but I may check with a cmp instruction if it contains any data that interests me and if not, just jump to original code.
So what should I do to deal with the problem?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Aug 28, 2016 12:16 pm    Post subject: Reply with quote

Try moving the injection point up 1 instruction.
It's possible the game's original code is attempting to jump to that second instruction you are overwriting.
When that happens, it starts in the middle of the instruction and executes the wrong bytes.

Also, use the AOB Injection template, instead of Code Injection.
It will find the instruction's new location for you.
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Sun Aug 28, 2016 4:14 pm    Post subject: Reply with quote

CE can't compile the instructions

mov [edi+ecx*4-10],eax
mov eax,[esi+ecx*4-0C]

So are you sure you are re-creating the bytes properly ? I think that's what happening. Post the instructions around where you are injecting.

If CE compiles them for you, it's possible the bytes aren't proper so make sure the generated code at code-cave is exactly like it should be (check the bytes)

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
jaros1024
How do I cheat?
Reputation: 0

Joined: 28 Aug 2016
Posts: 2

PostPosted: Sun Aug 28, 2016 4:54 pm    Post subject: Reply with quote

Zanzer wrote:
Try moving the injection point up 1 instruction.

That's it, thank you! Smile
Back to top
View user's profile Send private message
sbryzl
Master Cheater
Reputation: 6

Joined: 25 Jul 2016
Posts: 252

PostPosted: Sun Aug 28, 2016 8:04 pm    Post subject: Reply with quote

code should look more like this in order to run right I would think
Code:
originalcode:
push ecx
imul ecx,ecx,4
add ecx,edi
mov [ecx-10],eax
sub ecx,edi
add ecx,esi
mov eax,[ecx-0c]
pop ecx
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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