Compile WDM driver with VC ++ 6.0

xiaoxiao2021-03-14  198

Compile WDM driver with VC 6.0

Author: Arthur Tu September 28, 2003 Sunday Title: VC 6.0 to compile with WDM drivers (limited to 2K DDK) Version 1.02, if posted, be sure to add the following: *************** ************************ author: Arthur Tu source: drive open source www.driverdevelop.com ************ ************************** content: Use VC 6.0 to edit (not compiled) Driver's source file is very good choice, especially Match Visual Assist is more convenient. The editor is over, it is more convenient in VC . I have a reference for the Site, the DSW generated by the DS, and the log file generated by the Build. In fact, the M $ site is to change the VC's setting based on the build's log file. Me TOO;) is limited to 2k DDK because XP DDK and 2003 DDK do not require VC 6.0. And when I use VC6 to Build, I will tell you "Compiler Version Not Supported by Windows DDK", but there is no further try. DDK has a link, 98, 2k DDK seems to be VC5, if you do this, actually use VC6's LINK. Don't consider Source, Dir, make files. The DDK's build is actually an called NMAKE tool, while NMAKE wants to adjust the corresponding files such as CL.EXE, LINK.EXE, and so on. CL option setting, mainly pay attention to the DDK's include path problem, the LINK option is to let Link go to Link out of a SYS instead of EXE, huh, huh, huh, huh, huh, (呵, nonsense). The directory name is best not to bring a space. 2. Create a Workspace to add files such as C, H, RC. 3, configurations, add Checked, Free, don't debug, Release (in fact, this is not necessary, checked, debug, see how you call it). The rest is to change the settings, so that the VC has an SYS file for you Build. Let's come one by one. All changes are all under Project-> Setting. Mainly concentrated under C / C and Link.

1, General, in place, NOT USING MFC; 2, Debug, Nothing can be changed; 3, C / C : 1.1 general: 3.1.1 Warning Level, use Level3, drive, stable overwhelming, and DDK Sample is Warning 3, Warnings as errors selection; 3.1.2 Optimizations, for Checked, I am disable (debug), the province's use of Softice, there will be variables that Watch can't say, for Free, I am Customize, will tell later , 3.1.3 Debug Info, Free, you have to be your business, Checked, I use C7; VC default Program Database for "Edit & Continue", and Link / Driver option conflict; 3.1 .4 preprocessor definitions, some I have not figured out, some may be DS, probably talking. Here is my DSW. RDRDBG, SRVDBG, FPO = 0, WIN32 = 100, STD_CALL, CONDition_Handling = 1, NT_UP = 1, NT_INST = 0, _NT1X_ = 100, WinNT = 1, _WIN32_WINNT = 0x0400, Win32_Lean_and_mean = 1, DEVL = 1, _dll = 1, _X86_ = 1, $ (CPU) = 1, NTVersion = 'WDM', Winver = 0x500, NTDebug = NTSD, DBG = 1std_call does not have to say, Driver's function is __stdcall, in fact, there is setting in other places. Winver = 0x500 is because you are for 2k. XP is 0x501, but it is useless, anyway, it can't use VC6. _X86_ = 1, no words, hey. The CPU, etc., etc. are not this value. If DBG, Free, do not define, or 0. FPO, Checked is 0, Free of 1. I think I should refer to Fram-Pointer Omission, NTDEBUG = Checked? NTSD: NTSDNodeBugwin32_lean_and_mean, Exclude Rarely-UseTUFF from Windows Headers, Non-MFC, with this to reduce Build's time. There are no relationships, do not affect other good;) NT_UP, 0 represented is MP, multiprocessor, 1 means you are in single processors. NT_INST, SET to TURN ON INSTRUMENTATION According to Driver type, you may also add other PreProcessor Definitions, such as NDIS, NDIS50, NDIS_MINIPORT_DRIVER, NDIS50_MINIPORT.

3.1.5 Project Options You only need to add a few more, including / qifdiv- / qif / qi0f, can be found on the MSDN. It is worth mentioning that the debug setting of the Workspace generated by the VC. The default has a GZ option, Catch Release-Build Errors in Debug Build, it will be said when compiled, Error LNK2001: Unresolved External Symbol __chkesp, it will be fine. 1.2 C Language doesn't say anything, don't rtti, Exception handling looks out if you use it. 1.3 Code Generation Use __stdcall with __stdcall, no matter (remember STD_CALL); 1.4 Customize is nothing to say, I usually function-level linking, because adding GF options, Eliminate Duplicate strings, I will not choose. 1.5 Listing files can be said to Listing File Type. If you want to see the assembly code, you can change here; 1.6 Optimizations Checked is naturally disable, free, I chosen is Full Optimization and Frame_Popinter OMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIMIZATION, and ONLY __INLINE, in fact, this is personal; 1.7 precompiled headers This is not Say, look at MSDN, defaults; 1.8 Preprocessor Preprocessor Definition Some Expedition, Head In Additional Include Directories, $ (BASEDIR) IncDDKWDM, $ (Basedir) IncDDK, $ (Basedir) Inc, $ (basedir) incwin98 , .... INC, this is my DSW, so the basedir's environment variable should be set, I will use the DS tool to START VC, it happens to be set, of course you can write directly The installation path of your DDK. Can't find the include path, will trigger a lot of errors, such as WDM.H has an error. . .

It is a question that many people ask questions; 4, ok, turn to link 4.1 General Select Ignore All Default Libraries, you can choose Generate Map File, the map file is sometimes useful; Checked is of course to select Generate Debug Info, Link Incrementally is not selected; Objects / library modules, add WDM.Lib, etc., ntoskrnl.lib seems to output some functions such as sprintf, strcat (Note 1), according to Driver may still have other, such as ndis.lib; don't forget Output file name is changed to YourName.sys, not Yourname.exe;) 4.2 Debug To change, select Debug Info, I am choosing Both Formats; 4. One of the INPUT, Additional Lib Path, $ (Basedir LIBCHKI386, this is my DSW, Checked fills the path of Checked Lib, Free Fill Freelib's path 4.4 Output In Entry-Point Symbol, fill in DRIVERENTRY, or _DRIVEENTRY @ 8, the same; according to LINK output, Base Address should fill in 0x10000, Stack, Reserve should be filled with 0x40000, Commit Fill in 0x1000; Version Info, fill yourself; 4.5 Project Options, focus, many options To add them directly here. To add include: / machine: ix86, CPU-related / debug: Full, / debugty: Both According to the M $ site, in order to make Windbg to find your Symbol, these two are all, but also separately Linker is coming to Link once, VC does not recognize / debug: Full, Free doesn't have this problem. According to M $ method, you can write a LNK file, in Post-build step, then Link once, add link @ YourLnk.lnk, this LNK file, you can extract from the log file, if you don't need to use, it doesn't matter; / Driver, Use this linker option to build a Windows NT Kernel Mode Driver, MSDN said / Ignore: 4001, 4037, 4039, 4065, 4070, 4078, 4087, 4089, 4096, 4210 Check MSDN / MERGE: _PAGE = Page / Merge : _Text = .text / section: init, d, Driverentry can be placed in init section. / Fullbuild / release, add checksum / force: multiple / opt: ref / opt: ICF / align: 0x20 /osVersion: ICF / ALIGN: 0X20 / OPT: ICF / ALIGN: 0X20 / OPT: ICF / Align: 0x20 / Option: NATIVE: NATIVE and / DRIVER do not want to miss.

转载请注明原文地址:https://www.9cbs.com/read-129294.html

New Post(0)