| View previous topic :: View next topic |
| Author |
Message |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 12:30 am Post subject: Help My Script Crashes |
|
|
Don't know why its crashing. Btw this is my first time trying to create my very own code cave scripts..( address is up to date )
| Code: |
[ENABLE]
//Created By Gwinx
//GMS v99
//Remove Loot Animations on Item Count
Alloc(CheckIt,150)
Label(GoRet)
Label(EndIt)
Label(DoIt)
0044CCFF: //Remove Loot Animation
Jmp CheckIt
GoRet:
CheckIt:
Mov ESI,[00DCA0A0]//Item Base
Mov ESI,[ESI+014]//Item Count Offset
Test ESI,ESI//Check for crash
JE EndIt //If equal go to EndIt
Cmp Dword PTR[ESI+014],00//Compare Item Count value with 00
JE EndIt //If Equal go to EndIt
Cmp Dword PTR[ESI+014],01 //Compare Item Count value with 01
JGE DoIt //Item Count value is equal or greater than 01 go to DoIt
DoIt:
JL 0044D075 //Remove Loot Animations
EndIt:
JNL 0044D075//Original Opcode
Jmp GoRet //Return
[DISABLE]
0044CCFF:
JNL 0044D075
Dealloc(CheckIt)
|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25934 Location: The netherlands
|
Posted: Mon Jul 04, 2011 4:21 am Post subject: |
|
|
the test and cmp instructions change the eflags that the original jnl is looking for
try storing the eflags and restore it when calling the original code
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 10:25 am Post subject: |
|
|
And besides, if JL is not true, it will just go to the next instruction which is JNL so it will jump anyway.
| Code: | DoIt:
JL 0044D075 //Remove Loot Animations
//if not true, continue to EndIt
EndIt:
JNL 0044D075//Original Opcode
//if JL was not true, JNL will be true so here it will jump for sure
Jmp GoRet //Return |
You can save the flags with pushfd and load the flags in popfd. Make sure to insert the pushfd instruction before you would make any compare, test, etc and use the popfd instruction before the original code would be executed.
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 2:05 pm Post subject: |
|
|
What do you guys mean by flags? Please show me an example. I appreciate this guys!
@Geri
this is what I did after reading your post
| Code: |
[ENABLE]
//Created By Gwinx
//GMS v99
//Remove Loot Animations on Item Count
Alloc(CheckIt,150)
Label(GoRet)
Label(EndIt)
Label(DoIt)
0044CCFF: //Remove Loot Animation
Jmp CheckIt
GoRet:
CheckIt:
Pushfd
Mov ESI,[00DCA0A0]//Item Base
Mov ESI,[ESI+014]//Item Count Offset
Test ESI,ESI//Check for crash
JE EndIt //If equal go to EndIt
Cmp Dword PTR[ESI+014],00//Compare Item Count value with 00
JE EndIt //If Equal go to EndIt
Cmp Dword PTR[ESI+014],01 //Compare Item Count value with 01
JGE DoIt //Item Count value is equal or greater than 01 go to DoIt
Cmp Dword PTR[ESI+014],01 //Compare Item Count value with 01
JL EndIt
DoIt:
JL 0044D075 //Remove Loot Animations
EndIt:
Popfd
JNL 0044D075//Original Opcode
Jmp GoRet //Return
[DISABLE]
0044CCFF:
JNL 0044D075
Dealloc(CheckIt)
|
Not sure what is an eflag and do you restore it and such. Are there any tutorials or example on flags?
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 2:34 pm Post subject: |
|
|
I am not sure what is the purpose of your code, but I guess it should look like this:
1. pushfd
2. your code.
3. do your compares.
4. if compare is false, continue to custom code 1.
5. popfd
6. jump back to originalcode
7. if compare is true, continue to custom code 2.
8. popfd
9. jump back to originalcode
So you need to make sure that after custom code 1, you have a jump back to originalcode and you do not execute custom code 2 after it.
Also, you need to make sure that custom code 1 and 2 is containing popfd to make sure that either way, the flags are restored.
As for what are flags, you can find the answer in the CE help file.
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 3:20 pm Post subject: |
|
|
Like this?
| Code: |
[Enable]
Alloc(CheckIt,256)
Alloc(DoIt,100)
Alloc(EndIt,100)
Alloc(Original,100)
Label(GoReturn)
0044CCFF:
Jmp CheckIt
GoReturn:
CheckIt:
Pushfd
Mov ESI,[00DCA0A0]
Mov ESI,[ESI+0014]
Cmp Dword PTR [ESI+0014],00
JE EndIt
Popfd
Jmp Original
Cmp Dword PTR [ESI+0014],01
JGE DoIt
Popfd
Jmp Original
Original:
JNL 0044D075
DoIt:
Popfd
JL 0044D075
Jmp Original
EndIt:
Popfd
JNL 0044D075
Jmp GoReturn
[Disable]
0044CCFF:
JNL 0044D075
Dealloc(CheckIt)
Dealloc(DoIt)
Dealloc(EndIt)
Dealloc(Original)
|
| Dark Byte wrote: | the test and cmp instructions change the eflags that the original jnl is looking for
try storing the eflags and restore it when calling the original code |
How do I store it and when do I that?
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 3:54 pm Post subject: |
|
|
| Quote: | | How do I store it and when do I that? |
You store the flags with pushfd and you load them with popfd. You need to store them before you would change any flags with cmp or test or any other instruction that is affecting the flags, then you need to load them before you would proceed to the originalcode.
If you read what are flags and how is cmp working, you will see what is wrong with your whole concept. For example:
| Code: | Cmp Dword PTR [ESI+0014],00
JE EndIt
Popfd
Jmp Original //lines between this and Original will never be executed
Cmp Dword PTR [ESI+0014],01 //not executed
JGE DoIt //not executed
Popfd //not executed
Jmp Original //not executed
Original:
JNL 0044D075 //if it is not true, it should return to continue executing the original code after your hook or it will execute DoIt after that
DoIt:
Popfd
JL 0044D075 //I am not sure what are you comparing but it is sure that after you have done popfd, all of your compares' results will be gone
Jmp Original
EndIt:
Popfd
JNL 0044D075 //again, your compares does not affect this conditional jump at all but we know that your compare was 0, otherwise this code would not run, so it is useless to make a compare to see if it is 0 or not, as we know already that it is 0
Jmp GoReturn |
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 5:03 pm Post subject: |
|
|
Arg, im sorry - im so confused :/
Can you please complete the script for me? :0
I will learn from it :/
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 5:18 pm Post subject: |
|
|
Well I would have completed it but I don't have a clue what should it do. I see it has 2 compares but I don't know what are you comparing and when should it jump and why.
You could try to write down what should the code do and I can try to fix.
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 5:53 pm Post subject: |
|
|
Ok this the orignal script:
[Enable]
0044CCFF:
JL 0044D075
[Disable]
0044CCFF:
JNL 0044D075
What it does is remove loot animations
but I am trying to make it check if there are more than 5 items on the ground
then it will remove loot animations else if its below 5 then it won't remove the loot animation
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 6:16 pm Post subject: |
|
|
Mov ESI,[00DCA0A0]//Item Base
Mov ESI,[ESI+014]//Item Count Offset
Is esi+014 the number of items on the ground? Or why do you compare it to 1?
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Mon Jul 04, 2011 6:33 pm Post subject: |
|
|
014 is the offset for item counter
I compare to one to see if it works if there are 1 items on the ground
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Mon Jul 04, 2011 6:52 pm Post subject: |
|
|
Then I guess it would look something like this:
| Code: | blablabla:
pusfd
push esi //save esi before you change it, unless the next 2 lines are original codes
Mov ESI,[00DCA0A0]//Item Base
Mov ESI,[ESI+014]//Item Count Offset
Test ESI,ESI//Check for crash //this can be probably removed
JE EndIt //If equal go to EndIt //this can be probably removed
Cmp Dword PTR[ESI+014],00 //Compare Item Count value with 00
JE EndIt //If Equal go to EndIt
Cmp Dword PTR[ESI+014],01 //Compare Item Count value with 01
JGE DoIt //Item Count value is equal or greater than 01 go to DoIt
EndIt:
pop esi //load the original esi
popfd
JNL 0044D075//Original Opcode
jmp exit //end of messing with anything, continue with the original code
DoIt:
pop esi
popfd
JL 0044D075 //Remove Loot Animations
jmp exit //just to make sure |
If I were you I would figure out what happens when JNL is jumping and what happens when not and I would do that in the code instead of using another conditional jump, but it is up to you. Maybe even this will work.
_________________
|
|
| Back to top |
|
 |
Gwinx Advanced Cheater
Reputation: 0
Joined: 30 Jul 2010 Posts: 65
|
Posted: Tue Jul 05, 2011 6:41 am Post subject: |
|
|
| Still crash :/
|
|
| Back to top |
|
 |
Geri Moderator
Reputation: 112
Joined: 05 Feb 2010 Posts: 5627
|
Posted: Tue Jul 05, 2011 11:19 am Post subject: |
|
|
Attach the debugger to your script and check out why is it crashing. Best solution when you cannot find the error manually.
_________________
|
|
| Back to top |
|
 |
|