Skip to content

Commit

Permalink
System.Drawing.Color.Yellow->System.Drawing.Color.Purple
Browse files Browse the repository at this point in the history
  • Loading branch information
divadiow committed Dec 27, 2024
1 parent 339f0dc commit 6340d04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions BK7231Flasher/OBKConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,20 +545,20 @@ public static bool isValid(byte [] raw, int extraOfs = 0)
byte crc = 0;
if (raw[extraOfs+0] != (byte)'C' || raw[extraOfs + 1] != (byte)'F' || raw[extraOfs + 2] != (byte)'G')
{
FormMain.Singleton.addLog("It's not an OBK config, header is bad"+Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("It's not an OBK config, header is bad"+Environment.NewLine, System.Drawing.Color.Purple);
return false;
}
int version = BitConverter.ToInt32(raw, extraOfs + 4);
if(version > 100)
{
FormMain.Singleton.addLog("OBK config has wrong version? Skipping" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("OBK config has wrong version? Skipping" + Environment.NewLine, System.Drawing.Color.Purple);
return false;
}
int useLen = getLenForVersion(version);
crc = CRC.Tiny_CRC8(raw, extraOfs + 4, useLen - 4);
if(raw[extraOfs + 3] != crc)
{
FormMain.Singleton.addLog("OBK config has wrong checksum? Skipping" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("OBK config has wrong checksum? Skipping" + Environment.NewLine, System.Drawing.Color.Purple);
return false;
}
return true;
Expand Down
20 changes: 10 additions & 10 deletions BK7231Flasher/TuyaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ public bool fromBytes(byte[] data)
int needle = MiscUtils.indexOf(data, MAGIC_CONFIG_START);
if(needle < 0)
{
FormMain.Singleton.addLog("Failed to extract Tuya keys - magic constant header not found in binary" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("Failed to extract Tuya keys - magic constant header not found in binary" + Environment.NewLine, System.Drawing.Color.Purple);

if (MiscUtils.isFullOf(data, 0xff))
{
FormMain.Singleton.addLog("It seems that dragged binary is full of 0xff, someone must have erased the flash" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("It seems that dragged binary is full of 0xff, someone must have erased the flash" + Environment.NewLine, System.Drawing.Color.Purple);
bGivenBinaryIsFullOf0xff = true;
}
if(data.Length>3 && data[0] == (byte)'C' && data[1] == (byte)'F' && data[2] == (byte)'G')
{
FormMain.Singleton.addLog("It seems that dragged binary is OBK config, not a Tuya one" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("It seems that dragged binary is OBK config, not a Tuya one" + Environment.NewLine, System.Drawing.Color.Purple);
this.bLastBinaryOBKConfig = true;
}
return true;
Expand All @@ -199,14 +199,14 @@ public bool fromBytes(byte[] data)
UInt32 mag = br.ReadUInt32();
if (mag != MAGIC_FIRST_BLOCK)
{
FormMain.Singleton.addLog("Failed to extract Tuya keys - bad firstblock header" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("Failed to extract Tuya keys - bad firstblock header" + Environment.NewLine, System.Drawing.Color.Purple);
return true;
}
uint crc = br.ReadUInt32();
key = br.ReadBytes(16);
if (checkCRC(crc, key, 0, key.Length) == false)
{
FormMain.Singleton.addLog("Failed to extract Tuya keys - bad firstblock crc" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("Failed to extract Tuya keys - bad firstblock crc" + Environment.NewLine, System.Drawing.Color.Purple);
return true;
}
key = makeSecondaryKey(key);
Expand All @@ -225,17 +225,17 @@ public bool fromBytes(byte[] data)
if (mag != MAGIC_NEXT_BLOCK && mag != 324478635)
{
// it seems that TuyaOS3 binaries have here 324478635?
//FormMain.Singleton.addLog("Failed to extract Tuya keys - bad nextblock header" + Environment.NewLine, System.Drawing.Color.Yellow);
//FormMain.Singleton.addLog("Failed to extract Tuya keys - bad nextblock header" + Environment.NewLine, System.Drawing.Color.Purple);
//return true;
FormMain.Singleton.addLog("WARNING - strange nextblock header " + mag.ToString("X4") + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("WARNING - strange nextblock header " + mag.ToString("X4") + Environment.NewLine, System.Drawing.Color.Purple);

}
uint crc = br.ReadUInt32();
if (checkCRC(crc, next, 8, next.Length - 8) == false)
{
FormMain.Singleton.addLog("WARNING - bad nextblock CRC" + Environment.NewLine, System.Drawing.Color.Yellow);
FormMain.Singleton.addLog("WARNING - bad nextblock CRC" + Environment.NewLine, System.Drawing.Color.Purple);

// FormMain.Singleton.addLog("Failed to extract Tuya keys - bad nextblock CRC" + Environment.NewLine, System.Drawing.Color.Yellow);
// FormMain.Singleton.addLog("Failed to extract Tuya keys - bad nextblock CRC" + Environment.NewLine, System.Drawing.Color.Purple);
// return true;
}
bw.Write(next, 8, next.Length - 8);
Expand Down Expand Up @@ -785,7 +785,7 @@ public bool extractKeys()
int stopAT = MiscUtils.findMatching(descryptedRaw, (byte)'}', (byte)'{', first_at);
if (stopAT == -1)
{
//FormMain.Singleton.addLog("Failed to extract Tuya keys - no json end found" + Environment.NewLine, System.Drawing.Color.Yellow);
//FormMain.Singleton.addLog("Failed to extract Tuya keys - no json end found" + Environment.NewLine, System.Drawing.Color.Purple);
// return true;
stopAT = descryptedRaw.Length;
}
Expand Down

0 comments on commit 6340d04

Please sign in to comment.