Wince6.0移植Public目录的模块到自己的平台的步骤(移植OALIOCTL为例)

<< Windows CE: Starting an Application when the System Boots | Home | Platform Builder: Clone Public Code >> 
Windows CE 6.0: User Mode KernelIoControl


Windows CE 6.0 introduces some new security features including new meaning for User Mode and Kernel Mode.   Loosely speaking, Kernel Mode has access to the system’s resources and User Mode is greatly restricted. One of the new restrictions on User Mode code is that calls to KernelIoControl are limited to the following OEMIoControl IOCTLs:
        IOCTL_HAL_GET_CACHE_INFO
        IOCTL_HAL_GET_DEVICE_INFO
        IOCTL_HAL_GET_DEVICEID
        IOCTL_HAL_GET_UUID
        IOCTL_PROCESSOR_INFORMATION
As an OEM you can change this to allow access to other IOCTLs. The default restriction makes a lot of sense for consumer devices, but for closed systems or systems that the OEM wants to provide more functionality, there is a need to provide more IOCTLs for use from User Mode code.
User Mode code accesses these IOCTLS through a new oalioctl.dll. The code for oalioctl.dll is available in %_WINCEROOT%\Public\Common\Oak\Oalioctl, so I won’t publish the code here. But basically it has an IoControl function that has a switch statement which limits access to OEMIoControl(). So to add more IOCTLs, we need to clone the code and change the switch statement.

Platform Builder: Clone Public Code

I recently wrote an article about modifying the behavior of KernelIoControl when called by User Mode code. In that article, I stated that you need to clone the Public oemioctl code to your platform. Sounds so simple doesn’t it, and really it isn’t that difficult if you know what you are doing, but for the rest of you I thought that I would walk through the process of cloning code.
Many of us use the term “clone code” but what does it really mean? Cloning code means to copy the code to another build tree and modify the build environment to build the code under the new tree. In the old days of Windows CE development, that meant reverse engineering how Microsoft builds the code to apply your knowledge of the build system to it. Today we have sysgen_capture.bat to do most of the hard work for us.
Here is how I would clone oemioctl:
1.       Create a new folder in my platform to build oemoctl.dll, I will call mine OALIoctlDir. This folder will be a holding place for two new folders; one will build the lib that is built in Public\Common\OAK\oalioctl, and the other will link the lib to create the dll. You certainly can create the dll with one folder, but that is more involved that the discussion here.
2.       Copy the %_WINCEROOT%\Public\Common\OAK\OEMICTL folder and paste it as a new subfolder of OALIoctlDir. This is the folder that creates OALIoctl.lib.
3.       Create an new folder in OALIoctlDir named BuildDll; this is the folder that will do the linking to create OALIoctl.dll.
4.       Create a dirs file OALIoctlDir that contains
DIRS=oalioctl BuildDll
This tells build to go into OALIoctl first to build the lib, then go to BuildDll to link the dll.
5.       Add OEMIocltDir to its parent folder’s dirs file, which tells build to build our clone of OALIoctl.dll.
6.       Modify OALIoctlDir\OALIoctl\sources to:
		a.  Add RELEASETYPE=PLATFORM, this tells build to put the lib in the platform build tree
             	b.  Change the TARGETNAME to oalioctl_lib
7.       Open a build window and change directories to OALIocltDir\BuildDll
8.       Run “sysgen_capture OALIoctl” which will create a file named sources.OALIoctl. This new file contains the information that Microsoft uses to link OALIoctl.lib to create OALIoctl.dll, we need that information to build.
9.       Rename souces.OALIoctl to sources, so that build.exe can use it.
10.   	Modify OALIoctlDir\BuildDll\sources to 
		a.       change    $(_PUBLICROOT)\common\oak\lib\$(_CPUINDPATH)\OALIoctl.lib to    $(_TARGETPLATROOT	)				\lib\$(_CPUINDPATH)\OALIoctl_lib.lib
		b.      Change the DEFFILE to DEFFILE=OALIoctl.def
11.   Copy OALIoctl.def from OALIoctlDir\oalioclt to OALIoctlDir\BuildDll, this is necessary so that when BuildDll is built it can find the def file. There are alternative solutions for this, but this one is easy.
12.   Copy a makefile from one another folder to BuildDll, this is necessary because build.exe needs the makefile when it calls nmake.
13.   Change directories to OALIocltDir and run build
14.   Now you have an OALIoctl.dll in your Platform’s Target folder. When you run buildrel, this OALIoctl.dll will overwrite the one created in the Public folder.
		Now you have a clone of OALIoctl that you can modify to suit the needs of your platform.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值