NoMansSky:Creating Mods From MBINs: Difference between revisions

From Step Mods | Change The Game
mNo edit summary
Line 3: Line 3:
{{TOC_right}}
{{TOC_right}}
== The purpose of Hex Editing ==
== 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.
Hex Editing is the way to edit any computer file, whatever its format as long as it is not compressed.
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.<br>
So once NMS files are unpacked, any of them can be edited with an hexadecimal editor.
But do not expect to create mods this way, because files are structured and apart if you already studied the structure yourself (comparing .MBIN files with decompiled .EXML files for example), there's little chance you could know exactly what you have to change to create a mod.


In practice, the way to update a mod is simple :
So what's the point of hex editing ?
# Use a binary comparison between the original MBIN files and modded MBIN files (both from previous NMS version).
The point is to be able to update some mods in the following cases :
# Note the changes
* A new big update has been released and you temporarily can't decompile .MBIN files anymore as MBINCompiler hasn't been updated yet.
# Apply the same changes to the new .MBIN files from latest NMS version.  
* You found a very old mod and have a strong will to update it for current game version
 
==Updating mods by comparison==
In both cases, in theory, the way to update a mod is simple :
# Proceed a binary comparison between the modded .MBIN files you want to update and an original .MBIN files '''IDEALLY FROM THE SAME GAME VERSION'''.
# Note all the changes. Usually you might note the position in the file (the offset) and the new value for each change.
# '''APPLY THE SAME CHANGES'''' to the .MBIN files of the latest NMS version.  
# Recompile and repack the mod
# Recompile and repack the mod
That's for the theory. In practice, you don't always have a backup of all the game files from the previous game version and even you have them, sometimes new values have been added into the files and some values have shifted. In both cases, this will need a lot more work and you might need to recognize the patterns around the changes by human eye.
<br>
That's for the theory. In practice, you probably noticed the two bold sentences above.<br>
Indeed these could be some very difficult points:
* Game version : To be able to compare apples with apples, you need to have an original .mBIN file of the same game version, or close to this game version, than the modded files. If you are modding NMS since a long time, you probably made backups of older game versions, but if you're new on the scene, there's few chances you could find these original gems. There's some chance though that the file structure hasn't change so much, so you can also attempt at comparing the modded .MBIN file with your latest original .MBIN one, but it's all about luck.
* Applying changes : Even if the changes are simple, sometimes new values have been added into the files and a lot of values have shifted. Meaning you can't apply changes just based on offset/values but you need to recognize where your desired value has moved before applying the change.
 
So all in all, if you get a close enough original file that permit a clean comparison of files resulting in a very few changes, it will be trivial to update a mod. If the comparison results in hundreds of changes, added and removed parts, there's few luck you will be able to update this mod.


== Hexadecimal Editors ==
== Hexadecimal Editors ==

Revision as of 08:52, August 15, 2020

Template:TOC right

The purpose of Hex Editing[edit | edit source]

Hex Editing is the way to edit any computer file, whatever its format as long as it is not compressed. So once NMS files are unpacked, any of them can be edited with an hexadecimal editor. But do not expect to create mods this way, because files are structured and apart if you already studied the structure yourself (comparing .MBIN files with decompiled .EXML files for example), there's little chance you could know exactly what you have to change to create a mod.

So what's the point of hex editing ? The point is to be able to update some mods in the following cases :

  • A new big update has been released and you temporarily can't decompile .MBIN files anymore as MBINCompiler hasn't been updated yet.
  • You found a very old mod and have a strong will to update it for current game version

Updating mods by comparison[edit | edit source]

In both cases, in theory, the way to update a mod is simple :

  1. Proceed a binary comparison between the modded .MBIN files you want to update and an original .MBIN files IDEALLY FROM THE SAME GAME VERSION.
  2. Note all the changes. Usually you might note the position in the file (the offset) and the new value for each change.
  3. APPLY THE SAME CHANGES' to the .MBIN files of the latest NMS version.
  4. Recompile and repack the mod


That's for the theory. In practice, you probably noticed the two bold sentences above.
Indeed these could be some very difficult points:

  • Game version : To be able to compare apples with apples, you need to have an original .mBIN file of the same game version, or close to this game version, than the modded files. If you are modding NMS since a long time, you probably made backups of older game versions, but if you're new on the scene, there's few chances you could find these original gems. There's some chance though that the file structure hasn't change so much, so you can also attempt at comparing the modded .MBIN file with your latest original .MBIN one, but it's all about luck.
  • Applying changes : Even if the changes are simple, sometimes new values have been added into the files and a lot of values have shifted. Meaning you can't apply changes just based on offset/values but you need to recognize where your desired value has moved before applying the change.

So all in all, if you get a close enough original file that permit a clean comparison of files resulting in a very few changes, it will be trivial to update a mod. If the comparison results in hundreds of changes, added and removed parts, there's few luck you will be able to update this mod.

Hexadecimal Editors[edit | edit source]

To edit .MBIN binary files, you will need an hexadecimal editor and there's quite a lot of them.
Here is a list of some of them worth mentioning:

  • 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[edit | edit source]

As most file formats, .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[edit | edit source]

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.

Template:NMSPageClose