Difference between revisions of "NMS:Tutorials/Mod Creation by Hex Editing MBINs"

From STEP Modding Wiki
m (The purpose of Hex Editing)
m (The purpose of Hex Editing)
Line 9: Line 9:
 
# Use a binary comparison between the original MBIN files and modded MBIN files (both from previous NMS version).
 
# Use a binary comparison between the original MBIN files and modded MBIN files (both from previous NMS version).
 
# Note the changes
 
# Note the changes
* Apply the same changes to the new .MBIN files from latest NMS version.  
+
# Apply the same changes to the new .MBIN files from latest NMS version.  
 
# Recompile and repack the mod
 
# Recompile and repack the mod
 
{{Notice Small|text=Beware, sometimes new values are added into the files and some values have shifted. In that case, you will need to recognize the patterns by human eye.}}
 
{{Notice Small|text=Beware, sometimes new values are added into the files and some values have shifted. In that case, you will need to recognize the patterns by human eye.}}

Revision as of 20:29, August 11, 2020

<img src="NMSHeaderBG.jpg" alt="BannerLogo" style="border-radius:10px;">
Tutorials // Mod Creation by Hex Editing MBINs

Contents

The purpose of Hex Editing

Sometimes, after a game update for example, you can't decompile .MBIN files anymore because MBINCompiler has not been updated yet. If that happens, either you wait for a new MBINCompiler version supporting the files you want to edit, either you can still edit them with an hexadecimal editor.

In practice, the way to update a mod is simple :

  1. Use a binary comparison between the original MBIN files and modded MBIN files (both from previous NMS version).
  2. Note the changes
  3. Apply the same changes to the new .MBIN files from latest NMS version.
  4. Recompile and repack the mod

Template:Notice Small

Hexadecimal Editors

there are a lot of Hexadecimal editor available. Here is a list of some of them:

  • 010 (paid, with 30 day trial)
  • HxD (freeware, proprietary)
  • Hex Editor Neo (free, has paid versions)
  • Hex Workshop (paid)
  • HexEdit (mac only?)
  • XVI32 (freeware, very small (~1Mb) and portable)

.MBIN Header

As most of file format, .MBIN files start with a header.
The .MBIN header is 96 (0x60) bytes and is composed as follow :

  • Magic Data which is 4 bytes long. It is 0xCCCCCCCC for MBIN files and is 0xDDDDDDDD for MBIN.PC files.
  • Format ID, a 4 bytes long integer
  • Time stamp, an 8 bytes long integer. If the file was compiled with MBINCompiler, stamp is replaced by the MBINCompiler Tag "MBINCver".
  • Template GUID, an 8 bytes long integer. If the file was compiled with MBINCompiler, this is replaced by the MBINCompiler version in the form of xx.yy.zz matching the MBINCOmpiler version used to compile the file.
  • Template Name, a 72 (0x48) bytes string reserved for the internal file name.

For a litlle more details on the original header of MBINfiles and MBINCompiler ones, see here.

The rest of the file contains the data. This can't be detailed here as each MBIN file has a different data structure but this won't be an issue as most of the time, we don't need the structure to make the needed changes.

Editing MBIN files

First, you need to know that MBIN Files are all using little indian byte order. So before anything, set your Hexadecimal editor to read values in little indian order.