Just found out its works sorta... like if I only call it once, then it works perfectly, but if i call it twice (I.E. ask it to attack the same target that i'm already attacking, then it crashes).
I can delay until the target is dead, for target i can 1-hit and works fine.
So i need to find a way to detect if I am currently attacking a particular target. (And if I am attacking a particular target already, then i skip calling the function)
I wouldn't be surprised if co are using C++ exceptions now. And an unhandled exception saying the target is already being attack is unhanded from within the scope of the code cave which calls it.
I'll keep looking in olly to see if there are any JZ or JNZ or something that skips the calling if im already attacking a target.
Edit: ok... that already attacking target exception theory is not correct... ignore that, just found out conquer calls its own attack function when u select to attack a target ur already attacking anyway.
Edit: Right... a simple fix... how about i try and install a SE handler in assembly, so when the exception is thrown by the attack function i will just ignore the exception, because the attack function is working its just also throwing an exception if i attack a target that im already attacking. Maybe the function containing the attack function does this also, because c++ exceptions are not always for errors, they can also be used for other purposes.
Edit: Ok SE installed, but no exceptions captured from the attack() function, weird, its like there is an exception caused later on in the code.
PHP Code:
// http://www.rohitab.com/sourcecode/seh.html
// try {
asmWriter.pushAd(); // Save Current State
line3 = asmWriter.getLine();
asmWriter.movEsi(0); // Address of the new exception handler (filled in later)
asmWriter.pushEsi(); // Save Old Exception Handler
asmWriter.pushDwordPtrFs(0); // Install New Exception Handler
asmWriter.movDwordPtrFsEsp(0);
// Attack(StructAddr, Key)
asmWriter.push((uint8_t)1);
asmWriter.push((uint8_t)0);
asmWriter.pushDwordPtr(param2);
asmWriter.pushDwordPtr(param1);
asmWriter.call(0x4FDBFE);
asmWriter.movEcxEax();
/*
asmWriter.xorEbxEbx();
asmWriter.movEdx(2);
asmWriter.movEdi(0xF423F);
asmWriter.movEsi(0x19F0060);
*/
asmWriter.call(0x4F8C0A);
// } catch (...) {
line4 = asmWriter.getLine();
asmWriter.jmp(0); // No Exception Occured, so jump over (filled in later)
line5 = asmWriter.getLine();
asmWriter.setLine(line3);
asmWriter.movEsi(line5);
asmWriter.setLine(line5);
asmWriter.movEspDwordPtrEspPlus(8); // Exception Occured, Get old ESP
asmWriter.popDwordPtrFs(0); // Restore Old Exception Handler
asmWriter.addEsp(4); // ESP value before SEH was set
asmWriter.popAd(); // Restore Old State
// }
line3 = asmWriter.getLine();
asmWriter.jmp(0); // Exception was handled by catch (...) (filled in later)
line5 = asmWriter.getLine(); // No Exception Occured
asmWriter.setLine(line4);
asmWriter.jmp(line5);
asmWriter.setLine(line5);
asmWriter.popDwordPtrFs(0); // Restore Old Exception Handler
asmWriter.addEsp(32+4); // ESP value before SEH was set. 32 for pushad and 4 for push offset Handler. (No Restore State)
line4 = asmWriter.getLine(); // Exception has been handled, or no exception occured
asmWriter.setLine(line3);
asmWriter.jmp(line4);
asmWriter.setLine(line4);
I've also checked this very closely w/ ollydbg to make sure asmWriter is working correctly and to make sure the SE handler is installed properly and all was good. And in the conquer versions prior to patch 5127 i had no problem w/ the attack() function at all. It seems an exception is caused somewhere else inside conquer after the time i call attack w/ my code. very weird.
Edit: I know i shouldn't take notice of runtime errors but.... pure virtual function call, that means an something like the following was done
PHP Code:
class SomeClass {
public:
virtual void someFunc() = 0;
SomeClass() {
someFunc();
}
};
normally a complier would pick up on this when ur compiling the code, but since im inserting assembly into conquer... im just thinking since the mobs in the DequeEx keep shuffling around, they dont stay in the same place. So what would happen when i call an attack function on a Mob at the same time the mob is being constructed? (assuming the mob class has a base class w/ attack as a pure virtual function). Then i would expect "runtime error: pure virtual function call", which is what i'm getting.
I could be completely wrong, but maybe that is what is going on.