14.12.08

Tools

other pages:
home xda-project dumprom romtools serial-protocols tools versions wallaby-bootloader coldboot databases
flashfile-formats kernel-build kernelinfo memory-map platformbuilder rom-layout xda-controlpanel xda-rsupgrade
osimagetool gsmpart ril rilhook rilpatent cradle


note: the stuff in my source tree is the most up to date, usually contains lots of new features, which I have not yet released in a source + binary package. A collection of tools to do many things to a windows CE device via Activesync/RAPI.
These tools should work on most CE devices, tested on Ipaq, XDA(Wallaby), XDA-II(Himalaya), XDA-IIs(Blueangel), MDA Compact(Magician), i-mate SP3, i-mate SP3i, Yakumo P300, MPx200, Voq, Mitac Mio, Mitac Megas. with PocketPC 2002, PocketPC 2003, Windows Mobile 2003, Windows Mobile 2003 Second Edition, Smartphone 2002, Smartphone 2003, smartphone 2005, windows mobile 2005. ( wince 3.0 and wince 4.2 and wince 5.0 )

these are:

pps - dumps active wince processes
pdblist - dumps wince databases
pdel - delete wince file
pdir - list wince directory
pmkdir - create wince directory
pget - copy file from wince
pkill - kill wince process
preboot - reboot wince device
ppostmsg - send/post windows msgs to wince windows
pmemdump - copy memory block from wince
psetmem - set RAM memory location in your device
pmemmap - list available memory blocks on wince
pput - copy file to wince
pregutl - manipulate the wince registry
prun - run program in wince
dump - hexdump local file.
pdebug - capture debugoutput of processes
pdocread - raw read from disk-on-chip in your device
pdocwrite - raw write from disk-on-chip in your device
psdread - raw read from sd card in your device
psdwrite - raw write to the sd card in your device
pnewbmp - write new bootsplash bitmap to rom
pnewbootloader - replace your bootloader
prapi - interface to wince provisioning config api
psynctime - sync time with pc.

NOTE: sdread, sdwrite, postmsg, memdump, setmem and regutl are similar tools, but operate on your pc, instead of a remote device.

.... experimental stuff:
pgsmdump - attempt at memory dumper for gsm.
pget2 - attempt at improvement of pget
tlbdump - dumps virtual to physical memory mapping
riltest - dumps all kinds of info from the phone via ril
pcmon - attempt to talk 'rsupgrade'-protocol
testpi - tool to find out what handles are open on your PPC
tsttffs - tool to experiment with the trueffs API

NOTE: The experimental tools may not work, or may even cause damage. Use at your own risk, and after reading the source, and making sure you understand what they do!!!

some are vaguely based on the sample code in the pocketpc sdk.

you can leave comments with this blog article, or mail me
download
you can download the binaries here or here
or browse the source here
there is also a page on these tools at this wiki
more recent binary releases : ( newest first )

* itsutilsbin-20080923.zip
* itsutilsbin-20080731-2.zip
* itsutilsbin-20080731.zip
* itsutilsbin-20080730.zip
* itsutilsbin-20080602.zip
* itsutilsbin-20080313.zip
* itsutilsbin-20070705.zip
* itsutilsbin-20070323.zip
* itsutilsbin-20070302.zip
* itsutilsbin-20070301.zip
* itsutilsbin-20061103.zip
* itsutilsbin-20060821.zip

older versions

* itsutl050628.zip
* itsutl050119.zip
* itsutl040413.zip
* itsutl040318.zip
* itsutl040122.zip
* itsutl031023.zip
* itsutl030831.zip
* itsutl030803.zip

