private static bool ValidateField(KeyValuePair <uint, byte[]> kvCurrent, KeyValuePair <uint, byte[]> kvNext, out FieldInfo overrideFieldInfo) { FieldInfo fieldInfo = new FieldInfo(); overrideFieldInfo = fieldInfo; uint currentKey = kvCurrent.Key; byte[] currentValue = kvCurrent.Value; //string currentKeyName = StringHasher.ResolveHash((int)currentKey) ?? $"{currentKey:X8}"; string currentKeyName = ""; string currentValueString = BitConverter.ToString(currentValue).Replace("-", ""); string r_currentKeyName; if (StringHasher.TryResolveHash((int)currentKey, out r_currentKeyName)) { currentKeyName = r_currentKeyName; } if (kvNext.Value != null && kvNext.Value.Length > 0) { uint nextKey = kvNext.Key; byte[] nextValue = kvNext.Value; //string nextKeyName = StringHasher.ResolveHash((int) nextKey); string nextKeyName = ""; string nextValueString = BitConverter.ToString(nextValue).Replace("-", ""); string r_nextKeyName; if (StringHasher.TryResolveHash((int)nextKey, out r_nextKeyName)) { nextKeyName = r_nextKeyName; } /* * var textPrefix = "text_"; * var currentKeyGuessName = $"{textPrefix}{nextKeyName}"; * uint currentKeyGuessHash = FileFormats.Hashing.CRC32.Compute(currentKeyGuessName); * * if (currentKeyGuessHash == currentKey) * { * // current key is text of next key * * //Console.WriteLine($"{currentKeyGuessHash:X8} == {currentKey:X8}"); * * currentValueString = FieldHandling.Deserialize<string>(FieldType.String, currentValue); * } */ FieldType r_currentFieldType; string r_currentValueString; if (currentKeyName == "text_hidName") { currentValueString = FieldHandling.Deserialize <string>(FieldType.String, currentValue); Utility.Log("Exporting " + currentValueString); } else if (TypeGuesser.TryParse(currentValue, out r_currentFieldType, out r_currentValueString)) { if (r_currentFieldType == FieldType.String) { currentValueString = r_currentValueString; } } uint r_nextValueHash32 = 0; ulong r_nextValueHash64 = 0; ulong nextValueHash = 0; if (uint.TryParse(nextValueString, NumberStyles.HexNumber, null, out r_nextValueHash32)) { nextValueHash = r_nextValueHash32; //Console.WriteLine($"Parsing uint: {nextValueHash:X8}"); } else if (ulong.TryParse(nextValueString, NumberStyles.HexNumber, null, out r_nextValueHash64)) { nextValueHash = r_nextValueHash64; //Console.WriteLine($"Parsing ulong: {nextValueHash:X16}"); } ulong[] hashValues = HashHandler.CollectHashes(currentValueString); var hashTypeIterator = 0; for (int b = 0; b < hashValues.Length; b++) { ulong hash = hashValues[b]; //Console.WriteLine($"Iterating hash: {hash:X}"); if (hash > 0 && hash == nextValueHash) { hashTypeIterator = b; //Console.WriteLine($"{hash:X} == {nextValueHash:X}"); break; } } ulong resolvedHash = hashValues[hashTypeIterator]; if (hashTypeIterator > 0 && resolvedHash == nextValueHash) { // current value is text of next value //string fieldName = nextKeyName ?? $"{nextValueHash:X8}"; if (string.IsNullOrEmpty(nextKeyName)) { fieldInfo.key.type = "hash"; fieldInfo.key.name = $"{nextKey:X8}"; } else { fieldInfo.key.type = "name"; fieldInfo.key.name = nextKeyName; } fieldInfo.value.type = Convert.ToString((HashType)hashTypeIterator); fieldInfo.value.value = currentValueString; Console.WriteLine($"{fieldInfo.key.name} = {currentValueString}"); overrideFieldInfo = fieldInfo; //Utility.Log($"{fieldName} = \"{currentValueString}\""); //Utility.Log($"Found text value of field \"{fieldName}\": \"{currentValueString}\""); //Utility.Log($"Element:\n\tcurrent:\n\t\tname: {currentKey:X8} -> {currentKeyName}\n\t\tvalue: {currentValueString} -> {resolvedHash:X8}\n\tnext:\n\t\tname: {nextKeyName} -> {nextKey:X8}\n\t\tvalue: {nextValueString}"); return(false); } } return(true); }