Skip to content

Commit e73c79f

Browse files
committed
Downgraded compatibility from Windows 8 to Windows 7
1 parent 0718248 commit e73c79f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+533
-79
lines changed

.vs/BSODInspector/v14/.suo

-1.5 KB
Binary file not shown.

BSODInspector/App.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5-
</startup>
6-
</configuration>
4+
5+
<supportedRuntime version="v2.0.50727"/></startup>
6+
</configuration>

BSODInspector/BSODInspector.csproj

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>BSODInspector</RootNamespace>
1111
<AssemblyName>BSODInspector</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<IsWebBootstrapper>false</IsWebBootstrapper>
1515
<PublishUrl>publish\</PublishUrl>
@@ -27,6 +27,10 @@
2727
<UseApplicationTrust>false</UseApplicationTrust>
2828
<PublishWizardCompleted>true</PublishWizardCompleted>
2929
<BootstrapperEnabled>true</BootstrapperEnabled>
30+
<TargetFrameworkProfile>
31+
</TargetFrameworkProfile>
32+
<NuGetPackageImportStamp>
33+
</NuGetPackageImportStamp>
3034
</PropertyGroup>
3135
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3236
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -85,12 +89,10 @@
8589
<Reference Include="Microsoft.VisualBasic" />
8690
<Reference Include="System" />
8791
<Reference Include="System.Core" />
88-
<Reference Include="System.IO.Compression.FileSystem" />
8992
<Reference Include="System.Management" />
9093
<Reference Include="System.Security" />
9194
<Reference Include="System.Xml.Linq" />
9295
<Reference Include="System.Data.DataSetExtensions" />
93-
<Reference Include="Microsoft.CSharp" />
9496
<Reference Include="System.Data" />
9597
<Reference Include="System.Xml" />
9698
</ItemGroup>
@@ -100,8 +102,11 @@
100102
</ItemGroup>
101103
<ItemGroup>
102104
<None Include="App.config" />
103-
<None Include="app.manifest" />
105+
<None Include="app.manifest">
106+
<SubType>Designer</SubType>
107+
</None>
104108
<None Include="BSODInspector_TemporaryKey.pfx" />
109+
<None Include="packages.config" />
105110
</ItemGroup>
106111
<ItemGroup>
107112
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
@@ -120,6 +125,20 @@
120125
<Install>false</Install>
121126
</BootstrapperPackage>
122127
</ItemGroup>
128+
<ItemGroup>
129+
<COMReference Include="Shell32">
130+
<Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
131+
<VersionMajor>1</VersionMajor>
132+
<VersionMinor>0</VersionMinor>
133+
<Lcid>0</Lcid>
134+
<WrapperTool>tlbimp</WrapperTool>
135+
<Isolated>False</Isolated>
136+
<EmbedInteropTypes>True</EmbedInteropTypes>
137+
</COMReference>
138+
</ItemGroup>
139+
<ItemGroup>
140+
<Content Include="FodyWeavers.xml" />
141+
</ItemGroup>
123142
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
124143
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
125144
Other similar extension points exist, see Microsoft.Common.targets.

BSODInspector/FodyWeavers.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Weavers>
3+
4+
</Weavers>

BSODInspector/Program.cs

Lines changed: 130 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.VisualBasic.Devices;
55
using Microsoft.Win32;
66
using System.Management;
7-
using System.IO.Compression;
87
using System.Net;
98
using System.Security.AccessControl;
109
using System.Security.Principal;
@@ -42,7 +41,7 @@ private static void Main()
4241
string tempDirectory = Path.GetTempPath() + @"blueelvis";
4342
string systemDrive = Path.GetPathRoot(Environment.SystemDirectory);
4443
string applicationVersion = "1.0.4";
45-
44+
bool is64BitOperatingSystem=false;
4645
ComputerInfo sysinfo = new ComputerInfo(); //References Microsoft.VisualBasic.Devices
4746

4847