building
to compile it you need visual studio 2005, with the windows mobile 6 SDK. and also header files from the wince3, wince4 and wince5 platform builders.
INTRO
pps dumps active wince processes
pdblist dumps wince databases
pdel delete wince file
pdir list wince directory
pmkdir create wince directory
pget copy file from wince
pkill kill wince process
pmemdump copy memory block from wince
psetmem set RAM memory location in your device
pmemmap list available memory blocks on wince
pput copy file to wince
pregdmp dump wince registry
pregutl manipulate the wince registry
regutl manipulate the win32 registry
prun run program in wince
dump hexdump local file.
pdebug capture debugoutput of processes
pdocread raw read of m-systems DiskOnChip devices
psdread raw read from sd card in your device
psdwrite raw write to the sd card in your device
pnewbmp flash new bootsplash to device
pnewbootloader flash new bootloader to device
psynctime sync time with pc.
experimental tools
pgsmdump attempt at memory dumper for gsm.
pget2 attempt at improvement of pget
tlbdump dumps virtual to physical memory mapping
riltest dumps all kinds of info from the phone via ril
pcmon attempt to talk 'rsupgrade'-protocol
testpi tool to find out what handles are open on your PPC
tsttffs tool to experiment with the trueffs API
tstcpu tool to measure cpu speed
regbk tool to dump registry to a file
prapi tool upload certificate, or set regkeys via the provisioning api
# NOTE: The experimental tools may not work, or may even cause damage. Use at your own risk, and after reading the source, and making sure you understand what they do!!!

To build it both the embedded vc++ and 'desktop' vc++ compiler are needed.

Some environment variables pointing to various sdks need to be set to the correct values in mk.bat and mkarm.bat to build it correctly.

'itsutils.dll' is automatically copied to the windows directory of your CE device when it is detected to be out of date.

A compiled version is available at http://nah6.com/~itsme/itsutilsbin-20070705.zip

to compile, point the variables at the start of the mk.bat and mkarm.bat scripts to the right sdks. and run them.

you need the following compilers/sdk's:

* Microsoft Visual C++ ( version not important )
* Microsoft Embedded Visual C++ v4.0
* Platformbuilder v3.0
* Platformbuilder v4.2

of the platformbuilder, only the header files are used, no need to buy the complete product. the preview edition provided for free by microsoft is sufficient.
USAGE
dump.exe
This tool is not specifically meant for use with a windows CE device. I use it to make hexdumps of memory dumps.

If you have for example a romimage saved to a file, and the first byte in the file maps to address 0x80000000 in the CE device, and you want to list the dwords starting at 0x80040000. You would type something like this:

dump -b 0x80000000 -f romimage.bin -o 0x80040000 -4 -l 0x100

# using the -md5, -sha1, -sha256, -crc or -sum options, you can use dump.exe to calculate the checksum, crc or hash of a specific region of a file.
# you can also use dump.exe to extract a specific region of a file, and save it to another file by specifying a second filename on the commandline.
itsutils.dll
This is the workhorse for some of these tools ( pdebug, pkill, pmemdump, pps ). It it implements a interface callable by 'CeRapiInvoke' to do various useful things for the world. You should copy this dll to the \Windows directory of your CE device.

For instance using 'pput itsutils.dll \Windows'
pdblist.exe
This tool provides various ways of looking at the databases stored on your CE device. To get a list of all databases type 'pdblist -d', it lists the objectid, the database flags, the type of database, the nr of records, the size, the name, and the available indexes. Or if you know the name or id of the database you can list all records in this database by typing, 'pdblist -d pmailMsgClasses' ( ignore the error message, it does not mean anything ) or 'pdblist -d 0x1001568'. For each record it lists the record id, size, nr of fields, and the fields. For each field, it lists the field id, type, length, flags and value. To just list the contents of 1 record, you can type 'pdblist -r 0x0100156f' ( where 0100156f is the object id of the record ) you can also use this to list information about files. 'pdblist -r 0' will get you info on the root directory.

NOTE: this tool no longer works properly with windows mobile 2005. microsoft change the database API on the device. but did not update the activesync api to access databases.
pdebug.exe
This tool attaches as a debugger to the specified process, and prints all debug output to the console. Unfortunately the only programs I can find which have debug output are my own. It may make your CE device become unstable. a reboot after using it will do no harm.
pdel.exe
This tool works as 'del' under DOS. you can specify multiple files, and optionally a current directory with '-d' where these file should be deleted from. for example 'pdel -d \temp tst1.txt tst2.txt' will delete \temp\tst1.txt and \temp\tst2.txt.

