|
| 1 | +# The-Kernel-Driver-GUIDE |
| 2 | + |
1 | 3 | 
|
2 | 4 |
|
3 |
| -# The-Kernel-Driver-GUIDE. |
| 5 | +## Welcome to The Kernel Driver Guide! |
4 | 6 |
|
5 |
| -Kernal Driver Tutorial For Getting Started With Kernel Drivers |
| 7 | +Hello and welcome to this comprehensive guide. Please read through carefully to avoid any mistakes. This guide is designed to provide a straightforward walkthrough for creating a simple kernel driver for Windows. |
6 | 8 |
|
7 |
| -# Hello |
8 |
| -Hello and welcome to this GUIDE, remember to read everything carefully to not make any mistakes. |
9 |
| -This is a simple guide for getting started with Kernel Drivers. |
10 |
| -This was created to make an easy follow along guide on creating a simple kernel driver for windows. |
| 9 | +--- |
11 | 10 |
|
12 |
| -# Prerequisites |
| 11 | +## Prerequisites |
13 | 12 |
|
14 |
| -Before you begin, you will need to make sure you have the following: |
| 13 | +Before you begin, ensure that you have the following: |
15 | 14 |
|
16 |
| -- A Windows machine with Secure Boot Disabled |
17 |
| -- Windows Machine With at least 4 GB RAM |
| 15 | +- A Windows machine with Secure Boot disabled |
| 16 | +- At least 4 GB RAM on your Windows machine |
18 | 17 | - [Windows Redistributable](https://download.visualstudio.microsoft.com/download/pr/a061be25-c14a-489a-8c7c-bb72adfb3cab/4DFE83C91124CD542F4222FE2C396CABEAC617BB6F59BDCBDF89FD6F0DF0A32F/VC_redist.x64.exe)
|
19 | 18 | - [DirectX](https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe)
|
20 | 19 |
|
21 |
| -# Disabling Secure Boot |
22 |
| - |
23 |
| -- a. Restart your computer: Restart your computer and keep pressing the F2, F10, or Delete key (depending on your computer's manufacturer) until you enter the BIOS/UEFI settings. |
24 |
| - |
25 |
| -- b. Locte The Seucre Boot Feature: Once you have entered the BIOS, look for a section called "Security" or "Trusted Platform Module (TPM)". The Secure Boot setting should be within this section. If not, search for you rspecific manufacturer of motherboard. |
| 20 | +### Disabling Secure Boot |
26 | 21 |
|
27 |
| -- c. Save Settings: Once Secure Boot is disabled, save and exit BIOS and boot into windows. |
| 22 | +1. **Restart your computer:** Access the BIOS/UEFI settings by pressing F2, F10, or Delete (based on your computer's manufacturer). |
| 23 | +2. **Locate Secure Boot:** Find the Secure Boot setting in the "Security" or "Trusted Platform Module (TPM)" section. |
| 24 | +3. **Disable Secure Boot:** Save the settings and boot into Windows. |
28 | 25 |
|
29 |
| -# Additional tips for disabling Secure Boot: |
| 26 | +#### Additional Tips for Disabling Secure Boot: |
30 | 27 |
|
31 | 28 | - Back up your data before disabling Secure Boot.
|
| 29 | +- Disable Secure Boot only when necessary, such as running virtual machines or specific software. |
| 30 | +- Re-enable Secure Boot to protect your computer once done with the required tasks. |
32 | 31 |
|
33 |
| -- Disable Secure Boot only when you need to run a virtual machine or other software that requires it. |
34 |
| - |
35 |
| -- Once you have finished using the virtual machine or software that requires Secure Boot to be disabled, re-enable Secure Boot to protect your computer. |
36 |
| - |
37 |
| -# Download and Setup |
38 |
| - |
39 |
| -When we want to develop a kernel driver we first need to setup our Enviroment. |
40 |
| -We need to download a few requirements, which are listed down below: |
41 |
| - |
42 |
| - * Tip1: Remember to install "WDK" after installing Visual Studio 2022 as WDK is an extension to VS22 |
43 |
| - * Tip2: Remember to Install all Individual Components when installing Visual Studio 2022 |
44 |
| - |
45 |
| -Step 1: Install Visual Studio 2022 Link: https://visualstudio.microsoft.com/downloads/ |
46 |
| - |
47 |
| -Step 2: Install SDK Link: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ |
48 |
| - |
49 |
| -Step 3: Install WDK Link: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk |
50 |
| - |
51 |
| -- a1. Follow This Tutorial For Installing Windows Driver Kit if the tutorial above is outdated: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk |
52 |
| -- a2. When installing components for Visual Studio 2022 need to select "Desktop development with C++" with these individual components: |
53 |
| - |
54 |
| - - C++ ATL for latest v143 build tools with Spectre Mitigations (ARM64/ARM64EC) |
55 |
| - - C++ ATL for latest v143 build tools with Spectre Mitigations (x86 & x86) |
56 |
| - - C++ MFC for latest v143 build tools with Spectre Mitigations (ARM64/ARM64EC) |
57 |
| - - MSVC v143 - VS 2022 C++ ARM64/ARM64EC Spectre-mitigated libs (Latest) |
58 |
| - - MSVC v143 - VS 2022 C++ x64/x86 Spectre-mitigated libs (Latest) |
59 |
| - |
60 |
| -- **Installing Debug View** |
61 |
| -- * Download Debug View from this direct link: https://download.sysinternals.com/files/DebugView.zip |
62 |
| - * Or go here: https://learn.microsoft.com/en-us/sysinternals/downloads/debugview |
63 |
| - |
64 |
| - |
65 |
| -# Visual Studio 2022 Project Setup |
66 |
| - - 1 Create a new kernel mode driver project in Visual Studio. ( Kernel Mode Driver, Empty (KMDF). |
67 |
| - |
68 |
| -  |
69 |
| - |
| 32 | +--- |
70 | 33 |
|
| 34 | +## Download and Setup |
71 | 35 |
|
| 36 | +To develop a kernel driver, set up your environment by downloading the following requirements: |
72 | 37 |
|
73 |
| - Right click on the project |
74 |
| - |
75 |
| -  |
76 |
| - |
77 |
| - - 2 Activate "Use Local Time" and Enable Active(Release) |
78 |
| - |
79 |
| -  |
| 38 | +1. **Install Visual Studio 2022:** [Download Link](https://visualstudio.microsoft.com/downloads/) |
| 39 | +2. **Install Windows SDK:** [Download Link](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) |
| 40 | +3. **Install Windows Driver Kit (WDK):** [Download Link](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) |
80 | 41 |
|
81 |
| - - 3 Navigate to "Linker" -> "Command Line" and write |
| 42 | +- Follow [this tutorial](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) if the above WDK link is outdated. |
| 43 | +- When installing components for Visual Studio 2022, select "Desktop development with C++" and specific individual components as listed in the guide. |
82 | 44 |
|
83 |
| - "/INTEGRITYCHECK" |
| 45 | +#### Installing Debug View |
84 | 46 |
|
85 |
| - - 4 Add A Class |
| 47 | +- Download Debug View: [Direct Link](https://download.sysinternals.com/files/DebugView.zip) or [Sysinternals Website](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) |
86 | 48 |
|
87 |
| - Tip: Name this the same name as the project |
88 |
| - |
89 |
| - Right Click on Properties -> Hover on Add -> Click On Class |
90 |
| -  |
| 49 | +--- |
91 | 50 |
|
92 |
| - |
93 |
| -# Creating And Running The Driver ( Using Debug View ) |
| 51 | +## Visual Studio 2022 Project Setup |
94 | 52 |
|
95 |
| -- 2 Add a new header file named "messages.h" ( In the Header Files Folder ). |
96 |
| -- 3 Define a function called debug_message that takes a string and some extra parameters. |
97 |
| -  |
| 53 | +1. **Create a new kernel mode driver project:** Choose "Kernel Mode Driver, Empty (KMDF)" in Visual Studio. |
| 54 | + - Right-click on the project. |
| 55 | + - Activate "Use Local Time" and Enable Active(Release). |
| 56 | + - Navigate to "Linker" -> "Command Line" and add "/INTEGRITYCHECK". |
| 57 | + - Add a class with the same name as the project. |
98 | 58 |
|
99 |
| - |
100 |
| -- 4 Include the "messages.h" header file in your source file. |
| 59 | +--- |
101 | 60 |
|
102 |
| -  |
| 61 | +## Creating and Running the Driver (Using Debug View) |
103 | 62 |
|
104 |
| -- 5.1 Create a function called driver_entry that takes a PDRIVER_OBJECT and a PUNICODE_STRING. |
105 |
| -- 5.2 Create a function called unload_driver that takes a PDRIVER_OBJECT. |
106 |
| -- 5.3 Call the debug_message function to print a message when the driver starts and stops. |
107 |
| -  |
| 63 | +1. **Add a new header file:** Name it "messages.h" in the Header Files folder. |
| 64 | +2. **Define a function:** Create a function called `debug_message` that takes a string and extra parameters. |
| 65 | +3. **Include the header file:** Add "messages.h" in your source file. |
| 66 | +4. **Create functions:** |
| 67 | + - `driver_entry` that takes a `PDRIVER_OBJECT` and a `PUNICODE_STRING`. |
| 68 | + - `unload_driver` that takes a `PDRIVER_OBJECT`. |
| 69 | + - Call `debug_message` to print a message when the driver starts and stops. |
| 70 | +5. **Compile the driver.** |
108 | 71 |
|
109 |
| -- 8 Compile the driver. |
| 72 | +--- |
110 | 73 |
|
111 |
| -- 9 Set Kernal driver Bin Path using sc create command. |
112 |
| - tip: Assuming you have the project on C drive, just replace the "computer name" with your actual computer name, and "KernalReadWriteDriver.sys" With the name if your .sys file. |
| 74 | +## Setting Up Kernel Driver (Using `sc create` command) |
113 | 75 |
|
114 |
| - sc create KernelReadWriteDriver type= Kernel Binpath="C:\Users\computer name\source\repos\KernelReadWriteDriver\x64\Release\KernelReadWriteDriver.sys" |
115 |
| - |
116 |
| -- 10 Enable test signing |
117 |
| - Using the cmd enable testsigning with the following command: |
| 76 | +1. **Set Kernel driver Bin Path:** Use `sc create` command. |
| 77 | + - Replace "computer name" with your actual computer name and "KernelReadWriteDriver.sys" with your .sys file name. |
118 | 78 |
|
119 |
| - bcdedit /set testsigning on |
| 79 | + ```bash |
| 80 | + sc create KernelReadWriteDriver type= Kernel Binpath="C:\Users\computer name\source\repos\KernelReadWriteDriver\x64\Release\KernelReadWriteDriver.sys" |
| 81 | + ``` |
120 | 82 |
|
121 |
| -- 11 Start DebugView in ADMIN mode |
122 |
| - |
123 |
| -- 12 Enable Capture Kernel In Debug View |
124 |
| -  |
| 83 | +2. **Enable test signing:** Use the command: |
| 84 | + ```bash |
| 85 | + bcdedit /set testsigning on |
| 86 | + ``` |
125 | 87 |
|
126 |
| -- 13.1 Load the driver using the sc command. |
127 |
| - Without the quotation marks and with the name of your kernel driver |
| 88 | +3. **Start DebugView in ADMIN mode.** |
| 89 | +4. **Enable Capture Kernel In Debug View.** |
128 | 90 |
|
129 |
| - sc start "kernel driver name" |
| 91 | +5. **Load the driver using the sc command:** |
| 92 | + ```bash |
| 93 | + sc start "kernel driver name" |
| 94 | + ``` |
130 | 95 |
|
131 |
| -- 13.2 If you get an error when trying to start |
132 |
| - If you get an error when trying to start the service, try to enter this in to ADMIN cmd and restart. |
133 |
| - |
134 |
| - bcdedit /set nointegritychecks on |
| 96 | +6. **If you encounter an error:** |
| 97 | + - Run the following command in ADMIN cmd and restart: |
| 98 | + ```bash |
| 99 | + bcdedit /set nointegritychecks on |
| 100 | + ``` |
135 | 101 |
|
136 |
| -- 14 Stop the driver using the sc command. |
137 |
| - Without the quotation marks and with the name of your kernel driver |
| 102 | +7. **Stop the driver using the sc command:** |
| 103 | + ```bash |
| 104 | + sc stop "kernel driver name" |
| 105 | + ``` |
138 | 106 |
|
139 |
| - sc stop "kernel driver name" |
| 107 | +--- |
140 | 108 |
|
| 109 | +## Congratulations! |
141 | 110 |
|
142 | 111 | Congratulations on completing The-Kernel-Driver-Tutorial! You've successfully set up your development environment, disabled Secure Boot, and created a simple kernel driver for Windows.
|
143 | 112 |
|
144 |
| -# Cheat Table Content for Assaulted Cube Process |
145 | 113 | ---
|
146 | 114 |
|
147 |
| -- * Cheat Entries Can be found in this md [cheat-entries.md](cheat-entries.md) or from downloading the [assaultcube.CT](assaultcube.CT) file, and running with cheat engine whilst running the [game](https://github.com/assaultcube/AC/releases/tag/v1.3.0.2). |
| 115 | +## Cheat Table Content for Assaulted Cube Process |
148 | 116 |
|
149 |
| -Honerable mention of resouces and explenation videos / good to know sources: |
| 117 | +- Cheat entries can be found in [cheat-entries.md](cheat-entries.md) or by downloading the [assaultcube.CT](assaultcube.CT) file. Run it with Cheat Engine while playing the [game](https://github.com/assaultcube/AC/releases/tag/v1.3.0.2). |
150 | 118 |
|
151 |
| -https://www.youtube.com/watch?v=6TBQ7lWYQ0g |
152 |
| - |
153 |
| -https://www.youtube.com/watch?v=EaxaQYESDlM |
154 |
| - |
155 |
| -https://www.youtube.com/watch?v=KzD_nc5B_8w |
| 119 | +--- |
156 | 120 |
|
157 |
| -https://www.youtube.com/watch?v=eumG222Efzs |
| 121 | +## Honorable Mentions |
158 | 122 |
|
159 |
| -https://www.youtube.com/watch?v=8oC0w6WhZ1E |
| 123 | +Special thanks to the following resources and explanation videos: |
160 | 124 |
|
| 125 | +- [Video 1](https://www.youtube.com/watch?v=6TBQ7lWYQ0g) |
| 126 | +- [Video 2](https://www.youtube.com/watch?v=EaxaQYESDlM) |
| 127 | +- [Video 3](https://www.youtube.com/watch?v=KzD_nc5B_8w) |
| 128 | +- [Video 4](https://www.youtube.com/watch?v=eumG222Efzs) |
| 129 | +- [Video 5](https://www.youtube.com/watch?v=8oC0w6WhZ1E) |
0 commit comments