 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Attack Cheater
Reputation: 0
Joined: 21 Mar 2011 Posts: 46 Location: Canada
|
Posted: Fri Feb 06, 2015 9:24 pm Post subject: if x do aobscan? |
|
|
I don't know if this is possible. I need to do an aobscan, but only if I have set a flag.
Reason is, the character structure is not created until the level is loaded. So I set a flag for when the code is executed that creates the pointer, so that I know not to alter the value until then.
Does the aobscan always execute or only if I put it behind a cmp je?
I'm asking because at the moment it doesn't work and I am thinking it may be because of the aobscan.
Otherwise I am facing a different challenge. If the table is activated too late, i.e. level is already loaded, then the code I am attaching to won't set the flag... so I need another thing where I can do an aobscan and if it fails, set a flag, but AFAIK, if the aobscan fails, the script doesn't work?
Is it time to use LUA?
|
|
Back to top |
|
 |
Geri Moderator
Reputation: 111
Joined: 05 Feb 2010 Posts: 5636
|
Posted: Fri Feb 06, 2015 9:33 pm Post subject: |
|
|
aobscan is executed when you try to enable the script. And if aobscan will find nothing, the script will not be enabled at all.
_________________
|
|
Back to top |
|
 |
Attack Cheater
Reputation: 0
Joined: 21 Mar 2011 Posts: 46 Location: Canada
|
Posted: Fri Feb 06, 2015 9:35 pm Post subject: |
|
|
Geri wrote: | aobscan is executed when you try to enable the script. And if aobscan will find nothing, the script will not be enabled at all. |
So is there any work around I can use? Anything at all? I'm not sure what to do in this case.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 06, 2015 9:54 pm Post subject: |
|
|
Why can't the flags be used after the level is loaded? What are you checking against?
|
|
Back to top |
|
 |
Attack Cheater
Reputation: 0
Joined: 21 Mar 2011 Posts: 46 Location: Canada
|
Posted: Fri Feb 06, 2015 10:11 pm Post subject: |
|
|
++METHOS wrote: | Why can't the flags be used after the level is loaded? What are you checking against? |
This is the problem, the value I need to access is part of the character. The value doesn't exist until the level is loaded.
Script 0:
- attach to code that creates pointer to character sheet.
- set flag to 1 when it runs
Script 1:
- aobscan for invincibility timer and set value to 1
- aobscan for inv timer decrease and nop
- set flag to 0*
As long as everything is done in the correct order, it works.
Script 0 has to be run before a level is loaded. If not, it won't change the flag.
Script 1 has to be run once the level is loaded. If not, the aobscan will fail.
Basically I need some way to not execute the script until it is possible to perform the aobscan, which in my case means, once the flag is set to 1
*= script 1 sets the flag back to 0, because otherwise when the next level is loaded, script 0 won't run.
|
|
Back to top |
|
 |
SteveAndrew Master Cheater
Reputation: 30
Joined: 02 Sep 2012 Posts: 323
|
Posted: Fri Feb 06, 2015 10:17 pm Post subject: |
|
|
Yeah, and why not just test if the pointer is null before trying to use it? That usually works for most games.
ex.
Code: |
mov rax,[Game.exe+581932]
test rax,rax
je PointerNotReadyYet
mov rax,[rax+1c0]
test rax,rax
je PointerNotReadyYet
push rbx
mov ebx,[rax+24] //max health
mov [rax+20],ebx //write max health to health
pop rbx
PointerNotReadyYet:
jmp returnhere
|
EDIT: So it's not an actual pointer, but one that you yourself grab using script 0?
1. Enable script 0, as you say before the level loads... When the level loads you have your pointer [Ptr]
2. After the level loads enable script 1, have it check if [Ptr] hasn't been set yet and if so don't execute your code that modifies it until is has been filled...
But wait if script 1 can't be enabled before script 0... Is that only because you end up using the null pointer and crashing, or the code doesn't yet exist in memory? Also after you load a new level are you saying the memory deallocates and reallocates somewhere else upon loading a new level?
_________________
|
|
Back to top |
|
 |