you can also specify wildcards, or delete directories recursively. Sometimes the CE device gets in a state where it will not allow files to be deleted anymore, a reboot will usually fix this.
pdir.exe
Lists directories from your CE device. Specify '-r' to list them recursively. You can specify any number of paths with wildcards to list. Example: 'pdir \Temp \Windows' will list both the \temp and \windows directories. directories will be listed [bracketed].

you can specify device language independent paths using variables like %CSIDL_STARTUP%. to get a complete list of supported variables, type

pdir -l

pmkdir.exe
Tool to create directories on your WinCE device.
pmkdir also supports %CSIDL style variables.
pget.exe
Tool to copy files from your CE device to your local machine. you may use wildcards or multiple filenames to specify the source files. you may specify a directory for the target, if no target is specified it will default to the current directory. Example: 'pget \Windows\toolhelp.dll' will copy toolhelp.dll to the current directory.
# This tool currently does not allow you to copy certain ROM files. see 'dumprom' for that.
# pget also supports %CSIDL style variables.
# you can recursively copy all copyable files using pget -r
pkill.exe
Allows you to kill one or more processes on your CE device. If multiple processes exist with the same name, all will be killed. if result '2' is reported, this means kill successful, result '1' means process found, but unable to kill, '0' means process not found.
pmemdump.exe
Copies memory blocks to a local file, or just prints a hexdump on the console. you can specify the process context from which to read the memory. You can see the difference in context by dumping address 0x11000. for instance look at the difference between:

pmemdump -n filesys.exe 0x11000

and

pmemdump -n shell32.exe 0x11000

if no context is specified, memory is read from the perspective of the 'rapisrv.exe' process. You can use '-m' to read memory directly, bypassing ReadProcessMemory, this will crash when an invalid memory location is read.
# you can specify physical memory offsets using the -p option
# to get a rough overview of what you is in memory you can use the step -s option:

pmemdump 0x80000000 0x02000000 -s 0x10000

will list 16 bytes every 64k.
# pmemdump options are almost the same as dump.exe options

memdump.exe is the same tool, but then to access your local desktop pc memory.
psetmem.exe
this is the opposite of pmemdump, you can specify an offset and a list of bytes, words, or dwords to write to this location. this app does not write to flash memory, only to RAM.

setmem.exe is the same tool, but then to access your local desktop pc memory.
pmemmap.exe
tool to inspect the pagetables or section tables. you can also use it to create a 'hardcopy' of a specific section.
pps.exe
Display a list of processes currently running on your device. It also lists memory usage, processor usage, and commandline for each process.
# With '-s' you can specify how long it has to measure to get an accurate cpu usage reading.
# you can also see detailed thread information with '-t'
# '-m' will list all modules currently loaded in the device.
pput.exe
Like pget, but the other way around. Copies files from your local machine to your CE device. this is actually the same tool, just called with a different name.
# using '-c', pput copies data from its stdin to the device file, this is useful for instance to create .lnk files like this:

printf "#yourprogram.exe"|pput -c \windows\startup\yourpgm.lnk

pregutl.exe
Allows you to inspect or modify the registry of your CE device you can specify the hive to display ( hkcu, hkcr, hklm ) you can also import .reg files using this tool, delete keys, or modify values.
this tool is a complete rewrite of the now obsolete pregdmp
now there is also regutl.exe with the same functionality, but for desktop pc registry.
prun.exe
allows you to start programs on your CE device from your desktop machine. for instance:

prun cprog.exe -url tel:121

will start the phone application, and prompt you if you want to dial '121'.
psdread.exe
psdwrite.exe
These can be used to do raw disk read/writes from the disk device in your CE device, or USB/pccard flashdisk reader. ( like an MMC/SD card ) it defaults to using disk 1. ( on the XDA-II / Himalaya the sd card is DSK3: ) you have to specify a linear offset from the start of the device.

You can view all available disks with 'psdread -l' You can find the exact disk size of any device by specifying the '-t' option. This is because the size of Flashdisks is reported incorrectly by WindowsXP.

