Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,768,167 Members 44,655 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
Da_G
Old
(Last edited by Da_G; 16th May 2010 at 10:28 AM.)
#1  
Da_G's Avatar
Moderator Emeritus / Senior Recognized Developer - OP
Thanks Meter 1515
Posts: 3,275
Join Date: Aug 2007
Location: Riverside, CA

 
DONATE TO ME
Default NBHImageTool 1.2 (An NBH handling tool) (new WP7 NBH support)

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, 5230 views)
Support my work! The more phones I can get my hands on the more ROM goodness I can churn out. Like BUTTAH

conflipper Old
(Last edited by conflipper; 28th April 2010 at 06:58 AM.)
#2  
Guest
Thanks Meter
Posts: n/a
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.
 
d_train
Old
(Last edited by d_train; 28th April 2010 at 07:35 AM.)
#3  
d_train's Avatar
Senior Member
Thanks Meter 14
Posts: 1,517
Join Date: Feb 2009

 
DONATE TO ME
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
HTC One XL - Stock Telstra Rom
Samsung Galaxy S II: GT-I9100T
 
Da_G
Old
#4  
Da_G's Avatar
Moderator Emeritus / Senior Recognized Developer - OP
Thanks Meter 1515
Posts: 3,275
Join Date: Aug 2007
Location: Riverside, CA

 
DONATE TO ME
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
Support my work! The more phones I can get my hands on the more ROM goodness I can churn out. Like BUTTAH

 
TAEL
Old
(Last edited by TAEL; 28th April 2010 at 08:07 AM.) Reason: update
#5  
TAEL's Avatar
Recognized Developer
Thanks Meter 107
Posts: 2,109
Join Date: Feb 2006
Location: Tehran
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
Device: Galaxy Note SM-N9005
ROM: Latest Samsung Official ROM
 
d_train
Old
#6  
d_train's Avatar
Senior Member
Thanks Meter 14
Posts: 1,517
Join Date: Feb 2009

 
DONATE TO ME
Quote:
Originally Posted by Da_G View Post
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
HTC One XL - Stock Telstra Rom
Samsung Galaxy S II: GT-I9100T
 
d_train
Old
#7  
d_train's Avatar
Senior Member
Thanks Meter 14
Posts: 1,517
Join Date: Feb 2009

 
DONATE TO ME
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
HTC One XL - Stock Telstra Rom
Samsung Galaxy S II: GT-I9100T
 
Da_G
Old
#8  
Da_G's Avatar
Moderator Emeritus / Senior Recognized Developer - OP
Thanks Meter 1515
Posts: 3,275
Join Date: Aug 2007
Location: Riverside, CA

 
DONATE TO ME
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
Support my work! The more phones I can get my hands on the more ROM goodness I can churn out. Like BUTTAH

 
d_train
Old
#9  
d_train's Avatar
Senior Member
Thanks Meter 14
Posts: 1,517
Join Date: Feb 2009

 
DONATE TO ME
Quote:
Originally Posted by Da_G View Post
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
HTC One XL - Stock Telstra Rom
Samsung Galaxy S II: GT-I9100T
 
Nokser
Old
#10  
Nokser's Avatar
Recognized Developer
Thanks Meter 574
Posts: 3,234
Join Date: Mar 2008
Location: Warsaw

 
DONATE TO ME
Hi Da_G
Maybe you create Tool for file *.tsw - You build good and faster tools!
Thanks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Forums Added for the Nvidia Shield Tablet and Sharp Aquos Crystal

Just a few days ago, wetook an in depth look at theNvidia Shield Tabletand … more

[OTA Captured] Android 4.4.3 Lands on European HTC One M7

The secound release of the Android L Developer Previewmay be the new hotness for … more

Take a Perfectly Stable Shot with Open Camera

The camera app on our Android smartphones and tablets isn’t something we focus on all … more

Motorola Droid X Receives Almost Fully Functional KitKat Port

While we are all wondering when Google will decide to officially release … more