NoMansSky:Creating Mods From MBINs: Difference between revisions

From Step Mods | Change The Game
(27 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTITLE__
__NOTITLE__
{{NMSPage|contentTitle=Tutorials // Mod Creation by Hex Editing MBINs}}
{{NMSPage|contentTitle=Tutorials // Hex Editing MBINs}}
{{TOC_right}}
{{TOC_right}}
== Mod Creation by Hex Editing MBINs ==
== The purpose of Hex Editing ==
If the MBIN you want to edit is not supported by MBINCompiler (yet) after an NMS update, you can still edit MBIN files with a hex editor. The MBIN files store the game values in a binary serialized form. In order to update a mod you can use a binary comparison between the original MBIN file (from previous version) and modded MBIN file. Then you can apply the changes you have detected to the new original MBIN file. Sometimes values have shifted and you need to recognize the patterns by human eye.
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.


Here is a HexEditor tool list:
So what's the point of hex editing ?<br>
The point is to be able to update some mods and particulary 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==
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 {{fc|#FFF|FROM A VERY CLOSE GAME VERSION}}.
# Note all the changes. Usually you might note the position in the file (the offset) and the new value for each change.
# {{fc|#FFF|APPLY THE SAME CHANGES}} to the .MBIN files of the latest NMS version.
# Recompile and repack the mod
<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 (ideally), or close to the game version used for the modded files. If AMUMSS [https://wiki.step-project.com/NMS:Tutorials/ToyingwithAMUMSS can search and find the MBINCompiler version used for a mod], and thus hint on the used game version, you still have to find the original files for this version. 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 files. There's some chance though that the file structure hasn't change so much, so you can always 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 values have moved in the new file 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 ==
There's quite a lot of hexadecimal tools around.<br>
Here is a list of some of them worth mentioning:
* 010 (paid, with 30 day trial)
* 010 (paid, with 30 day trial)
* HxD (freeware, proprietary)
* HxD (freeware, proprietary)
Line 11: Line 34:
* Hex Workshop (paid)
* Hex Workshop (paid)
* HexEdit (mac only?)
* HexEdit (mac only?)
* XVI32 (freeware, very small (~1Mb) and portable)
For information, .MBIN Files are all using little indian byte order.<br>
So before anything, it's better to set your Hexadecimal editor to read values in little indian order.<br>
== .MBIN File Format ==
As most file formats, .MBIN files start with a header.<br><br>
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.<br>
* 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.<br>
You can [https://github.com/monkeyman192/MBINCompiler/wiki/MBIN-Format see here] for or a litlle more details on the original header of MBINfiles and the MBINCompiler custom ones.<br>


MBIN Files are all using little indian byte order.<br>
You usually will never touch the header though because all you want to edit are the data included in the rest of the file.<br>
They all start with a 24 bytes header starting with a 0xCCCCCCCC Magic data.<br>
Data themselves are arranged in a different way for almost each .MBIN file so this can't be detailed here but this won't be an issue as most of the time, we don't need the structure to make the needed changes, only the offsets and values we need to change to reproduce a mod in the latest .MBIN file.
Then there's a 72 bytes string reserved for the internal file name.<br>
Rest of the file contains the data.


{{NMSPageClose}}
{{NMSPageClose}}
[[Category:No Man's Sky]][[Category:NMS-Tutorial]]
[[Category:No Man's Sky]][[Category:NMS-Tutorial]]

Revision as of 09:12, 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 and particulary 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 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 FROM A VERY CLOSE 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 (ideally), or close to the game version used for the modded files. If AMUMSS can search and find the MBINCompiler version used for a mod, and thus hint on the used game version, you still have to find the original files for this version. 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 files. There's some chance though that the file structure hasn't change so much, so you can always 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 values have moved in the new file 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]

There's quite a lot of hexadecimal tools around.
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)

For information, .MBIN Files are all using little indian byte order.
So before anything, it's better to set your Hexadecimal editor to read values in little indian order.

.MBIN File Format[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.

You can see here for or a litlle more details on the original header of MBINfiles and the MBINCompiler custom ones.

You usually will never touch the header though because all you want to edit are the data included in the rest of the file.
Data themselves are arranged in a different way for almost each .MBIN file so this can't be detailed here but this won't be an issue as most of the time, we don't need the structure to make the needed changes, only the offsets and values we need to change to reproduce a mod in the latest .MBIN file.

Template:NMSPageClose