Skip to content

Commit

Permalink
Downgraded compatibility from Windows 8 to Windows 7
Browse files Browse the repository at this point in the history
  • Loading branch information
blueelvis committed Nov 25, 2015
1 parent 0718248 commit e73c79f
Show file tree
Hide file tree
Showing 44 changed files with 533 additions and 79 deletions.
Binary file modified .vs/BSODInspector/v14/.suo
Binary file not shown.
8 changes: 4 additions & 4 deletions BSODInspector/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

<supportedRuntime version="v2.0.50727"/></startup>
</configuration>
27 changes: 23 additions & 4 deletions BSODInspector/BSODInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BSODInspector</RootNamespace>
<AssemblyName>BSODInspector</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
Expand All @@ -27,6 +27,10 @@
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -85,12 +89,10 @@
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Management" />
<Reference Include="System.Security" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
Expand All @@ -100,8 +102,11 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="BSODInspector_TemporaryKey.pfx" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
Expand All @@ -120,6 +125,20 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<COMReference Include="Shell32">
<Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 4 additions & 0 deletions BSODInspector/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>

</Weavers>
185 changes: 130 additions & 55 deletions BSODInspector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.VisualBasic.Devices;
using Microsoft.Win32;
using System.Management;
using System.IO.Compression;
using System.Net;
using System.Security.AccessControl;
using System.Security.Principal;
Expand Down Expand Up @@ -42,7 +41,7 @@ private static void Main()
string tempDirectory = Path.GetTempPath() + @"blueelvis";
string systemDrive = Path.GetPathRoot(Environment.SystemDirectory);
string applicationVersion = "1.0.4";

bool is64BitOperatingSystem=false;
ComputerInfo sysinfo = new ComputerInfo(); //References Microsoft.VisualBasic.Devices


Expand Down Expand Up @@ -94,6 +93,30 @@ private static void Main()

// ======================================================================================

// ====================================================================================
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Generating SystemInfo\n\n");
using (StreamWriter fileWriter = new StreamWriter(tempDirectory + @"\systeminfo.txt"))
{
using (Process systeminfo = new Process())
{
if (File.Exists(Environment.SystemDirectory + @"\systeminfo.exe"))
{
systeminfo.StartInfo.FileName = Environment.SystemDirectory + @"\systeminfo.exe";
systeminfo.StartInfo.RedirectStandardOutput = true;
systeminfo.StartInfo.UseShellExecute = false;
systeminfo.Start();
fileWriter.WriteLine(systeminfo.StandardOutput.ReadToEnd());
systeminfo.WaitForExit();
fileWriter.Close();
systeminfo.Close();
}
else
{
Console.WriteLine("Systeminfo.exe not found in system");
}
}

}

// ======================================================================================
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Querying System for Drivers\n\n");
Expand Down Expand Up @@ -122,7 +145,33 @@ private static void Main()
}
}

// ======================================================================================
if (File.Exists(tempDirectory + @"\systeminfo.txt"))
{
using (StreamReader systeminfoReader = new StreamReader(tempDirectory + @"\systeminfo.txt"))
//Filter out the email address from the report for privacy concerns
{
using (StreamWriter goodsysinfoWriter = new StreamWriter(tempDirectory + @"\goodsysteminfo.txt"))
{
int lineNumber = -1;
while (systeminfoReader.Peek() >= 0)
{
string logFileContent = systeminfoReader.ReadLine();
lineNumber++;
if (lineNumber == 7)
continue;
if (lineNumber == 14)
if (logFileContent.Contains("x64"))
is64BitOperatingSystem = true;

goodsysinfoWriter.WriteLine(logFileContent);

}
}
}
}
else
Console.WriteLine("Cannot find SystemInfo.txt");
// ======================================================================================

using (StreamWriter fileWriter = new StreamWriter(tempDirectory + @"\driverlist.txt"))
Expand Down Expand Up @@ -241,33 +290,8 @@ private static void Main()

}