local (to windows) disks should be specified by drive-letter. WARNING: the drive letter assignments are quite dynamic, a disk may return on a different letter after removing/ re-adding it. psdwrite does attempt to verify that you are not overwriting your harddisk, but still be sure to specify the correct drive.

psdwrite/psdread can now also write/read partial sectors.
pdocread.exe
This tool can be used to read and list various parts of m-systems Disk On Chip devices. The -d, -p, and -h options can be used to select a specific disk device. Only specifying -d will open that device directly. Specifying -d and -p, will open the device using the storage manager, and then us the partition specified with -p. To circumvent a problem with truncated device names in some WinCE versions, you can also specify a known open device handle, using -h.

Use "pdocread -l" to get a list of known devices, and open handles on your wince device.

The -n, -w, and -o options are used to select what access method is to be used. -n 0 will read from the binary partition number 0. -w will use the standard disk api to access the device, -o will access the One-time-programmable area of your DOC. when no access method is specified, the 'normal' TFFS partition will be accessed.

Be warned that the tffs API is not very stable, it causes device crashes, and on several devices it is only partially implemented.

binary partition sectorsizes
the sector size can be different for each sector in binary partitions, to find out how the layout of these sectors, you can use this cmd.exe command:

for %i in (0 1 2 3 4 5 6 7 8 9 a b c d e f) do (
pdocread -n 1 -b 0x1000 -G 0x400000 0x%i000 0x400000 x
)

it will try to read a very large block from each sector, and output errors, indicating how many bytes were actually read.

to read the bootloader on a G4 htc device, you would need to specify -b 0x20000, while on a G3 device you would need to specify -b 0x8000.
or to read the bootsplash on a G4 device you would need to do this:

pdocread -n 1 -G 0x30000 -b 0x10000 0xF0000 0x30000 bdk1-f-splash.nb

pdocwrite.exe
This tool can write Disk On Chip partitions.

The -u PASSWD option can be used to temporarily unlock a locked diskonchip device, useful for instance for writing the himalaya extended rom, which has password "aYaLaMiH"

other options are identical to those of pdocread.
pnewbmp.exe
you must specify a bmp file, as required by splitrom, and the romversion with '-3' or '-4', this determines the location where the bootsplash is written, for (most!!) 3.x roms this is at 81900000, for 4.x roms, and the chinese 3.x rom it is at 81ec0000.
so be careful, you must first verify that the bootsplash is indeed at this location, otherwise you will overwrite essential data in your rom
pnewbootloader.exe
possibly the most dangerous tool in this collection, it allows you to overwrite the bootloader with something else. this tool depends on specific memory locations for certain roms. it does verify that it is talking to a known rom. it also does a very minimalisitc check if the file presented to it resembles a bootloader.

big warning: be sure to use a real bootloader image when updating your bootloader,
!!!!! the CLoader_usb.nb and CLoader_serial.nb files are NOT bootloaders. !!!!! this tool can be used to flash any rom area on wallaby, himalaya and magician. be very careful, and aware of what you are doing. I do not provide services to fix ruined devices.
psynctime.exe
Tool to synchronize your PDA time with your desktop pc, you have it run automatically by adding this value to your PC registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect]
"psynctime"="c:\\path-to\\psynctime.exe"

this will also correct a problem that your current application loses focus when your cradle your device.
preboot.exe
tool to remotely reboot your device, while it is cradled.
ppostmsg.exe
Utility to send messages to windows on your pocket pc device.

postmsg.exe does the same, but then for your desktop pc.
tstril2.exe
Ril Logger utility, to see what is going on with RIL.
prapi.exe
this tool talks to the device using the CeProcessConfig API.
# you can set/get/delete registry keys using repectively: '-s', '-q', and '-d'
# you can upload certificates using '-c'
# you can download certificates using '-q -c'
# you can set/get policy settings using '-p' or '-q -p'
FUTURE
pdblist

* should get a better interface,
* DONE: allow specific fields to be listed for all records
* DONE: allow less verbose field display, f.i. column wise
* DONE: allow user to set/add field, values to a record
* DONE: add support for other database volumes