@@ -94,6 +93,30 @@ private static void Main()
9493

9594
// ======================================================================================
9695

96+
// ====================================================================================
97+
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Generating SystemInfo\n\n");
98+
using (StreamWriter fileWriter = new StreamWriter(tempDirectory + @"\systeminfo.txt"))
99+
{
100+
using (Process systeminfo = new Process())
101+
{
102+
if (File.Exists(Environment.SystemDirectory + @"\systeminfo.exe"))
103+
{
104+
systeminfo.StartInfo.FileName = Environment.SystemDirectory + @"\systeminfo.exe";
105+
systeminfo.StartInfo.RedirectStandardOutput = true;
106+
systeminfo.StartInfo.UseShellExecute = false;
107+
systeminfo.Start();
108+
fileWriter.WriteLine(systeminfo.StandardOutput.ReadToEnd());
109+
systeminfo.WaitForExit();
110+
fileWriter.Close();
111+
systeminfo.Close();
112+
}
113+
else
114+
{
115+
Console.WriteLine("Systeminfo.exe not found in system");
116+
}
117+
}
118+
119+
}
97120

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

148+
// ======================================================================================
149+
if (File.Exists(tempDirectory + @"\systeminfo.txt"))
150+
{
151+
using (StreamReader systeminfoReader = new StreamReader(tempDirectory + @"\systeminfo.txt"))
152+
//Filter out the email address from the report for privacy concerns
153+
{
154+
using (StreamWriter goodsysinfoWriter = new StreamWriter(tempDirectory + @"\goodsysteminfo.txt"))
155+
{
156+
int lineNumber = -1;
157+
while (systeminfoReader.Peek() >= 0)
158+
{
159+
string logFileContent = systeminfoReader.ReadLine();
160+
lineNumber++;
161+
if (lineNumber == 7)
162+
continue;
163+
if (lineNumber == 14)
164+
if (logFileContent.Contains("x64"))
165+
is64BitOperatingSystem = true;
166+
167+
goodsysinfoWriter.WriteLine(logFileContent);
125168

169+
}
170+
}
171+
}
172+
}
173+
else
174+
Console.WriteLine("Cannot find SystemInfo.txt");
126175
// ======================================================================================
127176

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

242291
}
243292

