Module 7: Advanced Components and Additional Support Tools

components, and Windows XP Embedded operating systems. ▫ Explain the ... MOC2545C, Developing Embedded Solutions for Microsoft Windows XP. Embedded. ..... Run SCAN1 which will scan the files and registry on your C drive (XP/XPe.
2MB taille 34 téléchargements 228 vues
Contents

Module 7: Advanced Components and Additional Support Tools

Overview..................................................................................................1  Converting Components .....................................................................2  Creating Custom Shell Components .................................................14  Component Building Tools...............................................................16  Security .............................................................................................28  Real-Time Extensions .......................................................................29  Debugging.........................................................................................30 Lab 8: Creating More Custom Components ..........................................33 Review ...................................................................................................50

Module 7: Advanced Components and Additional Support Tools

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, places or events is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.  2001 Microsoft Corporation. All rights reserved. Microsoft, MS-DOS, Windows, Windows NT, Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

Module 7: Advanced Components and Additional Support Tools

Overview 

Converting Components



Creating Custom Shell Components



Component Building Tools & 3rd Party Extensions



Debugging

In this module, you will learn about the tools that assist in building custom components, as well as, in debugging components. After completing this module, you will be able to: 

Explain the different ways in which existing files can be converted into Windows XP Embedded components.



Create custom shell components.



Explain the various tools which can assist in building and debugging components, and Windows XP Embedded operating systems.



Explain the different ways that system debugging can be accomplished both locally and remotely.

1

2

Module 7: Advanced Components and Additional Support Tools

 Converting Components 

Target Analyzer PMQ Files 



Installation INF Files 



The INF File Import Process

Windows NT Embedded KDF Files 



The PMQ File Import Process

The KDF File Import Process

Registry Files 

The .REG Import Process

Component Designer can be used to create XPe components from scratch, but it is not always necessary if PMQ, INF, or KDF files exist for the desired components. Component Designer has the capability of importing these definition files and converting them to XPe component definition files, SLD files. 

Target Analyzer PMQ Files Target Analyzer output files generated by TA.EXE or TAP.EXE utility programs.



Setup Information INF Files Windows 2000/XP installation setup information files. Device Driver INF files can be imported to create a SLD and component.



Windows NT Embedded Component Definition KDF Files Converts Windows NT Embedded 4.0 Component Definition Files into XPe SLD files.



Registry Files .REG You can export registry keys via REGEDIT.eXE and import the keys into Component Designer. The resulting component only contains registry key resources.

Module 7: Advanced Components and Additional Support Tools

3

PMQ Files 



PMQ Target Analyzer files are created by: 

TA.exe



TAP.exe

Target Analyzer Output 

SLD – XML file with the target hardware configuration

PMQ PMQ files are created by the two Target Analyzer utility programs: 

TA.EXE



TAP.EXE

The Target Analyzer utility programs are run on the target system to analyze the hardware configuration of that platform. The analysis is output as an Extensible Markup Language (XML) file with the .PMQ extension that represents the configuration of the target hardware. In this section, you will learn about importing Target Analyzer PMQ files into Component Designer. Note: For information about Importing Target Analyzer information into Target Designer, see Module 3, “Target Designer and Target Analyzer,” in Course MOC2545C, Developing Embedded Solutions for Microsoft Windows XP Embedded.

4

Module 7: Advanced Components and Additional Support Tools

The PMQ Import Process 

Import a PMQ file:  



File Menu Import Select the file for Import File of type: PMQ Specify Log File Useful for debugging



When completed, creates a new “macro” component and adds any components found in the data to the Component or Group Dependency resource



Also Add the “Selector Prototype Component” so a picker list of the component dependencies appears in the settings for the component.

Importing in Component Designer Importing Target Analyzer information into Component Designer allows you to build a single component for a particular piece of hardware. These particular types of components are called Macro components because they do not contain typical component resources such as, files and registry keys. Instead they only require other components to be included into a build. The Macro component contains dependencies to other components. (The component dependencies are for the hardware detected by Target Analyzer). If this hardware specific macro component is included into a build by Target Designer, the required components will automatically be included.

 To import a Target Analyzer PMQ file to create a macro component: 1. Open Component Designer 2. On the File menu, click Import. 3. In the Choose File for Import dialog box, select the Files of type to be Target Analyzer Files (*.pmq), browse to the folder containing the desired PMQ file and click the file you want to import, and then click Open. 4. It is recommended that you specify a log file. Enter the location and file name for this file in the Import File dialog box, and then click Start. 5. After the file has been successfully imported, click Close.

Module 7: Advanced Components and Additional Support Tools

5

Example: PMQ Import Log File 

Determine unrecognized devices

…… Status Status update:Analyzing update:Analyzing PortGear PortGear Ethernet Ethernet Adapter. Adapter. …… Warning:Could Warning:Could not not find find aa driver driver for for PCI PCI Device Device (PCI\VEN_1093&DEV_0160&SUBSYS_00000000&REV_00). (PCI\VEN_1093&DEV_0160&SUBSYS_00000000&REV_00). …… Info:Adding Info:Adding ACPI ACPI Sleep Sleep Button Button to to the the configuration. configuration. ……

It is recommended that the import log file be reviewed after importing a PMQ file into a component. In the example displayed on the slide, three important log entries are shown. 

Status update Importing a PMQ file can be a time consuming process. Component Designer compares resources for each component to see if it matches any of the hardware detected.



Warning While Windows XP Embedded provides a large number of components, it is possible that the target device has unknown hardware. In the example displayed on the slide, the Warning is caused by the detection of a device that contains a PCI card for which Windows XP Embedded does not have a corresponding component. It is recommended that the target hardware specifications be compared to the component created after the input to verify that all hardware was found. If hardware was not found, then a component may need to be created for it. Generic Volume is a component that will never be found in the database. This warning will always occur when you import a PMQ file created with TAP.EXE



Info In the example displayed on the slide, one of the devices found was an ACPI Sleep Button. Reviewing the info section of the import log will quickly show all of the recognized hardware.

6

Module 7: Advanced Components and Additional Support Tools

INF Files 

An INF is required by 2000/XP when installing a driver



INF files are plain text files which contain setup information.



An INF file is a text file divided into different types of formatted sections. Some of them are: 



An INF file can also contain private sections. 



[Version], [Install], [Add Registry], [Rename Files], [Service Install] Private sections in an INF file can be used to store specialized information used by a specific setup application.

INF files may include: 

Registry Information



File Resources



Device information (PnP ID/Device Class)

INF files are plain text files, which contain setup information. Typically, INF files are used with drivers; however, they can also install programs and services. An INF file is a text file divided into different types of formatted sections. Each section is designed for a particular purpose, for example, to copy files or to add entries to the registry. The number and type of sections in an INF file depends on the particular installation procedure. Each section consists of lines that contribute to the purpose of that section. INF files store information in a format that is described in the General Guidelines for INF File and INF File Sections and Directives sections of the Microsoft Windows 2000 Driver Development Kit. You should refer to these resources in the DDK if you plan to author INF files. The setup function uses this format when retrieving information from the INF file Note: A new INF file format was introduced for Microsoft® Windows®95 and Microsoft Windows NT® 4.0. This new format replaced the script-based INF files used with Windows NT3.x. Note: For more information about INF files, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/setupapi/setup/ about_inf_files.asp

Module 7: Advanced Components and Additional Support Tools

7

The INF Import Process 

Obtain INF file from installation software for the device 



Installation of driver might be required

Import an INF file 







File Menu  Import File of type: INF Select Parsing Options Automatic / Manual section selection Specify Log File Useful for debugging Create a repository

In order to import INF information into a component, you must first obtain the INF file. Typically, an INF file is present with the installation software for the device. Note: INF files can refer to other INF files. If the INF file being used references additional INF files, then they must all be in the same folder.

 To import an INF file: 1. Open Component Designer. 2. On the File menu, click Import. 3. In the Choose File for Import dialog box, select the Files of type to be Setup Information Files (*.inf), browse to the folder containing the desired INF file and click the file you want to import, and then click Open. 4. The INF Processing Options dialog box appears. Select the parsing option for the INF file, and then click OK. Note: For more information on the INF processing options, refer to the Component Designer help. 5. It is recommended that you specify a log file. Enter the location and file name for this file in the Import File dialog box, and then click Start. 6. Create a repository for all files referenced in the component.

8

Module 7: Advanced Components and Additional Support Tools

Important Importing an INF file will not create a repository. Typically, the final step when creating a component from an INF is to create a repository. Verify that all file references in the component are also within the repository. For information about creating a repository, see Module 6, “Building XP Embedded Components Using Component Designer,” in Course 2545C, Developing Embedded Solutions for Microsoft Windows XP Embedded.

Module 7: Advanced Components and Additional Support Tools

KDF Files 

Windows NT Embedded 4.0 Component Definition Files



Contains:





File Information



Registry Information

Needs: 

Repository Creation



Dependencies re-mapped

KDF files are Windows NT Embedded 4.0 component definition files. Refer to the illustration given below to see a KDF file created with the Windows NT Embedded Component Designer. Windows NT Embedded components also contain file, registry, and dependency information.

9

10

Module 7: Advanced Components and Additional Support Tools

Important: With KDF files, a repository must be created. Verify that all file references in the component are also within the repository. For information about creating a repository, see Module 6, “Building XP Embedded Components Using Component Designer,” in Course 2545C, Developing Embedded Solutions for Microsoft Windows XP Embedded. KDF files also contain dependencies; however, the dependencies are specific to Windows NT 4.0 Embedded. The component specified in the dependency may not exist in Windows XP Embedded. It is important to examine the dependencies of KDF files to see if an equivalent component exists in Windows XP Embedded. Example

Suppose you are converting a KDF file, which has a component that requires a component named: El Torito CD as Disk. Although XP Embedded has a very similar component El Torito CD, this dependency must be recreated.

Module 7: Advanced Components and Additional Support Tools

11

The KDF Import Process 

Importing a KDF file 





File Menu  Import File of type: KDF Specify Log File Useful for debugging

After import process, creates the basic structure of an SLD file for a new component: 

Component, Repository, and Package

The KDF Importer add-in enables Component Designer to support migration of Windows NT Embedded 4.0 component definition files (.kdf) into Windows XP Embedded component definition files (.sld files). This is provided as an add-in.

Installing the KDF Importer Copy the KDF importer plug-in (KDFImporter.dll) to the Windows Embedded utilities directory. Note: In a typical installation this will be located in the Program Files\Windows Embedded\utilities directory on the machine’s boot drive. Register the plug-in DLL using the RegSvr32 command. This is accomplished using the command line:RegSvr32 KdfImporter.dll

Copy the KDF support definitions SLD file (KDFDefns.sld) to the Windows Embedded Utilities directory Using Component Database Manager, import the KDF support definitions SLD file. Uncheck the copy files checkbox before importing. Once the import has completed the KDF import plug-in is ready for use.

 Importing a KDF file 1. Open Component Designer. 2. On the File menu, click Import. 3. In the Choose File for Import dialog box, select the Files of type to be Windows NT Embedded KDF files (*.kdf), browse to the folder

12

Module 7: Advanced Components and Additional Support Tools

containing the desired KDF file and click the file you want to import, and then click Open 4. It is recommended that you specify a log file. Enter the location and file name for this file in the Import File dialog box, and then click Start. 5. On successful import, the generated SLD file will be available in Component Designer for subsequent editing.

Module 7: Advanced Components and Additional Support Tools

13

REG Files



Capture .REG file using Regedit.exe’s export feature



Creates a component with Registry resources



Importing a KDF file 



File Menu  Import File of type: KDF Specify Log File Useful for debugging

REG Files can be imported in to Component Designer. You may encounter situations where REGEDIT.EXE is required to export registry information for a component. The .REG file can then be imported to create a component that only has registry resources.

14

Module 7: Advanced Components and Additional Support Tools

 Creating Custom Shell Components 

Component must inherit Shell Prototype Component



Contains Advanced Properties: 

Name: cmiShellPath



Type: String





Value: Location of the shell executable -ex: %SystemRoot%\System32\cmd.exe

Member of Shell Dependency Group

You can create a custom shell for your device and include it in your run-time image. Before you start authoring a component for your custom shell, create a new repository for your shell binary files. Note: For information about creating a repository, see Adding a New Repository in the Component Designer Guide.

 To create a custom shell component: 1. Open Component Designer. 2. On the File menu, click New to create a new .sld file. 3. Expand the platform node, right-click Components, and then click Add Component. 4. In the details pane, type or choose the following properties for your shell component: a. Name b. Description 5. To select the prototype component, click Browse, in the Select Prototype Component dialog box, select whether the prototype is to be selected from the database or and SLD file, search for Shell prototype component, and then click OK. 6. In the lower right of the details pane, click Advanced. 7. In the Advanced Properties dialog box, click Add. 8. In the Extended Property dialog box, type the following information: a. Name: cmiShellPath

Module 7: Advanced Components and Additional Support Tools

15

b. Format: String c. Value: Name of your shell application, for example, %SystemRoot%\System32\cmd.exe 9. Click OK. The properties you entered appear in the Advanced Properties dialog box. 10. Click OK. 11. To add your shell component to a dependency group, in the SLD browser, under your component, right-click Group Memberships, and then click Add Group Membership. 12. In the Add Component Group Memberships dialog box, expand the Dependencies node, and then search for the Shell group, and then click OK. 13. To add your shell component to a category, in the SLD browser, under your component, right-click Group Memberships, and then click Add Group Membership. 14. In the Add Group Memberships dialog box, expand the Categories node, and then browse to Software\System\User Interface\Shells, and then click OK.

16

Module 7: Advanced Components and Additional Support Tools

 Component Building Tools 

What is a snapshot?



Snapshot Technique



Snapshot Tool Example:InCtrl5 & Component Helper



Dependency Walker



File Monitoring: FileMon



Registry Monitoring: RegMon



Component Tracker

In this section, you will examine tools, which can assist in the component creation and debugging process. They can be split into the following groups: 

Snapshot Tool InCtrl5



Monitoring Tools FileMon, RegMon



Debugging Tools DLL Dependencies

Module 7: Advanced Components and Additional Support Tools

17

What is a snapshot? 



Snapshot consists of two sets of information: 

Registry Information



Files

To obtain a good snapshot: 



You must record every registry key, its value and every file. Simply recording file names may not be enough since a file may be replaced with a more recent file.

A snapshot is a recording of systems contents at a particular point in time. With Windows,snapshot generally consists of two sets of information: 

Registry information



Files

In order to obtain a good snapshot, you must record every registry key, its value and every file. Your recording of contents should be good enough to determine if any of these change from one snapshot to the next. Simply recording file names and not time and dates stamps may not be enough, since a file may be replaced with a more recent file.

18

Module 7: Advanced Components and Additional Support Tools

Snapshot Technique 

Take a snapshot of a clean system



Perform changes to the system 

Install Software



Configure Software/Operating System



Take a Snapshot of the modified system



Compare the two snapshot files

Taking snapshots of a system is a useful way to build and debug components. The overview of the snapshot technique is as follows: 1. First, take a snapshot of a clean system. Mostly, this should be a development system. However, you can take a snapshot of a target device too depending on what the snapshot will be used for. 2. Second, make changes to the system. If you are building a component for an application, you would then run the applications installer. Important: After the initial snapshot is taken, it is recommended to only make the desired changes to the system. It is easy to inadvertently use the system for some other purpose like browsing the Internet. The snapshot technique records every change in the system. Therefore, it is important not to use the system while trying to build a component for an application.

3. Third, perform another snapshot of the system. This snapshot contains all of the modifications made while taking the first snapshot of the system. 4. The software selected to take the system snapshot must also be able to compare the initial snapshot with the final snapshot. The difference should contain the necessary information for building a component or provide a better understanding of how items interact with the operating system.

Module 7: Advanced Components and Additional Support Tools

19

Snapshot Tool Example: InCtrl5 

InCtrl5 is designed to determine how a software installation modifies a system.



Obtain InCtrl5 from http://www.pcmag.com



Using InCtrl5:  



Open Ctrl5 Specify the installer executable in the Install program: field Click Go!

An example of a tool which uses the snapshot technique is InCtrl5. InCtrl5 is designed to determine how a software installation modifies a system. It produces a report showing all modifications to the registry, as well as, to files on a system.

How to Obtain InCtrl5 You can obtain InCtrl5 from www.xpefiles.com.

 Using InCtrl5 1. Open InCtrl5. 2. Specify the installer executable in the Install program: field. Note: Filling the Install program field is optional. It allows InCTRL5 to start the application automatically. The alternative is to manually start the install program or make system changes between snap shots. a. If the installer has command line parameters, type those in the Parameters field. b. Provide a description which will be used in the report. InCtrl5 allows you to customize which registry keys and files are monitored. It also records the contents of important files (such as INI files which are sometimes used to store settings). It is recommended that the first time this tool is used, the default settings are kept. However, if extraneous information is included with the report, it is advisable to tune what the program records. 3. Click GO! The tool then follows the snapshot method described on the previous page. First it records all files on the system, all registry keys and values, as well as the contents of important configuration files. Once this is done, the program

20

Module 7: Advanced Components and Additional Support Tools

will then execute the install. Use the install to install the software. When the installer is done, InCtrl5 will resume. It will now compare all files on the system, all registry keys, as well as the contents of import files to those stored in the beginning of this process. A report will be produced that contains all changes made to the system. You will have to go through the list of files and registry keys to add to your component.

Module 7: Advanced Components and Additional Support Tools

21

Component Helper



Snapshot Technique - Design specifically for XPe 

Output .KDF and .REG that can be imported into Component Designer



Looks for new files only, and new or changed registry keys



Part of XP Embedded Supplemental Toolkit – (www.sjjmicro.com)

Another tool that uses the Snapshot technique is Component Helper. Unlike InCtrl5, Component Helper was designed specifically for XPe development. The utility outputs a KDF and .REG file that can be imported into Component Designer.

How to obtain Component Helper Component Helper is part of the Windows XP Embedded Supplemental Toolkit available from SJJ Embedded Micro Solutions – www.sjjmicro.com.

 Using Component Helper 1. Open Component Helper 2. Create a new project. 3. Run SCAN1 which will scan the files and registry on your C drive (XP/XPe OS drive). 4. Install the application and/or driver 5. Run SCAN2 6. Finally run the difference check, which will compare the two scans and output a KDF and REG file to your project directory. Any new files found are copied to the project directory.

22

Module 7: Advanced Components and Additional Support Tools

Dependency Walker 

The Dependency Walker tool can determine and list all DLLs required by an executable program.



Dependency Walker - Depends.exe



Obtain from:http://msdn.microsoft.com

A common issue when building components is ensuring that all of the required DLLs are included for an application or driver. The Dependency Walker tool can determine and list all DLLs required by an executable program. After determining which DLLs are required, you can then either include them in their component or determine which existing components provide that DLL and make it a dependency.

How to obtain Dependency Walker: The Dependency Walker is included in the Microsoft Platform SDK which can be obtained from: http://www.microsoft.com/msdownload/platformsdk/sdkupdate/. Note: Dependency Walker only works for implicitly loaded DLLs. Process Explorer, from Sysinternals, will work for both implicit and explicit DLLs. Process Explorer can be obtained from: http://www.sysinternals.com/ntw2k/freeware/procexp.shtml.

Module 7: Advanced Components and Additional Support Tools

23

File Monitoring: FileMon 

Monitor File Access



Monitor Registry Access



Uses: 



Determining File/Registry Function Debugging Components



Obtain FileMon from http://www.sysin ternals.com



Filter Feature

The snapshot technique is useful to determine what registry keys and files a program installs. However, it is even more useful to understand how a program uses the registry and files. FileMon monitors and displays file system activity on a system in real-time. This tool allows you to see what files a program uses, including DLLs and configuration files. When building Windows XP Embedded components, FileMon is useful in debugging a component, if required files are missing. For example, a program may use a file to store configuration settings. Using FileMon, when the application accesses this file, it will be logged.

How to obtain FileMon You can obtain FileMon from http://www.sysinternals.com.This is a free tool.

24

Module 7: Advanced Components and Additional Support Tools

Registry Monitoring: RegMon 

RegMon monitors registry activity in real-time.



RegMon loads the registry as a driver and a monitor from very early on in the boot process.



Obtain from www.sysinterna ls.com



Filter Feature

RegMon is a registry monitoring utility that displays which applications are accessing the registry, which keys applications are accessing, and the registry data that applications are reading and writing - all in real-time. This information is useful when trying to determine how a program is using the registry. Often it is not easy or possible to configure an application after it is built into a Windows XP Embedded system, and therefore, to understand why a program uses a registry is critical. RegMon also has the ability to load the registry as a driver and a monitor from very early on in the boot process. This is useful when debugging issues related to device drivers.

How to obtain RegMon You can obtain RegMon from http://www.sysinternals.com. This is a free tool.

Module 7: Advanced Components and Additional Support Tools

25

Component Tracking



CMIEXP.WSF – CMI Explorer Script File 



Command line script that performs a variety of functions including component relationships

Component Tracker 



Finds dependency and dependent-on relationships a for a component. Part of XP Embedded Supplemental Toolkit – (www.sjjmicro.com)

Finding the relationships between components becomes necessary when you are trying to shrink an image into a specific footprint. XPe comes with the CMIEXP.WSF – a script utility that performs several command line tasks including component tracking. Component Tracker is a graphical utility that shows a components dependency relationships, as well as, components that are dependent on a component.

How to obtain Component Tracker Component Tracker is part of the Windows XP Embedded Supplemental Toolkit available from SJJ Embedded Micro Solutions – www.sjjmicro.com.

26

Module 7: Advanced Components and Additional Support Tools

Component Development Process

Start



Tools combined make a component development process

No

Dependency Walker

Installation Utility?



Each tool provides different information that goes into build the component

C omponent Tracker

Yes INCTR L5 or Component H elper

FileMon / RegMon

INF, KD F, REG, or PMQ file available?

No

Yes

Import the File

All of the tools and techniques discussed in this module can be combined into a component development process. Each tool provides a different piece of data that goes into the creation of a component. The flow diagram shows the flow of the process starting by asking is there an installation utility.

Module 7: Advanced Components and Additional Support Tools

27

 InCtrl5 and Component Helper provide information on files and registry keys added to the system during installation.  Importing and INF, KDF, REG, and PMQ – quickly brings in the need resources for a component.  DependencyWalker – locates the DLLs both static and dynamic that are needed for a given binary.  Component Tracker – can help locate the component relationships that are already in the database.  FileMon and REgMon – Dynamic analysis used to track files and registry touched by an application.

28

Module 7: Advanced Components and Additional Support Tools

 Security



Windows Firewall



Internet Explorer



Antivirus for XPe



Security Templates



Enhanced Write Filter



Data Execution Prevention (DEP)

Starting with Windows XPe SP2, security has been a major focus to improving the XP / XPe OS:  Windows Firewall - The Windows Firewall has been updated to provide a flexible interface and reporting solution. Within Target Designer you can pre-set the application that will have permission to access the network.  Internet Explorer – A pop-up blocker has been added to prevent malicious programs and scripts being downloaded to the device.  Antivirus Software – There are different companies offer antivirus solution for Window XP Embedded.  Security Templates – The XPe online help discusses how to present an OS image’s security policies. You can control what the user has access to and how they will access the system.  Enhanced Write Filter – If you use RAM or RAM Reg overlays, a simple power down removes any threats that might have been downloaded to the system. The EWF APIs will only run in an administrator account, thus preventing user accounts from disabling EWF.  Data Execution Prevention (DEP) - Data Execution Prevention (DEP) helps to prevent malicious code from attacking different memory locations. DEP goes one step further; DEP monitors memory to see if programs are using system memory safely. DEP operates either standalone or in cooperation with DEP enabled microprocessors.

Module 7: Advanced Components and Additional Support Tools

29

 Real-Time Extensions



Real-Time Response – measurement of how fast a system responds to external stimulus



Improve Real-Time Performance with 3rd party products





Nematron – HyperKernel – www.nematron.com



TenAsys – InTime – www.tenasys.com



VenturCom – RTX – www.venturcom.com

Add on Kernel running in a high priority

Real-Time response is measured in an operating system by how fast a kernel responds to an external stimulus or more specifically interrupts. The Embedded market contains a number of small operating systems designed for specific realtime functionality. XP Embedded has been improved to provide faster response times, and addresses these needs for most applications. There are imbedded device applications that require faster response to particular external stimuli or applications than Windows XP Embedded can provide. There are a few third-party companies that provide add-on support to improve the real-time performance of XPe: 

Nematron – HyperKernel



TenAsys – InTime



VenturCom – RTX

In general each product provides an add-on kernel and API set. This real-time kernel runs as a process in XPe memory and handles higher priority interrupts instead of XPe processes. The developers of these add-on kernels provide a specific API set that expose the real-time services of their kernel. This API set can be used to exploit the real-time functions when writing time-critical device drivers and application software.

30

Module 7: Advanced Components and Additional Support Tools

 Debugging



XPe supports remote application and kernel debugging



Remote application debugging allows testing of applications on a real target system that might be different from your development workstation.



Kernel debugging adds the support to debug device drivers and/or monitor the load process as XPe boots up.

Both remote application and kernel debugging are supported in Windows XP Embedded. Remote application debugging allows you to test an application on the actual platform. This type of debugging allows you to debug an application on a specific hardware device, where the hardware device might be a unique system with special hardware to control I/O devices. Remote application debugging also allows debug and testing of headless devices. Kernel debugging is resident system debugging. Kernel debugging allows you to see what is loaded by the OS at start-up and possibly debug components that are intended to start during the system boot process. Kernel debugging is particularly useful for debugging device drivers that are unique to the target system.

Module 7: Advanced Components and Additional Support Tools

31

Remote Application Debugging

Local development machine

Open Visual Studio, Create and Build an Application From Dev Studio, Execute the Application

TCP/IP network connection

Remote XPE device

Remote execute

Application is executing on the remote XPE Device Application Is Broken Into (Being Remotely Debugged)

From the Visual Studio Debugger, Break Into the Application

Remote application debugging uses the target-host development process. Connection to a remote device is over a TCP/IP link. The target must have a network card, and the XPe operating system image must have Telnet Server and security support built into the image to allow a remote user to logon to the target. The XPe operating system image must also have Remote Monitor Tools that come with Visual Studio.NET – they can be found at \Program Files\Microsoft Visual Studio.NET\Common7\Packages\Debugger A network share is created on the remote device. Visual Studio can use the network share to create a new development workspace. Once the development workspace has been created, the properties of the application must be modified for remote debugging.

32

Module 7: Advanced Components and Additional Support Tools

Kernel Debugging



Do not build a Debug Version of the OS



Change the Boot.INI information to support debug over a serial port 



/baudrate=number /debug /debugport=comnumber

KD.EXE or WinDBG.EXE used to set and track break points in a device driver.

Do not build a Debug Version of the OS, the debug version doesn’t build properly. The kernel debugger is installed in the image. You must manually define a serial port in the BOOT.ini file of the XPe image. Example: multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect /baudrate=115200 /debug /debugport=com1 A null-modem serial cable is required to connect the host and target. WINDBG and the XP-SP1 Symbols must be installed on the local development machine or you can reference over the internet in the SYMPATH var. If you want to download the debugger and symbols, they can be found here http://microsoft.com/ddk/debugging/ When the XPe-debug image boots, the output from the kernel debugger will be transferred to the local development machine via the serial connection. This output will display startup information indicating what is loaded by the operating system. This will aid in trouble-shooting issues with components that might fail to load.

Module 7: Advanced Components and Additional Support Tools

Lab 8: Creating More Custom Components

Objectives After completing this lab, you will be able to create a custom shell component.

Estimated time to complete this lab: 45 minutes

33

34

Module 7: Advanced Components and Additional Support Tools

Exercise 1 Importing an INF File Let’s start with something simple. The VIA M9000 has a 3D Video controller built into the chipset, but a driver is not part of the standard XPe distribution, so a component needs to be created. Even though the creating the component is simple, it is important to keep in mind on how to architect components so that groups of components can be packaged together.

 Create the directory structure. When components have many file resources, it is import to create a good directory structure when developing components. When creating drivers for a specific platform, it is good practice to group components under the platform directory. The following steps will create this file and directory structure:

1. In Explorer, under c:\XPE_DATA create a new directory called S3Video 2. Under c:\XPE_DATA\S3Video create a new directory called Files. 3. Copy all the files found under C:\Program Files\ MSDNTrain\ 2545C\ Labs\ Lab08\ S3Video to the c:\XPE_DATA\S3Video\Files directory. When the SLD is created and saved, it will be saved to the c:\XPE_DATA\S3Video directory with the repository pointing to the directory below the component: c:\XPE_DATA\S3Video\Files.

 Import the INF Now that the directory structure has been created, let’s create the component. 1. Open Component Designer 2. From the menu select File, then click Import. 3. Change the File type to .INF. 4. Locate the VIAGFX.INF found in the c:\XPE_DATA\S3Video\Files directory. 5. Click Open. 6. The INF Processing Options dialog box appears. Keep the defaults and click OK. 7. The INF Import dialog appears. Set the log file to c:\XPE_DATA\S3Video\VIAGFX.log. 8. Click Start. The import process will take a few minutes. 9. When the import is completed, click Close. An SLD and the VIA/S3G CLE266 Graphics Driver component will be created. 10. Save the SLD to c:\XPE_DATA\S3Video.

Module 7: Advanced Components and Additional Support Tools

35

 Complete the SLD Importing only creates the basic resources. The developer needs to manually create the other objects and miscellaneous items, as well as, gather any file resources and dependencies. 1. Under Repositories, create a new repository called S3Video REP. 2. Under Packages, create a new package called S3Video PAK. 3. Under S3 Video REP’s Group Membership add S3 Video PAK. 4. Under the VIA/S3G CLE266 Graphics Driver component’s Group Membership, add S3 Video PAK. Now both the repository and the component are part of the same package. If you ever need to delete the component and repository from the database, all you have to do is delete the package. 5. Now let’s point the repository path to the location of the files. In the details pane of the S3Video Rep, set the Source Path to c:\XPE_DATA\S3Video\Files. The resulting path in the details pane will show “.\Files”, which is the directory below the SLD file location. The path is relative to the location of the SLD. By having the files one directory level below the SLD, this helps keep the SLD and files together, especially if you check them into your version control. 6. A very important step is to associate the repository with the component. In the Details Pane for the VIA/S3G CLE266 Graphics Driver component, set Repositories to the S3Video REP. 7. Save the SLD. Note: Notice that the import automatically added the group membership for Hardware->Device->Display adapters for the Component Browser and Device: Display as the prototype. The Display prototype provides settings to change resolution and color depth.

 Clean up the Resources Importing an INF file simplifies the effort to create the component by filling in the file and registry resources that the driver will need. There is some clean-up that sometimes has to occur. Under the VIA/S3G CLE266 Graphics Driver component, you will notice that the file resources listed can be found under c:\XPE_DATA\S3Video\Files. There are some extra setup files that we don’t need and some duplicate files listed in the resources. 1. The first file that you should notice is VIAGFX.CAT. The path for this file is %66000%, and when you look at it closely your will see that a %66000% is not a predefined XPe destination variable. VIAGFX.CAT is not needed for driver functionality so delete the entry for VIAGFX.CAT. The catalog (CAT) file is used during installation 2. Save the SLD and close Component Designer.

3. In the c:\XPE_DATA\S3Video\Files, you can delete the files below and the SETUPDIR directory since they are not needed to run the driver. These files will not be copied to the repository during the import process, thus they would simply be taking up space on the hard drive.

36

Module 7: Advanced Components and Additional Support Tools

          

Setup.EXE Setup.INI Setup.INS Setup.LID VIAGFX.CAT SETUPDIR (Directory) _INST32I.EX_ _ISDEL.EXE _SYS1.CAB _USER1.CAB DATA1.CAB

 Import and Test the Driver The next steps would be to test the component to make sure that it worked. The driver was taken from a VIA M9000/M10000 board. If you have this board you can test the driver. See http://www.travla.com/. 1. Open Component Database Manager 2. Import the newly created SLD into the database. A new repository will be created under \Windows Embedded Data and the files gathered in Step 4 will be copied to the new repository. 3. Close Component Database Manager. 4. The next steps are to create a new configuration in Target Designer that includes the new video component and other support components to verify that the driver is working properly. When you create the configuration, you will want to add the following components:  Platform components found using TAP.  VIA/S3G CLE266 Graphics Driver (Change the resolution settings to 800x600).  Display Control Panel.  Explorer Shell.  Fat & NTFS support.  English Language Support.  NT Loader. 5. Find the settings for the User Interface Core component, and select the following:  Show My Network Places on Start Menu.  Show Control Panel on Start Menu.  Show Network Connections on Start Menu.  Show Run on Start Menu.

Module 7: Advanced Components and Additional Support Tools

 Show All Programs list on Start menu.  Show context menu on Shell folders.  Show context menu on Task bar. 6. After the image has been built, downloaded to the target, and FBA has completed, go to the Display Control Panel and verify that the driver is working.

37

38

Module 7: Advanced Components and Additional Support Tools

Exercise 2 Implementing a RAM Driver There are times when a driver is shipped without an INF file or the INF file is not accessible because it is part of a setup file. One of the more popular requested drivers is a RAM driver. In this exercise, we will download Arsoft’s XP RAM driver and use InCtrl5 to track down the necessary resources to build a component. The target system for this exercise is either the dual-boot system or the VPC.

 Create a Directory Structure 1. In Explorer, under c:\XPE_DATA create a new directory called RAMDISK. 2. Under c:\XPE_DATA\RAMDISK create a new directory called Files.

 Download and Install the RAM driver 1. Download the AR RAM driver (ramdisk.zip) from the Arsoft website: http://www.arsoft-online.de/products/download.php?id=1. 2. Unzip the ZIP file. 3. Use InCtrl5 to run the setup file and track the installation information, namely the files and registry entries. 4. In InCrtl5, select Report File Name and name the report file RAMDISK RPT_0000.TXT, choosing type text. Note the default directory for the report file. 5. You will have to reboot the system for the driver to run.

 Locate the files 1. Open RAMDISK RPT_0000.TXT, the output from InCtrl5, to locate the two required files for the component: ramdisk.cpl and ramdisk.sys. 2. Copy the files to the c:\XPE_DATA\RAMDISK\Files directory.

 Capturing the Registry Entries Registry keys play an important role for device drivers. The InCtrl5 output lists a bunch of keys for the RAMDISK driver. Now, we need to capture these registry keys for the driver. 1. Open Regedit.EXE 2. Using the table below, export the following Registry Key branches to their respective files. Save the files to the c:\XPE_DATA\RAMDISK directory.

Registry Key Branch HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00 1\Services\ramdisk

File RAMServices.REG

Module 7: Advanced Components and Additional Support Tools HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00 1\Enum\Root\RAMDISK\0000

RAMRoot.REG

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00 1\Control\Class\{1EFCBBB4-8750-46D8-A75492D9911DD587}

RAMClass.REG

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ Windows\CurrentVersion\Control Panel\Cpls (RAMDISK key only)

RAMCPL.REG

39

 Create the SLD and basic Objects 1. Open Component Designer. 2. Create a new SLD. 3. Create a new component called XP RAMDISK Driver. 4. Create a Repository called XP RAMDISK Driver REP. 5. Set the repository path to c:\XPE_DATA\RAMDISK\Files. 6. Create a Package called XP RAMDISK Driver PAK. 7. Make the new repository a member of the new package. Under group membership for XP RAMDISK Driver REP add XP RAMDISK Driver PAK. 8. Make the new component a member of the new package. Under group membership for XP RAMDISK Driver component add XP RAMDISK Driver PAK. 9. In the XP RAMDISK Driver’s details, add XP RAMDISK Driver REP as the repository for the component. 10. Now let’s place the component in a couple of locations in the Component Browser. Under group membership for XP RAMDISK Driver component add Hardware->Other and Software->System->Other.

 Add the File and Dependency resources 1. Under the File resource for the XP RAMDISK component add ramdisk.cpl and ramdisk.sys. 2. Change the path entries for both file resources to the following:  RAMDISK.SYS – Destination: %12%  RAMDISK.CPL – Destination %11% 3. Under Component or Group Dependency, add the FAT component as a required component. 4. Under Component or Group Dependency, add Windows RAM Disk Driver component as a conflicting component. These two components cannot be in the same configuration or the ArSoft RAM driver will not work. 5. Save the SLD as RAMDISK.SLD to the c:\XPE_DATA\RAMDISK directory.

40

Module 7: Advanced Components and Additional Support Tools

 Importing the REG files Now we will import all four REG files created earlier. Each import will create a new SLD with a component that only has registry resources. We will copy the registry resources to the RAMDISK component’s registry resources. 1. In Component Designer, from the menu select File and click Import. 2. Change the file type to Registry files (*.reg) 3. Locate the RAMServices.reg file and click OPEN. 4. Click Start. The import process should complete quickly. 5. Click Close. A new RAMServices.SLD file will be created with a single component. 6. Expand the new SLD file and click on the Registry under the new component. The details pane on the right will list the registry keys for the imported component. 7. Select all the registry keys and copy them to the XP RAMDISK driver component’s registry resource. 8. Close the RAMService.sld file, but don’t save the file. 9. Repeat Steps 1 thru 8 above for the remaining three REG files. 10. Save the RAMDISK SLD.

 Testing the Component 1. Open Component Database Manager. 2. Import RAMdisk.SLD. 3. Close Component Database Manager. 4. Open Target Designer and create a new configuration called XPERD. 5. Add the platform macro component to the new configuration. If you are using dual-boot, add the macro component for the dual-boot system. If you are using VPC, use the macro component for the VPC. 6. Add the following components:     

Explorer Shell NTFS NT Loader XP RAMDISK driver English Language Support (or your local language)

7. Make sure that Auto-resolve is enabled and run a dependency check. Resolve any errors. 8. Save the configuration as XPERD.slx in the \XPE_DATA directory. 9. Modify the User Interface Core component’s settings and enable the following items:  Show Desktop icons.

Module 7: Advanced Components and Additional Support Tools

41

 Show Help and Support on Start Menu.  Show Control Panel on Start Menu.  Show Printers and Faxes on Start Menu.  Show Network Connections on Start Menu.  Show Search on Start Menu.  Show Run on Start Menu.  Show Log Off on Start Menu.  Show Shut Down on Start Menu.  Show Internet Explorer on Start menu.  Show All Programs list on Start menu.  Show context menu on Shell folders.  Show context menu on Task bar.  Show Notifications on Task bar.  Lock Task bar.  Use Windows Classic folders.  Enable Drag and Drop on Start Menu. 10. Make sure that Auto-resolve is enabled and run a dependency check. Resolve any errors. 11. Build the image, Download the image to the target system, and reboot the target: dual-boot or VPC. 12. Save the configuration as XPERD.slx in the \XPE_DATA directory. 13. When the Target completes FBA, Open Explorer after the image completes FBA. You should see a Z drive. 14. Open Control Panel, and open the RAMdisk driver applet. You can modify the RAM driver properties. You can also preset the RAM dive properties by modifying the registry entries of the RAMdisk component in Target Designer.

42

Module 7: Advanced Components and Additional Support Tools

Exercise 3 Creating a Shell Component Any application can be a shell. In this exercise, you will create a component for a custom shell for a simple Windows application called TestShell.exe, which was built using Visual Studio.

The TestShell application is a very simple 3 button application that opens a command window and supports the special power management APIs for XPe (XPEPM.DLL). The application doesn’t have an installation utility, so InCtrl5 is not needed, but the application will require file resources, so DependencyWalker will be used in this exercise to find these resources.

 Create a Directory Structure 1. In Explorer, under c:\XPE_DATA create a new directory called TestShell. 2. Under c:\XPE_DATA\TestShell create a new directory called Files. 3. Copy the TestShell.exe application and other files found in C:\Program Files\MSDNTrain\2545C\Labs\Lab08\testshell to the c:\XPE_DATA\TestShell\Files directory.

 To create a new Component Objects 1. Open Component Designer. Click Start, point to All Programs, point to Microsoft Windows Embedded Studio, and then click Component Designer. 2. Create a new SLD. On the File menu, click New. 3. Save the SLD as TestShell.sld to the c:\XPE_DATA\TestShell folder. 4. In the new SLD, Expand the Windows XP Embedded Client (x86) platform.

Module 7: Advanced Components and Additional Support Tools

5. Create the new custom shell component. Right-click Components and click Add Component. 6. Name the component TestShell. 7. Create a new Repository called TestShell REP. 8. Create a new Package called TestShell PAK. 9. Make the new repository a member of the new package. Under group membership for TestShell REP add TestShell PAK. 10. Make the new component a member of the new package. Under group membership for TeshShell component add TestShell PAK. 11. Under the TestShell REP repository, set the source path to c:\XPE_DATA\TestShell\Files. The resulting path should be \Files if you have saved the SLD to the c:\XPE_DATA\TestShell directory. 12. In the details for the TestShell component, add TestShell REP as the repository. 13. Save the SLD

 Fill in the Basic Component Structure 1. To make this a shell component, it must have a Prototype of Shell prototype component. To establish this, click the Browse button next to Prototype. a. Double-click Software, double-click System, double-click User Interface, double-click Shells, double-click Windows Shell and select Shell prototype component. Click OK.

43

44

Module 7: Advanced Components and Additional Support Tools

2. We must specify the location of the custom shell executable. This is done by setting the cmiShellPath extended property. a. Click the Advanced button at the bottom of the Component Properties page. b. To add an extended property, click Add. c. Name the extended property cmiShellPath of the format type String with the value: %Systemroot%\System32\testshell.exe d. Click OK. e. Click OK to close the Advanced Properties dialog box. 3. For the custom shell component to be visible in the same location of the database as the other shell components, we need to add a shell group membership to our component. a. Right-click Group Memberships and select Add Group Membership.

Module 7: Advanced Components and Additional Support Tools

45

b. Expand Categories, double-click Software, double-click System, double-click User Interface, and select Shells. Click OK. This will place our new component at the Shells level.

4. To be sure that another shell component is not added to the build when our new shell component is used, we need to create a Shell dependency, so that the dependency check will identify our shell component as needing to be exclusive.

46

Module 7: Advanced Components and Additional Support Tools

a. Again, right-click Group Memberships and select Add Group Membership. b. This time expand Dependencies and select Shell from the list of Dependency groups. You may have to scroll down the list a bit or use Find.

c. Click OK. This group membership will require our new shell component to be exclusive from other shells. 5. Under the TestShell component’s File resources, add the Testshell.exe. 6. Change the destination to %11%. This will change the effective path to C:\WINDOWS\system32\TestShell.exe. 7. Click OK. 8. Save the SLD.

 Finding the Resources - DependencyWalker 1. We already know that the TestShell opens a command window so we need to add support for this to TestShell component. Under TestShell’s Component or Group Dependency, add CMD – Windows Command Processor component.

Module 7: Advanced Components and Additional Support Tools

47

2. Open DependencyWalker. Your instructor will have to tell you were the application is installed. 3. From the file menu select Open, and open the TestShell.EXE. The analysis of the application will begin immediately. You may get an error that a resource was not found. This error is expected since XPEPM.DLL is not in the C:\WINDOWS\system32 directory. 4. Click OK, if there is a warning dialog box. 5. The upper left pane with a tree listing of DLLs is what we are looking for. Collapse all tree branches (by click on the “[-]”) so only the roots are displayed. These are the files required to run the TestShell application.

Now we need to find the components for these files, if there are any. If you were to run a filter search for Kernel32.dll, User32.dll, Shell32.dll, and comctl32.dll, you would notice that these files are part of every XP Embedded configuration, so we don’t have to worry about these DLLs. This will leave us with three files to establish either as a file resource or a component dependency. 6. Open Component Database Manager, and use the component filter under the Component tab to search on XPEPM.DLL, MFC71.DLL, and MSVCR71.DLL. 7. If you find a component that contains the DLL, add the component to the Components or Group Dependency resources under the TestShell component. 8. If no component is found for a particular DLL, you will need to locate the individual DLL and copy the DLL to the c:\XPE_DATA\TestShell\files directory. Next, add the DLL file to the File resources under the TestShell

48

Module 7: Advanced Components and Additional Support Tools

component. DLLs are typically found under c:\Windows\System32 so make sure the destination for each file resource is set to %11%. 9. Save the SLD.

 To import the SLD 1. To open Component Database Manager, click Start, point to All Programs, point to Microsoft Windows Embedded Studio, and then click Component Database Manager. 2. In the Database tab, click Import, navigate to the c:\XPE_DATA\TestShell folder on the desktop and select TestShell.sld. 3. Click Open. 4. Select your computer’s repository root. 5. Click Import. 6. When the import has successfully completed, close the Import SLD dialog box. 7. Close Component Database Manager.

 Test the component 1. Open Target Designer 2. Create a new configuration called TestShell.slx. 3. Add the platform macro component to the new configuration. If you are using dual-boot, add the macro component for the dual-boot system. If you are using VPC, use the macro component for the VPC. 4. Add the following components:  TestShell  FAT  NTFS  NT Loader  MinLogon  English Language Support (or your local language)  Task Manager 5. Check the configuration dependencies. On the Configuration menu, click Check Dependencies. 6. Resolve any tasks that occur as a result of Check Dependencies and re-run the Check Dependencies. 7. Click Close. 8. On the Configuration menu, click Build Target Image, and then click Build. 9. You will be prompted to confirm the deletion of all the contents of the folder. Click Yes. 10. Save the configuration, and exit Target Designer.

Module 7: Advanced Components and Additional Support Tools

49

11. Deploy the image to the target system, either Dual boot or VPC 2004. Boot the XPe system. After FBA has completed, the TestShell should appear.

50

Module 7: Advanced Components and Additional Support Tools

Review 

Converting Components



Creating Custom Shell Components



Component Building Tools & 3rd Party Extensions



Debugging

1. Components created by importing Target Analyzer PMQ files do not contain files. What type of component are they and what do they contain instead?

2. When creating a custom shell, which component must the shell component inherit?

3. Which tool can be used to determine what registry keys are used by an application while it is running?

4. How can strict real-time system requirements be accommodated with Windows XP Embedded?

Module 7: Advanced Components and Additional Support Tools

51

5. What debugging technique would be used for a headless target system?

6. What debugging technique would be used if a driver is failing to load during system boot-up?