// ====================================================================================
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Generating SystemInfo\n\n");
using (StreamWriter fileWriter = new StreamWriter(tempDirectory + @"\systeminfo.txt"))
{
using (Process systeminfo = new Process())
{
if (File.Exists(Environment.SystemDirectory + @"\systeminfo.exe"))
{
systeminfo.StartInfo.FileName = Environment.SystemDirectory + @"\systeminfo.exe";
systeminfo.StartInfo.RedirectStandardOutput = true;
systeminfo.StartInfo.UseShellExecute = false;
systeminfo.Start();
fileWriter.WriteLine(systeminfo.StandardOutput.ReadToEnd());
systeminfo.WaitForExit();
fileWriter.Close();
systeminfo.Close();
}
else
{
Console.WriteLine("Systeminfo.exe not found in system");
}
}

}

// ==================================================================================
if (Environment.Is64BitOperatingSystem)
if (is64BitOperatingSystem)
{
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Exporting x86 Uninstall Registry\n\n");

Expand All @@ -279,7 +303,7 @@ private static void Main()
uninstallListx86.StartInfo.Arguments =
@"export HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\ " + "\"" +
tempDirectory +
@"\uninstallx86.txt" + "\"";
@"\uninstallx86.txt" + "\"" +" /reg:32";
uninstallListx86.Start();
uninstallListx86.WaitForExit();
uninstallListx86.Close();
Expand Down Expand Up @@ -380,7 +404,7 @@ private static void Main()
{
if (File.Exists(systemDrive + @"\Windows\System32\reg.exe"))
{
if (!Environment.Is64BitOperatingSystem)
if (!is64BitOperatingSystem)
{
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\System32\reg.exe";
uninstallListx64.StartInfo.Arguments =
Expand All @@ -390,7 +414,7 @@ private static void Main()
}
else
{
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\Sysnative\reg.exe";
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\System32\reg.exe";
uninstallListx64.StartInfo.Arguments =
@"export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall " +
"\"" + tempDirectory + "\"" +
Expand All @@ -406,6 +430,7 @@ private static void Main()
{
Console.WriteLine("reg.exe not found in system");
}
Console.WriteLine("HelloWorld");
}

}
Expand Down Expand Up @@ -515,7 +540,7 @@ private static void Main()
Console.WriteLine(DateTime.Now.ToString("G") +
"\t - Blank File for x64 Uninstall List Created\n\n");
}
using (var output = File.Create(tempDirectory + @"\uninstall-reg.txt"))
/*using (var output = File.Create(tempDirectory + @"\uninstall-reg.txt"))
{
foreach (
var file in new[] { tempDirectory + @"\uninstallx86.txt", tempDirectory + @"\uninstallx64.txt" })
Expand All @@ -525,7 +550,25 @@ private static void Main()
input.CopyTo(output);
}
}
}
}*/
using (StreamReader uninstallx86Reader = new StreamReader(tempDirectory + @"\uninstallx86.txt"))
{
using (StreamReader uninstallx64Reader = new StreamReader(tempDirectory + @"\uninstallx64.txt"))
{
using (StreamWriter uninstallRegWriter = new StreamWriter(tempDirectory + @"\uninstall-reg.txt"))
{
while (uninstallx86Reader.Peek() >= 0)
{
uninstallRegWriter.WriteLine(uninstallx86Reader.ReadLine());
}
while (uninstallx64Reader.Peek() >= 0)
{
uninstallRegWriter.WriteLine(uninstallx64Reader.ReadLine());
}
}
}
}


//Process the exported uninstall registry and filter out values and compile a single list
using (
Expand Down Expand Up @@ -663,23 +706,6 @@ private static void Main()
}
}

using (StreamReader systeminfoReader = new StreamReader(tempDirectory + @"\systeminfo.txt")) //Filter out the email address from the report for privacy concerns
{
using (StreamWriter goodsysinfoWriter = new StreamWriter(tempDirectory + @"\goodsysteminfo.txt"))
{
int lineNumber = -1;
while (systeminfoReader.Peek() >= 0)
{
string logFileContent = systeminfoReader.ReadLine();
lineNumber++;
if (lineNumber == 7)
continue;
goodsysinfoWriter.WriteLine(logFileContent);

}
}
}