244-
// ====================================================================================
245-
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Generating SystemInfo\n\n");
246-
using (StreamWriter fileWriter = new StreamWriter(tempDirectory + @"\systeminfo.txt"))
247-
{
248-
using (Process systeminfo = new Process())
249-
{
250-
if (File.Exists(Environment.SystemDirectory + @"\systeminfo.exe"))
251-
{
252-
systeminfo.StartInfo.FileName = Environment.SystemDirectory + @"\systeminfo.exe";
253-
systeminfo.StartInfo.RedirectStandardOutput = true;
254-
systeminfo.StartInfo.UseShellExecute = false;
255-
systeminfo.Start();
256-
fileWriter.WriteLine(systeminfo.StandardOutput.ReadToEnd());
257-
systeminfo.WaitForExit();
258-
fileWriter.Close();
259-
systeminfo.Close();
260-
}
261-
else
262-
{
263-
Console.WriteLine("Systeminfo.exe not found in system");
264-
}
265-
}
266-
267-
}
268-
269293
// ==================================================================================
270-
if (Environment.Is64BitOperatingSystem)
294+
if (is64BitOperatingSystem)
271295
{
272296
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Exporting x86 Uninstall Registry\n\n");
273297

@@ -279,7 +303,7 @@ private static void Main()
279303
uninstallListx86.StartInfo.Arguments =
280304
@"export HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\ " + "\"" +
281305
tempDirectory +
282-
@"\uninstallx86.txt" + "\"";
306+
@"\uninstallx86.txt" + "\"" +" /reg:32";
283307
uninstallListx86.Start();
284308
uninstallListx86.WaitForExit();
285309
uninstallListx86.Close();
@@ -380,7 +404,7 @@ private static void Main()
380404
{
381405
if (File.Exists(systemDrive + @"\Windows\System32\reg.exe"))
382406
{
383-
if (!Environment.Is64BitOperatingSystem)
407+
if (!is64BitOperatingSystem)
384408
{
385409
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\System32\reg.exe";
386410
uninstallListx64.StartInfo.Arguments =
@@ -390,7 +414,7 @@ private static void Main()
390414
}
391415
else
392416
{
393-
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\Sysnative\reg.exe";
417+
uninstallListx64.StartInfo.FileName = systemDrive + @"\Windows\System32\reg.exe";
394418
uninstallListx64.StartInfo.Arguments =
395419
@"export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall " +
396420
"\"" + tempDirectory + "\"" +
@@ -406,6 +430,7 @@ private static void Main()
406430
{
407431
Console.WriteLine("reg.exe not found in system");
408432
}
433+
Console.WriteLine("HelloWorld");
409434
}
410435

411436
}
@@ -515,7 +540,7 @@ private static void Main()
515540
Console.WriteLine(DateTime.Now.ToString("G") +
516541
"\t - Blank File for x64 Uninstall List Created\n\n");
517542
}
518-
using (var output = File.Create(tempDirectory + @"\uninstall-reg.txt"))
543+
/*using (var output = File.Create(tempDirectory + @"\uninstall-reg.txt"))
519544
{
520545
foreach (
521546
var file in new[] { tempDirectory + @"\uninstallx86.txt", tempDirectory + @"\uninstallx64.txt" })
@@ -525,7 +550,25 @@ private static void Main()
525550
input.CopyTo(output);
526551
}
527552
}
528-
}
553+
}*/
554+
using (StreamReader uninstallx86Reader = new StreamReader(tempDirectory + @"\uninstallx86.txt"))
555+
{
556+
using (StreamReader uninstallx64Reader = new StreamReader(tempDirectory + @"\uninstallx64.txt"))
557+
{
558+
using (StreamWriter uninstallRegWriter = new StreamWriter(tempDirectory + @"\uninstall-reg.txt"))
559+
{
560+
while (uninstallx86Reader.Peek() >= 0)
561+
{
562+
uninstallRegWriter.WriteLine(uninstallx86Reader.ReadLine());
563+
}
564+
while (uninstallx64Reader.Peek() >= 0)
565+
{
566+
uninstallRegWriter.WriteLine(uninstallx64Reader.ReadLine());
567+
}
568+
}
569+
}
570+
}
571+
529572

530573
//Process the exported uninstall registry and filter out values and compile a single list
531574
using (
@@ -663,23 +706,6 @@ private static void Main()
663706
}
664707
}
665708

666-
using (StreamReader systeminfoReader = new StreamReader(tempDirectory + @"\systeminfo.txt")) //Filter out the email address from the report for privacy concerns
667-
{
668-
using (StreamWriter goodsysinfoWriter = new StreamWriter(tempDirectory + @"\goodsysteminfo.txt"))
669-
{
670-
int lineNumber = -1;
671-
while (systeminfoReader.Peek() >= 0)
672-
{
673-
string logFileContent = systeminfoReader.ReadLine();
674-
lineNumber++;
675-
if (lineNumber == 7)
676-
continue;
677-
goodsysinfoWriter.WriteLine(logFileContent);
678-
679-
}
680-
}
681-
}
682-
683709
using (StreamReader hotFixReader = new StreamReader(tempDirectory + @"\InstalledWindowsUpdates.txt")) //Check the number of Windows Updates installed on a system
684710
{
685711
while (hotFixReader.Peek() >= 0)
@@ -869,9 +895,11 @@ private static void Main()
869895
Thread.Sleep(8000);
870896
}
871897
Console.WriteLine(DateTime.Now.ToString("G") + "\t - Zipping Up Files!");
872-
ZipFile.CreateFromDirectory(tempDirectory,
873-
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" + zipFileName,
874-
CompressionLevel.Optimal, false);
898+
bool zipFileStatus = ZipFile(tempDirectory, zipFileName);
899+
if (!zipFileStatus)
900+
{
901+
Console.WriteLine("There was an error while creating the ZIP file");
902+
}
875903
var greetingsProcess = Process.Start(tempDirectory + @"\greetings.txt");
876904
Thread.Sleep(1000);
877905
if (greetingsProcess!=null) //Flash the taskbar icon of Notepad in case user has lost focus
@@ -925,23 +953,70 @@ static string Quotes()
925953
}
926954
}
927955

