能力值:
( LV8,RANK:130 )
2 楼
脱离编译器。。。 向lz鞠躬
能力值:
( LV2,RANK:10 )
3 楼
不好意思,说错了,我是指脱离VC等IDE的,
我是想问,如何用CL LINK 等命令行工具来手工编译
能力值:
( LV6,RANK:90 )
4 楼
ddk===>build
能力值:
( LV8,RANK:130 )
5 楼
DDK有 Windows XX(2K/XP/2K3 etc) YYY(Checked/Free) Build Environment
能力值:
( LV8,RANK:130 )
6 楼
写好了makefile然后进build environment然后输入build
能力值:
( LV12,RANK:1010 )
7 楼
还有个source哦~
能力值:
( LV2,RANK:10 )
8 楼
脱离编译器的,改扩展名吧
能力值:
( LV8,RANK:130 )
9 楼
恩 还有个source
能力值:
( LV2,RANK:10 )
10 楼
我现在想编译MS的例子,请问该如何做:
SOURCE文件内容
TARGETNAME=SerEnum
TARGETPATH=obj
TARGETTYPE=DRIVER
MSC_WARNING_LEVEL=-W3 -WX
SOURCES= pnp.c \
enum.c \
serenum.rc \
serenum.c \
string.c \
power.c \
log.c
PRECOMPILED_INCLUDE=pch.h
PRECOMPILED_PCH=pch.pch
PRECOMPILED_OBJ=pch.obj
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
MAKEFILE文件内容 #############################################################################
#
# Copyright (C) Microsoft Corporation 1998, 1999
# All Rights Reserved.
#
#############################################################################
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the driver components of Windows NT
#
!INCLUDE $(NTMAKEENV)\makefile.def 例子路径:
D:\WINDDK\2600\src\kernel\serenum
路径下所有文件:
D:\WINDDK\2600\src\kernel\serenum 的目录
2006-04-27 09:26 <DIR> .
2006-04-27 09:26 <DIR> ..
2001-08-17 12:51 47,121 enum.c
2001-08-17 12:51 3,184 log.c
2001-08-17 12:51 313 serenum.rc
2001-08-17 12:51 310 sources
2001-08-17 12:51 21,793 string.c
2001-08-17 12:51 950 log.h
2001-08-17 12:51 519 makefile
2001-08-17 12:51 195 pch.h
2001-08-17 12:51 44,242 pnp.c
2001-08-17 12:51 6,916 power.c
2001-08-17 12:51 16,613 serenum.c
2001-08-17 12:51 14,366 serenum.h
2001-08-17 12:51 2,381 serenum.htm
13 个文件 158,903 字节
2 个目录 8,943,468,544 可用字节
请问,我该如何做,才能弄出那个SYS文件来呢
能力值:
( LV3,RANK:30 )
11 楼
在开始菜单选择进入你要build的cmd环境,然后cd到SOURCE文件所在的目录,输入build命令即可
能力值:
( LV12,RANK:1010 )
12 楼
嗯,就是这样的呀
StarsunYzL说得完全正确~
能力值:
( LV2,RANK:10 )
13 楼
非常感谢
请问,这个SYS就是最终我们所求的吗???
D:\WINDDK\2600\src\kernel\serenum\objchk\i386 的目录
008-01-24 09:24 <DIR> .
008-01-24 09:24 <DIR> ..
008-01-24 09:24 1,204,304 pch.pch
008-01-24 09:24 188,367 pch.obj
008-01-24 09:24 1,260 serenum.res
008-01-24 09:24 34,862 pnp.obj
008-01-24 09:24 43,610 enum.obj
008-01-24 09:24 17,368 serenum.obj
008-01-24 09:24 26,946 string.obj
008-01-24 09:24 8,248 power.obj
008-01-24 09:24 5,252 log.obj
008-01-24 09:24 42,368 SerEnum.sys
008-01-24 09:24 281,600 SerEnum.pdb
11 个文件 1,854,185 字节
2 个目录 8,941,174,784 可用字节
其他那些文件是不是都是没有用的中间文件呢???????????
能力值:
( LV3,RANK:30 )
14 楼
嗯,基本上其它文件不会用到,不过调试的时候有pdb文件最好
能力值:
( LV2,RANK:10 )
15 楼
恩,谢谢,困惑好些天的问题终于得到解决
(PS:类似这样的超级EASY的问题,网上搜不到,书上也不写,郁闷啊)
能力值:
( LV12,RANK:1010 )
16 楼
网上搜的到的.
嘿嘿,你木有搜到关键词
能力值:
( LV2,RANK:10 )
17 楼
HELLOWORD 驱动程序:
DDK FOR XP
原程序:HELLOWORD.CPP
//一定要的头文件,声明了函数模块和变量:
#include "ntddk.h"
/***************************************************************
函数名称:DriverEntry()
功能描述:WDM程序入口(原来的WinMain被换成了DriverEntry,也是驱动程序的大门)
***************************************************************/
//extern "C"是必须的,表示“用C链接”
extern "C"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, //IN 是一个关键字表示这是一个输 入参数,PDRIVER_OBJECT是一个数据结构的指针,就像PCHAR一样,这个数据结构是什么样子的,后面我会列出来。她描述了一个驱动设备对象。
IN PUNICODE_STRING RegistryPath)//参数RegistryPath指定了驱动程序注册表健的路径,因为驱动程序安装后总会在系统注册表里留下一点东西的。
{
DbgPrint("驱动加载了....");
//返回一个NTSTATUS值STATUS_SUCCESS。几乎所有的驱动程序例程都必须返回一个NTSTATUS值,这些值在NTSTATUS.H DDK头文件中有详细的定义。
return STATUS_SUCCESS;
}
SOURCE文件
TARGETNAME=helloword
TARGETPATH=obj
TARGETTYPE=DRIVER
MSC_WARNING_LEVEL=-W3 -WX
SOURCES= helloword.cpp
从MS的示例代码中COPY了一个MAKEFILE
准备工作完成,接下来的BUILD
请看提示信息
G:\mytest>build
BUILD: Object root set to: ==> objchk
BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: /i switch ignored
BUILD: Compile and Link for i386
BUILD: Loading D:\WINDDK\2600\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Examining g:\mytest directory for files to compile.
g:\mytest - 1 source files (16 lines)
BUILD: Saving D:\WINDDK\2600\build.dat...
BUILD: Compiling g:\mytest directory
Compiling - helloword.cpp for i386
d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C2220: warning treated as error
- no object file generated
d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C4162: '_ReturnAddress' : no fu
nction with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6852) : error C4162: '_InterlockedExchange' :
no function with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6878) : error C4162: '_InterlockedIncrement'
: no function with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6891) : error C4162: '_InterlockedDecrement'
: no function with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6905) : error C4162: '_InterlockedExchangeAdd
' : no function with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6935) : error C4162: '_InterlockedCompareExch
ange' : no function with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6987) : error C4162: '_InterlockedOr' : no fu
nction with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(6997) : error C4162: '_InterlockedAnd' : no f
unction with C linkage found
d:\winddk\2600\inc\ddk\wxp\ntddk.h(7007) : error C4162: '_InterlockedXor' : no f
unction with C linkage found
BUILD: Compile errors: not linking g:\mytest directory
BUILD: Done
2 files compiled - 10 Errors
G:\mytest>G:\mytest>build
'G:\mytest' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Object root set to: ==> objchk
拒绝访问。
G:\mytest>BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: /i switch ignored
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compile and Link for i386
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Loading D:\WINDDK\2600\build.dat...
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Computing Include file dependencies:
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Examining g:\mytest directory for files to compile.
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest> g:\mytest - 1 source files (16 lines)
'g:\mytest' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Saving D:\WINDDK\2600\build.dat...
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compiling g:\mytest directory
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>Compiling - helloword.cpp for i386
'Compiling' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C2220: warning treated as error
G:\mytest> - no object file generated
'-' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C4162: '_ReturnAddress' : no fu
G:\mytest>nction with C linkage found
'nction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6852) : error C4162: '_InterlockedExchange' :
G:\mytest> no function with C linkage found
'no' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6878) : error C4162: '_InterlockedIncrement'
G:\mytest>: no function with C linkage found
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6891) : error C4162: '_InterlockedDecrement'
G:\mytest>: no function with C linkage found
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6905) : error C4162: '_InterlockedExchangeAdd
G:\mytest>' : no function with C linkage found
''' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6935) : error C4162: '_InterlockedCompareExch
G:\mytest>ange' : no function with C linkage found
'ange'' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6987) : error C4162: '_InterlockedOr' : no fu
G:\mytest>nction with C linkage found
'nction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6997) : error C4162: '_InterlockedAnd' : no f
G:\mytest>unction with C linkage found
'unction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(7007) : error C4162: '_InterlockedXor' : no f
G:\mytest>unction with C linkage found
'unction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compile errors: not linking g:\mytest directory
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Done
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>
G:\mytest> 2 files compiled - 10 Errors
'2' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>G:\mytest>build
'G:\mytest' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Object root set to: ==> objchk
拒绝访问。
G:\mytest>BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: /i switch ignored
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compile and Link for i386
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Loading D:\WINDDK\2600\build.dat...
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Computing Include file dependencies:
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Examining g:\mytest directory for files to compile.
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest> g:\mytest - 1 source files (16 lines)
'g:\mytest' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Saving D:\WINDDK\2600\build.dat...
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compiling g:\mytest directory
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>Compiling - helloword.cpp for i386
'Compiling' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C2220: warning treated as error
G:\mytest> - no object file generated
'-' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(2152) : error C4162: '_ReturnAddress' : no fu
G:\mytest>nction with C linkage found
'nction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6852) : error C4162: '_InterlockedExchange' :
G:\mytest> no function with C linkage found
'no' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6878) : error C4162: '_InterlockedIncrement'
G:\mytest>: no function with C linkage found
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6891) : error C4162: '_InterlockedDecrement'
G:\mytest>: no function with C linkage found
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6905) : error C4162: '_InterlockedExchangeAdd
G:\mytest>' : no function with C linkage found
''' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6935) : error C4162: '_InterlockedCompareExch
G:\mytest>ange' : no function with C linkage found
'ange'' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6987) : error C4162: '_InterlockedOr' : no fu
G:\mytest>nction with C linkage found
'nction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(6997) : error C4162: '_InterlockedAnd' : no f
G:\mytest>unction with C linkage found
'unction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>d:\winddk\2600\inc\ddk\wxp\ntddk.h(7007) : error C4162: '_InterlockedXor' : no f
G:\mytest>unction with C linkage found
'unction' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Compile errors: not linking g:\mytest directory
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>BUILD: Done
'BUILD:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>
G:\mytest> 2 files compiled - 10 Errors
'2' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
G:\mytest>
能力值:
( LV8,RANK:130 )
18 楼
#include "ntddk.h"
也要extern "C"
一般sys就用.c写吧。。
能力值:
( LV2,RANK:10 )
19 楼
现在的问题是这样的
G:\mytest>build
BUILD: Object root set to: ==> objchk
BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: /i switch ignored
BUILD: Compile and Link for i386
BUILD: Loading D:\WINDDK\2600\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Examining g:\mytest directory for files to compile.
g:\mytest - 1 source files (9 lines)
BUILD: Saving D:\WINDDK\2600\build.dat...
BUILD: Compiling g:\mytest directory
Compiling - helloword.c for i386
helloword.c(1) : error C2059: syntax error : 'string'
d:\winddk\2600\inc\crt\excpt.h(82) : error C2143: syntax error : missing '{' before '__cdecl'
d:\winddk\2600\inc\wxp\ntdef.h(1471) : error C2143: syntax error : missing ')' before '*'
d:\winddk\2600\inc\wxp\ntdef.h(1471) : error C2143: syntax error : missing '{' before '*'
d:\winddk\2600\inc\wxp\ntdef.h(1471) : error C2059: syntax error : ')'
helloword.c(4) : error C2059: syntax error : 'string'
BUILD: Compile errors: not linking g:\mytest directory
BUILD: Done
2 files compiled - 6 Errors - 9 LPS
//////////////////////////////////////////////////////////////////////////////////////////////////
原文件如下:
extern "C"
#include "ntddk.h"
extern "C"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
DbgPrint("驱动加载了....");
return STATUS_SUCCESS;
}
扩展名也改为.C了,同时更改了SOURCE文件
能力值:
( LV12,RANK:1010 )
20 楼
#ifdef __cplusplus extern "C" { #endif .
字不少拉.还不让回复!
能力值:
( LV12,RANK:1010 )
21 楼
如果定义了C++格式,那么你需要申明成C的调用,编译器才不会在你滴函数前头乱加东西。让它老老实实的按你滴意思去做~
懂了不?
你滴 {} 木有加呀
能力值:
( LV2,RANK:10 )
22 楼
真是气死人:
一生气,直接
#include "ntddk.h"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
DbgPrint("驱动加载了....");
return STATUS_SUCCESS;
}
然后BUILD,然后OK,晕晕的
能力值:
( LV2,RANK:10 )
23 楼
现在SYS也编译成功了,打开DBGVIEW
然后安装服务,并启动服务,可是DBGVIEW里怎么什么信息都没有呢???
能力值:
( LV2,RANK:10 )
24 楼
DBGVIEW要capture kernel....
能力值:
( LV8,RANK:130 )
25 楼
其实直接写成aaa.c这样文件名(注意扩展名) 就不用extern半天了。
ps#20:大概是quote不算字数吧。。 呵呵,dz就不算quote的字数(算下限的时候不算,算上限的时候算-___-!!!)