forked from HOOK11/WindowProtect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
HOOK11
committed
Jun 27, 2023
1 parent
379e86a
commit 3c7bb88
Showing
25 changed files
with
3,796 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "hook.hpp" | ||
|
||
typedef NTSTATUS(NTAPI* PNtCreateFile)( | ||
OUT PHANDLE FileHandle, | ||
IN ACCESS_MASK DesiredAccess, | ||
IN POBJECT_ATTRIBUTES ObjectAttributes, | ||
OUT PIO_STATUS_BLOCK IoStatusBlock, | ||
IN PLARGE_INTEGER AllocationSize OPTIONAL, | ||
IN ULONG FileAttributes, | ||
IN ULONG ShareAccess, | ||
IN ULONG CreateDisposition, | ||
IN ULONG CreateOptions, | ||
IN PVOID EaBuffer, | ||
IN ULONG EaLength); | ||
PNtCreateFile g_NtCreateFile = 0; | ||
|
||
NTSTATUS NTAPI MyNtCreateFile( | ||
PHANDLE FileHandle, | ||
ACCESS_MASK DesiredAccess, | ||
POBJECT_ATTRIBUTES ObjectAttributes, | ||
PIO_STATUS_BLOCK IoStatusBlock, | ||
PLARGE_INTEGER AllocationSize, | ||
ULONG FileAttributes, | ||
ULONG ShareAccess, | ||
ULONG CreateDisposition, | ||
ULONG CreateOptions, | ||
PVOID EaBuffer, | ||
ULONG EaLength) | ||
{ | ||
if (ObjectAttributes && | ||
ObjectAttributes->ObjectName && | ||
ObjectAttributes->ObjectName->Buffer) | ||
{ | ||
wchar_t* name = (wchar_t*)ExAllocatePoolWithTag(NonPagedPool, ObjectAttributes->ObjectName->Length + sizeof(wchar_t),'xiq2'); | ||
if (name) | ||
{ | ||
RtlZeroMemory(name, ObjectAttributes->ObjectName->Length + sizeof(wchar_t)); | ||
RtlCopyMemory(name, ObjectAttributes->ObjectName->Buffer, ObjectAttributes->ObjectName->Length); | ||
KdPrintEx((0, 0, "[%s] name:%wZ \n", __FUNCTION__, ObjectAttributes->ObjectName)); | ||
|
||
if (wcsstr(name, L"tips.txt")) | ||
{ | ||
ExFreePool(name); | ||
return STATUS_ACCESS_DENIED; | ||
} | ||
|
||
ExFreePool(name); | ||
} | ||
} | ||
|
||
return NtCreateFile( | ||
FileHandle, | ||
DesiredAccess, | ||
ObjectAttributes, | ||
IoStatusBlock, | ||
AllocationSize, | ||
FileAttributes, | ||
ShareAccess, | ||
CreateDisposition, | ||
CreateOptions, | ||
EaBuffer, | ||
EaLength); | ||
} | ||
|
||
void __fastcall call_back(_In_ unsigned int SystemCallIndex, _Inout_ void** SystemCallFunction) | ||
{ | ||
UNREFERENCED_PARAMETER(SystemCallIndex); | ||
|
||
if (*SystemCallFunction == NtCreateFile) | ||
{ | ||
*SystemCallFunction = MyNtCreateFile; | ||
} | ||
} | ||
|
||
VOID DriverUnload(PDRIVER_OBJECT driver) | ||
{ | ||
UNREFERENCED_PARAMETER(driver); | ||
|
||
KdPrintEx((0, 0, "[%s] \n", __FUNCTION__)); | ||
|
||
IfhRelease2(); | ||
} | ||
|
||
EXTERN_C | ||
NTSTATUS | ||
DriverEntry( | ||
PDRIVER_OBJECT driver, | ||
PUNICODE_STRING registe) | ||
{ | ||
|
||
UNREFERENCED_PARAMETER(registe); | ||
|
||
KdPrintEx((0, 0, "[%s] \n", __FUNCTION__)); | ||
|
||
driver->DriverUnload = DriverUnload; | ||
|
||
// ³õʼ»¯²¢¹Ò¹³ | ||
IfhInitialize2(call_back); | ||
|
||
return STATUS_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
<?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|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|ARM"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>ARM</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|ARM"> | ||
<Configuration>Release</Configuration> | ||
<Platform>ARM</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|ARM64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|ARM64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{1508383A-6C98-4451-8B0E-894DE0F9511B}</ProjectGuid> | ||
<TemplateGuid>{dd38f7fc-d7bd-488b-9242-7d8754cde80d}</TemplateGuid> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion> | ||
<Configuration>Debug</Configuration> | ||
<Platform Condition="'$(Platform)' == ''">Win32</Platform> | ||
<RootNamespace>EtwHook</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion> | ||
<ProjectName>EtwHookLib</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
<Driver_SpectreMitigation>false</Driver_SpectreMitigation> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>StaticLibrary</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
<Driver_SpectreMitigation>false</Driver_SpectreMitigation> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> | ||
<TargetVersion>Windows10</TargetVersion> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> | ||
<ConfigurationType>Driver</ConfigurationType> | ||
<DriverType>WDM</DriverType> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> | ||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<TreatWarningAsError>false</TreatWarningAsError> | ||
<Optimization>Disabled</Optimization> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<TreatWarningAsError>false</TreatWarningAsError> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<FilesToPackage Include="$(TargetPath)" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="hde\hde64.cpp" /> | ||
<ClCompile Include="hook.cpp" /> | ||
<ClCompile Include="DriverMain.cpp"> | ||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="hde\hde64.h" /> | ||
<ClInclude Include="hde\pstdint.h" /> | ||
<ClInclude Include="hde\table64.h" /> | ||
<ClInclude Include="headers.hpp" /> | ||
<ClInclude Include="hook.h" /> | ||
<ClInclude Include="imports.hpp" /> | ||
<ClInclude Include="utils.hpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<MASM Include="hook.asm"> | ||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> | ||
</MASM> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Driver Files"> | ||
<UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier> | ||
<Extensions>inf;inv;inx;mof;mc;</Extensions> | ||
</Filter> | ||
<Filter Include="Hde"> | ||
<UniqueIdentifier>{edae21d4-7ff9-4804-9dec-4d72e3413c77}</UniqueIdentifier> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="hde\hde64.cpp"> | ||
<Filter>Hde</Filter> | ||
</ClCompile> | ||
<ClCompile Include="hook.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="DriverMain.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="hde\hde64.h"> | ||
<Filter>Hde</Filter> | ||
</ClInclude> | ||
<ClInclude Include="hde\pstdint.h"> | ||
<Filter>Hde</Filter> | ||
</ClInclude> | ||
<ClInclude Include="hde\table64.h"> | ||
<Filter>Hde</Filter> | ||
</ClInclude> | ||
<ClInclude Include="headers.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="hook.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="imports.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="utils.hpp"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<MASM Include="hook.asm"> | ||
<Filter>Source Files</Filter> | ||
</MASM> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.