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

Search This thread

Da_G

Inactive Senior RD / Moderator Emeritus
Aug 20, 2007
3,330
1,560
Riverside, CA
Samsung Galaxy S22 Ultra
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 ([b]param1[/b]). 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)
 

Attachments

  • NBHImageToolv1-2.zip
    135.9 KB · Views: 5,688
Last edited:
  • Like
Reactions: nenebear
C

conflipper

Guest
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:

d_train

Senior Member
Feb 19, 2009
1,522
15
Thanks Da_G - but I get an error on my Windows 7 x64 system - what am I missing??

52kmrp.png


I installed the x64 runtime files from here

DT

edit: had to install the x86 version :eek:
 
Last edited:

Da_G

Inactive Senior RD / Moderator Emeritus
Aug 20, 2007
3,330
1,560
Riverside, CA
Samsung Galaxy S22 Ultra
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 :)
 

TAEL

Retired Recognized Developer
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:

d_train

Senior Member
Feb 19, 2009
1,522
15
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
 

Da_G

Inactive Senior RD / Moderator Emeritus
Aug 20, 2007
3,330
1,560
Riverside, CA
Samsung Galaxy S22 Ultra
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 :)
 

d_train

Senior Member
Feb 19, 2009
1,522
15
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
 

Laurentius26

Inactive Recognized Developer
Nov 22, 2005
7,972
1,151
Thanks Da_G, works like a charm on my XP Pro machine. :)
I send you some beer money so you can order La Chouffe from Holland. :D;)

Congrats :)
 
Last edited:

mac_es

Senior Member
May 20, 2008
273
6
Hi,

Which are the advantages os this utility compared to nbhutil from olipro?

Thanks
 

airxtreme

Retired Recognized Developer
Feb 19, 2008
1,119
22
Hi,

Which are the advantages os this utility compared to nbhutil from olipro?

Thanks

NBHUtil and HTCRT need configuration files provided by other users that often lack support for new devices and are incomplete/inaccurate. This utility instead can make its own building configuration file from the NBH itself so you can rebuild any NBH without having to desperately search for the correct configuration file that supports your device.
 

hartv427

Senior Member
Jan 16, 2009
103
5
Thank you for this Da_g your work is always appreciated
Excellent tool works flawlessly

Transaction ID: 5LV66560PR5951831
 
Last edited:

Da_G

Inactive Senior RD / Moderator Emeritus
Aug 20, 2007
3,330
1,560
Riverside, CA
Samsung Galaxy S22 Ultra
@mac_es:

As airxtreme already stated, one of the bigger drawbacks of previous tools is that you had to come up with a configuration file somewhere. This one will automatically generate one from any ROM for your device. This has the advantage of picking up on any ItemIDs that we hadn't previously seen in a ROM or didn't exist until recently (like radiocust, radioconf)

I'm working with l3v5y to add another nice feature, automatic dumping of a splash screen .nb to .bmp, and then automatic rebuilding of the splash screen .nb from the .bmp (i'll probably add a flag to the xml for that auto rebuild from bmp) - this way you can work directly on the .bmp and avoid unneccessary conversions every time you make an edit to it.

I'm looking at making a routine to pull the radio.nb version out too, and store it in the xml, just for informational purposes.
 

rgb-rgb

Senior Member
Feb 18, 2007
385
3
Texas
Very nice work Da_G. Really appreciate the time and effort you put into doing this stuff for us.

Just one question, now that we have this tool for getting the .nbh, what is a good option for us at the moment to get the packages extracted from the .nbh?
 
Last edited:

Da_G

Inactive Senior RD / Moderator Emeritus
Aug 20, 2007
3,330
1,560
Riverside, CA
Samsung Galaxy S22 Ultra
xidump from Bepe is a fine tool for this, it can work directly with the os.nb, and output directly from it.

Unfortunately it has no build support yet, that is my next target, to replace NBImageTool with a new version that handles dumping and building :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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 ([b]param1[/b]). 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)