Skip to content

Instantly share code, notes, and snippets.

@Sascha-T
Last active August 5, 2022 18:10
Show Gist options
  • Save Sascha-T/c5f217aa0804679b7281aa986e53004e to your computer and use it in GitHub Desktop.
Save Sascha-T/c5f217aa0804679b7281aa986e53004e to your computer and use it in GitHub Desktop.
.NET Core Bundle Topography

.net core bundle topography

finding the header

First, one must locate the marker by searching for 0x8b1202b96a612038727b930214d7a03213f5b9e6efae3318ee3b2dce24b36aae, then stepping back 8 bytes from the start of the market
At this location, reading a long (little endian) will give one the absolute file offset to the single file bundle header.
If the read value is 0, then it is not a single file bundle.

the header

offset size value
0x00 0x4 (D.W.) major version
0x04 0x4 (D.W.) minor version
0x08 0x4 (D.W.) embedded file count
0x0C 0x1 (B) bundle id length
0x0D above value bundle id
0x0D + bdl id length 0x8 (Q.W.) deps json offset
0x15 + bdl id length 0x8 (Q.W.) deps json size
0x1D + bdl id length 0x8 (Q.W.) runtime json offset
0x25 + bdl id length 0x8 (Q.W.) runtime json size
0x2D + bdl id length 0x8 (Q.W.) flags

After this, there is (embedded file count)x file entries

file entry

offset size value
0x00 0x8 (Q.W) absolute offset of file
0x08 0x8 (Q.W) size of file
0x10 0x8 (Q.W) compressed size1.
0x18 0x1 (B) type
0x19 0x1 (B) name size
0x1A above value file name

types

value meaning
0x00 unknown file type
0x01 .net assemblies (il/r2r)
0x02 native binary
0x03 .deps.json config
0x04 .runtimeconfig.json config
0x05 pdb symbols

sources

https://github.com/dotnet/runtime/tree/main/src/native/corehost/apphost
https://www.jetbrains.com/decompiler/

Compiled by Sascha_T.

Footnotes

  1. If this field reads 0, then the embedded file is not compressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment