string[] sTypeText_ItemToLString(SearchListView.SearchListViewItem item) { SearchControl.ncSearchType type = SearchTypes[item.align]; string[] ret = new string[4]; ret[0] = item.addr.ToString("X8"); ret[1] = misc.ByteAToString(item.newVal, ""); ret[2] = "Invalid"; ret[3] = type.Name; return(ret); }
void sTypeText_Initialize(string arg, int typeIndex) { int len = arg.Length; if ((len % 2) == 1) { len++; } SearchControl.ncSearchType type = SearchTypes[typeIndex]; type.ByteSize = len; SearchTypes[typeIndex] = type; }
void CopySelection() { bool cont = true; if (SelectedIndices.Count > 100000) { //cont = MessageBox.Show("You are about to copy a hell of a lot of codes... And it will probably take some time.\nAre you sure you want to go through with this?", "Art thou surest?", MessageBoxButtons.YesNo) == DialogResult.Yes; } if (!cont) { return; } string res = ""; List <int> selParsed = new List <int>(); SearchControl.ncSearcher searcher = SearchControl.SearchComparisons.Where(sc => sc.Name == SearchControl.Instance.searchNameBox.Items[SearchControl.Instance.searchNameBox.SelectedIndex].ToString()).FirstOrDefault(); string[] codes = new string[SelectedIndices.Count]; int codeIndex = 0; foreach (int x in SelectedIndices) { //if (!selParsed.Contains(x)) { //selParsed.Add(x); SearchListViewItem item = GetItemAtIndex(x); if (item.newVal != null) { SearchControl.ncSearchType type = SearchControl.SearchTypes[item.align]; if (searcher.ItemToString != null) { codes[codeIndex] = searcher.ItemToString(item) + Environment.NewLine; } else { codes[codeIndex] = type.ItemToString(item) + Environment.NewLine; } codeIndex++; } } } Clipboard.SetDataObject(new DataObject(DataFormats.Text, (String.Join("", codes, 0, codeIndex)).Replace("\0", ""))); }
string[] standardByte_ItemToLString(SearchListView.SearchListViewItem item) { SearchControl.ncSearchType type = SearchTypes[item.align]; string[] ret = new string[4]; int size = type.ByteSize; string post = ""; if (type.ByteSize > 8) { size = 8; post = "..."; } ulong val = misc.ByteArrayToLong(item.newVal, 0, size); ret[0] = item.addr.ToString("X8"); ret[1] = val.ToString("X" + (type.ByteSize * 2).ToString()) + post; ret[2] = val.ToString(); ret[3] = type.Name; return(ret); }
public string[] ParseItem(SearchListViewItem item, int ind) { SearchControl.ncSearchType type = SearchControl.SearchTypes[item.align]; SearchControl.ncSearcher searcher = SearchControl.SearchComparisons.Where(sc => sc.Name == SearchControl.Instance.searchNameBox.Items[SearchControl.Instance.searchNameBox.SelectedIndex].ToString()).FirstOrDefault(); if (item.refresh) { byte[] newVal = new byte[type.ByteSize]; Form1.apiGetMem(item.addr, ref newVal); newVal = misc.notrevif(newVal); item.oldVal = item.newVal; item.newVal = newVal; item.refresh = false; SetItemAtIndex(item, ind); } if (searcher.ItemToLString != null) { return(searcher.ItemToLString(item)); } else { return(type.ItemToLString(item)); } }
public void LoadSearch() { //Search Comparisons ncSearcher ncS = new ncSearcher(); //Equal To ncS.Name = "Equal To"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(EqualTo_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Not Equal To ncS.Name = "Not Equal To"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(NotEqualTo_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Less Than ncS.Name = "Less Than"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(LessThan_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Less Than or Equal ncS.Name = "Less Than or Equal"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(LessThanEqualTo_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Greater Than ncS.Name = "Greater Than"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(GreaterThan_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Greater Than or Equal ncS.Name = "Greater Than or Equal"; ncS.Args = new string[] { "Old Val", "New Val" }; ncS.InitialSearch = new InitialSearch(GreaterThanEqualTo_InitSearch); ncS.Exceptions = new string[0]; SearchComparisons.Add(ncS); //Search Types SearchControl.ncSearchType ncST = new SearchControl.ncSearchType(); //1 byte ncST.ByteSize = 1; ncST.Name = "1 byte"; ncST.ToItem = new SearchControl.SearchToItem(standardByte_ToItem); ncST.BAToString = new SearchControl.ByteAToString(sType1B_ToString); ncST.CheckboxName = "Hex"; ncST.DefaultValue = "00"; ncST.CheckboxConvert = new SearchControl.CheckboxConvert(ConvertHexDec); ncST.ToByteArray = new SearchControl.StringToByteA(sType1B_ToByteArray); ncST.ItemToString = new SearchControl.ToSListViewItem(sType1B_ItemToString); ncST.ItemToLString = new SearchControl.ParseItemToListString(standardByte_ItemToLString); ncST.Initialize = new SearchControl.TypeInitialize(NullTypeInitialize); ncST.ignoreAlignment = false; SearchTypes.Add(ncST); //2 bytes ncST.ByteSize = 2; ncST.Name = "2 bytes"; ncST.ToItem = new SearchControl.SearchToItem(standardByte_ToItem); ncST.BAToString = new SearchControl.ByteAToString(sType2B_ToString); ncST.CheckboxName = "Hex"; ncST.DefaultValue = "0000"; ncST.CheckboxConvert = new SearchControl.CheckboxConvert(ConvertHexDec); ncST.ToByteArray = new SearchControl.StringToByteA(sType2B_ToByteArray); ncST.ItemToString = new SearchControl.ToSListViewItem(sType2B_ItemToString); ncST.ItemToLString = new SearchControl.ParseItemToListString(standardByte_ItemToLString); ncST.Initialize = new SearchControl.TypeInitialize(NullTypeInitialize); ncST.ignoreAlignment = false; SearchTypes.Add(ncST); //4 bytes ncST.ByteSize = 4; ncST.Name = "4 bytes"; ncST.ToItem = new SearchControl.SearchToItem(standardByte_ToItem); ncST.BAToString = new SearchControl.ByteAToString(sType4B_ToString); ncST.CheckboxName = "Hex"; ncST.DefaultValue = "00000000"; ncST.CheckboxConvert = new SearchControl.CheckboxConvert(ConvertHexDec); ncST.ToByteArray = new SearchControl.StringToByteA(sType4B_ToByteArray); ncST.ItemToString = new SearchControl.ToSListViewItem(sType4B_ItemToString); ncST.ItemToLString = new SearchControl.ParseItemToListString(standardByte_ItemToLString); ncST.Initialize = new SearchControl.TypeInitialize(NullTypeInitialize); ncST.ignoreAlignment = false; SearchTypes.Add(ncST); //8 bytes ncST.ByteSize = 8; ncST.Name = "8 bytes"; ncST.ToItem = new SearchControl.SearchToItem(standardByte_ToItem); ncST.BAToString = new SearchControl.ByteAToString(sType8B_ToString); ncST.CheckboxName = "Hex"; ncST.DefaultValue = "0000000000000000"; ncST.CheckboxConvert = new SearchControl.CheckboxConvert(ConvertHexDec); ncST.ToByteArray = new SearchControl.StringToByteA(sType8B_ToByteArray); ncST.ItemToString = new SearchControl.ToSListViewItem(sType8B_ItemToString); ncST.ItemToLString = new SearchControl.ParseItemToListString(standardByte_ItemToLString); ncST.Initialize = new SearchControl.TypeInitialize(NullTypeInitialize); ncST.ignoreAlignment = false; SearchTypes.Add(ncST); //X bytes ncST.ByteSize = 0; ncST.Name = "X bytes"; ncST.ToItem = new SearchControl.SearchToItem(standardByte_ToItem); ncST.BAToString = new SearchControl.ByteAToString(sTypeXB_ToString); ncST.CheckboxName = ""; ncST.DefaultValue = "00000000"; ncST.CheckboxConvert = new SearchControl.CheckboxConvert(ConvertHexDec); ncST.ToByteArray = new SearchControl.StringToByteA(sTypeXB_ToByteArray); ncST.ItemToString = new SearchControl.ToSListViewItem(sTypeXB_ItemToString); ncST.ItemToLString = new SearchControl.ParseItemToListString(standardByte_ItemToLString); ncST.Initialize = new SearchControl.TypeInitialize(sTypeXB_Initialize); ncST.ignoreAlignment = true; SearchTypes.Add(ncST); //Populate Search combo box Form1.Instance.ResetSearchCompBox(); }
void standardByte_InitSearch(int start, int stop, ulong addr, int typeIndex, string[] args, int cmpIntType) { FileStream fsIN1 = new FileStream(Form1.inputBins[0], FileMode.Open); FileStream fsIN2 = new FileStream(Form1.inputBins[1], FileMode.Open); SearchControl.ncSearchType type = SearchTypes[typeIndex]; type.Initialize((string)args[0], typeIndex); type = SearchTypes[typeIndex]; bool updateCont = false; int size = 0x1000; if ((stop - start) <= size) { updateCont = true; } byte[] oldBA = type.ToByteArray(args[0]); byte[] newBA = type.ToByteArray(args[1]); byte[] cmp1, cmp2; if (!updateCont) { Form1.Instance.progBar.Maximum = (stop - start) / size; } else { Form1.Instance.progBar.Maximum = (stop - start); } byte[] cmpArray = type.ToByteArray((string)args[0]); int resCnt = 0; int incSize = type.ByteSize; if (type.ignoreAlignment) { incSize = 1; } //List<SearchListView.SearchListViewItem> itemsToAdd = new List<SearchListView.SearchListViewItem>(); byte[] tempArr = new byte[type.ByteSize], tempArr2 = new byte[type.ByteSize]; for (int xAddr = start; xAddr < stop; xAddr += size) { if (_shouldStopSearch) { break; } cmp2 = null; cmp1 = null; ulong curAddr = (ulong)xAddr + addr; cmp1 = ReadBytes(fsIN1, xAddr, size); if (cmp1 != null) { for (int x = 0; x <= (size - type.ByteSize); x += incSize) { if (_shouldStopSearch) { break; } Array.Copy(cmp1, x, tempArr, 0, type.ByteSize); bool isTrue = misc.ArrayCompare(tempArr, oldBA, null, cmpIntType); if (isTrue) { if (cmp2 == null) { cmp2 = ReadBytes(fsIN2, xAddr, size); } Array.Copy(cmp2, x, tempArr2, 0, type.ByteSize); isTrue = misc.ArrayCompare(tempArr2, newBA, null, cmpIntType); if (isTrue) { Items.Add(type.ToItem(curAddr + (ulong)x, (byte[])tempArr2.Clone(), (byte[])tempArr.Clone(), typeIndex)); resCnt++; Form1.Instance.progBar.printText = "Results: " + resCnt.ToString(); } } if (updateCont) { Form1.Instance.progBar.Increment(incSize); Application.DoEvents(); } } } //Thread.Sleep(100); if (!updateCont) { Form1.Instance.progBar.Increment(1); Application.DoEvents(); } } fsIN1.Close(); fsIN2.Close(); }