956+
/// <summary>
957+
/// Zip File mechanism using Shell32. Easiest way to do without any 3rd party API
958+
/// </summary>
959+
/// <param name="inputPath"></param>
960+
/// <param name="zipFileName"></param>
961+
/// <returns></returns>
962+
private static bool ZipFile(string inputPath, string zipFileName)
963+
{
964+
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};
965+
FileStream fs = File.Create(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" +
966+
zipFileName);
967+
fs.Write(emptyzip,0,emptyzip.Length);
968+
fs.Flush();
969+
fs.Close();
970+
try
971+
{
972+
Shell32.Folder zipInput = GetShell32NameSpace(inputPath);
973+
Shell32.Folder zipOutput =
974+
GetShell32NameSpace(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" +
975+
zipFileName);
976+
foreach (var file in zipInput.Items())
977+
{
978+
if (file != null)
979+
zipOutput.CopyHere(file, 4 | 16);
980+
Thread.Sleep(1000);
981+
}
982+
return true;
983+
}
984+
catch (Exception)
985+
{
986+
return false;
987+
}
988+
}
989+
928990
/// <summary>
929991
/// Converts the Date & Time which is generated by several WMI commands into human readable form
930992
/// </summary>
931993
/// <param name="stringDateToConvert">String parameter which contains the date & time outputted by several WMI Commands</param>
932994
/// <returns>Returns a string containing the date & time</returns>
933-
static string ConvertDateTime(string stringDateToConvert)
995+
private static string ConvertDateTime(string stringDateToConvert)
934996
{
935997
stringDateToConvert = stringDateToConvert.Replace("\r", "").Replace("\n", "");
936998
if (stringDateToConvert.Length > 8)
937999
stringDateToConvert = stringDateToConvert.Remove(8);
9381000

9391001
var temporaryArray = stringDateToConvert.ToCharArray();
940-
var output = temporaryArray[0].ToString() + temporaryArray[1].ToString() + temporaryArray[2].ToString() + temporaryArray[3].ToString() + "-";
1002+
var output = temporaryArray[0].ToString() + temporaryArray[1].ToString() + temporaryArray[2].ToString() +
1003+
temporaryArray[3].ToString() + "-";
9411004
output += temporaryArray[4].ToString() + temporaryArray[5].ToString() + "-";
9421005
output += temporaryArray[6].ToString() + temporaryArray[7].ToString();
9431006

9441007
return output;
9451008
}
1009+
1010+
/// <summary>
1011+
/// 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
1012+
/// </summary>
1013+
/// <param name="folder"></param>
1014+
/// <returns></returns>
1015+
static public Shell32.Folder GetShell32NameSpace(Object folder)
1016+
{
1017+
Type shellAppType = Type.GetTypeFromProgID("Shell.Application");
1018+
var shell = Activator.CreateInstance(shellAppType);
1019+
return (Shell32.Folder)shellAppType.InvokeMember("NameSpace", System.Reflection.BindingFlags.InvokeMethod, null, shell, new[] { folder });
1020+
}
9461021
}
9471022
}
1 KB
Binary file not shown.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5-
</startup>
6-
</configuration>
4+
5+
<supportedRuntime version="v2.0.50727"/></startup>
6+
</configuration>
2 KB
Binary file not shown.
-1016 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)