public static void ReadRollbackServices(string fileName, List <string> rollbackList, bool addUnique) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(fs, "IURUSV1")) { throw new Exception("Identifier incorrect"); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // service to start again if (addUnique) { ClientFile.AddUniqueString(ReadFiles.ReadString(fs), rollbackList); } else { rollbackList.Add(ReadFiles.ReadString(fs)); } break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
public static void ReadRollbackCOM(string fileName, List <UninstallFileInfo> rollbackList) { using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "IURUCV1")) { throw new Exception("Identifier incorrect"); } UninstallFileInfo uninstallFileInfo = new UninstallFileInfo(); byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 1: uninstallFileInfo.Path = ReadFiles.ReadString(fileStream); break; case 2: uninstallFileInfo.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fileStream); break; case 155: rollbackList.Add(uninstallFileInfo); uninstallFileInfo = new UninstallFileInfo(); break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } } }
public static void ReadRollbackRegistry(string fileName, List <RegChange> rollbackRegistry) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(fs, "IURURV1")) { throw new Exception("Identifier incorrect"); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: //num of registry changes rollbackRegistry.Capacity = ReadFiles.ReadInt(fs); break; case 0x8E: //add RegChange rollbackRegistry.Add(RegChange.ReadFromStream(fs)); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
public static void ReadRollbackServices(string fileName, List <string> rollbackList, bool addUnique) { using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "IURUSV1")) { throw new Exception("Identifier incorrect"); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { byte b2 = b; if (b2 == 1) { if (addUnique) { ClientFile.AddUniqueString(ReadFiles.ReadString(fileStream), rollbackList); } else { rollbackList.Add(ReadFiles.ReadString(fileStream)); } } else { ReadFiles.SkipField(fileStream, b); } b = (byte)fileStream.ReadByte(); } } }
public static void ReadRollbackRegistry(string fileName, List <RegChange> rollbackRegistry) { using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "IURURV1")) { throw new Exception("Identifier incorrect"); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 1: rollbackRegistry.Capacity = ReadFiles.ReadInt(fileStream); break; case 142: rollbackRegistry.Add(RegChange.ReadFromStream(fileStream)); break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } } }
void Load(string filename) { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fs, "AUIF")) { //free up the file so it can be deleted fs.Close(); throw new Exception("Auto update state file ID is wrong."); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // Date last checked for update LastCheckedForUpdate = ReadFiles.ReadDateTime(fs); break; case 0x02: // update step on UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs); break; case 0x03: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs); break; case 0x04: // update succeeded UpdateVersion = ReadFiles.ReadString(fs); break; case 0x05: ChangesInLatestVersion = ReadFiles.ReadString(fs); break; case 0x06: ChangesIsRTF = ReadFiles.ReadBool(fs); break; case 0x07: // update failed ErrorTitle = ReadFiles.ReadString(fs); break; case 0x08: ErrorMessage = ReadFiles.ReadString(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
private void Load(string filename) { using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "AUIF")) { fileStream.Close(); throw new Exception("Auto update state file ID is wrong."); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 1: LastCheckedForUpdate = ReadFiles.ReadDateTime(fileStream); break; case 2: UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fileStream); break; case 3: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fileStream); break; case 4: UpdateVersion = ReadFiles.ReadString(fileStream); break; case 5: ChangesInLatestVersion = ReadFiles.ReadString(fileStream); break; case 6: ChangesIsRTF = ReadFiles.ReadBool(fileStream); break; case 7: ErrorTitle = ReadFiles.ReadString(fileStream); break; case 8: ErrorMessage = ReadFiles.ReadString(fileStream); break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } } }
static void LoadUninstallData(Stream ms, List <UninstallFileInfo> uninstallFiles, List <string> uninstallFolders, List <RegChange> uninstallRegistry, List <UninstallFileInfo> comDllsToUnreg, List <string> servicesToStop) { ms.Position = 0; // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(ms, "IUUFRV1")) { //free up the file so it can be deleted ms.Close(); throw new Exception("The uninstall file does not have the correct identifier - this is usually caused by file corruption."); } byte bType = (byte)ms.ReadByte(); while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF)) { switch (bType) { case 0x8A: //file to delete uninstallFiles.Add(UninstallFileInfo.Read(ms)); break; case 0x8B: // files to unreg COM comDllsToUnreg.Add(UninstallFileInfo.Read(ms)); break; case 0x10: //folder to delete uninstallFolders.Add(ReadFiles.ReadDeprecatedString(ms)); break; case 0x11: //service to stop servicesToStop.Add(ReadFiles.ReadString(ms)); break; case 0x8E: //regChanges to execute uninstallRegistry.Add(RegChange.ReadFromStream(ms)); break; default: ReadFiles.SkipField(ms, bType); break; } bType = (byte)ms.ReadByte(); } }
public static void ReadRollbackFiles(string fileName, List <string> rollbackFiles, List <string> rollbackFolders, List <string> createFolders) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(fs, "IURUFV1")) { throw new Exception("Identifier incorrect"); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x02: // file to delete rollbackFiles.Add(ReadFiles.ReadString(fs)); break; case 0x04: // folder to delete rollbackFolders.Add(ReadFiles.ReadString(fs)); break; case 0x06: //folder to create if (createFolders != null) { createFolders.Add(ReadFiles.ReadString(fs)); } else { ReadFiles.SkipField(fs, bType); } break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
private static void LoadUninstallData(Stream ms, List <UninstallFileInfo> uninstallFiles, List <string> uninstallFolders, List <RegChange> uninstallRegistry, List <UninstallFileInfo> comDllsToUnreg, List <string> servicesToStop) { ms.Position = 0L; if (!ReadFiles.IsHeaderValid(ms, "IUUFRV1")) { ms.Close(); throw new Exception("The uninstall file does not have the correct identifier - this is usually caused by file corruption."); } byte b = (byte)ms.ReadByte(); while (!ReadFiles.ReachedEndByte(ms, b, byte.MaxValue)) { switch (b) { case 138: uninstallFiles.Add(UninstallFileInfo.Read(ms)); break; case 139: comDllsToUnreg.Add(UninstallFileInfo.Read(ms)); break; case 16: uninstallFolders.Add(ReadFiles.ReadDeprecatedString(ms)); break; case 17: servicesToStop.Add(ReadFiles.ReadString(ms)); break; case 142: uninstallRegistry.Add(RegChange.ReadFromStream(ms)); break; default: ReadFiles.SkipField(ms, b); break; } b = (byte)ms.ReadByte(); } }
public static void ReadRollbackFiles(string fileName, List <string> rollbackFiles, List <string> rollbackFolders, List <string> createFolders) { using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "IURUFV1")) { throw new Exception("Identifier incorrect"); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 2: rollbackFiles.Add(ReadFiles.ReadString(fileStream)); break; case 4: rollbackFolders.Add(ReadFiles.ReadString(fileStream)); break; case 6: if (createFolders != null) { createFolders.Add(ReadFiles.ReadString(fileStream)); } else { ReadFiles.SkipField(fileStream, b); } break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } } }
public static void ReadRollbackCOM(string fileName, List <UninstallFileInfo> rollbackList) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(fs, "IURUCV1")) { throw new Exception("Identifier incorrect"); } UninstallFileInfo tempUpdateFile = new UninstallFileInfo(); byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: tempUpdateFile.Path = ReadFiles.ReadString(fs); break; case 0x02: tempUpdateFile.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs); break; case 0x9B: //end of file rollbackList.Add(tempUpdateFile); tempUpdateFile = new UninstallFileInfo(); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
void LoadAutoUpdateData() { autoUpdateStateFile = Path.Combine(tempDirectory, "autoupdate"); using (FileStream fs = new FileStream(autoUpdateStateFile, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fs, "IUAUFV1")) { throw new Exception("Auto update state file ID is wrong."); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: startStep = (UpdateStepOn)ReadFiles.ReadInt(fs); break; case 0x02: // file to execute updateHelper.FileOrServiceToExecuteAfterUpdate = ReadFiles.ReadString(fs); break; case 0x03: // autoupdate ID updateHelper.AutoUpdateID = ReadFiles.ReadString(fs); break; case 0x0C: updateHelper.ExecutionArguments = ReadFiles.ReadString(fs); break; case 0x80: updateHelper.IsAService = true; break; case 0x04: // Server data file location serverFileLoc = ReadFiles.ReadString(fs); if (!File.Exists(serverFileLoc)) { serverFileLoc = null; } break; case 0x05: // Client's server file location (self update server file) clientSFLoc = ReadFiles.ReadString(fs); if (!File.Exists(clientSFLoc)) { clientSFLoc = null; } break; case 0x06: // Temp directory oldAUTempFolder = ReadFiles.ReadString(fs); break; case 0x0B: tempDirectory = ReadFiles.ReadString(fs); break; case 0x07: // update filename updateFilename = ReadFiles.ReadString(fs); break; case 0x08: SelfUpdateState = (SelfUpdateState)ReadFiles.ReadInt(fs); break; case 0x09: if (SelfUpdateState == SelfUpdateState.Downloaded) { updateFilename = ReadFiles.ReadString(fs); } else { newSelfLocation = ReadFiles.ReadString(fs); } break; case 0x0A: oldSelfLocation = ReadFiles.ReadString(fs); break; case 0x0D: // load the self update file LoadSelfUpdateData(ReadFiles.ReadString(fs)); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } // if the server file doesn't exist we need to download a new one if (serverFileLoc == null) { startStep = UpdateStepOn.Checking; } else { // load the server file LoadServerFile(true); // if frameOn != Frame.Checking - it means we're either up-to-date OR an error occurred. // We shouldn't under any circumstance StartNewSelfAndClose. Just remove temp files & exit. if (frameOn != Frame.Checking) { // neither OnClosed nor OnClosing will be called because // the form is being disposed in the constructor. // Thus we need to cleanup the temp directory now. RemoveTempDirectory(); return; } if (SelfUpdateState == SelfUpdateState.Extracted && !IsNewSelf) { // launch new wyUpdate StartNewSelfAndClose(); } else if (SelfUpdateState == SelfUpdateState.WillUpdate || SelfUpdateState == SelfUpdateState.Downloaded) { LoadClientServerFile(); } } }
void Load(string filename) { #if !CLIENT // Disable filesystem redirection on x64 (mostly for Windows Services) if (Is32BitProcessOn64BitProcessor()) { EnableWow64FSRedirection(false); } try { #endif using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fs, "AUIF")) { //free up the file so it can be deleted fs.Close(); throw new Exception("Auto update state file ID is wrong."); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // Date last checked for update LastCheckedForUpdate = ReadFiles.ReadDateTime(fs); break; case 0x02: // update step on UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs); break; case 0x03: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs); break; case 0x04: // update succeeded UpdateVersion = ReadFiles.ReadString(fs); break; case 0x05: ChangesInLatestVersion = ReadFiles.ReadString(fs); break; case 0x06: ChangesIsRTF = ReadFiles.ReadBool(fs); break; case 0x07: // update failed ErrorTitle = ReadFiles.ReadString(fs); break; case 0x08: ErrorMessage = ReadFiles.ReadString(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } #if !CLIENT } finally { // Re-enable filesystem redirection on x64 if (Is32BitProcessOn64BitProcessor()) { EnableWow64FSRedirection(true); } } #endif }