NoMansSky:Creating Mods From MBINs: Difference between revisions

From Step Mods | Change The Game
(11 intermediate revisions by the same user not shown)
Line 7: Line 7:
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.
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 ?
So what's the point of hex editing ?<br>
The point is to be able to update some mods in the following cases :
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.
* 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
* You found a very old mod and have a strong will to update it for current game version


==Updating mods by comparison==
==Updating mods by comparison==
In both cases, in theory, the way to update a mod is simple :
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'''.
# 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.
# 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.  
# {{fc|#FFF|APPLY THE SAME CHANGES}} to the .MBIN files of the latest NMS version.  
# Recompile and repack the mod
# Recompile and repack the mod
<br>
<br>
That's for the theory. In practice, you probably noticed the two bold sentences above.<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:
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.
* 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 value has moved before applying the change.
* 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.
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 ==
To edit .MBIN binary files, you will need an hexadecimal editor and there's quite a lot of them.<br>
There's quite a lot of hexadecimal tools around.<br>
Here is a list of some of them worth mentioning:
Here is a list of some of them worth mentioning:
* 010 (paid, with 30 day trial)
* 010 (paid, with 30 day trial)
Line 36: Line 36:
* XVI32 (freeware, very small (~1Mb) and portable)
* XVI32 (freeware, very small (~1Mb) and portable)


== .MBIN Header ==
For information, .MBIN Files are all using little indian byte order.<br>
As most file formats, .MBIN files start with a header.<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 :
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>
* Magic Data which is 4 bytes long. It is 0xCCCCCCCC for MBIN files and is 0xDDDDDDDD for MBIN.PC files.<br>
Line 45: Line 48:
* Template Name, a 72 (0x48) bytes string reserved for the internal file name.<br>
* Template Name, a 72 (0x48) bytes string reserved for the internal file name.<br>


For a litlle more details on the original header of MBINfiles and MBINCompiler ones, see [https://github.com/monkeyman192/MBINCompiler/wiki/MBIN-Format here].<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>
 
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 ==
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>
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.<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.


{{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