阅读:1087回复:1
问一个有关驱动调试的问题
我现在搞1394图像采集系统的开发。驱动装上后,在设备管理器中可以发现设备,而且系统提示该设备工作正常。但用应用程序找不到设备。之后,我仿照Christ cant讲WDM驱动那本书上,第五章中wdm1 test,写了一个简单的win32 console程序,如下:
#include <iostream.h> #include <windows.h> #include <stdio.h> #include "d:\ntddk\inc\setupapi.h" #include "initguid.h"//不清楚有什么用途,是否有用 #include "winioctl.h"//不清楚有什么用途,是否有用 typedef PVOID HDEVINFO; static const GUID GUID_TEST1394 = { 0x87dd9849, 0xaca2, 0x469f, { 0xa4, 0x29, 0xb4, 0xf, 0x72, 0x8f, 0x65, 0x4f } }; HANDLE GetDeviceViaInterface( GUID* pGuid, DWORD instance); void main() { // Open device HANDLE h1394 = GetDeviceViaInterface((LPGUID)&GUID_TEST1394,0); if( h1394==NULL) {printf("XXX Could not find open 1394 device!\n"); } printf(" Opened OK\n"); } /////////////////////////////////////////////////////////////////////////////////////// HANDLE GetDeviceViaInterface( GUID* pGuid, DWORD instance) { HDEVINFO info = SetupDiGetClassDevs(pGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); if(info==INVALID_HANDLE_VALUE) { printf("No HDEVINFO available for this GUID\n"); return NULL; } SP_INTERFACE_DEVICE_DATA ifdata; ifdata.cbSize = sizeof(ifdata); if(!SetupDiEnumDeviceInterfaces(info, NULL, pGuid, instance, &ifdata))// &ifdata OUT { printf("No SP_INTERFACE_DEVICE_DATA available for this GUID instance\n"); SetupDiDestroyDeviceInfoList(info); return NULL; } DWORD ReqLen; SetupDiGetDeviceInterfaceDetail(info, &ifdata, NULL, 0, &ReqLen, NULL); PSP_INTERFACE_DEVICE_DETAIL_DATA ifDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)(new char[ReqLen]); if( ifDetail==NULL) { SetupDiDestroyDeviceInfoList(info); return NULL; } ifDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA); if( !SetupDiGetDeviceInterfaceDetail(info, &ifdata, ifDetail, ReqLen, NULL, NULL)) { SetupDiDestroyDeviceInfoList(info); delete ifDetail; return NULL; } printf("Symbolic link is %s\n",ifDetail->DevicePath); // Open file HANDLE rv = CreateFile( ifDetail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if( rv==INVALID_HANDLE_VALUE) rv = NULL; delete ifDetail; SetupDiDestroyDeviceInfoList(info); return rv; } 编译时出错提示为: Configuration: main - Win32 Debug-------------------- Linking... main.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailA@24 main.obj : error LNK2001: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 main.obj : error LNK2001: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 main.obj : error LNK2001: unresolved external symbol __imp__SetupDiGetClassDevsA@16 Debug/main.exe : fatal error LNK1120: 4 unresolved externals Error executing link.exe. main.exe - 5 error(s), 0 warning(s) 烦劳各位古道热肠的大虾给看一看,问题出在哪里? 另外:请指点一下如何调试驱动,用什么工具,有没有入门级的书籍或资料? |
|
沙发#
发布于:2004-09-23 10:29
问题在于你少加一个头文件
加上 #include <setupapi.h>试试 #include "winioctl.h" 用途:This module defines the 32-Bit Windows Device I/O control codes. |
|