Nicolas Besson - Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Здесь есть возможность читать онлайн «Nicolas Besson - Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Redmond, Год выпуска: 2008, Издательство: Microsoft, Жанр: Руководства, ОС и Сети, Программы, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Microsoft Windows Embedded CE 6.0 Exam Preparation Kit: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Microsoft Windows Embedded CE 6.0 Exam Preparation Kit — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Lesson 6: Marshaling Data across Boundaries<\/p> <\/div>

In Windows Embedded CE 6.0, each process has its own separate virtual memory space and memory context. Accordingly, marshaling data from one process to another requires either a copying process or a mapping of physical memory sections. Windows Embedded CE 6.0 handles most of the details and provides system functions, such as OALPAtoVA and MmMapIoSpace, to map physical memory addresses to virtual memory addresses in a relatively straightforward way. However, driver developers must understand the details of data marshaling to ensure a reliable and secure system. It is imperative to validate embedded pointers and properly handle asynchronous buffer access so that a user application cannot exploit a kernel- mode driver to manipulate memory regions that the application should not be able to access. Poorly implemented kernel-mode drivers can open a back door for malicious applications to take over the entire system.<\/p>

After this lesson, you will be able to:<\/strong> <\/p>

■ Allocate and use buffers in device drivers.<\/p>

■ Use embedded pointers in an application.<\/p>

■ Verify the validity of embedded pointers in a device driver.<\/p>

Estimated lesson time: 30 minutes.<\/strong> <\/p> <\/cite>

Understanding Memory Access<\/p> <\/div>

Windows Embedded CE works in a virtual memory context and hides the physical memory, as illustrated in Figure 6-8. The operating system relies on the Virtual Memory Manager (VMM) and the processor's Memory Management Unit (MMU) for the translation of the virtual addresses into physical addresses and for other memory access management tasks.<\/p> NOTE<\/div>

Physical memory access restrictions<\/div>

Applications and user-mode drivers cannot access physical device memory directly. User-mode processes must call HalTranslateBusAddress to map the physical device memory range for the bus to a physical system memory address before calling MmMapIoSpace. To convert a bus address into a virtual address in a single function call, use the TransBusAddrToVirtual function, which in turn calls HalTranslateBusAddress and MmMapIoSpace.<\/p> <\/cite>

Allocating Physical Memory<\/p> <\/div>

It's possible to allocate a portion of memory so you can use it in a driver or the kernel. There are two ways to do this:<\/p>

Dynamically, by calling the AllocPhysMem function<\/strong>AllocPhysMem allocates contiguous physical memory in one or more pages that you can map to virtual memory in the user space by calling MmMapIoSpace or OALPAtoVA, depending on whether the code is running in user mode or kernel mode. Because physical memory is allocated in units of memory pages, it is not possible to allocate less than a page of physical memory. The size of the memory page depends on the hardware platform. A typical page size is 64 KB.<\/p>

Statically, by creating a RESERVED section in the Config.bib file<\/strong>You can statically reserve physical memory by using the MEMORY section of a run-time image's BIB file, such as Config.bib in the BSP folder. Figure 6-9 illustrates this approach. The names of the memory regions are for informational purposes and are only used to identify the different memory areas defined on the system. The important pieces of information are the address definitions and the RESERVED keyword. According to these settings, Windows Embedded CE excludes the reserved regions from system memory so that they can be used for DMA by peripherals and data transfers. There is no risk of access conflicts because the system does not use reserved memory areas.<\/p>

Application Caller Buffers<\/p> <\/div>

In Windows Embedded CE 6.0, applications and device drivers run in different process spaces. For example, Device Manager loads stream drivers into the kernel process (Nk.exe) or into the user-mode driver host process (Udevice.exe), whereas each application runs in its own individual process space. Because pointers to virtual memory addresses in one process space are invalid in other process spaces, you must map or marshal pointer parameters if separate processes are supposed to access the same buffer region in physical memory for communication and data transfer across process boundaries.<\/p>

Using Pointer Parameters<\/p> <\/div>

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:<\/p>

WINBASEAPI BOOL WINAPI DeviceIoControl (HANDLE hDevice,<\/code> <\/p>

DWORD dwIoControlCode,<\/code> <\/p>

__inout_bcount_opt(nInBufSize)LPVOID lpInBuf,<\/code> <\/p>

DWORD nInBufSize,<\/code> <\/p>

__inout_bcount_opt(nOutBufSize) LPVOID lpOutBuf,<\/code> <\/p>

DWORD nOutBufSize,<\/code> <\/p>

__out_opt LPDWORD lpBytesReturned,<\/code> <\/p>

__reserved LPOVERLAPPED lpOverlapped);<\/code> <\/p>

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).<\/p>

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»

Представляем Вашему вниманию похожие книги на «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit»

Обсуждение, отзывы о книге «Microsoft Windows Embedded CE 6.0 Exam Preparation Kit» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x