阅读:1418回复:3
问wince不能加载流驱动的问题
在华硕的A626上,没有在开发板上。
用pb生成了一个流式的helloworld式的驱动dll,然后考到windows 目录里了,然后也改了注册表 [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample] "Dll" = "mydriver.Dll" "Prefix" = "DEM" "Index" = dword:1 "Order" = dword:0 "FriendlyName" = "Demo Driver" "Ioctl" = dword:0 然后关机,在开机,用进程查看器查看device.exe没有加载mydriver.dll , active 注册表里也没有。 请问怎么回事? -------------------------------------------------源文件-------------------------------- // MyDriver.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" DWORD DEM_Init(LPCTSTR pContext, LPCVOID lpvBusContext); BOOL DEM_Deinit( DWORD hDeviceContext ); DWORD DEM_Open( DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode ); BOOL DEM_Close( DWORD hOpenContext ); BOOL DEM_IOControl( DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut ); void DEM_PowerUp( DWORD hDeviceContext ); void DEM_PowerDown( DWORD hDeviceContext ); DWORD DEM_Read( DWORD hOpenContext, LPVOID pBuffer, DWORD Count ); DWORD DEM_Write( DWORD hOpenContext, LPCVOID pBuffer, DWORD Count ); DWORD DEM_Seek( DWORD hOpenContext, long Amount, WORD Type ); #define IOCTL_DRIVER_DEMO 42 FILE *file = NULL; // Not exposed by the Device Driver void DBGOut(DWORD dwValue) { TCHAR tcTemp[10]; wsprintf(tcTemp,L"%ld",dwValue); OutputDebugString(tcTemp); fprintf(file,"%s",tcTemp); } HANDLE hMem=NULL; DWORD dwCount; BOOL APIENTRY DllMain( HANDLE hModule, aDWORD ul_reason_for_call, LPVOID lpReserved ) { switch ( ul_reason_for_call ) { case DLL_PROCESS_ATTACH: OutputDebugString(L"MyDriver - DLL_PROCESS_ATTACH\n"); MessageBox(NULL,_T("DLL_PROCESS_ATTACH"),NULL,MB_OK); break; case DLL_PROCESS_DETACH: OutputDebugString(L"MyDriver - DLL_PROCESS_DETACH\n"); MessageBox(NULL,_T("DLL_PROCESS_DEATTACH"),NULL,MB_OK); break; case DLL_THREAD_ATTACH: OutputDebugString(L"MyDriver - DLL_THREAD_ATTACH\n"); MessageBox(NULL,_T("DLL_THREAD_ATTACH"),NULL,MB_OK); break; case DLL_THREAD_DETACH: OutputDebugString(L"MyDriver - DLL_THREAD_DETACH\n"); MessageBox(NULL,_T("DLL_THREAD_DEATTACH"),NULL,MB_OK); break; } return TRUE; } DWORD DEM_Init( LPCTSTR pContext, LPCVOID lpvBusContext) { OutputDebugString(L"MyDriver - DEM_Init - Context: "); OutputDebugString(pContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_Init\n"); file = fopen("dump_Mydriver","at"); return 0x1234; } BOOL DEM_Deinit( DWORD hDeviceContext ) { OutputDebugString(L"MyDriver - DEM_Deinit\n"); OutputDebugString(L"MyDriver - ~ DEM_Deinit\n"); fclose(file); return TRUE; } DWORD DEM_Open( DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode ) { OutputDebugString(L"MyDriver - DEM_Open\n"); OutputDebugString(L"hDeviceContext - "); DBGOut(hDeviceContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_Open\n"); return 0x5678; } BOOL DEM_Close( DWORD hOpenContext ) { OutputDebugString(L"MyDriver - DEM_Close\n"); OutputDebugString(L"hOpenContext - "); DBGOut(hOpenContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_Close\n"); return TRUE; } BOOL DEM_IOControl( DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut ) { OutputDebugString(L"MyDriver - DEM_IOControl\n"); OutputDebugString(L"hOpenContext - "); DBGOut(hOpenContext); OutputDebugString(L"\n"); switch (dwCode) { case IOCTL_DRIVER_DEMO: { OutputDebugString(L"DRIVER DEMO IOCTL...\n"); // reverse the string... HANDLE hTemp=LocalAlloc(LPTR,dwLenIn+1); memset(hTemp,0x00,dwLenIn+1); TCHAR *tcOut=(TCHAR*)hTemp; TCHAR *tcIn=(TCHAR*)pBufIn; DWORD dwChars=dwLenIn/2; for (DWORD x=0;x < dwChars;x++) { tcOut[x]=tcIn[dwChars-x-1]; } memcpy(pBufOut,hTemp,dwLenIn); LocalFree(hTemp); *pdwActualOut=dwLenIn; } break; default: OutputDebugString(L"Unknown IOCTL\n"); break; } OutputDebugString(L"MyDriver - ~ DEM_IOControl\n"); return TRUE; } void DEM_PowerUp( DWORD hDeviceContext ) { OutputDebugString(L"MyDriver - DEM_PowerUp\n"); OutputDebugString(L"hDeviceContext - "); DBGOut(hDeviceContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_PowerUp\n"); } void DEM_PowerDown( DWORD hDeviceContext ) { OutputDebugString(L"MyDriver - DEM_PowerDown\n"); OutputDebugString(L"hDeviceContext - "); DBGOut(hDeviceContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_PowerDown\n"); } DWORD DEM_Read( DWORD hOpenContext, LPVOID pBuffer, DWORD Count ) { DWORD dwRetCount=0xffff; // default to error OutputDebugString(L"MyDriver - DEM_Read\n"); OutputDebugString(L"hOpenContext - "); DBGOut(hOpenContext); OutputDebugString(L"\n"); if (NULL != hMem) { dwRetCount=dwCount; memcpy(pBuffer,hMem,dwCount); } OutputDebugString(L"MyDriver - ~ DEM_Read\n"); return dwRetCount; } DWORD DEM_Write( DWORD hOpenContext, LPCVOID pBuffer, DWORD Count ) { OutputDebugString(L"MyDriver - DEM_Write\n"); OutputDebugString(L"hOpenContext - "); DBGOut(hOpenContext); OutputDebugString(L"\n"); if (NULL != hMem) { LocalFree(hMem); } hMem=LocalAlloc(LPTR,Count); memcpy(hMem,pBuffer,Count); dwCount=Count; OutputDebugString(L"MyDriver - ~ DEM_Write\n"); return Count; } DWORD DEM_Seek( DWORD hOpenContext, long Amount, WORD Type ) { OutputDebugString(L"MyDriver - DEM_Seek\n"); OutputDebugString(L"hOpenContext - "); DBGOut(hOpenContext); OutputDebugString(L"\n"); OutputDebugString(L"MyDriver - ~ DEM_Seek\n"); return 0; } -------------------------------def 文件------------------------------------------ LIBRARY MyDriver EXPORTS DEM_Init DEM_Deinit DEM_Open DEM_Close DEM_IOControl DEM_PowerUp DEM_PowerDown DEM_Read DEM_Write DEM_Seek |
|
沙发#
发布于:2007-10-06 11:38
"Prefix"
"Dll" "Flags" "Index" "Order" 一个流驱动的注册表中有这五项的话,就可以正常加载,这是不用怀疑的 你的缺少 flags 在这你的 "Order" = dword:0 把这值改的大一些,比如说40 在试试 如果不明白order这个项的含义,可以查查MS的文档 |
|
板凳#
发布于:2007-10-06 12:02
应该是加载失败了,
根据调试信息查吧, 把MessageBox去掉 |
|
|
地板#
发布于:2007-10-09 22:51
DEM_Init 返回值应该是TRUE。
但是返回return 0x1234;不知道是否合法。 |
|