public void JumpOut() { bpstatus = BreakpointStatus.OUT; SimulateDllModel.JumpOut(); BreakpointResume(this, new BreakpointPauseEventArgs(bpaddr, bpstatus)); _pause_old = 0; }
public void CallMove() { bpstatus = BreakpointStatus.CALL; SimulateDllModel.CallStep(); if (SimuStatus != SIMU_RUNNING) { Start(); } BreakpointResume(this, new BreakpointPauseEventArgs(bpaddr, bpstatus)); _pause_old = 0; }
public void JumpTo(int bpaddr) { bpstatus = BreakpointStatus.JUMP; SimulateDllModel.JumpTo(bpaddr); if (SimuStatus != SIMU_RUNNING) { Start(); } BreakpointResume(this, new BreakpointPauseEventArgs(bpaddr, bpstatus)); _pause_old = 0; }
/// <summary> 更新线程运行的更新方法 </summary> private void Update() { _pause_old = 0; _pause_new = 0; // 存活时运行循环 while (updateactive) { // 更新所有变量模型 foreach (SimulateVariableModel svmodel in Variables) { svmodel.Update(dllmodel); } // 更新所有未锁定的变量单元 foreach (List <SimulateVariableUnit> svulist in udict.Values) { foreach (SimulateVariableUnit svunit in svulist) { svunit.Update(dllmodel); } } // 更新所有已锁定的变量单元 foreach (List <SimulateVariableUnit> svulist in ldict.Values) { foreach (SimulateVariableUnit svunit in svulist) { svunit.Set(dllmodel); } } // 若检查到暂停状态的改变则进行处理 _pause_new = SimulateDllModel.GetBPPause(); isbppause = (_pause_new > 0); if (_pause_old == 0 && _pause_new > 0) { if (SimulateDllModel.GetCallCount() > 256) { bpstatus = BreakpointStatus.SOF; } OnBreakpointPause(new BreakpointPauseEventArgs( SimulateDllModel.GetBPAddr(), bpstatus)); } if (_pause_old > 0 && _pause_new == 0) { OnBreakpointResume(new BreakpointPauseEventArgs( SimulateDllModel.GetBPAddr(), bpstatus)); } _pause_old = _pause_new; // 测试dll系统栈的访问 //TestRBP(); // 等待 Thread.Sleep(50); } }
unsafe private void TestRBP() { int call = SimulateDllModel.GetCallCount(); void *rbp = SimulateDllModel.GetRBP(); byte[] data = new byte[64]; if ((int)(rbp) > 0x08) { for (int i = 0; i < data.Length; i++) { data[i] = *(((byte *)(rbp)) + i - 32); } } }
/// <summary> /// 开始仿真 /// </summary> public void Start() { // 已处于仿真状态 if (SimuStatus == SIMU_RUNNING) { // 从断点暂停中继续 if (ISBPPause) { SimulateDllModel.SetBPPause(0); BreakpointResume(this, new BreakpointPauseEventArgs(bpaddr, bpstatus)); _pause_old = 0; } } // 开始仿真 //SimuStatus = SIMU_RUNNING; dllmodel.Start(); //UpdateStart(); }
/// <summary> /// 停止仿真 /// </summary> public void Stop() { // 已处于停止状态则忽略 if (SimuStatus == SIMU_STOP) { return; } // 取消断点暂停 if (ISBPPause) { SimulateDllModel.SetBPPause(0); SimulateDllModel.SetBPEnable(0); BreakpointResume(this, new BreakpointPauseEventArgs(bpaddr, bpstatus)); _pause_old = 0; } // 停止仿真 //SimuStatus = SIMU_STOP; dllmodel.Abort(); //UpdateStop(); }
/// <summary> /// 初始化构造函数 /// </summary> public SimulateManager() { // 初始化成员 dllmodel = new SimulateDllModel(); vlist = new ObservableCollection <SimulateVariableModel>(); udict = new Dictionary <string, List <SimulateVariableUnit> >(); ldict = new Dictionary <string, List <SimulateVariableUnit> >(); vndict = new Dictionary <string, string>(); lddict = new Dictionary <string, SimulateDataModel>(); vddict = new Dictionary <string, SimulateDataModel>(); // 初始化事件监听 //dllmodel.RunDataFinished += OnRunDataFinished; //dllmodel.RunDrawFinished += OnRunDrawFinished; // 初始化更新线程 updateactive = false; updatethread = null; UpdateStart(); dllmodel.SimulateStart += OnSimulateStart; dllmodel.SimulatePause += OnSimulatePause; dllmodel.SimulateAbort += OnSimulateAbort; dllmodel.SimulateException += OnSimulateException; }