Attack Cheater
Reputation: 0
Joined: 21 Mar 2011 Posts: 46 Location: Canada
|
Posted: Fri Feb 06, 2015 10:30 pm Post subject: |
|
|
I didn't know about that. Would've saved me some hours. Oh well, I learnt how to do some things the hard way.
Can I get some more insight on your code? What I want is a code that keeps trying until it can enable itself. As far as I can tell, you just have to keep trying to enable what you wrote until it works?
I don't want to create an infinite loop, just a script that waits to run until it can.
Though I may have just made a realization while typing this. I can edit the code, and people will become invincible after the first hit. Then I don't need to worry about anything else. Not as nice as I would like it, but it'll do.
EDIT: As for your edits. I was really just looking at a piece of code that runs every level that changes the value of the pointer. I never bothered to find the actual pointer as it wasn't necessary anymore at that point.
The only problem that can arise now is that the pointer, once set initially, will remain until the new level loads. An issue for another time.
Script 1 cannot be enabled because it checks a flag. Or more accurately, if enabled and flag is 0, it does nothing. Runs the same code on enable and disable. Script 0 runs all the real clean up.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 06, 2015 10:43 pm Post subject: |
|
|
I'm having a hard time following. First, what you're describing regarding the invincibility is indicative of using 'what writes' as opposed to 'what accesses' when using the debugger to check addresses.
Second, are you checking a pointer by manually adding it to the script, or from the register, or from a pointer tree inside a data structure?
You should be able to do as SteveAndrew suggests, and just check that pointer to see if it's any good, and if it is, allow your custom code to run. Better yet, don't use any pointers, and just use multiple scripts.
|
|
Back to top |
|
 |
SteveAndrew Master Cheater
Reputation: 30
Joined: 02 Sep 2012 Posts: 323
|
Posted: Fri Feb 06, 2015 10:57 pm Post subject: |
|
|
Yeah it's not an infinite loop, it's more like everytime your hooked code runs it determines whether the pointer you captured is able to be written to. If your first script has gotten the pointer it will use it, if not you execute the game's original code and jump back (jmp returnhere).
It's never a good idea to trap one of the game's running threads and hold it in an infinite loop. (except rare circumstances which I can't even think of one right now)
So say the game's code is: (for your second script / script 1)
Code: |
Game.exe+123456:
mov [rax+20],edx
|
You wont hook it and put it into an infinite loop when its called, no. It'll be just like normal except with your added code.
Code: |
[enable]
alloc(script1,1024,Game.exe+123456)
label(PointerIsNull)
label(returnhere)
script1:
push rax
mov rax,[Pointer] //Pointer is a registered symbol in script0 which wont let this script unable unless it exists
test rax,rax
je PointerIsNull
push rdx
mov edx,5 //or whatever value to write to your pointer
mov [rax],edx
pop rdx
PointerIsNull:
pop rax
mov [rax+20],edx //execute original code
jmp returnhere //allow the thread to continue executing like normal
Game.exe+123456:
jmp script1
returnhere:
[disable]
Game.exe+123456:
mov [rax+20],edx
dealloc(script1)
|
While posting this I see your new edit... Getting a new pointer after a new level loads isn't really a problem is it? As long as it isn't invalid or null it will work fine...
If you really want to be lazy you could also just work in a WriteProcessMemory to handle -1 (current process) which wont crash if it's invalid memory, it just wont work...
Also your script shouldn't really have the same exact code on enable and disable! Use enable for enabling code and disable for disabling code... It's kind of silly to do anything else.
Also I don't get why your code won't do anything unless your flag is set, where you have to keep ticking it on/off... Are you not hooking the game's code but instead creating a thread or something? If it is a thread maybe you should do the infinite loop idea... If your worried about it slowing down the game, you just have forgotten to include a Sleep(10);
_________________
|
|
Back to top |
|
 |
Attack Cheater
Reputation: 0
Joined: 21 Mar 2011 Posts: 46 Location: Canada
|
Posted: Sat Feb 07, 2015 12:19 am Post subject: |
|
|
Steve, you just gave me a different idea, basically adding what you suggested into my script 0. As that only runs on level load, I will do all my stuff regarding altering the value there. Why I didn't do this before is beyond me. I feel like a retard. It's such a simple solution. I am already hooking into something that runs after level load, creates the pointer, and thus executing my value change afterwards will be fine. Duh.
Now I just need to figure out what my pointer is, because originally I was going to use an aobscan.
SteveAndrew wrote: | Also your script shouldn't really have the same exact code on enable and disable! Use enable for enabling code and disable for disabling code... It's kind of silly to do anything else.
Also I don't get why your code won't do anything unless your flag is set, where you have to keep ticking it on/off... Are you not hooking the game's code but instead creating a thread or something? If it is a thread maybe you should do the infinite loop idea... If your worried about it slowing down the game, you just have forgotten to include a Sleep(10); |
Here's the thing, there's a main script that enables the option. The other script only checks the flag and runs only if it is set. I don't want to have to press a key twice to do the thing I want, so the key does the same thing both times.
The actual code is disabled by disabling the entire trainer.
Trust me it makes sense and cleans u perfectly. It's something I learnt about after asking about an AA script that overwrites itself to the original code.
|
|
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
|
|