Wince6.0 添加IOCTL
来源:互联网 发布:网络借贷的风险 编辑:程序博客网 时间:2024/05/22 11:46
在WinCE5.0中,应用程序和驱动程序可以通过调用KernelIoControl(..)函数来访问WinCE内核,导致调用OEMIoControl函数,这样应用程序和驱动程序就可以访问到OAL中的资源了。但在WinCE6.0中,提供了更好的安全性,应用程序能够访问OEMIoControl中的case受到了限制,只有下面的这些case是可以让应用程序访问的:
IOCTL_HAL_GET_DEVICE_INFO
IOCTL_HAL_GET_DEVICEID
IOCTL_HAL_GET_UUID
IOCTL_PROCESSOR_INFORMATION
如果用户在应用程序中试图访问其他的case,肯定会返回失败的。在WinCE6.0中,驱动程序还像以前一样,可以访问OEMIoControl中的任何case。也许有人会问,那么我们如何让应用程序也访问到一些case呢?既然微软已经公开了这些代码,我们就可以修改了,哈哈!以下以我添加用户设置UUID为例,详细讲解如何添加IOCTL了:
1. D:/WINCE600/PUBLIC/COMMON/OAK/INC/pkfuncs.h 添加要设置的IOCTL:
2. D:/WINCE600/PUBLIC/COMMON/OAK/OALIOCTL/oalioctl.cpp 添加我们定义的IOCTL:
BOOL
IOControl(
DWORD dwIoControlCode,
PBYTE pInBuf,
DWORD nInBufSize,
PBYTE pOutBuf,
DWORD nOutBufSize,
PDWORD pBytesReturned
)
{
BOOL fRet = FALSE;
//
// By default the following ioctls are supported for user mode threads.
// If a new ioctl is being added to this list, make sure the corresponding
// data associated with that ioctl is marshalled properly to the OAL
// ioctl implementation. In normal cases, one doesn't need any
// marshaling as first level user specified buffers are already validated
// by kernel that:
// -- the buffers are within the user process space
// Check out IsValidUsrPtr() function in vmlayout.h for details on kernel
// validation of user specified buffers. Kernel doesn't validate that the
// buffers are accessible; it only checks that the buffer start and end
// addresses are within the user process space.
//
switch (dwIoControlCode) {
case IOCTL_HAL_GET_CACHE_INFO:
case IOCTL_HAL_GET_DEVICE_INFO:
case IOCTL_HAL_GET_DEVICEID:
case IOCTL_HAL_GET_UUID:
case IOCTL_HAL_SET_UUID: //Hugo
case IOCTL_PROCESSOR_INFORMATION:
// request is to service the ioctl - forward the call to OAL code
// OAL code will set the last error if there is a failure
fRet = (*g_pfnExtOALIoctl)(dwIoControlCode, pInBuf, nInBufSize, pOutBuf, nOutBufSize, pBytesReturned);
break;
default:
SetLastError(ERROR_NOT_SUPPORTED);
break;
}
return fRet;
}
这些IOCTL 都是用户可以调用的;
3. 到OAL 层的oalioctl.cpp 里添加我们定义的IOCTL :
这些IOCTL 都是驱动可以调用的;
4. D:/WINCE600/PLATFORM/COMMON/SRC/INC/oal_ioctl_tab.h 添加 IOCTL 对应的函数:
5. D:/WINCE600/PLATFORM/COMMON/SRC/INC/oal_ioctl.h 添加函数声明:
6. D:/WINCE600/PLATFORM/COMMON/SRC/COMMON/IOCTL/uuid.c 添加函数定义:
OK, 到了这里,rebuild 一下我们的os image 就可以在应用层调用KernelIoControl(..) 设置UUID了,so easy? ^_^!!!
- Wince6.0 添加IOCTL
- Wince6.0 添加IOCTL
- Wince6.0 添加IOCTL
- [转帖]Wince6.0 添加IOCTL
- wince6.0添加外部字体库
- Wince6.0 添加中文支持
- WINCE6.0添加特定的软件键盘
- WINCE6.0 RIL [一]添加组件
- WINCE6.0添加微软简体中文输入法3.0
- WINCE6.0添加特定的软件键盘
- WINCE6.0添加特定的软件键盘
- WINCE6.0 RIL [一]添加组件
- WINCE6.0在控制面板添加应用程序
- 添加字符设备ioctl
- IOCTL 添加路由
- 在WinCE6.0中,添加自定义的工程模板
- 如何导出wince6.0的SDK 添加MFC支持
- 如何导出wince6.0的SDK 添加MFC支持
- flex:配置svn地址
- WinCE的电池驱动实现
- iBATIS相关
- 可以用 linq2sql或是entity framework
- cognos
- Wince6.0 添加IOCTL
- Build boost 1.45 with VC++ 2008 on Windows XP and gcc on Ubuntu
- 关于URL编码
- Android View的导出与导入
- webkit的history
- 给想成为程序员的大学生的建议:好程序员是“写”出来的,不是学出来的
- How big is it?-ACM
- WinCE6下的kernelIoControl使用方法
- Google code 获取密码页打不开的解决办法