diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-08-30 11:51:46 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-08-31 08:13:07 +0200 |
commit | c4c97962ac44c35623604add7acc5eca9fd3506a (patch) | |
tree | 48709a662f5c07e7ab64025782a0b84e296ea23a |
initial commitmain
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | driver.cpp | 22 |
3 files changed, 53 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c83210b --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +ifndef DPP_ROOT +$(error DPP_ROOT is undefined) +endif + +include $(DPP_ROOT)/Makefile.inc + +DRIVER_NAME = driver +DRIVER_OBJECTS = $(DRIVER_NAME).o +DRIVER_TARGET = $(DRIVER_NAME).sys + +all: $(DRIVER_TARGET) + +clean: + rm -f $(DRIVER_OBJECTS) $(DRIVER_TARGET) + +%.o: %.cpp + $(call BUILD_CPP_OBJECT,$<,$@) + +$(DRIVER_TARGET): $(DRIVER_OBJECTS) + $(call LINK_CPP_KERNEL_TARGET,$(DRIVER_OBJECTS),$@) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8bc4580 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Mingw64 C++ Driver Example + +An example ready to use together with [mingw-w64-dpp](https://github.com/utoni/mingw-w64-dpp). + +You can lookup the documentation there. + +For TLDR folks: + +```shell +make DPP_ROOT="[path-to-mingw-w64-ddk-template-dir]" all +``` diff --git a/driver.cpp b/driver.cpp new file mode 100644 index 0000000..69c82ff --- /dev/null +++ b/driver.cpp @@ -0,0 +1,22 @@ +#include <ntddk.h> + +extern "C" { +DRIVER_INITIALIZE DriverEntry; +DRIVER_UNLOAD DriverUnload; + +NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, + _In_ PUNICODE_STRING RegistryPath) { + UNREFERENCED_PARAMETER(DriverObject); + UNREFERENCED_PARAMETER(RegistryPath); + + DbgPrint("%s\n", "Hello ring0!"); + + return STATUS_SUCCESS; +} + +VOID DriverUnload(_In_ struct _DRIVER_OBJECT *DriverObject) { + UNREFERENCED_PARAMETER(DriverObject); + + DbgPrint("%s\n", "Bye ring0!"); +} +} |