Shattered Screen? Turn Your Broken Device into a Complete Media Center!

A cracked screen usually means you’ll have to spend a hefty … more

Gmail 5.0: Material Design and Multiple Account Support

Google started to materialize many of its applications right after announcing the … more

Some of Our Favorite Features in Android 5.0 Lollipop

Android 5.0 Lollipop is the latest major revision to Google’s mobile operating … more

Sony SmartEyeglass SDK Developer Preview Released

A little over a month ago in Tokyo, Japan, Sony unveiled its new SmartEyeglasstechnology. … more
Post Reply

NBHImageTool 1.2 (An NBH handling tool) (new WP7 NBH support)

OP Da_G

28th April 2010, 04:42 AM   |  #1  
Da_G's Avatar
OP Moderator Emeritus / Senior Recognized Developer
Flag Riverside, CA
Thanks Meter: 1,520
 
3,275 posts
Join Date:Joined: Aug 2007
Donate to Me
More
usage:

NBHImageTool -build|-dump param1 param2 param3

What is NBHImageTool?

NBHImageTool is a command line application to handle dumping and re-creation of .NBH files, which are data containers designed by HTC to be read by their SPL. The .nbh file contains a number of data partitions identified by their ItemID. NBHImageTool uses just a small subset of libnb, which is a library designed to handle Windows Mobile firmware images, and is in development. New! Support for WP7 unsigned NBH dumping and rebuilding

How do I use NBHImageTool?
Included in the archive are 2 batch files which demonstrate the usage of NBHImageTool, one will dump the .nbh to its .nb components, and an xml configuration file which defines the parameters to rebuild it. The other will build an .nbh from its .nb components and an .xml. Note that ImageHash.exe and TEST.pvk must be in the same folder as libnb.dll or it will fail to sign the output NBH. These files are not required if your output NBH is not signed.

What is the output from NBHImageTool?
It will generate an RUU_Unsigned.nbh and an RUU_Signed.nbh. The RUU_Signed.nbh is signed with the TEST.pvk certificate contained in the archive, and the RUU_Unsigned.nbh is unsigned.

What are the .nb files generated with unknown in the name?
These are some binary data that i'm not sure about. If you know what they are (and optionally how to manipulate them) let me know!

What can I change in the xml configuration and still obtain a valid .nbh to flash to my device?
Code:
Defaults for the following parameters are all generated by the dump function.
<NBHFile>
The Signed attribute tells NBHImageTool if it should sign your output .NBH with TEST.pvk.
The ModelID attribute must match your device ModelID. An asterisk (*) can be used to match any character.
The CID attribute must match your device CID if you are running the stock bootloader. If you are running HardSPL the CID can be any value.
The Version attribute can be any value.
The Language attribute can be any value.
The DataChunkSize attribute should match the original dumped value from your .NBH. This value defines the maximum size of data to be allocated inbetween signature chunks written by ImageHash.exe.
<Item>
The IncludedInNBH attribute determines if the program should look for this item in the input folder. The remaining attributes will be skipped if this is not set to 1.
The ItemID attribute defines the Item's type. 0x400 defines an os.nb, which contains most of the relevant Windows Mobile files. This is the only ItemID which defaults to be included in the final NBH. ItemID and FileName will only be read if IncludedInNBH is set to 1.
The FileName attribute defines the filename for NBHImageTool to grab from the input directory (param1). ItemID and FileName will only be read if IncludedInNBH is set to 1.
Are there any other things I can do with NBHImageTool?
RUU_Signed.nbh and RUU_Unsigned.nbh are both generated in the output folder. You could change "TEST.pvk" in the .\tools folder to a .pvk of your choosing to sign the resulting .nbh with that certificate. Or you could use the RUU_Unsigned.nbh raw image to be processed in some other way (signed using a 3rd party tool, etc.)

What are the "unknown" .nb files generated by NBHImageTool?
These are data partitions that unknown to me! If you know what one is, please drop me a PM and let me know, I will update the library with this information.

What's this "param1", "param2" nonsense?
The parameters take different values, depending if you are running -dump or -build. The values are:
-dump:
param1: Path to the .nbh to dump. This Path must end in the filename (eg. RUU_Signed.nbh)
param2: Path to the folder to extract to. This Path must end in a folder name (eg. C:\Kitchen\dumpfolder)
param3: Path to an .xml to create with configuration data to rebuild the .nbh. This path must end in an .xml file name (eg. C:\Kitchen\xml\raphael.xml)
-build:
param1: Path to the folder to take .nb files from to build resulting .nbh. This path must end in a folder name (eg. C:\Kitchen\dumpfolder)
param2: Path to the folder to build the .nbh files in. This path must end in a folder name (eg. C:\Kitchen\buildfolder)
param3: Path to an .xml to read with configuration data to rebuild the .nbh. This path must end in an .xml file name (eg. C:\Kitchen\xml\raphael.xml)

