Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit
Using Pointer Parameters
Using Pointer Parameters
A pointer parameter is a pointer that a caller can pass as a parameter to a function. The DeviceIoControl parameters lpInBuf and lpOutBuf are perfect examples. Applications can use DeviceIoControl to perform direct input and output operations. A pointer to an input buffer (lpInBuf) and a pointer to an output buffer (lpOutBuf) enable data transfer between the application and the driver. DeviceIoControl is declared in Winbase.h as follows:
WINBASEAPI BOOL WINAPI DeviceIoControl (HANDLE hDevice,
DWORD dwIoControlCode,
__inout_bcount_opt(nInBufSize)LPVOID lpInBuf,
DWORD nInBufSize,
__inout_bcount_opt(nOutBufSize) LPVOID lpOutBuf,
DWORD nOutBufSize,
__out_opt LPDWORD lpBytesReturned,
__reserved LPOVERLAPPED lpOverlapped);
Pointer parameters are convenient to use in Windows Embedded CE 6.0 because the kernel automatically performs full access checks and marshaling on these parameters. In the DeviceIoControl declaration above, you can see that the buffer parameters lpInBuf and lpOutBuf are defined as in/out parameters of a specified size, while lpBytesReturned is an out-only parameter. Based on these declarations, the kernel can ensure that an application does not pass in an address to read-only memory (such as a shared heap, which is read-only to user-mode processes, but writable to the kernel) as an in/out or out-only buffer pointer or it will trigger an exception. In this way, Windows Embedded CE 6.0 ensures that an application cannot gain elevated access permissions to a memory region through a kernel-mode driver. Accordingly, on the driver's side, you do not have to perform any access checks for the pointers passed in through the XXX_IOControl stream interface function (pBufIn and pBufOut).
- Using Embedded Pointers
- Common IRP Parameters
- pointer_to_binary_function
- Using Constraints in a Generic Type
- Caveats using NAT
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- Data Binding Using the GridView Control
- Using the kill Command to Control Processes
- Installing Using a Network
- Using X
- Using a Display Manager
- Starting X from the Console by Using startx