Directly construct the NT kmode drive sequence in visualstudio98

Source: Internet
Author: User

 

Directly construct the NT kmode drive sequence in visualstudio98

Shen Yandi Rui Computing Technology Limited Company
Jiang zongwen

---- Microsoft visualstudio98 is a great environment for C and C ++ programming, among them, there are a few of my skills (Xiangxin is also a broad C and C ++ programmers). Don't like it: The color sentence method sensitivity, source code preview, class and file overview, direct fixed-bit syntax errors, etc.

---- However, this is a good tool, but it makes a lot of NT kmode drive, the start of the thread is not often angry, because for her (HE) and can not directly use vs98. MS provided for a history of difficult to use the command line build! It cannot be said that the last line of incomplete, which was born during the build operation, was a mess of amazing minds, the most annoying thing is to correct the error and check the meaning and definitions of the number of letters.

---- Actually, build also uses the compiler and concatenation tool similar to vs to slightly define, we can wake up from the evil dream.

---- 1. Create a kmode project:

---- Select file/New from vs98, and generate a new Win32 dynamic-Link Library item.

---- 2. Change the all tolerations option:

---- Select project/settings/all deployments and go to the C/C ++ tag. Change the settings as follows:

2.1 remove enable Exception Handling in category "C/C ++ language. 2.2 In category "code generation", set calling convention to _ stdcall, and struct member alignment to 8-bytes. 2.3 In category "precompiled headers", set "not using... ". 2.4 In category "Preprocessor", enter the definition _ x86 _ = 1, i386 = 1, std_call = 1, condition_handling = 1, win32_lean_and_mean = 1, nt_up = 1, nt_inst = 0, win32 = 100, _ nt1x _ = 100, winnt = 1, _ win32_winnt = 0x0400, devl = 1, ndebug, _ DLL = 1, _ idwbuild, DBCS, PRC, kkbugfix, dbcs_vert, fe_sb. add the include Directory D:/DDK/Inc. (If the setting is different when you install DDK, write your setting value ). go to the link tag and customize it as follows: 2.5 remove Generate debug info from category "general" and select ignore all default libaries and doesn't produce. lib. add the library you want to connect to in object/library modules, which is generally int64.lib ntoskrnl. lib Hal. lib. 2.6 remove the program database check box in category "Custom. 2.7 set entry-point symbol to DriverEntry @ 8 in category "output. go to the resource tag, add D:/DDK/INC to the include directory, and define the symbol _ x86 _ = 1, i386 = 1, std_call, condition_handling = 1, nt_up = 1, nt_inst = 0, Win32 = 100, _ nt1x _ = 100, winnt = 1, _ win32_winnt = 0x0400, win32_lean_and_mean = 1, devl = 1, ndebug, _ DLL = 1, _ idwbuild, DBCS, PRC, kkbugfix, dbcs_vert, fe_sb.

---- 3. Specify the Win32 debug option (checked build ):

---- Select project/settings/Win32 debug and go to the C/C ++ tag, as shown below:

3.1 in category "General", select debug info as C7 compatible. add the dbg = 1, FPO = 0, rdrdbg, and srvdbg symbols before the symbols in Preprocessor definitions. add the three compilation options/GF/qifdiv-/QIF at the end of project options. go to the link tag and customize it as follows: 3.2 set the output file to debug/mydriver in category "General. sys (the SYS file you want to generate ). add/libpath: "D:/DDK/lib/i386/checked"/subsystem: Native at the end of project options. go to the resource tag and add the following symbols to define dbg = 1, FPO = 0, rdrdbg, and srvdbg.

---- We regret that we cannot adjust the kmode drive sequence from vs. This is only a good change to Ms, but we can only use windbg. it's slow. We cannot use the selected item just created to connect it. sys File debugging, because it is the/debug: full and/debugtype: both options used for windbg connection, if vs98 is not the same, the support is two (you can try it ). A solution is to delete the file after the connection is complete. sys File, hand workers (from the command line) transport line link, that more sweeping Xing which. in reality, VS can execute some life-saving orders after the connection is completed, you only need to go to the post-build step tag settings. I set it like this:

link /nologo @mydriver.lnkrebase -b 0x10000 -x Debug Debug/mydriver.sysif exist Debug/mydriver.dbg del /f Debug/mydriver.dbgmove Debug/sys/mydriver.dbg Debugrd Debug/sys

---- Production debugging test file mydriver. dbg, you can remember to copy the shells to the WINNT/symbols/sys directory of the commissioning and control system. mydriver. lnk is a link command file, as shown in the following figure:

-machine:i386-MERGE:_PAGE=PAGE -MERGE:_TEXT=.text -SECTION:INIT,d -OPT:REF -INCREMENTAL:NO -FORCE:MULTIPLE -RELEASE -FULLBUILD -IGNORE:4001,4037,4039,4065,4070,4078,4087,4089,4096 -NODEFAULTLIB -debug:notmapped,FULL -debugtype:both -version:4.00 -osversion:4.00 -PDB:NONE -MERGE:.rdata=.text -optidata -driver -align:0x20 -subsystem:native,4.00 -base:0x10000 -entry:DriverEntry@8 -out:Debug/mydriver.sys Debug/mydriver.res Debug/mydrv1.obj Debug/mydrv2.obj D:/DDK/lib/i386/checked/int64.lib D:/DDK/lib/i386/checked/ntoskrnl.lib D:/DDK/lib/i386/checked/hal.lib 

---- This long string of commands is from build. log to paste. Are there any doubts that can be found in the join machine book.

---- Now, the big part has been self-driven. If it is not possible, it is necessary to add a source file. add a line to the lnk file. OBJ, but in the world there are not many things as intended, and there is no such thing. well, you won't add source files frequently.

---- 4. Set the Win32 release option (Free Build.

---- Select project/settings/Win32 release and go to the C/C ++ tag, as shown below:

4.1 In category "General", select debug info as none. add FPO = 1 to the symbols in Preprocessor definitions. then select the optimization method you like. go to the link tag. The customization is as follows: 4.2 set the output file as relase/mydriver in category "General. SYS. add/libpath: "D:/DDK/lib/i386/free"/subsystem: Native at the end of project options. go to the resource tag and add the symbol definition FPO = 1.

---- Well, set it. after adding your source file to the project, you can press F7, the tool vs98 will be used to develop a quick and convenient sense of the kmode drive thread sequence. It is similar to build.

---- In this article, some internal parameters are taken into account in the msdn chapter "the Windows NT kernel-mode driver cookbook, featuring visual c ++. asche), but the main part is my own work experience, hope to help you.

 

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.