cwindowsdriver

How to program kernel drivers for windows without visual studio?


Everytime I see a driver tutorial I see they use visual studio, I was just wondering if it is absolutely required to install it in order to develop windows drivers?

Say for example I would like to compile the following driver: (source)

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)    
{
        DbgPrint("Hello World\n");  
        return STATUS_SUCCESS;
}  

How would I be able to compile/link it without visual studio? I have searched all over the place.


Solution

  • after so many years I found the solution, just use mingw: https://stackoverflow.com/a/79589883/10000823

    Indeed the only problem was getting the headers to work, fortunately if you look for headers in github you have way way way many headers now, from wine,reactos, nt clones, just copy it, fix the errors, and you don't need that MSVC crap.

    it "werks" (for definition of working you must still declare every function you want to manually use, so it is a little bit of work).

    But to answer the question: Get the wdk declarations somehow, compile with gcc. then link like this

    gcc -m64 -nostartfiles -Wl,--subsystem,native -Wl,--entry,DriverEntry -o driver.sys driver.o -lntoskrnl
    

    assuming you've compiled the driver to driver.o as object.