Beispiel #1
0
 private void MenuItem_Click_7(object sender, RoutedEventArgs e)
 {
     if (LVMain.SelectedIndex >= 0)
     {
         DisasmItem disasmItem = List[LVMain.SelectedIndex];
         PVZ.Memory.CreateThread(disasmItem.address);
     }
 }
Beispiel #2
0
 private void MenuItem_Click_5(object sender, RoutedEventArgs e)
 {
     if (LVMain.SelectedIndex >= 0)
     {
         DisasmItem disasmItem = List[LVMain.SelectedIndex];
         Clipboard.SetText(disasmItem.AsmCode);
     }
 }
Beispiel #3
0
 private void MenuItem_Click_2(object sender, RoutedEventArgs e)
 {
     if (LVMain.SelectedIndex >= 0)
     {
         DisasmItem disasmItem = List[LVMain.SelectedIndex];
         PVZ.Memory.WriteBytesStrong(disasmItem.address, Enumerable.Repeat <byte>(0x90, disasmItem.length).ToArray(), disasmItem.length);
         AddDisasmItem();
     }
 }
Beispiel #4
0
 private void MenuItem_Click_1(object sender, RoutedEventArgs e)
 {
     if (LVMain.SelectedIndex >= 0)
     {
         int        index      = LVMain.SelectedIndex;
         DisasmItem disasmItem = List[index];
         string     result     = DarkStyle.InputDialog.ShowInputDialog($"汇编于{disasmItem.Address}", "输入汇编指令", disasmItem.AsmCode);
         if (result != null && result != "??")
         {
             XEDPARSE xed = new XEDPARSE();
             xed.cip   = (ulong)disasmItem.address;
             xed.instr = result;
             XEDParse.XEDParseAssemble(ref xed);
             if (xed.dest_size == 0)
             {
                 MessageBox.Show(xed.error, "汇编指令错误", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             else
             {
                 if (xed.dest_size == disasmItem.length)
                 {
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                     AddDisasmItem();
                 }
                 else if (xed.dest_size < disasmItem.length)
                 {
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, Enumerable.Repeat <byte>(0x90, disasmItem.length).ToArray(), disasmItem.length);
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                     AddDisasmItem();
                 }
                 else if (xed.dest_size > disasmItem.length)
                 {
                     if (MessageBox.Show("目标指令长度大于当前指令长度,使用nop覆盖?", "提问", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                     {
                         int length = disasmItem.length;
                         try
                         {
                             while (xed.dest_size > length)
                             {
                                 index++;
                                 length += List[index].length;
                             }
                         }
                         catch (IndexOutOfRangeException)
                         {
                             MessageBox.Show("指令长度未知", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                             return;
                         }
                         PVZ.Memory.WriteBytesStrong(disasmItem.address, Enumerable.Repeat <byte>(0x90, length).ToArray(), length);
                         PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                         AddDisasmItem();
                     }
                 }
             }
         }
     }
 }
Beispiel #5
0
 private void ContextMenu_Opened(object sender, RoutedEventArgs e)
 {
     if (privousAddress.Count > 0)
     {
         MIBack.Header     = "退回地址" + privousAddress.Peek().ToString("X8");
         MIBack.Visibility = Visibility.Visible;
     }
     else
     {
         MIBack.Visibility = Visibility.Collapsed;
     }
     if (LVMain.SelectedIndex >= 0)
     {
         DisasmItem disasmItem = List[LVMain.SelectedIndex];
         if (disasmItem.AsmCode.StartsWith("j") || disasmItem.AsmCode.StartsWith("call"))
         {
             string[] subs = disasmItem.AsmCode.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
             if (subs.Length == 2)
             {
                 try
                 {
                     int address = Convert.ToInt32(subs[1].Trim().Substring(2), 16);
                     MIFollow.Header     = "跟随地址" + address.ToString("X8");
                     MIFollow.Tag        = address;
                     MIFollow.Visibility = Visibility.Visible;
                     return;
                 }
                 catch (FormatException)
                 {
                     MIFollow.Visibility = Visibility.Collapsed;
                     return;
                 }
             }
         }
         MIFollow.Visibility = Visibility.Collapsed;
     }
 }
Beispiel #6
0
 private void MenuItem_Click_1(object sender, RoutedEventArgs e)
 {
     if (LVMain.SelectedIndex >= 0)
     {
         int        index      = LVMain.SelectedIndex;
         DisasmItem disasmItem = _list[index];
         string     result     = DarkStyle.InputDialog.ShowInputDialog(
             Lang.IsChinese ? $"汇编于{disasmItem.Address}" : $"Assemble at {disasmItem.Address}",
             Lang.IsChinese ? "输入汇编指令" : "Enter assembly instructions",
             disasmItem.AsmCode, !Lang.IsChinese);
         if (result != null && result != "??")
         {
             XEDPARSE xed = new XEDPARSE();
             xed.cip   = (ulong)disasmItem.address;
             xed.instr = result;
             XEDParse.XEDParseAssemble(ref xed);
             if (xed.dest_size == 0)
             {
                 MessageBox.Show(xed.error,
                                 Lang.IsChinese ? "汇编指令错误" : "Assembly instructions error",
                                 MessageBoxButton.OK,
                                 MessageBoxImage.Error);
             }
             else
             {
                 if (xed.dest_size == disasmItem.length)
                 {
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                     AddDisasmItem();
                 }
                 else if (xed.dest_size < disasmItem.length)
                 {
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, Enumerable.Repeat <byte>(0x90, disasmItem.length).ToArray(), disasmItem.length);
                     PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                     AddDisasmItem();
                 }
                 else if (xed.dest_size > disasmItem.length)
                 {
                     if (MessageBox.Show(
                             Lang.IsChinese ? "目标指令长度大于当前指令长度,使用nop覆盖?" :
                             "The target instruction length is greater than the current instruction length. Use nop to cover it?",
                             Lang.IsChinese ? "提问" : "Question",
                             MessageBoxButton.YesNo,
                             MessageBoxImage.Question) == MessageBoxResult.Yes)
                     {
                         int length = disasmItem.length;
                         try
                         {
                             while (xed.dest_size > length)
                             {
                                 index++;
                                 length += _list[index].length;
                             }
                         }
                         catch (IndexOutOfRangeException)
                         {
                             if (Lang.IsChinese)
                             {
                                 MessageBox.Show("指令长度未知", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                             }
                             else
                             {
                                 MessageBox.Show("Unknown instruction length", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                             }
                             return;
                         }
                         PVZ.Memory.WriteBytesStrong(disasmItem.address, Enumerable.Repeat <byte>(0x90, length).ToArray(), length);
                         PVZ.Memory.WriteBytesStrong(disasmItem.address, xed.dest, xed.dest_size);
                         AddDisasmItem();
                     }
                 }
             }
         }
     }
 }