public void resize(int newsize) { switch (type) { case etype.DW: dw = Helper.resize(dw, newsize); size = newsize; break; case etype.STR: if (newsize < size) { if (IsBuf) { str = '#' + ToHexString().Substring(0, newsize * 2) + '#'; } else { str.Remove(newsize); } size = newsize; } break; } }
public static rulong str2rul(string str, uint @base) { rulong num = 0; rulong charnum; if (@base < 2 || @base > 32) { return(0); } for (int i = 0; i < str.Length; i++) { charnum = char2rul(str[i]); if (charnum < 0 || charnum >= @base) { break; } num *= @base; num += charnum; } return(num); /* #ifdef _WIN64 * return _strtoui64(string.c_str(), NULL, Base); #else * return strtoul(string.c_str(), NULL, Base); #endif */ }
public static string rul2str(rulong x, uint @base, uint fill = 0) { StringBuilder @out = new StringBuilder(); uint i = 0; if (@base < 2 || @base > 32) { return(""); } do { @out.Insert(0, digits[(int)(x % @base)]); x /= @base; i++; }while (x != 0 || i < fill); return(@out.ToString()); /* #ifdef _WIN64 * _ui64toa(x, buffer, Base); #else * _ultoa(x, buffer, Base); #endif * string @out = buffer; * if(fill > @out.size()) * @out.insert(0, [email protected](), '0'); * return @out; */ }
/// <summary> /// Masks off the high part of the given value. /// </summary> public static rulong resize(rulong dw, int size) { if (0 <= size && size < sizeof(ulong)) { dw &= Bits.Mask(0, size * 8); } return(dw); }
private void emu_BeforeStart(object sender, EventArgs e) { scriptInterpreter.Reset(); scriptInterpreter.debuggee_running = false; OldIP = 0; scriptInterpreter.InitGlobalVariables(); ScripterResume(); }
/// <summary> /// Masks off the high part of the given value. /// </summary> public static rulong resize(rulong dw, int byteSize) { if (0 <= byteSize && byteSize < sizeof(ulong)) { dw &= Bits.Mask(0, 8 * byteSize); } return(dw); }
public void SetBPX(rulong addr, byte type, Action SoftwareCallback) { if (type == Ue.UE_BREAKPOINT) { emu.SetBreakpoint((uint)addr, SoftwareCallback); return; } throw new NotImplementedException(); }
// Number manipulation public static rulong reverse(rulong dw) { throw new NotImplementedException(); #if LATER byte [] pdw = (byte *)&dw; reverse(pdw, pdw + sizeof(dw)); return(dw); #endif }
public static rulong round_up(rulong dw, rulong val) { rulong mod = dw % val; if (mod != 0) { dw += (val - mod); } return(dw); }
public virtual Var reverse() { switch (type) { case etype.DW: dw = Helper.reverse(dw); break; } return(this); }
public virtual Var Add(rulong rhs) { switch (type) { case etype.DW: return(Create(this.dw + rhs)); case etype.FLT: return(Create(this.flt + rhs)); } return(this); }
public override Var Add(rulong rhs) { if (this.IsBuf) // buf + rulong -> buf { return(Var.Create("#" + this.to_bytes() + Helper.rul2hexstr(Helper.reverse(rhs), sizeof(rulong) * 2) + '#')); } else // str + rulong -> str { return(Var.Create(this.str + Helper.toupper(Helper.rul2hexstr(rhs)))); } }
public bool SetContextData(eContextData reg, rulong value) { switch (reg) { case eContextData.UE_EIP: var cAddr = Constant.Create(arch.PointerType, value); emu.InstructionPointer = arch.MakeAddressFromConstant(cAddr, true); return(true); } throw new NotImplementedException(); }
public static rulong resize(rulong dw, int size) { throw new NotImplementedException(); #if LATER if (size > 0 && size < sizeof(dw)) { dw &= ((1 << (size * 8)) - 1); } return(dw); #endif }
public override Var Add(rulong rhs) { if (this.IsBuf) // buf + rulong -> buf { return(Var.Create("#" + this.ToHexString() + Helper.rul2hexstr(Helper.reverse(rhs), sizeof(rulong) * 2) + '#')); } else // str + rulong -> str { return(Var.Create(this.str + Helper.rul2hexstr(rhs).ToUpperInvariant())); } }
/* * Design: * * ScripterResume MUST be called from within the debug loop * - BP callback * - or via plugin interface: + Call to ScripterAutoDebug which loads exe and calls DebugLoop and calls ScripterResume on EP + it will immediately return, this is needed for returning to the debug loop + and executing until a breakpoint/exception occurs: + + / + DebugLoop() + ^ + OnBP/OnException callback | + OllyLang::Step() | ^ [do commands until return to loop is required (RUN, STI, etc.)] | - | ^ - \ - \ \ When done, call FinishedCallback \ (if script loaded inside debug loop and not via ScripterExecuteScript) \ or return */ // TitanEngine plugin callbacks void TitanDebuggingCallBack(DEBUG_EVENT debugEvent, int CallReason) { switch (CallReason) { case Ue.UE_PLUGIN_CALL_REASON_POSTDEBUG: break; case Ue.UE_PLUGIN_CALL_REASON_EXCEPTION: switch (debugEvent.dwDebugEventCode) { case DEBUG_EVENT.CREATE_PROCESS_DEBUG_EVENT: scriptInterpreter.InitGlobalVariables(); break; case DEBUG_EVENT.EXCEPTION_DEBUG_EVENT: if (scriptInterpreter.script_running) { rulong NewIP = debugger.GetContextData(eContextData.UE_CIP); //if(debugEvent.u.Exception.ExceptionRecord.ExceptionCode == 1) // EXCEPTION_BREAKPOINT) NewIP--; //DBG_LOG("Exception debug event @ " + Helper.rul2hexstr(NewIP)); //$LATER if (NewIP != OldIP) { scriptInterpreter.debuggee_running = false; } //$LATER //if(!debugEvent.u.Exception.dwFirstChance) // ollylang.OnException(); OldIP = NewIP; } break; } break; } }
public static void SetHardwareBreakPoint(rulong addr, object o, eHWBPType type, byte size, Action callback) { }
public bool SetMemoryBPXEx(rulong addr, rulong size, byte p1, bool p2, Action MemoryCallback) { throw new NotImplementedException(); }
public bool SetContextData(RegisterStorage reg, rulong value) { emu.WriteRegister(reg, value); return(true); }
public bool SetMemoryBPXEx(Address addr, rulong size, byte p1, bool p2, Action MemoryCallback) { throw new NotImplementedException(); }
public static rulong round_down(rulong dw, rulong val) { return (dw - (dw % val)); }
public static rulong resize(rulong dw, int size) { throw new NotImplementedException(); #if LATER if (size > 0 && size < sizeof(dw)) { dw &= ((1 << (size * 8)) - 1); } return dw; #endif }
public static string rul2decstr(rulong x, uint fill = 0) { return rul2str(x, 10, fill); }
public override Var Add(rulong rhs) { if (this.IsBuf) // buf + rulong -> buf { return Var.Create("#" + this.to_bytes() + Helper.rul2hexstr(Helper.reverse(rhs), sizeof(rulong) * 2) + '#'); } else // str + rulong -> str { return Var.Create(this.str + Helper.toupper(Helper.rul2hexstr(rhs))); } }
public void DeleteBPX(rulong addr) { emu.DeleteBreakpoint((uint)addr); }
public bool SetContextData(eContextData p1, rulong p2) { throw new NotImplementedException(); }
public Var GetJumpDestination(object p, rulong addr) { throw new NotImplementedException(); }
public static Var Create(rulong rhs) { return(new Var { type = etype.DW, dw = (rhs), size = 4 }); }
public virtual Var Add(rulong rhs) { switch (type) { case etype.DW: return Create(this.dw + rhs); case etype.FLT: return Create(this.flt + rhs); } return this; }
// Number manipulation public static rulong reverse(rulong dw) { throw new NotImplementedException(); #if LATER byte [] pdw = (byte*)&dw; reverse(pdw, pdw + sizeof(dw)); return dw; #endif }
public void resize(int newsize) { switch (type) { case etype.DW: dw = Helper.resize(dw, newsize); size = newsize; break; case etype.STR: if (newsize < size) { if (IsBuf) str = '#' + to_bytes().Substring(0, newsize * 2) + '#'; else str.Remove(newsize); size = newsize; } break; } }
public static rulong round_up(rulong dw, rulong val) { rulong mod = dw % val; if (mod != 0) dw += (val - mod); return dw; }
public virtual Var reverse() { switch (type) { case etype.DW: dw = Helper.reverse(dw); break; } return this; }
public static string rul2str(rulong x, uint @base, uint fill = 0) { StringBuilder @out = new StringBuilder(); uint i = 0; if (@base < 2 || @base > 32) return ""; do { @out.Insert(0, digits[(int)(x % @base)]); x /= @base; i++; } while (x != 0 || i < fill); return @out.ToString(); /* #ifdef _WIN64 _ui64toa(x, buffer, Base); #else _ultoa(x, buffer, Base); #endif string @out = buffer; if(fill > @out.size()) @out.insert(0, [email protected](), '0'); return @out; */ }
public static string rul2hexstr(rulong x, uint fill = 0) { return(rul2str(x, 16, fill)); }
public void RemoveMemoryBPX(Address membpaddr, rulong membpsize) { throw new NotImplementedException(); }
public void DisableBPX(rulong addr) { throw new NotImplementedException(); }
private bool DoBPHWC(string[] args) { rulong addr; if (args.Length >= 0 && args.Length <= 1) { if (args.Length == 0) { return DoBPHWCA(new string[0]); } else if (GetRulong(args[0], out addr)) { rulong[] DRX = new rulong[4]; DRX[0] = Debugger.GetContextData(eContextData.UE_DR0); DRX[1] = Debugger.GetContextData(eContextData.UE_DR1); DRX[2] = Debugger.GetContextData(eContextData.UE_DR2); DRX[3] = Debugger.GetContextData(eContextData.UE_DR3); for (int i = 0; i < DRX.Length; i++) { if (DRX[i] == addr) { Debugger.DeleteHardwareBreakPoint(i); } } return true; } } return false; }
public static string rul2decstr(rulong x, uint fill = 0) { return(rul2str(x, 10, fill)); }
public void RemoveMemoryBPX(rulong membpaddr, rulong membpsize) { throw new NotImplementedException(); }
/* Design: ScripterResume MUST be called from within the debug loop - BP callback - or via plugin interface: + Call to ScripterAutoDebug which loads exe and calls DebugLoop and calls ScripterResume on EP it will immediately return, this is needed for returning to the debug loop and executing until a breakpoint/exception occurs: / + DebugLoop() ^ + OnBP/OnException callback | + OllyLang::Step() ^ [do commands until return to loop is required (RUN, STI, etc.)] | - ^ - \ - When done, call FinishedCallback (if script loaded inside debug loop and not via ScripterExecuteScript) or return */ // TitanEngine plugin callbacks void TitanDebuggingCallBack(DEBUG_EVENT debugEvent, int CallReason) { switch (CallReason) { case Ue.UE_PLUGIN_CALL_REASON_POSTDEBUG: break; case Ue.UE_PLUGIN_CALL_REASON_EXCEPTION: switch (debugEvent.dwDebugEventCode) { case DEBUG_EVENT.CREATE_PROCESS_DEBUG_EVENT: scriptInterpreter.InitGlobalVariables(); break; case DEBUG_EVENT.EXCEPTION_DEBUG_EVENT: if (scriptInterpreter.script_running) { rulong NewIP = debugger.GetContextData(eContextData.UE_CIP); //if(debugEvent.u.Exception.ExceptionRecord.ExceptionCode == 1) // EXCEPTION_BREAKPOINT) NewIP--; //DBG_LOG("Exception debug event @ " + Helper.rul2hexstr(NewIP)); //$LATER if (NewIP != OldIP) scriptInterpreter.debuggee_running = false; //$LATER //if(!debugEvent.u.Exception.dwFirstChance) // ollylang.OnException(); OldIP = NewIP; } break; } break; } }
public static rulong round_down(rulong dw, rulong val) { return(dw - (dw % val)); }
public static string rul2hexstr(rulong x, uint fill = 0) { return rul2str(x, 16, fill); }
public static Var Create(rulong rhs) { return new Var { type = etype.DW, dw = (rhs), size = 4 }; }