阅读:1736回复:16
非常感谢你们!
我再问一个问题,为何有些涵数(如 IoGetConfigurationInformation())在以C的形式连接时正确,但以C++的形式连接时确库找不到,如何解决,
|
|
沙发#
发布于:2002-06-02 20:21
你没用extern\"C\"{
... }? |
|
板凳#
发布于:2002-06-02 20:28
当然用过,这样也不行
|
|
地板#
发布于:2002-06-02 20:36
LINK NTOSKRNL.LIB
|
|
地下室#
发布于:2002-06-02 20:40
也不在这个库中,我查了MSDN,里面没有说在哪个库
|
|
5楼#
发布于:2002-06-02 20:47
没有使用ddk? 这么说你的问题和所有的回答都没有意义了。 拜拜
|
|
6楼#
发布于:2002-06-02 20:50
当然用DDK了,这个涵数在2000DDK的头文件中有定义,但不知在哪个库中,为何用C++连接时通不过,面用C则可以
|
|
7楼#
发布于:2002-06-02 20:58
same as pjf
#ifdef __cplusplus extern \"C\"{ #endif #include <ntddk.h> //or wdm.h #ifdef __cplusplus }; #endif and like NTOSKRNL.LIB (see ddk help) [编辑 - 6/2/02 by zdhe] |
|
8楼#
发布于:2002-06-02 21:00
这个我也试过,也不行,是不是这个函数使用是否有限制
|
|
9楼#
发布于:2002-06-02 21:05
two question:
1. which os you use ?2k ? xp, 9x 2. you program is for ring0 or ring3? paste your project file here. and compile error output.(no cut) [这个我也试过,也不行,是不是这个函数使用是否有限制] in runtime, maybe thinkable, in compile phase, you need not think about this. [编辑 - 6/2/02 by zdhe] |
|
10楼#
发布于:2002-06-02 21:11
我用Win2000,以下是我代码的一部分:
extern \"C\" NTSTATUS DriverEntry ( IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING pRegistryPath ) { ULONG ulDeviceNumber = 0; NTSTATUS status; //////////////////////////////// PCONFIG_DATA ConfigData; PCONFIGURATION_INFORMATION ConfigInfo ; ConfigInfo = IoGetConfigurationInformation() ; //就是这个涵数 ConfigData = (CONFIG_DATA *)ExAllocatePool(PagedPool, sizeof (CONFIG_DATA)); if(ConfigData == NULL) { return STATUS_INSUFFICIENT_RESOURCES; } RtlZeroMemory(ConfigData,sizeof(CONFIG_DATA)); pDriverObject->DriverUnload = DriverUnload; status = CreateDevice(pDriverObject, ulDeviceNumber); ulDeviceNumber++; status = CreateDevice(pDriverObject, ulDeviceNumber); return status; } |
|
11楼#
发布于:2002-06-02 21:14
出错信息是:
onfig.obj : error LNK2001: unresolved external symbol \"__declspec(dllimport) struct _CONFIGURATION_INFORMATION * __stdcall IoGetConfigurationInformation(void)\" (__imp_?IoGetConfigurationInformation@@YGPAU_CONFIGURATION_INFORMATION@@XZ) Debug\\Minimal.SYS : fatal error LNK1120: 2 unresolved externals Error executing link.exe. |
|
12楼#
发布于:2002-06-02 21:14
paste your project file here.(dsp or makefile, or build -cZ source file)
|
|
13楼#
发布于:2002-06-02 21:16
it\'s c++ compile symbol name.
you must modify program as following (every file use ddk header) #ifdef __cplusplus extern \"C\"{ #endif #include <ntddk.h> //or wdm.h #include ....... #ifdef __cplusplus }; #endif and for confirm, clean and rebuild. [编辑 - 6/2/02 by zdhe] |
|
14楼#
发布于:2002-06-02 21:21
我已经按这种方法试过很多次了,就是不行
|
|
15楼#
发布于:2002-06-02 21:32
funny. people use c++ and ddk but no problem.
you can send your project to zdhe@hotmail.com (all) i will try it . [编辑 - 6/2/02 by zdhe] |
|
16楼#
发布于:2002-06-02 21:35
ok,thank you very much
|
|