itsutils

* create macro for method declaration
* add seakable stream-interface to read-memory
* add handle-scan :
* DONE: add cmdline to processinfo
* add socketinfo interface
* DONE: add version check
* DONE: add mechanism for tools to automatically update dll if nescesary

pdel

* DONE: add support for recursive delete.

pget

* DONE: clean up code
* DONE: change interface, to allow specification of rootdir, and multiple src files.
* DONE: think of convenient way of encoding both 'default to curdir' and 'other target file/dir'
* DONE: support recursive downloading
* DONE: support wildcards

pput

* DONE: clean up code
* DONE: change interface, to allow specification of multiple source files
* support recursive uploading
* DONE: support wildcards

pps

* DONE: add cmdline info
* add openfiles info, ...
* DONE: support both wince 3.x and 4.x

pregdmp

* DONE: clean up code - rewrote tool, now called pregutl
* make more efficient
* DONE: allow change of registry
* DONE: updated tool is called pregutl

pkill

* DONE: clean up code

prun

* DONE: clean up code

ptlbdump

* finish implementing it.
NOTE: pmemmap now does what i intended this to do.

planned tools

* DONE: pmkdir
* prmdir

Changelog
Changelog
040318 -> 050119

* made hexdumping interface more universal among different tools
* switched compiler from EVC3 to EVC4
* added tffsreader interface to itsutils.dll
* itsutils logs to \storage on smartphones
* added 'readphysicalmemory' -p option to pmemdump
* pps now also works on smartphones
* added more handle interpreters to 'testpi.cpp'
* added cpu speed testing tool
* added several requests and notifications to RilClass.cpp
* dump can now also save a chunk of a file
* more types of hexdump formatting.
* pdblist now also supports volumes
* added pdocread tool, to read from tffs / DOC chips
* added new himalaya, and magician roms support to pnewbootloader
* added option to pput, to take data from stdin.
* pregutl now compiles both to wince and win32 tool
* merged psdread and psdwrite tools

050119 -> 050628

* dumprom: fixed problem with negative import RVA's
* dumprom: added support for wm2005 xip sections
* dumprom: cleaned up output
* dumpxip: now uses xdadevelopers::NbfUtils, fixed decompress.
* parsecrash.pl: added more constantsa, usage info.
* formatdata.idc: added functions to inspect internals of IDA.
* hotkeys.idc: added function to swap 2 instructions, and relocate appropriately.
* hotkeys.idc: added several useful hotkeys
* debug.cpp: now logfile automatically written to the correct root.
* stringutils.cpp: simplified conversion functions
* pmemmap: now reads from page+section tables. much quicker.
* pnewbootloader: added several osses.
* pget: now can recursively copy from wince to pc.
* pregutl: added support to also run under wince.
* hexedit: added unicode-string, and fill-range options
* zipdbg: script to analyze .zip file
* peinfo: script to analyze EXE file
* makexip: added options to specify most rom params
* reg2fdf: entries no longer sorted. ... fixes problem with smartphone rom generation
* splitrom: user patches are now applied last
* typeinfo.cpp: missing from wce sdk, allows use of exception handling
* itsutils/math: scripts to do simple rsa signing/verification
* regsort: sorts a .reg file
* yakumo-img-info: manages eten-p300 image flash files
* psdwrite: now writing of DOC is supported.
* nbfutils: perl support module, for faster manipulation of nbf's.
* typhoonnbfdecode: now also can create flashable sd-card images.
* crc32: calculate crc32 of a file
* im.cmd: interface to image magick commands
* rdmsflsh.pl: script to decode MSFLSH50 rom filesystem
* Added option to pmemmap, to save an entire section as a 32M file.

050628 -> 070323
... TODO: have to write up a summary for this some time
070323 -> 070705

* pdir/pput/pget/prun/pmkir/pdel now support %CSIDL_...% style paths
* pdir -l lists all csidl paths
* pdir -l CSIDL_... prints only that path
* (p)regutl: fixed 'expand' specification
* (p)regutl: allow for much longer lines to be read
* (p)setmem: fixed '-l' load file option
* prapi: added '-d' to delete item
* prapi: added '-m' to add metabase entry
* improved activesync wait
* pdocread/write: added '-S' option to specify the partition signature, useful for H3 based devices
* pdocread/write: added '-u' option for password protected partitions

