阅读:946回复:0
关于98下虚拟驱动的PNP安装问题 --要多少分尽管开口
我在座98 下的虚拟设备驱动,设备事串口外设,要做成PNP,,我的INF文件如下:
[Version] Signature=$CHICAGO$ Class=UnKnown Provider=%YDA% [DestinationDirs] DefaultDestDir=11 [Manufacturer] %YDA%=SECTION_0 [SECTION_0] %SerialDeviceDesc%=dev.install,SERENUM\YDA4518 [dev.install] CopyFiles=dev.copy AddReg=dev.registry [dev.copy] TOUCH.VXD [dev.registry] HKR,,FriendlyDriver,,TOUCH.VXD HKR,,DevLoader,0,*vcomm HKR,,Enumerator,,SERENUM.VXD [ControlFlags] [SourceDisksNames] 1=TOUCH.VXD, DISK1, [SourceDisksFiles] TOUCH.VXD=1 [Strings] 。。。。。。 在安装万设备后,用VXDVIEW却发现,系统根本就没有载入驱动程序 我的源代码如下: // TOUCH.h - include file for VxD TOUCH #include <vtoolsc.h> #define TOUCH_Major 1 #define TOUCH_Minor 0 #define TOUCH_DeviceID UNDEFINED_DEVICE_ID #define TOUCH_Init_Order UNDEFINED_INIT_ORDER // TOUCH.c - main module for VxD TOUCH #define DEVICE_MAIN #include "touch.h" #undef DEVICE_MAIN Declare_Virtual_Device(TOUCH) VOID __cdecl PM_Api_Handler(VMHANDLE hVM, PCLIENT_STRUCT pcrs) { } DefineControlHandler(SYS_DYNAMIC_DEVICE_INIT, OnSysDynamicDeviceInit); DefineControlHandler(SYS_DYNAMIC_DEVICE_EXIT, OnSysDynamicDeviceExit); DefineControlHandler(PNP_NEW_DEVNODE, OnPnpNewDevnode); DefineControlHandler(W32_DEVICEIOCONTROL, OnW32Deviceiocontrol); CONFIGRET OnConfigure(CONFIGFUNC cf, SUBCONFIGFUNC scf, DEVNODE devnode, DWORD refdata, ULONG flags); WORD COMBASENAME= 0x3F8; BYTE irq = 0x04; // The following declarations define the strings used to identify calls to the driver // when building for debug #ifdef DEBUG DEBUG_CONFIG_NAMES // macro defines lpszConfigName array char *subfunc = ""; char *substart[] = { "DYNAMIC_START", "FIRST_START" }; char *substop[] = { "DYNAMIC_STOP", "HAS_PROBLEM" }; char *subremove[] = { "DYNAMIC", "SHUTDOWN", "REBOOT" }; char *subtest[] = { "CAN_STOP", "CAN_REMOVE" }; char *subapm[] = { "TEST_STANDBY", "TEST_SUSPEND", "TEST_STANDBY_FAILED", "TEST_SUSPEND_FAILED", "TEST_STANDBY_SUCCEEDED", "TEST_SUSPEND_SUCCEEDED", "RESUME_STANDBY", "RESUME_SUSPEND", "RESUME_CRITICAL", "UI_ALLOWED" }; #endif // DEBUG BOOL __cdecl ControlDispatcher( DWORD dwControlMessage, DWORD EBX, DWORD EDX, DWORD ESI, DWORD EDI, DWORD ECX) { START_CONTROL_DISPATCH ON_SYS_DYNAMIC_DEVICE_INIT(OnSysDynamicDeviceInit); ON_SYS_DYNAMIC_DEVICE_EXIT(OnSysDynamicDeviceExit); ON_PNP_NEW_DEVNODE(OnPnpNewDevnode); ON_W32_DEVICEIOCONTROL(OnW32Deviceiocontrol); END_CONTROL_DISPATCH return TRUE; } BOOL OnSysDynamicDeviceInit() { return TRUE; } BOOL OnSysDynamicDeviceExit() { return TRUE; } // ----------------------------------------------------------------------- // Handler for control message PNP_NEW_DEVNODE // // Input: // Node DEVNODE of the device // LoadType identifies the operation being performed // CONFIGRET OnPnpNewDevnode(DEVNODE Node, DWORD LoadType) { switch (LoadType) // select function to perform { case DLVXD_LOAD_DRIVER /*2*/: return CONFIGMG_Register_Device_Driver( Node, OnConfigure, 0, CM_REGISTER_DEVICE_DRIVER_REMOVABLE | CM_REGISTER_DEVICE_DRIVER_DISABLEABLE ); }; return CR_DEFAULT; } DWORD OnW32Deviceiocontrol(PIOCTLPARAMS p) { return 0; } // Configuration handler // // This is the routine that this VxD supplies to CONFIGMG when registering as // the device driver. It handles various configuration messages sent by CONFIGMG. CONFIGRET OnConfigure( CONFIGFUNC cf, // function id SUBCONFIGFUNC scf, // subfunction id DEVNODE devnode, // device node being configured DWORD refdata, // context information (function specific) ULONG flags // function specific flags ) { CMCONFIG config; LOG_CONF logconf; RES_DES hres; // If this is the debug build, emit messages to debug console #ifdef DEBUG char id[MAX_DEVICE_ID_LEN]; switch (cf) { // get subfunction name case CONFIG_START: subfunc = substart[scf]; break; case CONFIG_STOP: subfunc = substop[scf]; break; case CONFIG_REMOVE: subfunc = subremove[scf]; break; case CONFIG_TEST: subfunc = subtest[scf]; break; case CONFIG_APM: subfunc = subapm[scf]; break; } CONFIGMG_Get_Device_ID(devnode, id, sizeof(id), 0); if (cf < NUM_CONFIG_COMMANDS) dprintf("TELEPATH DRIVER: %s(%s), %s\r\n", lpszConfigName[cf], subfunc, id); else dprintf("TELEPATH DRIVER: %X(%X), %s\r\n", cf, scf, id); #endif switch (cf) // branch on function code { case CONFIG_START: // This is the normal way to obtain a configuration that // only includes the standard resources: CONFIGMG_Get_Alloc_Log_Conf(&config, devnode, CM_GET_ALLOC_LOG_CONF_ALLOC); //得到分配的终断号 irq = config.bIRQRegisters[0]; //得到分配的端口基址 // COMBASENAME = config.wIOPortBase; #ifdef DEBUG dprintf("the irq is %x\n",irq); dprintf("the portbase is %x\n",COMBASENAME); // dout<<"the port base is "<<COMBASENAME<<endl; #endif // This is how to get a configuration that includes a // private resource: /* CONFIGMG_Get_First_Log_Conf(&logconf, devnode, ALLOC_LOG_CONF); if (CONFIGMG_Get_Next_Res_Des(&hres, (RES_DES) logconf, ResType_Telepath, NULL, 0) == CR_SUCCESS) { TELEPATH_RESOURCE* pres = (TELEPATH_RESOURCE*) hres; // do something with pres->allocated } */// Here we would initialize the device, doing things // like VPICD_Virtualize_IRQ, etc. return CR_SUCCESS; case CONFIG_REMOVE /* 4 */: case CONFIG_STOP /* 2 */: // Here we would disable the device and do things // like unvirtualizing our IRQ irq = 0xff; return CR_SUCCESS; default: return CR_DEFAULT; } } # TOUCH.mak - makefile for VxD TOUCH DEVICENAME = TOUCH FRAMEWORK = C DYNAMIC = 1 DEBUG = 1 OBJECTS = touch.OBJ !include $(VTOOLSD)\include\vtoolsd.mak !include $(VTOOLSD)\include\vxdtarg.mak touch.OBJ: touch.c touch.h 那位大虾能给小弟指迷精,不胜感激!!,要多少分尽管开口 |
|