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(); } } }
static void NGenUninstall(string filename, UninstallFileInfo uninstallFile) { string[] dirs; switch (uninstallFile.FrameworkVersion) { case FrameworkVersion.Net2_0: if (frameworkV2_0Dirs == null) { GetFrameworkV2_0Directories(); } dirs = frameworkV2_0Dirs; break; case FrameworkVersion.Net4_0: if (frameworkV4_0Dirs == null) { GetFrameworkV4_0Directories(); } dirs = frameworkV4_0Dirs; break; default: // skip unknown .NET framework versions return; } //TODO: install .NET 4.0 (or 2.0) preemptively if any assemblies are included if (dirs == null) { return; } Process proc = new Process { StartInfo = { FileName = Path.Combine(dirs[uninstallFile.CPUVersion == CPUVersion.x86 ? 0 : dirs.Length - 1], "ngen.exe"), WindowStyle = ProcessWindowStyle.Hidden, Arguments = " uninstall \"" + filename + "\"" + " /nologo" } }; proc.Start(); proc.WaitForExit(); }
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 UninstallFileInfo Read(Stream fs) { UninstallFileInfo tempUFI = new UninstallFileInfo(); //read in the fileinfo byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0x9A)) //if end byte is detected, bail out { switch (bType) { case 0x01: //file path tempUFI.Path = ReadFiles.ReadDeprecatedString(fs); break; case 0x02: //delete the file? tempUFI.DeleteFile = ReadFiles.ReadBool(fs); break; case 0x03: //un-NGEN the file? tempUFI.UnNGENFile = ReadFiles.ReadBool(fs); break; case 0x04: tempUFI.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs); break; case 0x05: tempUFI.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs); break; case 0x06: tempUFI.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } return(tempUFI); }
public static UninstallFileInfo Read(Stream fs) { UninstallFileInfo uninstallFileInfo = new UninstallFileInfo(); byte b = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, b, 154)) { switch (b) { case 1: uninstallFileInfo.Path = ReadFiles.ReadDeprecatedString(fs); break; case 2: uninstallFileInfo.DeleteFile = ReadFiles.ReadBool(fs); break; case 3: uninstallFileInfo.UnNGENFile = ReadFiles.ReadBool(fs); break; case 4: uninstallFileInfo.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs); break; case 5: uninstallFileInfo.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs); break; case 6: uninstallFileInfo.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs); break; default: ReadFiles.SkipField(fs, b); break; } b = (byte)fs.ReadByte(); } return(uninstallFileInfo); }
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 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(); } } }
public static UninstallFileInfo Read(Stream fs) { UninstallFileInfo tempUFI = new UninstallFileInfo(); //read in the fileinfo byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0x9A)) //if end byte is detected, bail out { switch (bType) { case 0x01: //file path tempUFI.Path = ReadFiles.ReadDeprecatedString(fs); break; case 0x02: //delete the file? tempUFI.DeleteFile = ReadFiles.ReadBool(fs); break; case 0x03: //un-NGEN the file? tempUFI.UnNGENFile = ReadFiles.ReadBool(fs); break; case 0x04: tempUFI.CPUVersion = (CPUVersion) ReadFiles.ReadInt(fs); break; case 0x05: tempUFI.FrameworkVersion = (FrameworkVersion) ReadFiles.ReadInt(fs); break; case 0x06: tempUFI.RegisterCOMDll = (COMRegistration) ReadFiles.ReadInt(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } return tempUFI; }
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(); } } }
static void NGenUninstall(string filename, UninstallFileInfo uninstallFile) { string[] dirs; switch (uninstallFile.FrameworkVersion) { case FrameworkVersion.Net2_0: if (frameworkV2_0Dirs == null) GetFrameworkV2_0Directories(); dirs = frameworkV2_0Dirs; break; case FrameworkVersion.Net4_0: if (frameworkV4_0Dirs == null) GetFrameworkV4_0Directories(); dirs = frameworkV4_0Dirs; break; default: // skip unknown .NET framework versions return; } //TODO: install .NET 4.0 (or 2.0) preemptively if any assemblies are included if (dirs == null) return; Process proc = new Process { StartInfo = { FileName = Path.Combine(dirs[uninstallFile.CPUVersion == CPUVersion.x86 ? 0 : dirs.Length - 1], "ngen.exe"), WindowStyle = ProcessWindowStyle.Hidden, Arguments = " uninstall \"" + filename + "\"" + " /nologo" } }; proc.Start(); proc.WaitForExit(); }