VC6 Compiler-driven approach (includes 32 and 64 bits)

Source: Internet
Author: User
Tags win32

Compiled using the system's own build command

Later found that the Windows Drive development technology in the detailed explanation that the VC6 can be compiled, has been operating to the end, a compilation incredibly found no compile through, so in the online Google, found someone else's method, see the middle of the steps to find the problem came, the book is to take Win2K DDK do examples, But the DDK of the installed XP is compile has the problem, dizzy, the problem is where? That is, directories's executable files should be added to the bin/x86 directory of XP DDK, or the lower version will not compile, There is no hint in the book. After the addition, the compiler succeeded.

VC6 Compiler-driven approach (includes 32 and 64 bits)

Http://blog.csdn.net/linuxpgy/archive/2008/05/11/2434572.aspx VC6 is just an IDE that makes it easy to invoke compilers, linker, header files, library files, if edited and compiled drivers can be integrated together , which can improve development efficiency. For ordinary Win32 applications, the VC6 is supported by default, and the Project Wizard is not well set for the driver. In fact, the driver is a sys, is written in C language, so the compiler is not a problem in theory, but in the actual operation of a little trouble. Here is a description of the various platforms compiled SYS-driven methods (including 64-bit platform) First look at the 32-bit version-driven compilation method, first you have to prepare some compiler prerequisites: 1. To install VC6 2. Install DDK. This question is actually very simple, just a lot of people do not understand, install DDK of course is the newer the better, the more new support platform, like 2000DDK you are absolutely not compiled 64-bit SYS, because it does not have 64-bit library and compiler, so we choose now the most newer, 2003DDK (WDK is also possible), support a lot of platforms, amd64,ia64,2000,xp,2003 support. OK, this is our system has installed the most powerful development tools VC6, the latest DDK, in VC compile the driver of each platform is no problem. To begin with, assuming that our DDK is installed in the C:/2003DDK directory, then I will find that there are a number of driver examples (select all when installing), and we choose C:/2003DDK/SRC/WDM/USB/BULKUSB as our experimental example. The first step: Open VC, set up a WIN32 application project, and then choose an empty project (I use the English version of VC, I suggest you also replace the English version), meaning is to establish an empty Win32 project, project name is called BULKUSB, Dot finish. Step Two: Will C:/2003ddk/src/wdm/usb/bulkusb/sys (here is the driver code, the other EXE is the user program, regardless of it) all the files in the copy to the BULKUSB engineering directory. Then import the. h,.c,.rc into the corresponding directory in VC. Step three: Then start setting up the engineering options and compile the code into sys. To compile we need to DDK, so first in VC tool->options->directories set some path to VC call (set the basic principle: to ensure that all the following settings of the pathin front of the line)。 Set include path: C:/2003ddk/inc c:/2003ddk/inc/crt c:/2003ddk/inc/wnet c:/2003ddk/inc/ddk/wnet c:/2003ddk/inc/ddk/wdm/ WNET to be added in this order. Notice the WNET catalogue here. This is the 2003 of the latest header file, in fact, choose WXP or W2K directory is also possible, but the first file in WNET is the most complete, because the system continues to progress, some new APIs only new header file to be defined. Of course, it is best to choose the corresponding header file to compile the driver of the corresponding system, but I have tried to use the WNET compiled driver can be used at 2000, because we generally do not use the new API added. Set LIB path: C:/2003ddk/lib c:/2003ddk/lib/crt/i386 c:/2003ddk/lib/wnet/i386//wnet the same as above set executable FILE:C:/2003DDK /bin/x86//This is the compiler path, including the Cl.exe,link.exe directory, because we want to compile the 32-bit driver, so add this to the first item. In general, as long as you set up include,lib and compilers, compile what files are OK, you can also try to install the latest 2003SDK, compile Win32 application into 64-bit. The fourth step: begin to enter the project setting, set up C + + First, enter the following string in Preprocesser definitions: Release Enter: _x86_=1,i386=1,std_call,win32=100,_win32_ Winnt=0x0501,winver=0x0501,ndebug Debug Input: _x86_=1,i386=1,std_call,win32=100,_win32_winnt=0x0501,winver=0x0501, _DEBUG in the code generation calling convention with __stdcall, (this is the driver must) the DEBUG edition has a special compilation option /gz (Note is uppercase, lowercase do not delete.) Delete, otherwise there is a link error, CHKESP link does not have anything. Step Fifth: Start setting up the link page, change the output file name to the SYS extension, and, in general's object/library modules, fill in the several lib:ntoskrnl.lib that are called by the driver Hal.lib Usbd.lib Wmilib.lib. Then enter output in Entry-point symbol: Fill driverentry The following is to manually add some link options to project options, copy the following:/machine:ix86/driver/subsystem: native/section:init,d/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221 Delete the following options:/subsystem:windows/ Machine represents the target machine type,/driver represents the drive, and/subsystem:native is also representative of the drive. OK, we're done, we can compile the 32-bit driver. So what if we're going to compile 64-bit drivers. Here you notice, 64-bit has two kinds, one is AMD64, one is IA64, to select your target platform, the current AMD64 platform is most popular. In fact, compiled into 64-bit is also very simple, as long as the 32-bit configuration slightly modified on the line, we have to compile AMD64 bit drive for example (you will copy the VC project configurations bar, the 32-bit relase, Debug each copy a name renamed ReleaseAMD64 and DebugAMD64, and then modified on the basis of replicas: 1. To modify two LIB paths: c:/2003ddk/lib/crt/i386 to: c:/2003ddk/lib/crt/ AMD64 c:/2003ddk/lib/wnet/i386 changed to: C:/2003DDK/LIB/WNET/AMD64 2. Modify the compiler path: c:/2003ddk/bin/x86 to: c:/2003ddk/bin/win64/ X86/AMD64 c:/2003ddk/bin/x86         //This sentence also must exist 3. To modify C + + In the Preprocesser definitions: ReleaseAMD64 underInput: _amd64_,amd64,std_call,win32=100,_win32_winnt=0x0501,winver=0x0501,ndebug DebugAMD64 Input: _amd64_,amd64,std_ Call,win32=100,_win32_winnt=0x0501,winver=0x0501,_debug 4. You need to modify the project Options in the link page and manually change it: Change the/machine:ix86 to:/ Machine:amd64 5. In theory it's OK to set up here, but there is a link error unresolved external symbol __security_cookie, just add in the link lib BufferoverflowK.lib (why is bufferoverflowK.lib.) Look here: http://support.microsoft.com/kb/894573) is OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.