using (StreamReader hotFixReader = new StreamReader(tempDirectory + @"\InstalledWindowsUpdates.txt")) //Check the number of Windows Updates installed on a system
{
while (hotFixReader.Peek() >= 0)
Expand Down Expand Up @@ -869,9 +895,11 @@ private static void Main()
Thread.Sleep(8000);
}
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Zipping Up Files!");
ZipFile.CreateFromDirectory(tempDirectory,
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" + zipFileName,
CompressionLevel.Optimal, false);
bool zipFileStatus = ZipFile(tempDirectory, zipFileName);
if (!zipFileStatus)
{
Console.WriteLine("There was an error while creating the ZIP file");
}
var greetingsProcess = Process.Start(tempDirectory + @"\greetings.txt");
Thread.Sleep(1000);
if (greetingsProcess!=null) //Flash the taskbar icon of Notepad in case user has lost focus
Expand Down Expand Up @@ -925,23 +953,70 @@ static string Quotes()
}
}

/// <summary>
/// Zip File mechanism using Shell32. Easiest way to do without any 3rd party API
/// </summary>
/// <param name="inputPath"></param>
/// <param name="zipFileName"></param>
/// <returns></returns>
private static bool ZipFile(string inputPath, string zipFileName)
{
byte[] emptyzip = new byte[]{80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
FileStream fs = File.Create(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" +
zipFileName);
fs.Write(emptyzip,0,emptyzip.Length);
fs.Flush();
fs.Close();
try
{
Shell32.Folder zipInput = GetShell32NameSpace(inputPath);
Shell32.Folder zipOutput =
GetShell32NameSpace(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" +
zipFileName);
foreach (var file in zipInput.Items())
{
if (file != null)
zipOutput.CopyHere(file, 4 | 16);
Thread.Sleep(1000);
}
return true;
}
catch (Exception)
{
return false;
}
}

/// <summary>
/// Converts the Date & Time which is generated by several WMI commands into human readable form
/// </summary>
/// <param name="stringDateToConvert">String parameter which contains the date & time outputted by several WMI Commands</param>
/// <returns>Returns a string containing the date & time</returns>
static string ConvertDateTime(string stringDateToConvert)
private static string ConvertDateTime(string stringDateToConvert)
{
stringDateToConvert = stringDateToConvert.Replace("\r", "").Replace("\n", "");
if (stringDateToConvert.Length > 8)
stringDateToConvert = stringDateToConvert.Remove(8);

var temporaryArray = stringDateToConvert.ToCharArray();
var output = temporaryArray[0].ToString() + temporaryArray[1].ToString() + temporaryArray[2].ToString() + temporaryArray[3].ToString() + "-";
var output = temporaryArray[0].ToString() + temporaryArray[1].ToString() + temporaryArray[2].ToString() +
temporaryArray[3].ToString() + "-";
output += temporaryArray[4].ToString() + temporaryArray[5].ToString() + "-";
output += temporaryArray[6].ToString() + temporaryArray[7].ToString();

return output;
}

/// <summary>
/// Shell32 Code Since Shell32 changed in Windows 7. Read More over here - http://techitongue.blogspot.in/2012/06/shell32-code-compiled-on-windows-7.html
/// </summary>
/// <param name="folder"></param>
/// <returns></returns>
static public Shell32.Folder GetShell32NameSpace(Object folder)
{
Type shellAppType = Type.GetTypeFromProgID("Shell.Application");
var shell = Activator.CreateInstance(shellAppType);
return (Shell32.Folder)shellAppType.InvokeMember("NameSpace", System.Reflection.BindingFlags.InvokeMethod, null, shell, new[] { folder });
}
}
}
Binary file modified BSODInspector/bin/Debug/BSODInspector.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions BSODInspector/bin/Debug/BSODInspector.exe.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

<supportedRuntime version="v2.0.50727"/></startup>
</configuration>
Binary file modified BSODInspector/bin/Debug/BSODInspector.pdb
Binary file not shown.
Binary file modified BSODInspector/bin/Debug/BSODInspector.vshost.exe
Binary file not shown.
Loading

0 comments on commit e73c79f

Please sign in to comment.