070705 -> 080602

* with 'psetmem -l filename' you can now specify a fileoffset and bytecount.
* psynctime -q will print the current device time.
* pregutl: increased size of value buf, fixed crash on empty hex keys.
* pregutl: -x, -xx, -xxx print more/everything in hex, to be able to find strange keys.
* pps: increased max nr of threads displayed.
* pps: no longer needs 'toolhelp.dll' on the device.
* pps: improved heap usage display.
* memdump '-p' option now works again
* pdocwrite: added '-W' to specify the address of a write unlock flag.
* pps : improved module name detection for threads, added '-s0' option, to print the absolute thread times.
* dump, pget now open files with maximum sharing, making it possible to read more types of files.
* dump: now using openssl for hashing
* dump: -sum now also prints various crc's
* dump: -h prints all kinds of hashes.
* dump.exe and pdir.exe now build under macosx
* pdir: added '-v' to list file attributes
* ppostmsg: added 'trace messages' feature, added --setforeground, and many other window operations
* fixed unicode handling, now using the proper utf16<->utf8 conversion functions
* pmemmap: reduced memory usage.
* pdocread : '-o' (read OTP area) now really works.

080602 -> 080730

* ppostmsg: fixed '-W' option, now instead of waiting for the window handle ( which is not something that has an effect ), now ppostmsg waits for the window's process handle.
* pkill: added '-w' option, to wait until a process has really terminated
* pput: recursive copy does not abort on errors.
* prun: added 'waitforprocess' option, to wait until a process has exited
* prun: better quoting process parameters
* prun: added option to copy and execute a local file.

080730 -> 080731

* you can configure logging by setting values in your pc's registry: HKCU\software\itsutils
logtype= 0:no logging, 1:kernellog, 2:file, default=0(none)
devicelogpath= filename of the logfile, when type=2
devicedllpath= where to store itsutils.dll on the device, default=\windows\itsutils.dll

080731 -> 080731-2

* you can now specify handles for pdocread by index in the 'pdocread -l' handle list
example: pdocread -h #1 -t

080731-2 -> 080923

* added 'psendsms', to send smsses from the windows commandline
* added 'pdial' to dial a number on the connected phone
* added 'pmv' to move or rename files on the device
* added 'pchmod' to change file permissions on the device
* fixed recently introduced bug in prun, where it would no longer take params.
* dump.exe now supports files larger than 4G
* you can use dump.exe to read from devices too.
* dump.exe now has improved summary line handling
* fixed pmemmap issue where it would not save memory blocks

some wince ( on device ) tools

* regbk: tool running on wince device to dump registry
* rdwlan, loadflashdrv: tools to read kaiser flash
* tstdev: test device drivers
* logdev: logging device driver, sits in between the dev, and the real device driver.
* gsmbufmon: tool to monitor communication between wince and the TI radio part on htc omap baed phones
* tstdevio : tool to manually call DeviceIoControl
* tstrilmon : dumps sim contents.

Note, that when running on a smartphone, you have to sign itsutils.dll
another thing to note, is that itsutils.dll requires toolhelp.dll, which is installed on most devices, but if it is not, you can find it with the compactframework sdk, or pocketpc sdk, or here

create:
makecert -n "CN=key-common-name-minimum-32-chars" -sv "privkey.pvk" "pubkeycert.cer"
note that this must not be a selfsigned certificate.
it is however not a problem if the CA's certificate is not on the device.
sign:
signcode -v privkey.pvk -spc pubkeycert.cer itsutils.dll
upload certificate to device:
prapi.exe -c pubkeycert.cer
it may also be nescesary to change the policy using prapi:
prapi -p 4097 1

for more details on codesigning, see:
# smartphone-certificates
# smartphone-policies

0 Nhận xét:

Đăng nhận xét

Đăng ký Đăng Nhận xét [Atom]

<< Trang chủ