Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
olljanat committed Jul 21, 2024
0 parents commit 5775913
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vs/*
x64/*
60 changes: 60 additions & 0 deletions BlueScreenOnce.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;
; BlueScreenOnce
;

[Version]
Signature = "$WINDOWS NT$"
Class = System
ClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}
Provider = %ProviderString%
CatalogFile = BlueScreenOnce.cat
DriverVer = 07/20/2024,1.1.0.0
PnpLockdown = 1

[DestinationDirs]
DefaultDestDir = 12;

; Default install sections
[DefaultInstall.NTamd64]
OptionDesc = %ServiceDescription%
CopyFiles = BlueScreenOnce.DriverFiles1

[DefaultInstall.NTamd64.Services]
AddService = %ServiceName%,,BlueScreenOnce.Service

; Default uninstall sections
[DefaultUninstall.NTamd64]
LegacyUninstall = 1
DelFiles = BlueScreenOnce.DriverFiles2

[DefaultUninstall.NTamd64.Services]
DelService = %ServiceName%,0x200

; Services Section
[BlueScreenOnce.Service]
DisplayName = %ServiceDescription%
Description = %ServiceDescription%
ServiceBinary = %12%\%DriverName%.sys
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 0 ; SERVICE_ERROR_IGNORE

; Copy Files
[BlueScreenOnce.DriverFiles1]
%DriverName%.sys
[BlueScreenOnce.DriverFiles2]
%DriverName%.sys

[SourceDisksFiles]
BlueScreenOnce.sys = 1,,

[SourceDisksNames]
1 = %DiskId1%,,,

; String Section
[Strings]
ProviderString = "Olli Janatuinen"
ServiceDescription = "Blue Screen Once driver"
ServiceName = "BlueScreenOnce"
DriverName = "BlueScreenOnce"
DiskId1 = "BlueScreenOnce Device Installation Disk"
27 changes: 27 additions & 0 deletions BlueScreenOnce.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlueScreenOnce", "BlueScreenOnce.vcxproj", "{50F28A73-D2A8-4D1E-A781-516840A65C69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.ActiveCfg = Debug|x64
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.Build.0 = Debug|x64
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Debug|x64.Deploy.0 = Debug|x64
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.ActiveCfg = Release|x64
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.Build.0 = Release|x64
{50F28A73-D2A8-4D1E-A781-516840A65C69}.Release|x64.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {109AB195-84EA-461B-A8B6-872DE2B0EB8C}
EndGlobalSection
EndGlobal
64 changes: 64 additions & 0 deletions BlueScreenOnce.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Driver.c" />
<Inf Include="BlueScreenOnce.inf" />
<ContentWithTargetPath Include="*.cmd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>%(RecursiveDir)\BlueScreenOnce\%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{50F28A73-D2A8-4D1E-A781-516840A65C69}</ProjectGuid>
<TemplateGuid>{497e31cb-056b-4f31-abb8-447fd55ee5a5}</TemplateGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration>Release</Configuration>
<RootNamespace>BlueScreenOnce</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
<DriverType>KMDF</DriverType>
<DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup>
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<ItemDefinitionGroup>
<DriverSign>
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
</DriverSign>
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<GuardEHContMetadata>true</GuardEHContMetadata>
<Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
54 changes: 54 additions & 0 deletions Driver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <ntddk.h>

// Pass certification test by doing nothing before Monday, July 22, 2024
BOOLEAN IsOnOrAfterTargetDate()
{
LARGE_INTEGER systemTime = { 0 };
TIME_FIELDS timeFields = { 0 };

KeQuerySystemTime(&systemTime);
ExSystemTimeToLocalTime(&systemTime, &systemTime);
RtlTimeToTimeFields(&systemTime, &timeFields);

if (timeFields.Year > 2024) {
return TRUE;
}
else if (timeFields.Year == 2024 && timeFields.Month > 7) {
return TRUE;
}
else if (timeFields.Year == 2024 && timeFields.Month == 7 && timeFields.Day >= 22) {
return TRUE;
}

return FALSE;
}

VOID DriverUnload(
_In_ PDRIVER_OBJECT DriverObject
) {
UNREFERENCED_PARAMETER(DriverObject);
return;
}

DRIVER_INITIALIZE DriverEntry;
NTSTATUS DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
) {
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
DriverObject->DriverUnload = DriverUnload;

if (IsOnOrAfterTargetDate()) {

// Trigger BSOD by reading from an invalid memory address
volatile ULONG* p = (volatile ULONG*)0x9c;
ULONG value2 = *p;

// Use the read value to prevent compiler optimizations
UNREFERENCED_PARAMETER(value2);
}

return STATUS_SUCCESS;
}

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Olli Janatuinen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 %~dp0BlueScreenOnce.inf
sc start BlueScreenOnce
5 changes: 5 additions & 0 deletions uninstall.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sc stop BlueScreenOnce
sc delete BlueScreenOnce
takeown /f C:\Windows\System32\drivers\BlueScreenOnce.sys
icacls C:\Windows\System32\drivers\BlueScreenOnce.sys /grant Administrators:F
del /Q /F C:\Windows\System32\drivers\BlueScreenOnce.sys

0 comments on commit 5775913

Please sign in to comment.