{"id":30,"date":"2006-09-11T10:31:04","date_gmt":"2006-09-11T10:31:04","guid":{"rendered":"https:\/\/driverentry.com.br\/en\/2006\/09\/11\/getting-started\/"},"modified":"2026-07-24T17:23:17","modified_gmt":"2026-07-24T17:23:17","slug":"getting-started","status":"publish","type":"post","link":"https:\/\/driverentry.com.br\/en\/2006\/09\/11\/getting-started\/","title":{"rendered":"Getting Started&#8230;"},"content":{"rendered":"<div style=\"text-align: right;\"><a href=\"https:\/\/driverentry.com.br\/2006\/09\/11\/getting-started\/\"><img loading=\"lazy\" decoding=\"async\" title=\"Em Portugu\u00eas\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/br.gif\" alt=\"\" width=\"21\" height=\"19\" \/><\/a><\/div>\n<p>Let&#8217;s just stop the idle talk and get our hands dirty. Answering some requests, in this post I will take the steps to develop a minimum driver. At the end of this post, we will have a module that will be installed and loaded into the kernel without any functional purpose. I am not gonna talk yet about process context, Devices, Symbolic Links, IOCTL, IRP, DPC, ISR, FGTS, IR, or even about IPTU. I&#8217;ll talk a little about everything over time. Today we&#8217;ll just build from scratch an empty module that could eventually serve as a starting point for future experiments.<\/p>\n<p>To compile a driver for Windows, we need minimally the Windows Device Driver Kit (DDK).\u00a0The DDK can be obtained from the <a href=\"http:\/\/www.microsoft.com\/whdc\/DevTools\/ddk\/default.mspx\">Microsoft website<\/a>.\u00a0There are some alternatives to get the DDK, but the most economical of them is to opt \u00a0for downloading the ISO file.\u00a0When this post was created, the version available on the site was the &#8220;Windows Server 2003 SP1 DDK&#8221; with 230 MB.<\/p>\n<p>I do not think it&#8217;s necessary to provide each detail about the DDK installation, something like <em>&#8220;Take the mouse to the button which the text on it written NEXT and press the left mouse button&#8221;. <\/em>The default options are more than sufficient for our experiments.\u00a0If you don&#8217;t have much on disk space, change the options of <em>&#8220;Build Environments&#8221;<\/em> to be installed only Windows 2000 environments, as it appears below.\u00a0This will make the necessary space drop from 628 MB to 246 MB.\u00a0If you still have trouble installing the DDK, you might consider <a href=\"http:\/\/www.amazon.com\/PCs-Dummies-Dan-Gookin\/dp\/0470137282\/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1280582731&amp;sr=8-1\">professional help<\/a>.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/ddk_minimal.png\" alt=\"\" \/><\/div>\n<p>After installing the DDK, we have everything we need to create drivers.\u00a0Obviously, there are many other tools that make our work more comfortable, but in this post we will stay on bread and water.<\/p>\n<p>For our test, create a folder where we put the driver source (e.g. C:\\Projects\\Useless).\u00a0Inside this folder, create a text file named<em> &#8220;Useless.c&#8221;<\/em> and use your text editor from the bottom of your heart to enter the source below.\u00a0Not worth using <em>&#8220;Microsoft Word&#8221;<\/em>, but if you thought it, use the <em>&#8220;Notepad&#8221;<\/em> and <a href=\"http:\/\/www.amazon.com\/PCs-Dummies-Dan-Gookin\/dp\/0470137282\/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1280582731&amp;sr=8-1\">seek for professional help<\/a>.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: blue;\">#include<\/span> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">VOID OnDriverUnload(IN PDRIVER_OBJECT   pDriverObject);<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">\/****<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">***     DriverEntry <\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">**<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">**      That's the entry point of our driver, everything starts here,<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">**      and later it'll get confused and confused...<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">*\/<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">NTSTATUS DriverEntry(IN PDRIVER_OBJECT  pDriverObject,<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">                     IN PUNICODE_STRING pusRegistryPath)<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">{<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/-f--> If there is a debugger attached to the system,<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: green;\">\/\/      we could see the message below.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    DbgPrint(<span style=\"color: #a31515;\">\"Wow, it's really working!\\n\"<\/span>);<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/-f--> Here we inform the system that our driver can be<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: green;\">\/\/      unloaded dynamically and the callback routine that<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/      will handle the completion of all is the OnDriverUnload.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    pDriverObject->DriverUnload = OnDriverUnload;<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: green;\">\/\/-f--> Phew! We were able to get here, that deserves<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/      a success return code to the system.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: blue;\">return<\/span> STATUS_SUCCESS;<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">}<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">\/****<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">***     OnDriverUnload<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">**<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">**      Callback routine that deals with the necessary<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"><span style=\"color: green;\">**      terminations to get this driver unloaded.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\"><span style=\"color: green;\">*\/<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">VOID OnDriverUnload(IN PDRIVER_OBJECT   pDriverObject)<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">{<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/-f--> If there is a debugger attached to the system,<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: green;\">\/\/      we could see the message below.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    DbgPrint(<span style=\"color: #a31515;\">\"But now? I did nothing so far...\\n\"<\/span>);<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">}<\/pre>\n<\/div>\n<p>After doing <em>&#8220;Copy&#8221;<\/em> and <em>&#8220;Paste&#8221;<\/em> from the source above, we can notice some points.\u00a0In this example, remember saving your source file with extension <em>&#8220;.c&#8221;<\/em>; otherwise, we will have some problems in exporting our entry point.\u00a0In a few posts, I intend to demonstrate how to have <em>&#8220;.cpp&#8221;<\/em> files\u00a0and how to use object-orientation in building drivers.\u00a0Another important point to be noted is that the use of \u00a0DriverUnload callback\u00a0function is optional.\u00a0If you don&#8217;t wanna provide a callback function for the driver unload notification, just don&#8217;t do this assignment.\u00a0However, in these circumstances the driver will not be able to be unloaded.\u00a0You need this assignment even for an empty function, so that its driver is able to get turned off.\u00a0Let&#8217;s talk about this in more details later (see details in the DDK).<\/p>\n<p>It is still necessary to create files that define the project.\u00a0In the same directory as the source, create a file named <em>&#8220;makefile&#8221;<\/em> and copy the text below to it.\u00a0This file simply implements the real <em>&#8220;Makefile&#8221;<\/em> that is used to build various DDK\u00a0components.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">!INCLUDE $(NTMAKEENV)\\makefile.def<\/pre>\n<\/div>\n<p>The makefile\u00a0should never be edited.\u00a0All settings what type of driver will be compiled on, which sources will make up the driver, which libraries will be used and many other settings are specified in the file named &#8220;SOURCES&#8221; that must exist in the same directory. Its content is the one that appears below.\u00a0In conjunction with the <em>&#8220;makefile.def&#8221;<\/em> from DDK, these files create a series of macros that greatly facilitate the project file creation as a Visual Studio\u00a0<em>&#8220;.vcproj&#8221;<\/em>.\u00a0Posts about how to use Visual Studio 2005 to compile drivers are also on my list of tasks.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">TARGETNAME=Useless<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">TARGETPATH=obj<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">TARGETTYPE=DRIVER<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">SOURCES=Useless.c<\/pre>\n<\/div>\n<p>There are too many details to be discussed on a file <em>&#8220;SOURCES&#8221; <\/em>for now, let&#8217;s just limit it to know that your final binary name is defined by &#8220;TARGETNAME&#8221; variable, and the list of source code that makes up your driver should be set in &#8220;SOURCES&#8221; variables separated by space. (For more details, see it in DDK).<\/p>\n<p>At last, after having the files created, let&#8217;s compile them.\u00a0For this, we must set some environment variables to define where the libraries, headers and binaries are that will compile your sources.\u00a0Installing DDK provides a shortcut on your <em>Start Menu<\/em> that points to the file <em>&#8220;setenv.bat&#8221;<\/em>.\u00a0This shortcut opens a console window and sets up the environment to compile the driver.\u00a0You find the shortcut in <em>&#8220;Build Environments&#8221;<\/em> that was installed in your <em>Start Menu<\/em>.\u00a0Should there be a <em>&#8220;Checked&#8221;<\/em> and a\u00a0<em>&#8220;Free&#8221;<\/em> version of this shortcut.\u00a0Whereas the <em>&#8220;Checked&#8221;<\/em> version sets up the environment to generate drivers with debug information,\u00a0<em>&#8220;Free&#8221;<\/em> version sets up the environment for their final version, which is equivalent to <em>&#8220;Release&#8221;<\/em>. Selecting the <em>&#8220;Checked Build&#8221;<\/em> from <em>&#8220;Windows 2000&#8221; <\/em>menu, we\u00a0will have a Command Prompt window with the title as shown below. Follow the same image steps below to get the same results.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/buildenv.png\" alt=\"\" \/><\/div>\n<p>Launching the command <em>&#8220;build&#8221;<\/em>, we should have the following results:<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/buildenv2.png\" alt=\"\" \/><\/div>\n<p>All done now, we just need a victim, or rather, a volunteer.\u00a0It could be your cousin&#8217;s computer, a younger brother&#8217;s, an intern&#8217;s, or just anyone&#8217;s that is not bigger than you or also a person&#8217;s who can not make you lose your job.\u00a0Try not to use your own machine, we may need it later. Usually I use virtual machines; they are perfect victims.\u00a0Next, we will install our driver by the simplest way I know. We will edit some entries at the registry and restart the system.\u00a0There are some APIs and tools that register the driver and put it to work right away without restarting the system, but remember, we are just on bread and water.<\/p>\n<p>Firstly we copy the <em>&#8220;Useless.sys&#8221;<\/em> file that was generated in subfolder <em>&#8220;objchk_w2k_x86\\i386&#8221;<\/em> of\u00a0our project to the folder <em>&#8220;\\Windows\\System32\\drivers&#8221;<\/em>.\u00a0Then, using the registry editor, you need to create the\u00a0<em>&#8220;Useless&#8221;<\/em> key inside the\u00a0<em>&#8220;Services&#8221;<\/em> key of the system and put the values as shown in the figure below.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/regedit.png\" alt=\"\" \/><\/div>\n<p>These lines are the minimum for a driver in the registry.\u00a0The <em>&#8220;Type&#8221; <\/em>value\u00a0specifies a Kernel driver, the &#8220;<em>Start&#8221; <\/em>value indicates that it will be started manually and finally the <em>&#8220;ErrorControl&#8221; <\/em>value<em> <\/em>tells the system how it should behave if this driver fails in its load time (details, details and\u00a0details&#8230;).<\/p>\n<p>At this point, we have to restart the system, so that the system becomes aware of this new module.\u00a0Our driver won&#8217;t start automatically.\u00a0Once the system has restarted, go to the Console Prompt and start the driver with the command <em>&#8220;net start Useless&#8221;<\/em>. Isn&#8217;t it impressive as anything happened?\u00a0This means that the driver is doing exactly what it has been intended to do, <em>&#8220;Nothing&#8221;<\/em>. You can stop the driver using the <em>&#8220;net stop Useless&#8221; <\/em>command. If we had the debugger attached to the system, we&#8217;d have the following outputs.<\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/driverentry.com.br\/en\/wp-content\/uploads\/2026\/07\/running.png\" alt=\"\" \/><\/div>\n<p>For those who have never created a driver before and cannot see the output in WinDbg, it becomes very frustrating, because nothing happened to prove that our driver was really loaded and running in Kernel.\u00a0To give a little more action to this monotony, modify the <em>DriverEntry()<\/em> function as shown below.\u00a0Recompile the driver, replace it at the directory <em>&#8220;\\Windows\\System32\\drivers&#8221;<\/em> and finally reboot the machine.<\/p>\n<div style=\"font-family: Courier New; font-size: 9pt; color: black; background: #A4F64C; border: 1px outset; padding: 0 0 0 5px;\">\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">NTSTATUS DriverEntry(IN PDRIVER_OBJECT  pDriverObject,<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">                     IN PUNICODE_STRING pusRegistryPath)<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">{<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: green;\">\/\/-f--> Say hello to the BSOD and get used to it...<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    *(PVOID*)0x00000000 = 0;<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\"> <\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">    <span style=\"color: green;\">\/\/-f--> We wont survive to see this.<\/span><\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FFFFFF;\">    <span style=\"color: blue;\">return<\/span> STATUS_SUCCESS;<\/pre>\n<pre style=\"margin: 0px; padding: 0 0 0 5px; background: #FAFAFA;\">}<\/pre>\n<\/div>\n<p>In this case, when the driver starts, it will try to write at zero address; an exception is thrown here and we will have our first Blue Screen of Death (BSOD).\u00a0Have fun!<\/p>\n<p>I&#8217;ll try to interim posts for beginners with more advanced ones in order to try to attract the attention of both groups.\u00a0In this post we have nothing very useful, but we already have the basis for people who have never had contact with this type of development before, so they can do their first step.\u00a0Every citizen has the right to create a Blue Screen.\u00a0\ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s just stop the idle talk and get our hands dirty. Answering some requests, in this post I will take the steps to develop a minimum driver. At the end of this post, we will have a module that will be installed and loaded into the kernel without any functional purpose. I am not gonna [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":1,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":31,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/posts\/30\/revisions\/31"}],"wp:attachment":[{"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/driverentry.com.br\/en\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}