Windows Driver Development Foundation, reprint marked Source: http://blog.csdn.net/ikerpeng/article/details/38793995
Let's talk about how to compile the driver after it's developed. Generally there are several ways to do this:
1. Create makefile file, compile and link with NMAKE tool;
2. Build makefile,sources, dirs file, compile with build tool.
3. Compile the link with the integrated development environment.
I used the third way to configure the Windows Driver development environment through VS2010+WDK. Address: http://blog.csdn.net/ikerpeng/article/details/38761441
But the next thing to say is part of the reason for that configuration:
There are 4 calling conventions in the process of compiling a function: C language calling convention: function is decorated with _cdecl; standard calling convention: function is decorated with _stdcall; fast calling convention: function is decorated with _fastcall; C + + class member function calling convention: function is decorated with thiscall.
The first two of them are often used. In the C language calling convention, a symbol is produced in the target file in place of the function: Underscore + function name, while the standard calling convention is in the form of an underscore + the name +@x, and X is returned. where x represents the number needed to clean up the stack. For example:
The Windows driver needs to use the standard calling convention, and for the DriverEntry function, the system will look for [email protected] as the driver's entry, but the VS2010 default is the C language calling convention. So there is only _driverentry, so the call will go wrong. So you set the call in C + + to the _stdcall adornment.
Tips:
1. Many of the C/C + + usage techniques are used with caution, and even the malloc function in the language and the new operation in the + C are not used. Because in kernel mode, the program cannot invoke the following API in user mode.
2. Finally an debug driver can be used: DbgView, install the driver can use Drivermonitor.
The end of this section.
Reference books:
A detailed description of the Windows Driver Development technology
Windows Driver Development Fundamentals (iv) driver compilation debugging and Installation