From 974bd0388994715b4fa35ac54986e3c1ed4e3f55 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 27 Apr 2017 19:19:56 +0300 Subject: reorganize files * src/ -> km/src/ * utils/ -> um/ * Move WDK 7.1-specific *.bat files to km/build/wdk7.1/ * Move WDK 8.1 Update 1 solutions to km/build/wdk8.1update/ --- src/dirs | 1 - src/minimal/main.c | 12 - src/minimal/makefile | 1 - src/minimal/sources | 3 - src/minimal/vs12/.gitignore | 2 - src/minimal/vs12/minimal.vs12.sln | 64 ----- src/minimal/vs12/minimal.vs12.vcxproj | 285 --------------------- src/nt_path_converter/control_codes.h | 12 - src/nt_path_converter/device.c | 203 --------------- src/nt_path_converter/device.h | 13 - src/nt_path_converter/main.c | 27 -- src/nt_path_converter/makefile | 1 - src/nt_path_converter/nt2dos.c | 151 ----------- src/nt_path_converter/nt2dos.h | 12 - src/nt_path_converter/sources | 3 - src/nt_path_converter/vs12/.gitignore | 2 - .../vs12/nt_path_converter.vs12.sln | 64 ----- .../vs12/nt_path_converter.vs12.vcxproj | 232 ----------------- src/simple/device.c | 220 ---------------- src/simple/device.h | 13 - src/simple/main.c | 29 --- src/simple/makefile | 1 - src/simple/sources | 3 - src/simple/vs12/.gitignore | 2 - src/simple/vs12/simple.vs12.sln | 64 ----- src/simple/vs12/simple.vs12.vcxproj | 229 ----------------- src/sysenter/main.c | 106 -------- src/sysenter/makefile | 1 - src/sysenter/sources | 4 - src/sysenter/vs12/.gitignore | 2 - src/sysenter/vs12/sysenter.vs12.sln | 44 ---- src/sysenter/vs12/sysenter.vs12.vcxproj | 65 ----- 32 files changed, 1871 deletions(-) delete mode 100644 src/dirs delete mode 100644 src/minimal/main.c delete mode 100644 src/minimal/makefile delete mode 100644 src/minimal/sources delete mode 100644 src/minimal/vs12/.gitignore delete mode 100644 src/minimal/vs12/minimal.vs12.sln delete mode 100644 src/minimal/vs12/minimal.vs12.vcxproj delete mode 100644 src/nt_path_converter/control_codes.h delete mode 100644 src/nt_path_converter/device.c delete mode 100644 src/nt_path_converter/device.h delete mode 100644 src/nt_path_converter/main.c delete mode 100644 src/nt_path_converter/makefile delete mode 100644 src/nt_path_converter/nt2dos.c delete mode 100644 src/nt_path_converter/nt2dos.h delete mode 100644 src/nt_path_converter/sources delete mode 100644 src/nt_path_converter/vs12/.gitignore delete mode 100644 src/nt_path_converter/vs12/nt_path_converter.vs12.sln delete mode 100644 src/nt_path_converter/vs12/nt_path_converter.vs12.vcxproj delete mode 100644 src/simple/device.c delete mode 100644 src/simple/device.h delete mode 100644 src/simple/main.c delete mode 100644 src/simple/makefile delete mode 100644 src/simple/sources delete mode 100644 src/simple/vs12/.gitignore delete mode 100644 src/simple/vs12/simple.vs12.sln delete mode 100644 src/simple/vs12/simple.vs12.vcxproj delete mode 100644 src/sysenter/main.c delete mode 100644 src/sysenter/makefile delete mode 100644 src/sysenter/sources delete mode 100644 src/sysenter/vs12/.gitignore delete mode 100644 src/sysenter/vs12/sysenter.vs12.sln delete mode 100644 src/sysenter/vs12/sysenter.vs12.vcxproj (limited to 'src') diff --git a/src/dirs b/src/dirs deleted file mode 100644 index 065777a..0000000 --- a/src/dirs +++ /dev/null @@ -1 +0,0 @@ -DIRS = minimal nt_path_converter simple sysenter diff --git a/src/minimal/main.c b/src/minimal/main.c deleted file mode 100644 index 6983929..0000000 --- a/src/minimal/main.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -static void on_driver_unload(DRIVER_OBJECT *driver_object) -{ } - -NTSTATUS DriverEntry( - DRIVER_OBJECT *driver_object, - UNICODE_STRING *registry_path) -{ - driver_object->DriverUnload = on_driver_unload; - return STATUS_SUCCESS; -} diff --git a/src/minimal/makefile b/src/minimal/makefile deleted file mode 100644 index 5acbbd2..0000000 --- a/src/minimal/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/src/minimal/sources b/src/minimal/sources deleted file mode 100644 index b6e92c3..0000000 --- a/src/minimal/sources +++ /dev/null @@ -1,3 +0,0 @@ -TARGETTYPE = DRIVER -TARGETNAME = minimal -SOURCES = main.c diff --git a/src/minimal/vs12/.gitignore b/src/minimal/vs12/.gitignore deleted file mode 100644 index cd42ee3..0000000 --- a/src/minimal/vs12/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin/ -obj/ diff --git a/src/minimal/vs12/minimal.vs12.sln b/src/minimal/vs12/minimal.vs12.sln deleted file mode 100644 index ad150d0..0000000 --- a/src/minimal/vs12/minimal.vs12.sln +++ /dev/null @@ -1,64 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minimal.vs12", "minimal.vs12.vcxproj", "{4339268C-B8A8-422D-803B-5CF49DFA593B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win7 Debug|Win32 = Win7 Debug|Win32 - Win7 Debug|x64 = Win7 Debug|x64 - Win7 Release|Win32 = Win7 Release|Win32 - Win7 Release|x64 = Win7 Release|x64 - Win8 Debug|Win32 = Win8 Debug|Win32 - Win8 Debug|x64 = Win8 Debug|x64 - Win8 Release|Win32 = Win8 Release|Win32 - Win8 Release|x64 = Win8 Release|x64 - Win8.1 Debug|Win32 = Win8.1 Debug|Win32 - Win8.1 Debug|x64 = Win8.1 Debug|x64 - Win8.1 Release|Win32 = Win8.1 Release|Win32 - Win8.1 Release|x64 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|x64.Build.0 = Win7 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win7 Release|x64.Deploy.0 = Win7 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|x64.Build.0 = Win8 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8 Release|x64.Deploy.0 = Win8 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|Win32.Deploy.0 = Win8.1 Debug|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Debug|x64.Deploy.0 = Win8.1 Debug|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|Win32.Deploy.0 = Win8.1 Release|Win32 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 - {4339268C-B8A8-422D-803B-5CF49DFA593B}.Win8.1 Release|x64.Deploy.0 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/minimal/vs12/minimal.vs12.vcxproj b/src/minimal/vs12/minimal.vs12.vcxproj deleted file mode 100644 index b50d993..0000000 --- a/src/minimal/vs12/minimal.vs12.vcxproj +++ /dev/null @@ -1,285 +0,0 @@ - - - - - Win8.1 Debug - Win32 - - - Win8.1 Release - Win32 - - - Win8 Debug - Win32 - - - Win8 Release - Win32 - - - Win7 Debug - Win32 - - - Win7 Release - Win32 - - - Win8.1 Debug - x64 - - - Win8.1 Release - x64 - - - Win8 Debug - x64 - - - Win8 Release - x64 - - - Win7 Debug - x64 - - - Win7 Release - x64 - - - - {4339268C-B8A8-422D-803B-5CF49DFA593B} - {dd38f7fc-d7bd-488b-9242-7d8754cde80d} - v4.5 - 11.0 - Win8.1 Debug - Win32 - minimal_vs12 - - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - - - - - - - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - 4100;%(DisableSpecificWarnings) - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/nt_path_converter/control_codes.h b/src/nt_path_converter/control_codes.h deleted file mode 100644 index 3fb2aff..0000000 --- a/src/nt_path_converter/control_codes.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -#define CONVERT_NT_PATH CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/src/nt_path_converter/device.c b/src/nt_path_converter/device.c deleted file mode 100644 index a179984..0000000 --- a/src/nt_path_converter/device.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "control_codes.h" -#include "device.h" -#include "nt2dos.h" - -#include - -static NTSTATUS device_open(DEVICE_OBJECT *device_object, IRP *irp) -{ - NTSTATUS status = STATUS_SUCCESS; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - IoCompleteRequest(irp, IO_NO_INCREMENT); - return status; -} - -typedef NTSTATUS (*ioctl_handler)( - void *, unsigned long, - void *, unsigned long, - ULONG_PTR *); - -static NTSTATUS handle_convert_nt_path( - void *in_buf, - unsigned long in_buf_size, - void *out_buf, - unsigned long out_buf_size, - ULONG_PTR *nbwritten) -{ - UNICODE_STRING uUnresolved, uResolved; - NTSTATUS status = STATUS_SUCCESS; - - DbgPrint("nt_path_converter: unresolved path: %ws\n", (WCHAR *) in_buf); - DbgPrint("nt_path_converter: unresolved size: %lu\n", in_buf_size); - - RtlInitUnicodeString(&uUnresolved, (WCHAR *) in_buf); - status = nt2dos(&uResolved, &uUnresolved); - - if (!NT_SUCCESS(status)) - return status; - - *nbwritten = uResolved.Length + sizeof(WCHAR); - - DbgPrint("nt_path_converter: resolved path: %wZ\n", &uResolved); - DbgPrint("nt_path_converter: resolved size: %Iu\n", *nbwritten); - - if (out_buf_size < *nbwritten) - { - status = STATUS_BUFFER_OVERFLOW; - goto free_resolved; - } - - RtlFillMemory(out_buf, *nbwritten, L'\0'); - RtlCopyMemory(out_buf, uResolved.Buffer, uResolved.Length); - -free_resolved: - ExFreePool(uResolved.Buffer); - - return status; -} - -static NTSTATUS device_ioctl(DEVICE_OBJECT *device_object, IRP *irp) -{ - IO_STACK_LOCATION *io_stack_loc; - void* in_buf, *out_buf; - unsigned long in_buf_size, out_buf_size; - ioctl_handler handler; - NTSTATUS status = STATUS_UNSUCCESSFUL; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - io_stack_loc = IoGetCurrentIrpStackLocation(irp); - - in_buf = out_buf = irp->AssociatedIrp.SystemBuffer; - in_buf_size = io_stack_loc->Parameters.DeviceIoControl.InputBufferLength; - out_buf_size = io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength; - - switch (io_stack_loc->Parameters.DeviceIoControl.IoControlCode) - { - case CONVERT_NT_PATH: - handler = handle_convert_nt_path; - break; - - default: - status = irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - goto complete_request; - } - - status = irp->IoStatus.Status = handler( - in_buf, in_buf_size, - out_buf, out_buf_size, - &irp->IoStatus.Information); - -complete_request: - IoCompleteRequest(irp, IO_NO_INCREMENT); - - return status; -} - -typedef struct -{ - const wchar_t *path; - const wchar_t *symlink; -} -DeviceInfo; - -typedef struct -{ - DEVICE_OBJECT *object; - UNICODE_STRING path; - UNICODE_STRING symlink; -} -Device; - -#define NUMOF_DEVICES 1 - -static DeviceInfo devices_info[NUMOF_DEVICES] = -{ - { - L"\\Device\\nt_path_converter", - L"\\DosDevices\\nt_path_converter", - }, -}; - -static Device devices[NUMOF_DEVICES]; - -static void destroy_device(int i) -{ - IoDeleteSymbolicLink(&devices[i].symlink); - IoDeleteDevice(devices[i].object); -} - -void destroy_devices() -{ - int i; - for (i = 0; i < NUMOF_DEVICES; ++i) - destroy_device(i); -} - -static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) -{ - NTSTATUS status = STATUS_SUCCESS; - - RtlInitUnicodeString(&devices[i].path, devices_info[i].path); - RtlInitUnicodeString(&devices[i].symlink, devices_info[i].symlink); - - status = IoCreateDevice( - driver_object, - 0, - &devices[i].path, - FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &devices[i].object); - - if (!NT_SUCCESS(status)) - return status; - - devices[i].object->Flags |= DO_BUFFERED_IO; - devices[i].object->Flags &= ~DO_DEVICE_INITIALIZING; - - if (!NT_SUCCESS(status = IoCreateSymbolicLink( - &devices[i].symlink, &devices[i].path))) - goto delete_device; - - return status; - -delete_device: - IoDeleteDevice(devices[i].object); - - return status; -} - -NTSTATUS set_up_devices(DRIVER_OBJECT *driver_object) -{ - int i, j; - NTSTATUS status = STATUS_SUCCESS; - - for (i = 0; i < NUMOF_DEVICES; ++i) - if (!NT_SUCCESS(status = set_up_device(driver_object, i))) - goto destroy_devices; - - driver_object->MajorFunction[IRP_MJ_CREATE] = device_open; - driver_object->MajorFunction[IRP_MJ_DEVICE_CONTROL] = device_ioctl; - - return status; - -destroy_devices: - for (j = 0; j < i; ++j) - destroy_device(j); - - return status; -} diff --git a/src/nt_path_converter/device.h b/src/nt_path_converter/device.h deleted file mode 100644 index 4f117e9..0000000 --- a/src/nt_path_converter/device.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -NTSTATUS set_up_devices(DRIVER_OBJECT *); -void destroy_devices(); diff --git a/src/nt_path_converter/main.c b/src/nt_path_converter/main.c deleted file mode 100644 index a1c08e8..0000000 --- a/src/nt_path_converter/main.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "device.h" - -#include - -static void on_driver_unload(DRIVER_OBJECT *driver_object) -{ - UNREFERENCED_PARAMETER(driver_object); - - destroy_devices(); -} - -NTSTATUS DriverEntry( - DRIVER_OBJECT *driver_object, - UNICODE_STRING *registry_path) -{ - UNREFERENCED_PARAMETER(registry_path); - - driver_object->DriverUnload = on_driver_unload; - return set_up_devices(driver_object); -} diff --git a/src/nt_path_converter/makefile b/src/nt_path_converter/makefile deleted file mode 100644 index 5acbbd2..0000000 --- a/src/nt_path_converter/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/src/nt_path_converter/nt2dos.c b/src/nt_path_converter/nt2dos.c deleted file mode 100644 index d1bdb3d..0000000 --- a/src/nt_path_converter/nt2dos.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include - -#include "nt2dos.h" - -static NTSTATUS get_object_name_info( - void *object, - OBJECT_NAME_INFORMATION **object_name_info) -{ - unsigned long nbneeded; - NTSTATUS status = STATUS_SUCCESS; - - status = ObQueryNameString(object, NULL, 0, &nbneeded); - - if (status != STATUS_INFO_LENGTH_MISMATCH) - return status; - - *object_name_info = ExAllocatePoolWithTag(PagedPool, nbneeded, '1l'); - - if (*object_name_info == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - - status = ObQueryNameString(object, *object_name_info, nbneeded, &nbneeded); - - if (!NT_SUCCESS(status)) - goto free_object_name_info; - - return status; - -free_object_name_info: - ExFreePool(*object_name_info); - - return status; -} - -NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) -{ - IO_STATUS_BLOCK io_status_block; - DEVICE_OBJECT *volume_object; - FILE_OBJECT *file_object; - HANDLE file; - OBJECT_ATTRIBUTES file_attrs; - OBJECT_NAME_INFORMATION *file_name_info, *volume_name_info; - UNICODE_STRING u_dos_name; - USHORT u_resolved_size; - NTSTATUS status = STATUS_SUCCESS; - - InitializeObjectAttributes( - &file_attrs, - u_unresolved, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - NULL, - NULL); - - status = ZwCreateFile( - &file, - FILE_READ_ATTRIBUTES, - &file_attrs, - &io_status_block, - NULL, - FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_OPEN, - FILE_SYNCHRONOUS_IO_NONALERT, - NULL, - 0); - - if (!NT_SUCCESS(status)) - return status; - - status = ObReferenceObjectByHandle( - file, - FILE_READ_ATTRIBUTES, - *IoFileObjectType, - KernelMode, - &file_object, - NULL); - - if (!NT_SUCCESS(status)) - goto close_file; - - status = get_object_name_info(file_object, &file_name_info); - - if (!NT_SUCCESS(status)) - goto close_file; - - if (file_object->Vpb == NULL) - { - u_resolved->Buffer = ExAllocatePoolWithTag( - PagedPool, file_name_info->Name.Length, '1l'); - - if (u_resolved->Buffer == NULL) - { - status = STATUS_INSUFFICIENT_RESOURCES; - goto free_file_name_info; - } - - RtlInitEmptyUnicodeString( - u_resolved, u_resolved->Buffer, file_name_info->Name.Length); - RtlCopyUnicodeString(u_resolved, &file_name_info->Name); - goto free_file_name_info; - } - - volume_object = file_object->Vpb->RealDevice; - status = get_object_name_info(volume_object, &volume_name_info); - - if (!NT_SUCCESS(status)) - goto free_file_name_info; - - status = IoVolumeDeviceToDosName(volume_object, &u_dos_name); - - if (!NT_SUCCESS(status)) - goto free_volume_name_info; - - u_resolved_size = file_name_info->Name.Length - volume_name_info->Name.Length + u_dos_name.Length; - - u_resolved->Buffer = ExAllocatePoolWithTag(PagedPool, u_resolved_size, '1l'); - - if (u_resolved->Buffer == NULL) - { - status = STATUS_INSUFFICIENT_RESOURCES; - goto free_dos_name; - } - - RtlInitEmptyUnicodeString(u_resolved, u_resolved->Buffer, u_resolved_size); - - RtlCopyUnicodeString(u_resolved, &u_dos_name); - file_name_info->Name.Buffer += volume_name_info->Name.Length / sizeof(wchar_t); - file_name_info->Name.Length -= volume_name_info->Name.Length; - RtlUnicodeStringCat(u_resolved, &file_name_info->Name); - -free_dos_name: - ExFreePool(u_dos_name.Buffer); - -free_volume_name_info: - ExFreePool(volume_name_info); - -free_file_name_info: - ExFreePool(file_name_info); - -close_file: - ZwClose(file); - - return status; -} diff --git a/src/nt_path_converter/nt2dos.h b/src/nt_path_converter/nt2dos.h deleted file mode 100644 index ce0b690..0000000 --- a/src/nt_path_converter/nt2dos.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -NTSTATUS nt2dos(UNICODE_STRING *resolved, UNICODE_STRING *unresolved); diff --git a/src/nt_path_converter/sources b/src/nt_path_converter/sources deleted file mode 100644 index 02a42cd..0000000 --- a/src/nt_path_converter/sources +++ /dev/null @@ -1,3 +0,0 @@ -TARGETTYPE = DRIVER -TARGETNAME = nt_path_converter -SOURCES = device.c main.c nt2dos.c diff --git a/src/nt_path_converter/vs12/.gitignore b/src/nt_path_converter/vs12/.gitignore deleted file mode 100644 index cd42ee3..0000000 --- a/src/nt_path_converter/vs12/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin/ -obj/ diff --git a/src/nt_path_converter/vs12/nt_path_converter.vs12.sln b/src/nt_path_converter/vs12/nt_path_converter.vs12.sln deleted file mode 100644 index 45cf003..0000000 --- a/src/nt_path_converter/vs12/nt_path_converter.vs12.sln +++ /dev/null @@ -1,64 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nt_path_converter.vs12", "nt_path_converter.vs12.vcxproj", "{6B611107-4492-46B1-A233-12BAB1FF0FC2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win7 Debug|Win32 = Win7 Debug|Win32 - Win7 Debug|x64 = Win7 Debug|x64 - Win7 Release|Win32 = Win7 Release|Win32 - Win7 Release|x64 = Win7 Release|x64 - Win8 Debug|Win32 = Win8 Debug|Win32 - Win8 Debug|x64 = Win8 Debug|x64 - Win8 Release|Win32 = Win8 Release|Win32 - Win8 Release|x64 = Win8 Release|x64 - Win8.1 Debug|Win32 = Win8.1 Debug|Win32 - Win8.1 Debug|x64 = Win8.1 Debug|x64 - Win8.1 Release|Win32 = Win8.1 Release|Win32 - Win8.1 Release|x64 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Build.0 = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Deploy.0 = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Build.0 = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Deploy.0 = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Deploy.0 = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Deploy.0 = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Deploy.0 = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Deploy.0 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/nt_path_converter/vs12/nt_path_converter.vs12.vcxproj b/src/nt_path_converter/vs12/nt_path_converter.vs12.vcxproj deleted file mode 100644 index 4a50b17..0000000 --- a/src/nt_path_converter/vs12/nt_path_converter.vs12.vcxproj +++ /dev/null @@ -1,232 +0,0 @@ - - - - - Win8.1 Debug - Win32 - - - Win8.1 Release - Win32 - - - Win8 Debug - Win32 - - - Win8 Release - Win32 - - - Win7 Debug - Win32 - - - Win7 Release - Win32 - - - Win8.1 Debug - x64 - - - Win8.1 Release - x64 - - - Win8 Debug - x64 - - - Win8 Release - x64 - - - Win7 Debug - x64 - - - Win7 Release - x64 - - - - {6B611107-4492-46B1-A233-12BAB1FF0FC2} - {dd38f7fc-d7bd-488b-9242-7d8754cde80d} - v4.5 - 11.0 - Win8.1 Debug - Win32 - nt_path_converter_vs12 - - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - - - - - - - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/simple/device.c b/src/simple/device.c deleted file mode 100644 index 859ba67..0000000 --- a/src/simple/device.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "device.h" - -#include - -static NTSTATUS device_open(DEVICE_OBJECT *device_object, IRP *irp) -{ - NTSTATUS status = STATUS_SUCCESS; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - IoCompleteRequest(irp, IO_NO_INCREMENT); - return status; -} - -typedef NTSTATUS (*ioctl_handler)( - void *, unsigned long, - void *, unsigned long, - ULONG_PTR *); - -static NTSTATUS handle_say_hello( - void *in_buf, - unsigned long in_buf_size, - void *out_buf, - unsigned long out_buf_size, - ULONG_PTR *nbwritten) -{ - UNREFERENCED_PARAMETER(in_buf); - UNREFERENCED_PARAMETER(in_buf_size); - UNREFERENCED_PARAMETER(out_buf); - UNREFERENCED_PARAMETER(out_buf_size); - UNREFERENCED_PARAMETER(nbwritten); - - DbgPrint("Hello, world!\n"); - return STATUS_SUCCESS; -} - -static unsigned int i = 42; - -static NTSTATUS handle_exchange_ints( - void *in_buf, - unsigned long in_buf_size, - void *out_buf, - unsigned long out_buf_size, - ULONG_PTR *nbwritten) -{ - unsigned int temp_i; - - if (in_buf_size != sizeof(temp_i)) - return STATUS_INVALID_BUFFER_SIZE; - - RtlCopyMemory(&temp_i, in_buf, in_buf_size); - DbgPrint("%08x\n", temp_i); - - if (out_buf_size < sizeof(i)) - return STATUS_BUFFER_TOO_SMALL; - - RtlCopyMemory(out_buf, &i, sizeof(i)); - *nbwritten += sizeof(i); - i = temp_i; - return STATUS_SUCCESS; -} - -#define SAY_HELLO CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define EXCHANGE_INTS CTL_CODE(0x8001, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) - -static NTSTATUS device_ioctl(DEVICE_OBJECT *device_object, IRP *irp) -{ - IO_STACK_LOCATION *io_stack_loc; - void* in_buf, *out_buf; - unsigned long in_buf_size, out_buf_size; - ioctl_handler handler; - NTSTATUS status = STATUS_UNSUCCESSFUL; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - io_stack_loc = IoGetCurrentIrpStackLocation(irp); - - in_buf = out_buf = irp->AssociatedIrp.SystemBuffer; - in_buf_size = io_stack_loc->Parameters.DeviceIoControl.InputBufferLength; - out_buf_size = io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength; - - switch (io_stack_loc->Parameters.DeviceIoControl.IoControlCode) - { - case SAY_HELLO: - handler = handle_say_hello; - break; - - case EXCHANGE_INTS: - handler = handle_exchange_ints; - break; - - default: - status = irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - goto complete_request; - } - - status = irp->IoStatus.Status = handler( - in_buf, in_buf_size, - out_buf, out_buf_size, - &irp->IoStatus.Information); - -complete_request: - IoCompleteRequest(irp, IO_NO_INCREMENT); - - return status; -} - -typedef struct -{ - const wchar_t *path; - const wchar_t *symlink; -} -DeviceInfo; - -typedef struct -{ - DEVICE_OBJECT *object; - UNICODE_STRING path; - UNICODE_STRING symlink; -} -Device; - -#define NUMOF_DEVICES 2 - -static DeviceInfo devices_info[NUMOF_DEVICES] = -{ - { - L"\\Device\\simple_device1", - L"\\DosDevices\\simple_device1", - }, - { - L"\\Device\\simple_device2", - L"\\DosDevices\\simple_device2", - }, -}; - -static Device devices[NUMOF_DEVICES]; - -static void destroy_device(int i) -{ - IoDeleteSymbolicLink(&devices[i].symlink); - IoDeleteDevice(devices[i].object); -} - -void destroy_devices() -{ - int i; - for (i = 0; i < NUMOF_DEVICES; ++i) - destroy_device(i); -} - -static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) -{ - NTSTATUS status = STATUS_SUCCESS; - - DbgPrint("Setting up device...\n"); - DbgPrint("\tPath: %ws\n", devices_info[i].path); - DbgPrint("\tSymlink: %ws\n", devices_info[i].symlink); - - RtlInitUnicodeString(&devices[i].path, devices_info[i].path); - RtlInitUnicodeString(&devices[i].symlink, devices_info[i].symlink); - - status = IoCreateDevice( - driver_object, - 0, - &devices[i].path, - FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &devices[i].object); - - if (!NT_SUCCESS(status)) - return status; - - devices[i].object->Flags |= DO_BUFFERED_IO; - devices[i].object->Flags &= ~DO_DEVICE_INITIALIZING; - - if (!NT_SUCCESS(status = IoCreateSymbolicLink( - &devices[i].symlink, &devices[i].path))) - goto delete_device; - - return status; - -delete_device: - IoDeleteDevice(devices[i].object); - - return status; -} - -NTSTATUS set_up_devices(DRIVER_OBJECT *driver_object) -{ - int i, j; - NTSTATUS status = STATUS_SUCCESS; - - for (i = 0; i < NUMOF_DEVICES; ++i) - if (!NT_SUCCESS(status = set_up_device(driver_object, i))) - goto destroy_devices; - - driver_object->MajorFunction[IRP_MJ_CREATE] = device_open; - driver_object->MajorFunction[IRP_MJ_DEVICE_CONTROL] = device_ioctl; - - return status; - -destroy_devices: - for (j = 0; j < i; ++j) - destroy_device(j); - - return status; -} diff --git a/src/simple/device.h b/src/simple/device.h deleted file mode 100644 index 4f117e9..0000000 --- a/src/simple/device.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -NTSTATUS set_up_devices(DRIVER_OBJECT *); -void destroy_devices(); diff --git a/src/simple/main.c b/src/simple/main.c deleted file mode 100644 index 5148727..0000000 --- a/src/simple/main.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "device.h" - -#include - -static void on_driver_unload(DRIVER_OBJECT *driver_object) -{ - UNREFERENCED_PARAMETER(driver_object); - - DbgPrint("simple: unloading...\n"); - destroy_devices(); -} - -NTSTATUS DriverEntry( - DRIVER_OBJECT *driver_object, - UNICODE_STRING *registry_path) -{ - UNREFERENCED_PARAMETER(registry_path); - - DbgPrint("simple: loading...\n"); - driver_object->DriverUnload = on_driver_unload; - return set_up_devices(driver_object); -} diff --git a/src/simple/makefile b/src/simple/makefile deleted file mode 100644 index 5acbbd2..0000000 --- a/src/simple/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/src/simple/sources b/src/simple/sources deleted file mode 100644 index 1a5ce00..0000000 --- a/src/simple/sources +++ /dev/null @@ -1,3 +0,0 @@ -TARGETTYPE = DRIVER -TARGETNAME = simple -SOURCES = device.c main.c diff --git a/src/simple/vs12/.gitignore b/src/simple/vs12/.gitignore deleted file mode 100644 index cd42ee3..0000000 --- a/src/simple/vs12/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin/ -obj/ diff --git a/src/simple/vs12/simple.vs12.sln b/src/simple/vs12/simple.vs12.sln deleted file mode 100644 index 2b1ad11..0000000 --- a/src/simple/vs12/simple.vs12.sln +++ /dev/null @@ -1,64 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple.vs12", "simple.vs12.vcxproj", "{8251FD47-D3D6-4A5D-8DFD-84669E075DAF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win7 Debug|Win32 = Win7 Debug|Win32 - Win7 Debug|x64 = Win7 Debug|x64 - Win7 Release|Win32 = Win7 Release|Win32 - Win7 Release|x64 = Win7 Release|x64 - Win8 Debug|Win32 = Win8 Debug|Win32 - Win8 Debug|x64 = Win8 Debug|x64 - Win8 Release|Win32 = Win8 Release|Win32 - Win8 Release|x64 = Win8 Release|x64 - Win8.1 Debug|Win32 = Win8.1 Debug|Win32 - Win8.1 Debug|x64 = Win8.1 Debug|x64 - Win8.1 Release|Win32 = Win8.1 Release|Win32 - Win8.1 Release|x64 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|x64.Build.0 = Win7 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win7 Release|x64.Deploy.0 = Win7 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|x64.Build.0 = Win8 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8 Release|x64.Deploy.0 = Win8 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|Win32.Deploy.0 = Win8.1 Debug|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Debug|x64.Deploy.0 = Win8.1 Debug|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|Win32.Deploy.0 = Win8.1 Release|Win32 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF}.Win8.1 Release|x64.Deploy.0 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/simple/vs12/simple.vs12.vcxproj b/src/simple/vs12/simple.vs12.vcxproj deleted file mode 100644 index 5fee57f..0000000 --- a/src/simple/vs12/simple.vs12.vcxproj +++ /dev/null @@ -1,229 +0,0 @@ - - - - - Win8.1 Debug - Win32 - - - Win8.1 Release - Win32 - - - Win8 Debug - Win32 - - - Win8 Release - Win32 - - - Win7 Debug - Win32 - - - Win7 Release - Win32 - - - Win8.1 Debug - x64 - - - Win8.1 Release - x64 - - - Win8 Debug - x64 - - - Win8 Release - x64 - - - Win7 Debug - x64 - - - Win7 Release - x64 - - - - {8251FD47-D3D6-4A5D-8DFD-84669E075DAF} - {dd38f7fc-d7bd-488b-9242-7d8754cde80d} - v4.5 - 11.0 - Win8.1 Debug - Win32 - simple_vs12 - - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - - - - - - - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/sysenter/main.c b/src/sysenter/main.c deleted file mode 100644 index 9eb9b28..0000000 --- a/src/sysenter/main.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include - -static __int64 old_msr_value = 0; -static void *old_ki_fast_call_entry = NULL; - -static void __stdcall log_system_call() -{ - static LONG count = 0; - static const LONG throttle = 10000; - - LONG n = InterlockedIncrement(&count); - - if (n % throttle == 0) - DbgPrint("Another %ld of `sysenter`s (eax=)!\n", throttle); -} - -static void __declspec(naked) new_ki_fast_call_entry() -{ - __asm - { - pushad - pushfd - mov ecx, 0x23 - push 0x30 - pop fs - mov ds, cx - mov es, cx - call log_system_call - popfd - popad - jmp [old_ki_fast_call_entry] - } -} - -#define IA32_SYSENTER_EIP 0x176 - -static void hook_sysenter() -{ - /* - __asm - { - mov ecx, IA32_SYSENTER_EIP - rdmsr - mov old_ki_fast_call_entry, eax - mov eax, new_ki_fast_call_entry - xor edx, edx - wrmsr - } - */ - - old_msr_value = __readmsr(IA32_SYSENTER_EIP); -#pragma warning(push) -#pragma warning(disable: 4305) - old_ki_fast_call_entry = (void *) old_msr_value; -#pragma warning(pop) - __writemsr(IA32_SYSENTER_EIP, new_ki_fast_call_entry); -} - -static void unhook_sysenter() -{ - /* - __asm - { - mov ecx, IA32_SYSENTER_EIP - mov eax, old_ki_fast_call_entry - xor edx, edx - wrmsr - } - */ - - __writemsr(IA32_SYSENTER_EIP, old_msr_value); -} - -static void on_driver_unload(DRIVER_OBJECT *driver_object) -{ - KTIMER timer; - LARGE_INTEGER time_out; - - UNREFERENCED_PARAMETER(driver_object); - - unhook_sysenter(); - - KeInitializeTimer(&timer); - time_out.QuadPart = -30000000; - KeSetTimer(&timer, time_out, NULL); - - KeWaitForSingleObject(&timer, Executive, KernelMode, FALSE, NULL); -} - -NTSTATUS DriverEntry( - DRIVER_OBJECT *driver_object, - UNICODE_STRING *registry_path) -{ - UNREFERENCED_PARAMETER(registry_path); - - driver_object->DriverUnload = on_driver_unload; - hook_sysenter(); - return STATUS_SUCCESS; -} diff --git a/src/sysenter/makefile b/src/sysenter/makefile deleted file mode 100644 index 5acbbd2..0000000 --- a/src/sysenter/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/src/sysenter/sources b/src/sysenter/sources deleted file mode 100644 index d6371b3..0000000 --- a/src/sysenter/sources +++ /dev/null @@ -1,4 +0,0 @@ -TARGETTYPE = DRIVER -TARGETNAME = sysenter -SOURCES = -I386_SOURCES = main.c diff --git a/src/sysenter/vs12/.gitignore b/src/sysenter/vs12/.gitignore deleted file mode 100644 index cd42ee3..0000000 --- a/src/sysenter/vs12/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin/ -obj/ diff --git a/src/sysenter/vs12/sysenter.vs12.sln b/src/sysenter/vs12/sysenter.vs12.sln deleted file mode 100644 index ec3ab31..0000000 --- a/src/sysenter/vs12/sysenter.vs12.sln +++ /dev/null @@ -1,44 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sysenter.vs12", "sysenter.vs12.vcxproj", "{FEF249AF-C571-4F59-A72A-7226AA9F126E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win7 Debug|Win32 = Win7 Debug|Win32 - Win7 Debug|x64 = Win7 Debug|x64 - Win7 Release|Win32 = Win7 Release|Win32 - Win7 Release|x64 = Win7 Release|x64 - Win8 Debug|Win32 = Win8 Debug|Win32 - Win8 Debug|x64 = Win8 Debug|x64 - Win8 Release|Win32 = Win8 Release|Win32 - Win8 Release|x64 = Win8 Release|x64 - Win8.1 Debug|Win32 = Win8.1 Debug|Win32 - Win8.1 Debug|x64 = Win8.1 Debug|x64 - Win8.1 Release|Win32 = Win8.1 Release|Win32 - Win8.1 Release|x64 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Debug|x64.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win7 Release|x64.ActiveCfg = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8 Debug|x64.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8 Release|Win32.ActiveCfg = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8 Release|x64.ActiveCfg = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8.1 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8.1 Debug|x64.ActiveCfg = Win7 Debug|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8.1 Release|Win32.ActiveCfg = Win7 Release|Win32 - {FEF249AF-C571-4F59-A72A-7226AA9F126E}.Win8.1 Release|x64.ActiveCfg = Win7 Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/sysenter/vs12/sysenter.vs12.vcxproj b/src/sysenter/vs12/sysenter.vs12.vcxproj deleted file mode 100644 index eaba723..0000000 --- a/src/sysenter/vs12/sysenter.vs12.vcxproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Win7 Debug - Win32 - - - Win7 Release - Win32 - - - - {FEF249AF-C571-4F59-A72A-7226AA9F126E} - {dd38f7fc-d7bd-488b-9242-7d8754cde80d} - v4.5 - 11.0 - Win7 Debug - Win32 - sysenter_vs12 - - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - - - - - - - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3