From: http://www.chinaitpower.com/A/2004-06-11/83197.htmlLuckyhm recommendation
Jiazhengod 20071015
Introduction
There are multiple ways to create custom components for Microsoft Windows XP embedded. For example, you can directly import the import device driver. inf file to the component designer tool (this is a huge improvement compared to Microsoft Windows NT embedded 4.0 ). You can import devices. pmq (target analyzer probe (TAP) or target analyzer (TA) Output) to create a component-so far everything has been done well-but how to create a component that can describe a custom application?
For the purpose of this article, I decided to build a secure device that uses timershot Windows XP powertoy-a very cool application that can capture images from connected Image devices, and store the image to the preset location-my local hard disk or network sharing (the link to Windows XP powertoy can be found at the end of this Article ). Timershot can be configured to capture an image every several seconds or several minutes. All these are configured in the application and stored in the Windows XP registry. I will also include another application named "photodisplay", which I wrote specifically for this article. Photodisplay can be used to view stored JPEG files.
Unfortunately, there are no tools to automate the process of generating Windows XP embedded components for applications-some detective work is required. Therefore, I will get rid of the deer hunters, call my friend Dr Watson (here it is a forward sign), and start my work.
Installation Options
When building a Windows XP embedded device, you can use multiple options for adding third-party applications/technologies. These options mainly depend on the hardware configuration of the device and the method used to manufacture the distribution device.
The maximum flexibility is available when building a device that is started from the R/W media (usually hard drives) and contains a CD-ROM/DVD-ROM drive, display, keyboard, and mouse. In this configuration, you can directly run a third-party installer on the embedded target, which will directly copy and configure the application on the target device. If you want to build a one-time device, or if you want to test the application on Windows XP embedded to ensure that all required operating system components exist (as discussed below ), this option is useful.
Another option is to generate a Windows XP embedded image (usually generated in the/Windows Embedded images folder), and then manually add necessary applications/resources to the build folder. Then, you can copy the Windows XP embedded operating system image (and applications/resources) to a media file that can be started, and then test the application. This is only applicable to simple applications that do not require registration of COM objects or installation of basic operating system services.
The best way is to create a component that meets the following conditions: You can use this component within the target designer, and you can select this component like any other Windows XP embedded component. If you have installed the Windows XP embedded tool for multiple users, this is an ideal option. However, this requires some work. Let's analyze how to install the application and what parts of the operating system are usually modified.
The form and size of the installation program are different. It can be a simple xcopy or iexpress, or a GUI installer that requires users to provide registration information and may issue multiple CdS/DVDs. The installer may install database engines, operating system services, device drivers, or support DLL, and may change the operating system registry or INI file-in some cases, the installed files may be installed in Multiple folders on the PC: used to store the program files of the core application, used to store the "/Windows/system32" of the device driver ", or other folders depending on the installer. To determine what content should be included in your Windows XP embedded component, it seems that it is not a common task at first glance. We are pleased to have some tools and technologies to help you.
The next section provides an advanced overview of the tools required to determine which file/Registry Settings and operating system components are to be included in the Windows XP embedded component.
Detective Toolkit
This section describes the tools required to generate a custom Windows XP embedded component.
Two groups of tools are required for generating and testing components. Some of these tools will run on the development PC, while others will be included on the target device to debug applications or components. Let's divide these tools into the above two categories, and then evaluate the usage of each tool.
Tools used in PC development
Although the installation of the application cannot be changed, you can monitor the operating system to determine which changes have occurred after the application is installed. Many tools can be used to help complete this process. Because some installers require a restart during the installation process, you should ideally use a tool that can monitor the PC's file system and the changes in the registry after the restart. Applications such as inctrl5 (zdnet) and sysdiff (Microsoft) obtain the snapshot of the file system and registry before installing the application, and then obtain the snapshot of the file system and registry after installation, and provides reports on the differences between the two-This helps determine which files should be included in the component. Note that changes to the file system and registry may also be made to applications and services that are already running when the application is installed.
The following is a list of tools used on my development PC, to determine which files/registry items should be included in my custom components-I will explain the usage of each tool through the steps described later in this article.
• Inctrl5-used to obtain a snapshot of the file system and registry, and provides a list of differences (zdnet)
• Dumpbin-used to determine which DLL is used by the application/DLL (Microsoft Visual Studio. NET)
• Depends-it can also be used to determine which DLL (and API) is used by the application)
• Regmon-Dynamic Monitoring of registry changes (NT System internals)
• Filemon-dynamic File System Monitoring (NT System internals)
• Windows XP embedded development tools-target analyzer probe, component designer, component database manager, and target designer
Tools used on the target device
Using the above tools to determine which files and registry keys are needed is only part of the puzzle. After the Windows XP embedded image has been generated, the application will also need to be tested to ensure that it can work as expected-the application may dynamically load the DLL or create an instance of the COM object, however, you cannot use dumpbin or depends to capture the information. Therefore, some debugging tools are required on the target device. The following is a list of tools used on my target devices (these tools should be deleted before the final Operating System image is deployed ).
• Regmon-Dynamic Monitoring of registry changes (NT System internals)
• Filemon-dynamic File System Monitoring (NT System internals)
In the next section, I will test the usage of these tools.
Summary
Process Overview
First, let's repeat security devices and list available components. We plan to generate security devices based on Windows XP embedded. In this example, I will use Toshiba tecra 9000 laptop as my development PC and use Logitech USB camera and Windows XP embedded timershot powertoy (for the download location of this component, refer to the link at the end of this article) as my target device and use the detective toolkit mentioned above.
The toshba laptop has two hard disk partitions. The primary partition contains Windows XP Professional and all my development tools (Windows XP embedded, Visual Studio. NET, etc.) and is formatted as NTFS. I also have a secondary partition with a size of 700 mb (approximately equal to the size of the disc) and is formatted as FAT32. I have modified my boot. INI (it resides in the root directory of the boot drive to add secondary boot options for Windows XP embedded-Note: boot. INI is configured with the system and hidden attributes)-boot. INI:
[Boot loader]
Timeout = 30
Default = multi (0) disk (0) RDISK (0) Partition (1)/Windows
[Operating systems]
Multi (0) disk (0) RDISK (0) Partition (1)/Windows = "Microsoft Windows XP
Professional "/fastdetect
Multi (0) disk (0) RDISK (0) Partition (2)/Windows = "Microsoft Windows XP
Embedded "/fastdetect
At startup, I got two options: Start to Windows XP Professional (on my primary partition ), or start my Windows XP embedded image (on my secondary partition ). After 30 seconds of timeout, the default option is to start Windows XP Professional.
Step 1-capture information from the installer
The first step in creating a custom component is to determine the file and registry settings required by the application. The installer and Detective tool should run on Windows XP Professional. You can run and test applications for fully-configured operating system images-this article will soon test applications for Windows XP embedded.
The Windows XP powertoys web site lists some powertoy. When you click the corresponding link to download a powertoy, you are prompted to select Open, save, cancel, or more info. Click Save to save the timershotpowertoysetup.exe program to the hard disk. Note: When "open" is selected, powertoy will be downloaded and installed. In this case, you do not need to capture information during installation.
You will also need the file system and registry snapshot tools. For the purpose of this article, I have chosen to use the inctrl5 provided by zdnet, although many similar tools can be used.
The following shows the appearance of inctrl5: the installation program is inserted (in my example, C:/stuff/XP-powertoys/timershotpowertoysetup.exe ), the report output location is changed to point to my installation folder, and then I click Go !.
Figure "1.
Inctrl5 captures the registry and file system snapshots of my development PC, and then starts the powertoy installer. After the installation is complete, the second snapshot is obtained and a report is generated.
Compiled reports list file systems, registries, INI files, and text files (autoexec. NT and config. NT) all changes made-this report contains changes made to the file system and registry by other applications that are running when powertoy is installed. The report also contains registry keys and files used to uninstall powertoy. Because I want to build an embedded device and do not want users to delete the application, I can ignore the uninstall information.
Let's take a look at some changes to my system caused by installing powertoy.
Registry
17 registry items are added, including:
Hkey_classes_root/installer/products/ccbb1_a83433bb43879c6d9a91c526a
This is obviously used by the uninstallation program of powertoy and can be ignored. Some additional subitems are added. Similarly, they can be ignored.
138 values are added to the Registry, including:
HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/explorer recentdocs/. BMP
While installing powertoy, I am writing and saving this article, so some registry values are changed as I continue to work.
Hkey_classes_root/installer/products/ccbb1_a83433bb43879c6d9a91c526a
Some values used during the uninstall process have been added to the Registry-these values can be ignored because I do not want users to delete the application.
Strangely, no timershot registry entries are listed. Therefore, we can assume that timershot powertoy checks whether an optional registry item exists at runtime. If such registry settings do not exist, the default option is used.
File
Now the discussion file. The following is a list of files changed during timershot powertoy installation (from the inctrl5 Report)-You can see that most files are used during installation/uninstallation. The interesting line is timershot.exe; it has been installed in the/Windows/system32 folder.
C:/Documents and Settings/all users/Start Menu/programs/powertoys
Windows XP/timershot. lnk
Date: 4/29/2002 4:53 AM
Size: 1,641 bytes
C:/Windows/downloaded installations/timershot powertoy for Windows XP. MSI
Date: 4/29/2002 4:53 AM
Size: 411,684 bytes
C:/Windows/installer/2a1e66. MSI
Date: 4/29/2002 4:53 AM
Size: 349,696 bytes
C:/Windows/installer/{A743BBCC-3438-4BB3-8397-
6c9d9ac125a6}/arpproducticon.exe
Date: 4/29/2002 4:53 AM
Size: 22,486 bytes
C:/Windows/installer/{A743BBCC-3438-4BB3-8397-6C9D9AC125A6}/readme_1.htm
Date: 4/29/2002 4:53 AM
Size: 318 bytes
C:/Windows/installer/{A743BBCC-3438-4BB3-8397-
6c9d9ac125a6}/timershot_1.exe
Date: 4/29/2002 4:53 AM
Size: 22,486 bytes
C:/Windows/system32/timershot.exe
Date: 3/19/2002 pm
Size: 192,000 bytes
D:/system volume information/_ restore {1fe94af8-3502-4a8f-8658-
25737cdb40de}/rp46/change. log.1
Date: 4/29/2002 4:53 AM
Size: 496 bytes
D:/system volume information/_ restore {1fe94af8-3502-4a8f-8658-
25737cdb40de}/rp46/restorepointsize
Date: 4/29/2002 4:53 AM
Size: 8 bytes
Note that I have a file list for the application. Of course, this may include some executable files and DLL files.
Step 2-Registry Settings
Many options that can be configured by the user, including the timer interval for taking photos, the location of the output file, and the size of the output image. What I don't know at the moment is the location of the option in the Registry (I assume that the application stores its configuration information in the registry, applications can also easily store configuration information in ini files using writeprivateprofilestring ).
The following figure shows the appearance of the timershot application, including some options that can be configured by the user (note that I have cut some options to reduce the bitmap size in the document ).
Figure "2.
I can guess the name of the registry key used by timershot powertoy-it may be timershot or powertoy, and I can use Regedit to search for registry keys. However, some registry items may be changed within the Registry, including some registry items associated with Logitech camera. Therefore, I have the following options:
1. I can run the snapshot software, install and run timershot powertoy, change the powertoy option, and then let My snapshot Software List the differences.
2. I can also modify the registry and monitor changes at runtime. This is the time to use the sysinternals regmon utility. Regmon intercepts read and write requests to the Registry and lists these requests in its report window.
I can run the regmon utility to determine the registry key used by the program at runtime, and then run the application timershot. Then, I modify the options of the application, you can also use regmon to monitor the changed registry keys. The following is the running regmon. I have changed the timershot timer interval from 10 minutes (default) to 5 seconds. Note that the following registry items have been changed.
HKEY_CURRENT_USER/software/Microsoft/powertoys for XP/timershot
Figure "3.
Note that I have the file list and registry key required by the application.
Step 3-application dependencies
The name and location of the application binary file (EXE/DLL) and the Registry key used for the application are now known. What is unknown at this time is the core operating system file used by the application. It is convenient to use dumpbin (command line tool included with Visual Studio. NET) or depends (Web downloadable tool-For more information, see the link at the end of this Article.
Next, you can see the actual running depends.exe. In the upper left pane of the application, you can clearly see the list of required DLL. The list includes kernel32.dll, gdi32.dll, user32.dll (not surprising so far), and msvcrt. DLL and shlwapi. DLL-it has some dependencies, including ole32.dll and apphelp. DLL, mlang. DLL.
Figure "4.
Note that I have the file list and registry key required by the application.
Step 3-application dependencies
The name and location of the application binary file (EXE/DLL) and the Registry key used for the application are now known. What is unknown at this time is the core operating system file used by the application. It is convenient to use dumpbin (command line tool included with Visual Studio. NET) or depends (Web downloadable tool-For more information, see the link at the end of this Article.
Next, you can see the actual running depends.exe. In the upper left pane of the application, you can clearly see the list of required DLL. The list includes kernel32.dll, gdi32.dll, user32.dll (not surprising so far), and msvcrt. DLL and shlwapi. DLL-it has some dependencies, including ole32.dll and apphelp. DLL, mlang. DLL.
Figure "5.
Note that at this time, I have a list of files, registry keys, and required DLL-the next step is to generate this component.
Step 4: generate the component
Generating this component is no different from generating any other component. I have a list of required files, I know which registry items need to be added, and I have component dependencies (dependency file list output based on dumpbin/depends ). For more information about component design and development, see Windows XP embedded online document or msdn online document.
There are some issues to consider about custom components. For example, some COM objects or Microsoft ActiveX controls must be registered before they can be used by core applications. (You can use the dumpbin/exports command to analyze DLL export to determine whether the corresponding component is a COM/ActiveX component. If the functions dllregisterserver, dllunregisterserver, and dllcanunloadnow are exposed, they should be COM objects or ActiveX controls .) First boot agent (FBA) can be used to register COM objects. This is enabled through component resources. Observe the following component designer screen snapshot. You can see many custom resources that can be enabled, including fba com/DLL registry and quick creation. The Windows XP embedded document provides an overview of how to use the FBA command-go to the system design guide to find the Windows XP embedded topic-appendix information-custom resources.
Figure "6.
You may be wondering what the first boot agent has done. After you create a Windows XP embedded image and deploy it on the device, the device can be started for the first time when it is enabled. In this case, the first boot agent (FBA) can perform the following system configuration tasks:
• Tasks that cannot be performed offline using target designer, such as device detection and configuration using plug-and-play
• Execute more practical tasks at runtime, such as registering a Component Object Model (COM) Server
Step 5: generate a Windows XP Embedded Operating System Image
It is very easy to generate a Windows XP embedded image. I have completed the process of creating components based on the output of target analyzer probe (TAP), including the Logitech camera driver. However, I need to add a small component list to the project. These components include:
• Tecra9000-including Logitech webcam (Component created from the tap output)
• Timershot (the component just created in component designer)
• One of the design templates (I chose information appliance ).
• Fat component, located in SOFTWARE | system | storage and file systems | infrastructure | file systems.
• Fat format component, located under SOFTWARE | system | storage and file systems | applications.
• Explorer Shell component, located in SOFTWARE | system | User Interface | shells.
• You must include an OS loader. Select the Windows NT loader component, which is located under SOFTWARE | system services | base.
• English language component, located in SOFTWARE | system | International | infrastructure | English language support.
• I also added the Windows Image Acquisition user interface component, which is located under SOFTWARE | system | Printing & imaging | applications. I want to use the control panel scanners & cameras applet (which is enabled through the Windows Image Acquisition User Interface Component) to fully test Logitech camera on the Windows XP embedded image. Adding this component allows you to test the camera without having to run the timershot application. Once I know that the camera works, I can continue to run the application. If necessary, you can test the camera, delete the Control Panel applet, and regenerate the operating system image.
• I also need to change the user interface core | settings in the project workspace to enable the control panel on the Start Menu.
Figure "7.
Note that at this time, I can generate an operating system image (for details about how to configure and generate a Windows XP embedded operating system image, see target designer online help ).
Test applications in Windows XP embedded
Applications need to be tested to ensure that all components work as expected. Some tools should be included in the Windows XP embedded image to help in the testing/debugging phase of deploying custom applications.
The timershot application runs very well on Windows XP embedded. The following figure shows the running appearance:
Figure "8.
The first step to test an application is to simply run the application on Windows XP embedded and check which components can work normally (more importantly, which components cannot work normally ). If all components work properly, the test is complete. However, it is likely that one or more required resources are missing. These resources may be unregistered COM objects, rule DLL, auxiliary application (exe) and resource files (data file ,.wav files, etc.), or missing registry items. How can we determine which resources are missing? You can use the sysinternals tools Filemon and regmon. You have multiple options at this time. You can create a toolkit component for target designer, including the regmon and Filemon applications (preferred ), you can also generate your o/s image (usually generated in the/Windows Embedded images folder) and put the Filemon/regmon file into your generated folder. Then, when you copy the Windows XP embedded operating system image to a media file that can be started and start the o/s, you can use these applications.
Because I configured the timershot application option before generating the timershot component, you have learned how to use regmon to track registry changes. On Windows XP embedded devices, I can use regmon to track read/write operations on the registry, which helps determine which additional registry items are required to run the application. For example, you can start regmon on the target device, start the timershot application, and view the items read from the registry at startup. Regmon reports notfound for any entry that does not exist in the device registry.
Filemon tool can be used to track missing files and DLL-I have added two applications to my Windows XP embedded device: timershot (which can capture JPEG images from Logitech camera) and "photodisplay"; I also added an MFC application, which uses Visual Studio.. net, and has an external support DLL used to display JPEG files in the application workspace. When I run the photodisplay application, I receive a message with the following meanings:
Figure "9.
I know that the application will not work properly because a required DLL is missing. I cannot determine which DLL is missing, but I can run depends or dumpbin to list static link DLL (and all components that seem to be included in my Windows XP embedded image ). I don't know which DLL (or COM Object) is being Dynamically Loaded, But I can use regmon to track the files being loaded by the photodisplay application. The following is a snapshot of Filemon running on the target device of my Windows XP embedded. Note that I have highlighted the section that shows a photodisplay application trying to load dispimage. dll. This dll is not included in the Windows XP embedded image, so it cannot be loaded by the application. To fix this application, I only need to add the dispimage. dll file to the Windows XP embedded image (by updating my photodisplay component ).
Figure "10.
Note that I have created a component for the timershot application, including all the files and registry items required to run the timershot application on the Windows XP embedded device.
Summary
To generate the Windows XP embedded component for the application, you need to complete some work and use some tools. In this article, I focus on the general steps required to generate components for Windows XP Professional powertoy timershot; the principles and tools used to generate the component are the same as those used to generate components for large applications.