I've run into some bug with NBHImageTool, or found an .nbh that causes odd behavior!
Please drop me a PM to let me know, I will look into it ASAP!

I'm a programmer, and libnb sounds like a .dll I might be interested in.
Please contact me via PM! I'd like to support libnb.dll and all its functions for anyone interested in using it for their own program (not for commercial use)

This program is written in VS2010/C++ Native Code.
The Visual C++ 2010 (x86 or x64, depending which version you use) Runtime is required to run it.

Thanks to everyone who helped me to understand the .NBH format, the SPL, and what parameters it finds tasteful. Cmonex, Olipro, Bepe, and Ervius and many others!

Release History:
v1.0: Initial release
v1.1: Fixed a bug when the last NBH Item is smaller than DataChunkSize resulting in a crash on dumping, changed help text and error output to reflect the need for ImageHash.exe and TEST.pvk in launch folder
v1.2: Optimizations, x64 version added, WP7 Unsigned NBH format now supported for dumping, new "Signed" variable added to XML. Path issues with imagehash.exe addressed (keep it and test.pvk in the same folder with libnb.dll)
Attached Files
File Type: zip NBHImageToolv1-2.zip - [Click for QR Code] (135.9 KB, 5255 views)
Last edited by Da_G; 16th May 2010 at 10:28 AM.
The Following User Says Thank You to Da_G For This Useful Post: [ View ]
conflipper
28th April 2010, 04:46 AM   |  #2  
Guest
Thanks Meter: 0
 
n/a posts
This should be good enough, But everyone knows that if there are any errors b00n can find them, No idea how they come up wiht half the stuff they do.

This is a decent tool, that will do a lot more for everyone.

Spent the afternoon, trying everything I could think of to try and make it crash, and most of the issues have been fixed, I could not get anything else to go wrong with it, so we will have to see how it all works in the end.
Last edited by conflipper; 28th April 2010 at 06:58 AM.
28th April 2010, 07:33 AM   |  #3  
d_train's Avatar
Senior Member
Thanks Meter: 14
 
1,517 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Thanks Da_G - but I get an error on my Windows 7 x64 system - what am I missing??



I installed the x64 runtime files from here

DT

edit: had to install the x86 version
Last edited by d_train; 28th April 2010 at 07:35 AM.
28th April 2010, 07:38 AM   |  #4  
Da_G's Avatar
OP Moderator Emeritus / Senior Recognized Developer
Flag Riverside, CA
Thanks Meter: 1,520
 
3,275 posts
Join Date:Joined: Aug 2007
Donate to Me
More
Hi d_train!

Sorry, I put that in my post, but it's pretty small. I'll make it bigger, to be more clear! VS2010 is a recent release and so these files are installed on almost no machines right now
28th April 2010, 07:42 AM   |  #5  
TAEL's Avatar
Recognized Developer
Flag Tehran
Thanks Meter: 107
 
2,109 posts
Join Date:Joined: Feb 2006
More
Well done Da_G,
This is a great tool and here is my report of using it.

Original used NBH : Raphael O2 UK 5.12.206.1 ROM

First I tried to dump it via "1dump_nbh" and it worked without any errors and in ~1 second. 4 NB files created successfully: OS, Radio, SPL, Splash.

Here is the output XML:
Code:
<?xml version="1.0" encoding="utf-16"?>
<!--This document describes the contents of your NBH file. The IncludedInNBH attribute can be used to include (1) or exclude (0) that item from your final NBH-->
<NBHFile ModelID="RAPH12000" CID="O2___001" Version="5.12.206.1" Language="USA" DataChunkSize="64">
  <ItemList>
    <Item IncludedInNBH="0" ItemID="0x301" FileName="radio.nb" />
    <Item IncludedInNBH="0" ItemID="0x200" FileName="spl.nb" />
    <Item IncludedInNBH="0" ItemID="0x600" FileName="splash.nb" />
    <Item IncludedInNBH="1" ItemID="0x400" FileName="os.nb" />
  </ItemList>
</NBHFile>
Then, I tried to rebuild them via "2build_nbh". Yes, It worked great again and 2 NBH files are created in ~4 seconds. (included OS.NB only). And finally, I tried to edit XML to include all NB files and process completed successfully in ~10 seconds. (writing NBH and signing took ~3-4 seconds).

Tested in Windows 7 x86 (32bit) without installing any libraries and runtimes. (I'm using VS2010 and I think they were installed before.)
Regards
Last edited by TAEL; 28th April 2010 at 08:07 AM. Reason: update
28th April 2010, 08:01 AM   |  #6  
d_train's Avatar
Senior Member
Thanks Meter: 14
 
1,517 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Quote:
Originally Posted by Da_G

Hi d_train!

Sorry, I put that in my post, but it's pretty small. I'll make it bigger, to be more clear! VS2010 is a recent release and so these files are installed on almost no machines right now

lol now I see it

thanks for this great tool

DT
28th April 2010, 08:06 AM   |  #7  
d_train's Avatar
Senior Member
Thanks Meter: 14
 
1,517 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Here is the XML from a Leo ROM

Code:
<?xml version="1.0" encoding="utf-16"?>
<!--This document describes the contents of your NBH file. The IncludedInNBH attribute can be used to include (1) or exclude (0) that item from your final NBH-->
<NBHFile ModelID="PB8110000" CID="CSL__001" Version="1.72.831.1" Language="USA" DataChunkSize="64">
  <ItemList>
    <Item IncludedInNBH="0" ItemID="0x301" FileName="radio.nb" />
    <Item IncludedInNBH="0" ItemID="0x380" FileName="radiocust.nb" />
    <Item IncludedInNBH="0" ItemID="0x200" FileName="spl.nb" />
    <Item IncludedInNBH="0" ItemID="0x600" FileName="splash.nb" />
    <Item IncludedInNBH="1" ItemID="0x400" FileName="os.nb" />
    <Item IncludedInNBH="0" ItemID="0x920" FileName="conf.nb" />
    <Item IncludedInNBH="0" ItemID="0x900" FileName="extrom.nb" />
    <Item IncludedInNBH="0" ItemID="0x610" FileName="unknownsplash1.nb" />
    <Item IncludedInNBH="0" ItemID="0x611" FileName="unknownsplash2.nb" />
  </ItemList>
</NBHFile>
So do I assume that if I wanted to replace the splash screens I enable 0x600, 0x610 and 0x611?

Is there a utility that allows me to view and or convert WVGA splashscreen nb files?

Thanks again Da_G

DT
28th April 2010, 08:12 AM   |  #8  
Da_G's Avatar
OP Moderator Emeritus / Senior Recognized Developer
Flag Riverside, CA
Thanks Meter: 1,520
 
3,275 posts
Join Date:Joined: Aug 2007
Donate to Me
More
Yes, if you wanted to replace the splash screens you would enable the IncludedInNBH attribute for those items.

You would need to dump these .nb splash files to an editable format (such as .bmp) to work with them, and then re-create the .nb file to feed into the build function, in order to replace them in the final .nbh.

I will soon look at incorporating an automatic .nb HTC Splash Image Converter, to aid with replacing these splash images easily. I think the tool "nbimg" by pof may be able to work with them, for the time being. It accepts manual parameters for the width and height of the image. If it doesn't work, please let me know if you find or know of a tool that does, and I will update the first post until I can program a function for this tool to handle it. Thanks
28th April 2010, 08:18 AM   |  #9  
d_train's Avatar
Senior Member
Thanks Meter: 14
 
1,517 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Quote:
Originally Posted by Da_G

Yes, if you wanted to replace the splash screens you would enable the IncludedInNBH attribute for those items.

You would need to dump these .nb splash files to an editable format (such as .bmp) to work with them, and then re-create the .nb file to feed into the build function, in order to replace them in the final .nbh.

I will soon look at incorporating an automatic .nb HTC Splash Image Converter, to aid with replacing these splash images easily. I think the tool "nbimg" by pof may be able to work with them, for the time being. It accepts manual parameters for the width and height of the image. If it doesn't work, please let me know if you find or know of a tool that does, and I will update the first post until I can program a function for this tool to handle it. Thanks

Thanks Da_G - found the nbimg tool and it was able to convert the splash.nb file to bmp, but not the unknownsplash1.nb and unknownsplash2.nb files

Thanks again for your ongoing contribution to these forums

DT
28th April 2010, 10:01 AM   |  #10  
Nokser's Avatar
Recognized Developer
Flag Warsaw
Thanks Meter: 574
 
3,234 posts
Join Date:Joined: Mar 2008
Donate to Me
More
Hi Da_G
Maybe you create Tool for file *.tsw - You build good and faster tools!
Thanks

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes