├── loadFunctionTable
├── .gitignore
└── loadFunctionTables.py
├── slimshader
├── Gemini.dll
├── AvalonDock.dll
├── AvalonDock.pdb
├── GraphSharp.dll
├── QuickGraph.dll
├── SlimShader.dll
├── SlimShader.pdb
├── Caliburn.Micro.dll
├── Caliburn.Micro.pdb
├── QuickGraph.Data.dll
├── SlimShader.Studio.exe
├── SlimShader.Studio.pdb
├── GraphSharp.Controls.dll
├── QuickGraph.Graphviz.dll
├── System.Reactive.Core.dll
├── System.Reactive.Linq.dll
├── AvalonDock.Themes.VS2010.dll
├── AvalonDock.Themes.VS2010.pdb
├── QuickGraph.Serialization.dll
├── SlimShader.VirtualMachine.dll
├── SlimShader.VirtualMachine.pdb
├── System.Reactive.Interfaces.dll
├── System.Windows.Interactivity.dll
├── QuickGraph.Data.xml
├── QuickGraph.Graphviz.xml
└── System.Reactive.Interfaces.xml
├── TextureMapping
├── slinger1.png
├── slinger2.png
├── slinger3.png
└── slinger4.png
├── 010 Scripts
├── FixZombie.1sc
├── InjectShader.1sc
├── ShaderExtract.1sc
└── CopyConstantBuffer.1sc
├── shaderTest
├── shaders.shader
└── shader_example.cpp
├── LICENSE
├── fetch_shader_classes
├── list_bindings.py
├── fetch_classes.py
└── ListBindingNames.ryo
└── 010 Templates
├── LMT.bt
├── MHWGui.bt
├── Shader.bt
├── IBShader.bt
├── DXBC.bt
├── MRLTemplate.bt
├── MOD3.bt
└── IBMRLTemplate.bt
/loadFunctionTable/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | test.txt
3 | backup
4 | cache.db
--------------------------------------------------------------------------------
/slimshader/Gemini.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/Gemini.dll
--------------------------------------------------------------------------------
/slimshader/AvalonDock.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/AvalonDock.dll
--------------------------------------------------------------------------------
/slimshader/AvalonDock.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/AvalonDock.pdb
--------------------------------------------------------------------------------
/slimshader/GraphSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/GraphSharp.dll
--------------------------------------------------------------------------------
/slimshader/QuickGraph.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/QuickGraph.dll
--------------------------------------------------------------------------------
/slimshader/SlimShader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.dll
--------------------------------------------------------------------------------
/slimshader/SlimShader.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.pdb
--------------------------------------------------------------------------------
/TextureMapping/slinger1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/TextureMapping/slinger1.png
--------------------------------------------------------------------------------
/TextureMapping/slinger2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/TextureMapping/slinger2.png
--------------------------------------------------------------------------------
/TextureMapping/slinger3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/TextureMapping/slinger3.png
--------------------------------------------------------------------------------
/TextureMapping/slinger4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/TextureMapping/slinger4.png
--------------------------------------------------------------------------------
/slimshader/Caliburn.Micro.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/Caliburn.Micro.dll
--------------------------------------------------------------------------------
/slimshader/Caliburn.Micro.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/Caliburn.Micro.pdb
--------------------------------------------------------------------------------
/slimshader/QuickGraph.Data.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/QuickGraph.Data.dll
--------------------------------------------------------------------------------
/slimshader/SlimShader.Studio.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.Studio.exe
--------------------------------------------------------------------------------
/slimshader/SlimShader.Studio.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.Studio.pdb
--------------------------------------------------------------------------------
/slimshader/GraphSharp.Controls.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/GraphSharp.Controls.dll
--------------------------------------------------------------------------------
/slimshader/QuickGraph.Graphviz.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/QuickGraph.Graphviz.dll
--------------------------------------------------------------------------------
/slimshader/System.Reactive.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/System.Reactive.Core.dll
--------------------------------------------------------------------------------
/slimshader/System.Reactive.Linq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/System.Reactive.Linq.dll
--------------------------------------------------------------------------------
/slimshader/AvalonDock.Themes.VS2010.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/AvalonDock.Themes.VS2010.dll
--------------------------------------------------------------------------------
/slimshader/AvalonDock.Themes.VS2010.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/AvalonDock.Themes.VS2010.pdb
--------------------------------------------------------------------------------
/slimshader/QuickGraph.Serialization.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/QuickGraph.Serialization.dll
--------------------------------------------------------------------------------
/slimshader/SlimShader.VirtualMachine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.VirtualMachine.dll
--------------------------------------------------------------------------------
/slimshader/SlimShader.VirtualMachine.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/SlimShader.VirtualMachine.pdb
--------------------------------------------------------------------------------
/slimshader/System.Reactive.Interfaces.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/System.Reactive.Interfaces.dll
--------------------------------------------------------------------------------
/slimshader/System.Windows.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheCrazyT/MHW-Research/HEAD/slimshader/System.Windows.Interactivity.dll
--------------------------------------------------------------------------------
/010 Scripts/FixZombie.1sc:
--------------------------------------------------------------------------------
1 | //------------------------------------------------
2 | //--- 010 Editor v9.0 Script File
3 | //
4 | // File:
5 | // Authors:
6 | // Version:
7 | // Purpose:
8 | // Category:
9 | // History:
10 | //------------------------------------------------
11 | int i;
12 | for(i = 0; i
2 |
3 |
4 | QuickGraph.Data
5 |
6 |
7 |
8 |
9 | An algorithm that renders a DataSet graph to the Graphviz DOT format.
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/010 Scripts/InjectShader.1sc:
--------------------------------------------------------------------------------
1 | const char SHADER_PACKAGE[] = "d:\\tmp\\shaders\\ShaderPackage.sdf";
2 | const char SHADER_TEMPLATE[] = "d:\\Backups_and_projects\\BlenderScripts\\MHW-Research\\010 Templates\\Shader.bt";
3 | int idx = FindOpenFile(SHADER_PACKAGE);
4 | if(idx==-1){
5 | FileOpen(SHADER_PACKAGE);
6 | }
7 | int shaderIdx = InputNumber("Input shaderindex","Input shaderindex","0");
8 | char filename[] = InputOpenFileName("Input shader filename.","Shader (*.shdr)");
9 |
10 | idx = FindOpenFile(SHADER_PACKAGE);
11 | FileSelect(idx);
12 |
13 | int64 fs1 = FileSize();
14 | InsertFile(filename,fs1);
15 | RunTemplate(SHADER_TEMPLATE);
16 | int64 fs2 = FileSize()-fs1;
17 |
18 | shaderDatas.shaderData[shaderIdx].length = fs2;
19 | shaderDatas.shaderData[shaderIdx].pos = fs1;
20 | RunTemplate(SHADER_TEMPLATE);
--------------------------------------------------------------------------------
/shaderTest/shaders.shader:
--------------------------------------------------------------------------------
1 | struct VOut
2 | {
3 | float4 position : SV_POSITION;
4 | float4 color : COLOR;
5 | };
6 |
7 | VOut VShader(
8 | float3 position : POSITION,
9 | float3 normal : NORMAL,
10 | float4 tangent : TANGENT,
11 | float2 uvp:UV_Primary,
12 | float2 upv2:UV_Secondary,
13 | float4 color:COLOR,
14 | float3 posPF:PositionPF,
15 | uint iId:SV_InstanceID
16 | )
17 | {
18 | VOut output;
19 |
20 | output.color = color;
21 | output.position.x = position.x;
22 | output.position.y = position.y;
23 | output.position.z = position.z;
24 | output.position.w = 1.0;
25 |
26 | return output;
27 | }
28 |
29 | float4 PShader(float4 position : SV_POSITION) : SV_TARGET
30 | {
31 | return position;
32 | }
33 | /*float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
34 | {
35 | return color;
36 | }*/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 TheCrazyT
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/010 Scripts/ShaderExtract.1sc:
--------------------------------------------------------------------------------
1 | //--------------------------------------
2 | //--- 010 Editor v6.0.1 Script File
3 | //
4 | // File:
5 | // Author: CrazyT
6 | // Revision:
7 | // Purpose:
8 | //--------------------------------------
9 | //maybe also helpful:
10 | // https://github.com/tgjones/slimshader
11 |
12 | RunTemplate();
13 | int i;
14 | int cnt=head.shaderCount;
15 | string filename;
16 | int shaderPos[cnt];
17 | int shaderLength[cnt];
18 | for(i=0;i;
71 | return;
72 | }""" % (key,key,key));
73 |
74 | print("}")
75 | print("")
76 | for key,filename in classFiles.items():
77 | print("local int crc%s = createJamcrc(\"%s\");" % (key,key));
78 |
79 |
80 | print("")
81 | for key,filename in classFiles.items():
82 | print("//%s : %s" % (key,filename))
83 | with open(os.path.join(rootPath,filename), 'r') as content_file:
84 | content = content_file.read()
85 | start = False
86 | pos = 0
87 | ai = 0
88 | for line in content.split("\n"):
89 | line = line.strip()
90 | line = line.replace("struct ","struct %s_" % key)
91 | if start == True:
92 | if line == "// {":
93 | continue;
94 | if line == "// }":
95 | print("};\n")
96 | break;
97 | if not '=' in line:
98 | m = re.search("Offset: +([0-9]+) Size: +([0-9]+)",line)
99 | if(m):
100 | offset = int(m.group(1))
101 | if(offset != pos):
102 | print(" // align: %d to %d" % (pos,offset))
103 | print(" ubyte align%d[%d];" % (ai,offset-pos))
104 | pos += offset-pos
105 | ai += 1
106 | pos += int(m.group(2));
107 | else:
108 | pass
109 | #print("// no offset")
110 | print (line[3:])
111 | else:
112 | if line == "// cbuffer "+key:
113 | print("struct %s {\n" % key)
114 | start = True
115 | sg.close()
116 |
--------------------------------------------------------------------------------
/010 Templates/LMT.bt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------
2 | //--- 010 Editor v8.0.1 Binary Template
3 | //
4 | // File:
5 | // Authors: CrazyT
6 | // Version:
7 | // Purpose:
8 | // Category:
9 | // File Mask: *.lmt
10 | // ID Bytes:
11 | // History:
12 | //------------------------------------------------
13 | struct LMTKeyframeDef{
14 | ubyte bufferType;
15 | ubyte usage;
16 | ubyte jointType;
17 | ubyte boneId;
18 | long bufferSize;
19 | float weight;
20 | long unkn2;
21 | uint64 bufferOffset;
22 | float referenceFrame[4];
23 | uint64 boundsOffset;
24 | };
25 | struct LMTVec3{
26 | float x;
27 | float y;
28 | float z;
29 | };
30 | struct LMTQuadraticVector3{
31 | byte addcount;
32 | byte flags;
33 | short s;
34 | float vx;
35 | float vy;
36 | float vz;
37 | local int i=0;
38 | float f[8];
39 | };
40 | struct LMTVec3Frame{
41 | float x;
42 | float y;
43 | float z;
44 | };
45 | struct LMTQuatized8Vec3{
46 | byte f[3];
47 | byte reframe;
48 | };
49 | struct LMTQuatized16Vec3{
50 | short f[3];
51 | short relframe;
52 | };
53 | struct LMTQuat3Frame{
54 | float f[3];
55 | long l;
56 | };
57 | struct LMTQuatFramev14{
58 | long l1;
59 | long l2;
60 | };
61 | struct LMTQuatized32Quat{
62 | long l;
63 | };
64 | struct LMTXWQuat{
65 | long l;
66 | };
67 | struct LMTYWQuat{
68 | long l;
69 | };
70 | struct LMTZWQuat{
71 | long l;
72 | };
73 | struct LMTQuatized11Quat{
74 | short s[3];
75 | };
76 | struct LMTQuatized9Quat{
77 | byte b[5];
78 | };
79 | string readKBR(LMTKeyframeDef &x){
80 | string s;
81 | SPrintf( s, "BoundsOffset:%08x%08x BufferOffset:%08x%08x BufferType:%x",x.boundsOffset>>32,x.boundsOffset,x.bufferOffset>>32,x.bufferOffset,x.bufferType);
82 | return s;
83 | }
84 |
85 | struct Head{
86 | uint id;
87 | short version;
88 | short numBlocks;
89 | if(version > 90){
90 | uint64 unkn1;
91 | }
92 |
93 | uint64 offsets[numBlocks];
94 | } head;
95 |
96 | local int i;
97 | local int isub;
98 | struct{
99 | for(i=0;i;
110 | }
111 | }lheads;
112 | local int maxj = 0;
113 | struct{
114 | local int b;
115 | local int correct = 0;
116 | for(i=0;i;
124 | maxj++;
125 | }
126 | }
127 | } kbrs;
128 |
129 | local int j;
130 | for(j=0;j;
137 | }
138 | local int cursize;
139 | for(j=0;j;
203 | }
--------------------------------------------------------------------------------
/slimshader/QuickGraph.Graphviz.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | QuickGraph.Graphviz
5 |
6 |
7 |
8 |
9 | Edge formatter
10 |
11 |
12 |
13 |
14 | An algorithm that renders a graph to the Graphviz DOT format.
15 |
16 | type of the vertices
17 | type of the edges
18 |
19 |
20 |
21 | Dot output stream.
22 |
23 |
24 |
25 |
26 | Current image output type
27 |
28 |
29 |
30 |
31 | Client-side imagemaps
32 |
33 |
34 |
35 |
36 | HP-GL/2 format
37 |
38 |
39 |
40 |
41 | Server-side imagemaps
42 |
43 |
44 |
45 |
46 | FrameMaker MIF format
47 |
48 |
49 |
50 |
51 | MetaPost
52 |
53 |
54 |
55 |
56 | PCL format
57 |
58 |
59 |
60 |
61 | PIC format
62 |
63 |
64 |
65 |
66 | plain text format
67 |
68 |
69 |
70 |
71 | Portable Network Graphics format
72 |
73 |
74 |
75 |
76 | Postscript
77 |
78 |
79 |
80 |
81 | PostScript for PDF
82 |
83 |
84 |
85 |
86 | Scalable Vector Graphics
87 |
88 |
89 |
90 |
91 | Scalable Vector Graphics, gzipped
92 |
93 |
94 |
95 |
96 | VRML
97 |
98 |
99 |
100 |
101 | Visual Thought format
102 |
103 |
104 |
105 |
106 | Wireless BitMap format
107 |
108 |
109 |
110 |
111 | Helper extensions to render graphs to graphviz
112 |
113 |
114 |
115 |
116 | Renders a graph to the Graphviz DOT format.
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | Renders a graph to the Graphviz DOT format.
126 |
127 |
128 |
129 |
130 | delegate that initializes the algorithm
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/loadFunctionTable/loadFunctionTables.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 | import pefile
3 | import sys
4 | import sqlite3
5 | import md5
6 | import numpy as np
7 | from binascii import hexlify
8 | from struct import *
9 |
10 | def findFunctionTable(off,relocSectionData):
11 | global pe,sectionInfos
12 | for i in range(off,off+30):
13 | #0xE8 = call
14 | #0x48 = lea
15 | if (ord(relocSectionData[i]) == 0xE8)and(ord(relocSectionData[i+5]) == 0x48):
16 | relOff = unpack("i",relocSectionData[i+8:i+8+4])[0]
17 | n = i+7+5+relOff
18 | n += pe.OPTIONAL_HEADER.ImageBase + sectionInfos[".reloc"][1]
19 | return n
20 | return None
21 | def findFunctionTblStore(off,relocSectionData):
22 | global pe,sectionInfos
23 |
24 | #48 89 05 = mov qword ptr ds:[
25 | for i in range(off,off+50):
26 | if (ord(relocSectionData[i]) == 0x48)and(ord(relocSectionData[i+1]) == 0x89)and(ord(relocSectionData[i+2]) == 0x05):
27 | relOff = unpack("i",relocSectionData[i+3:i+3+4])[0]
28 | n = i+7+relOff
29 | n += pe.OPTIONAL_HEADER.ImageBase + sectionInfos[".reloc"][1]
30 | return n
31 | return None
32 | def dict_factory(cursor, row):
33 | d = {}
34 | for idx, col in enumerate(cursor.description):
35 | d[col[0]] = row[idx]
36 | return d
37 |
38 | conn = sqlite3.connect('cache.db')
39 | conn.row_factory = dict_factory
40 | conn.execute('''CREATE TABLE IF NOT EXISTS raw_off_cache
41 | (s text, offset number)''')
42 | conn.execute('''CREATE TABLE IF NOT EXISTS function_table_pointers_cache
43 | (s text, voffset number)''')
44 | conn.execute('''CREATE TABLE IF NOT EXISTS function_table_pointers_store_cache
45 | (s text, voffset number)''')
46 | conn.execute('''CREATE TABLE IF NOT EXISTS function_reference_cache
47 | (s text, offset number)''')
48 | conn.execute('''CREATE TABLE IF NOT EXISTS config
49 | (name text,value text,value_int number)''')
50 |
51 | file_hash = None
52 | for row in conn.execute('SELECT value FROM config where name="file_hash"'):
53 | file_hash = row["value"]
54 |
55 | print("Loading ...")
56 | sys.stdout.flush()
57 | pefile.fast_load = True
58 | pe = pefile.PE('MonsterHunterWorld.exe')
59 | print("\n\n")
60 | #print(pe.dump_info())
61 | #2e98b18 nDraw::Material
62 | #0000000149558F51 | 48:8D15 C00F94F9 | lea rdx,qword ptr ds:[142E99F18] | rdx:EntryPoint, 0000000142E99F18:"nDraw::Material"
63 | #0x142E99F18-0x149558F51=0xFFFFFFFFF9940FC7
64 | sectionInfos = {}
65 | for section in pe.sections:
66 | name = section.Name
67 | if "\x00" in name:
68 | name = name[:name.index("\x00")]
69 | sectionInfos[name] = (section,section.VirtualAddress,section.PointerToRawData, section.SizeOfRawData )
70 |
71 | tlsSectionData = sectionInfos[".tls"][0].get_data()
72 | relocSectionData = sectionInfos[".reloc"][0].get_data()
73 | m = md5.new()
74 | m.update(tlsSectionData)
75 | m.update(relocSectionData)
76 |
77 | digest = hexlify(m.digest())
78 |
79 | if(digest != file_hash):
80 | print("file changed,removing cache [%s != %s]" % (digest,file_hash))
81 | conn.execute('DELETE FROM raw_off_cache')
82 | conn.execute('DELETE FROM function_table_pointers_cache')
83 | conn.execute('DELETE FROM function_table_pointers_store_cache')
84 | conn.execute('DELETE FROM function_reference_cache')
85 | if file_hash is None:
86 | conn.execute('INSERT INTO config (value,name) VALUES (?,?)',(digest,'file_hash'))
87 | conn.commit()
88 | else:
89 | conn.execute('UPDATE config SET value=? WHERE name="file_hash"',digest)
90 | conn.commit()
91 |
92 | rawOffsCache = {}
93 | refCache = {}
94 | fTblCache = {}
95 | fTblStoreCache = {}
96 | for row in conn.execute('SELECT s,offset FROM raw_off_cache'):
97 | rawOffsCache[row["s"]] = row["offset"]
98 | for row in conn.execute('SELECT s,voffset FROM function_table_pointers_cache'):
99 | fTblCache[row["s"]] = row["voffset"]
100 | for row in conn.execute('SELECT s,voffset FROM function_table_pointers_store_cache'):
101 | fTblStoreCache[row["s"]] = row["voffset"]
102 | for row in conn.execute('SELECT s,offset FROM function_reference_cache'):
103 | refCache[row["s"]] = row["offset"]
104 |
105 |
106 | virtualOffs = {}
107 |
108 | with open("strings.txt") as infile:
109 | #with open("test.txt") as infile:
110 | i = 0
111 | for s in infile:
112 | i += 1
113 | s = s.strip()
114 | k = 0
115 | if s in rawOffsCache:
116 | k = rawOffsCache[s]
117 | else:
118 | try:
119 | k = tlsSectionData.index("%s\x00" % s)
120 | conn.execute('INSERT INTO raw_off_cache VALUES (?,?)', (s,k))
121 | if(i % 50 == 0):
122 | conn.commit()
123 | except ValueError as e:
124 | conn.execute('INSERT INTO raw_off_cache VALUES (?,?)', (s,None))
125 | if(i % 50 == 0):
126 | conn.commit()
127 | continue
128 | if (not(k is None)) and (k > 0):
129 | virtualOffs[s] = pe.OPTIONAL_HEADER.ImageBase + k + sectionInfos[".tls"][1]
130 |
131 |
132 | print("len fTblCache: %d\nlen virtualOffs: %d\nend: %d\n\n" % (len(fTblCache),len(virtualOffs),len(relocSectionData)))
133 | conn.commit()
134 | print('"Name","FunctionTable offset","FunctionTable Store offset"')
135 | sys.stdout.flush()
136 |
137 | N1 = (len(relocSectionData) / 4)
138 | N2 = (len(relocSectionData[1:]) / 4)
139 | N3 = (len(relocSectionData[2:]) / 4)
140 | N4 = (len(relocSectionData[3:]) / 4)
141 |
142 | # "splitting" this improves performance, sadly now you need about 9GB ram just for this python script.
143 | cmpN1 = np.array(list(unpack("%di" % N1,relocSectionData[0:N1*4])))
144 | cmpN2 = np.array(list(unpack("%di" % N2,relocSectionData[1:1+N2*4])))
145 | cmpN3 = np.array(list(unpack("%di" % N3,relocSectionData[2:2+N3*4])))
146 | cmpN4 = np.array(list(unpack("%di" % N4,relocSectionData[3:3+N4*4])))
147 |
148 | X = pe.OPTIONAL_HEADER.ImageBase + sectionInfos[".reloc"][1] + 4
149 | L1 = np.arange(0,len(cmpN1)*4,4)
150 | L2 = np.arange(1,len(cmpN2)*4,4)
151 | L3 = np.arange(2,len(cmpN3)*4,4)
152 | L4 = np.arange(3,len(cmpN4)*4,4)
153 |
154 | cmpN1 += X+L1
155 | cmpN2 += X+L2
156 | cmpN3 += X+L3
157 | cmpN4 += X+L4
158 |
159 | for s in fTblCache:
160 | fTbl = fTblCache[s]
161 | fTblStore = fTblStoreCache[s]
162 | if(fTblStore is None):
163 | print("\"%s\",0x%016x," % (s,fTbl))
164 | else:
165 | print("\"%s\",0x%016x,0x%016x" % (s,fTbl,fTblStore))
166 | sys.stdout.flush()
167 | del virtualOffs[s]
168 |
169 |
170 |
171 | for s in virtualOffs:
172 | v = virtualOffs[s]
173 | x = 0
174 | X = np.where(cmpN1 == v)[0]
175 | if(len(X)>0):
176 | x = X[0]
177 | i = 0
178 | if x <= 0:
179 | X = np.where(cmpN2 == v)[0]
180 | if(len(X)>0):
181 | x = X[0]
182 | if x > 0:
183 | i = 1
184 | else:
185 | X = np.where(cmpN3 == v)[0]
186 | if(len(X)>0):
187 | x = X[0]
188 | if x > 0:
189 | i = 2
190 | else:
191 | X = np.where(cmpN4 == v)[0]
192 | if(len(X)>0):
193 | x = X[0]
194 | if x > 0:
195 | i = 3
196 | i += x*4
197 |
198 | if(x > 0):
199 | pos = i
200 | fTbl = findFunctionTable(i,relocSectionData)
201 | if not fTbl is None:
202 | fTblStore = findFunctionTblStore(i,relocSectionData)
203 | conn.execute('INSERT INTO function_reference_cache (s,offset) VALUES (?,?)', (s,pos))
204 | conn.execute('INSERT INTO function_table_pointers_cache (s,voffset) VALUES (?,?)', (s,fTbl))
205 | conn.execute('INSERT INTO function_table_pointers_store_cache (s,voffset) VALUES (?,?)', (s,fTblStore))
206 | conn.commit()
207 | if(fTblStore is None):
208 | print("\"%s\",0x%016x," % (s,fTbl))
209 | else:
210 | print("\"%s\",0x%016x,0x%016x" % (s,fTbl,fTblStore))
211 | sys.stdout.flush()
212 |
213 |
--------------------------------------------------------------------------------
/010 Templates/MHWGui.bt:
--------------------------------------------------------------------------------
1 | //------------------------------------------------
2 | //--- 010 Editor v8.0.1 Binary Template
3 | //
4 | // File:
5 | // Authors: CrazyT
6 | // Version:
7 | // Purpose:
8 | // Category:
9 | // File Mask: *.gui
10 | // ID Bytes:
11 | // History:
12 | //------------------------------------------------
13 | SetForeColor(0xffffff);
14 |
15 | struct PropertiesVal;
16 | struct Object;
17 | struct SubUI;
18 | struct UnknStruct;
19 | struct UnknStruct2;
20 | struct UnknStruct3;
21 |
22 | struct Head{
23 | uint signature ;
24 | uint unkn1;
25 | uint size;
26 | ubyte unkn2[32];
27 | uint unknStruct3Count;
28 | uint objCount;
29 | ubyte unkn3[4];
30 | uint count;
31 | uint unknStructCount;
32 | uint unkn4;
33 | uint unknStruct2Count;
34 | uint textRefCount;
35 | ubyte unkn4_[36];
36 | uint subuiCount;
37 | ubyte unkn5[12];
38 | uint unknUiCount;
39 | ubyte unkn6[36];
40 | uint unknStructOff3;
41 | ubyte unkn8[12];
42 | uint objectOff;
43 | ubyte unkn9[12];
44 | uint propertiesValArrayOff ;
45 | uint unkn10;
46 | uint64 unknStructOff;
47 | uint64 unknStructOff2;
48 | uint64 startEnd;
49 | uint64 unkn;
50 | uint64 subUI[9];
51 | uint64 unkUI[4];
52 | ubyte unkn13[16];
53 | uint propertiesTextArrayOff ;
54 | uint unkn14[12];
55 | uint unkn15;
56 | uint floatArrOff ;
57 | uint unkn16[3];
58 | } head ;
59 |
60 | struct UnknUI{
61 | uint id;
62 | uint unkn1[3];
63 | uint suiToff;
64 | local int suipos = FTell();
65 | local int textPos = head.propertiesTextArrayOff+suiToff;
66 | FSeek(textPos);
67 | char suiText[];
68 | FSeek(suipos);
69 | uint unkn2;
70 | };
71 |
72 | struct TextRef{
73 | uint id;
74 | uint unkn1[3];
75 | uint suiToff;
76 | uint unkn2[3];
77 | local int suipos = FTell();
78 | local int textPos = head.propertiesTextArrayOff+suiToff;
79 | FSeek(textPos);
80 | char text[];
81 | FSeek(suipos);
82 | };
83 |
84 | string PropertiesValRead(PropertiesVal &v){
85 | if(v.type==7){
86 | return v.text + " \"" + v.vStr+"\"";
87 | }else{
88 | return v.text;
89 | }
90 | }
91 | string ObjectRead(Object &v){
92 | return v.text;
93 | }
94 | string SubUIRead(SubUI &v){
95 | return v.suiText2 + " \"" + v.suiText + "\"";
96 | }
97 | string UnknUIRead(UnknUI &v){
98 | return "\"" + v.suiText + "\"";
99 | }
100 | string TextRefRead(TextRef &v){
101 | return v.text;
102 | }
103 | string UnknStructRead(UnknStruct &v){
104 | return v.text;
105 | }
106 | string UnknStruct2Read(UnknStruct2 &v){
107 | string s;
108 | SPrintf( s, "%d", (int)v.id );
109 | return s+": "+v.text;
110 | }
111 | string UnknStruct3Read(UnknStruct3 &v){
112 | string s;
113 | SPrintf( s, "%d", (int)v.id );
114 | return s+": "+v.text;
115 | }
116 | struct StartEnd{
117 | local int i;
118 | for(i=0;i;
120 | }
121 | };
122 | struct SubUI{
123 | uint id;
124 | ubyte unkn1[44];
125 | uint suiToff;
126 | local int suipos = FTell();
127 | local int textPos = head.propertiesTextArrayOff+suiToff;
128 | FSeek(textPos);
129 | char suiText[];
130 | FSeek(suipos);
131 | uint unkn1;
132 | uint suiToff2;
133 | local int suipos2 = FTell();
134 | local int textPos2 = head.propertiesTextArrayOff+suiToff2;
135 | FSeek(textPos2);
136 | char suiText2[];
137 | FSeek(suipos2);
138 | uint unkn2;
139 | };
140 | struct Object (uint currentProp){
141 | local int cp = currentProp;
142 | uint id;
143 | ubyte propertyCount;
144 | ubyte unkn1[3];
145 | uint unkn2;
146 | uint unkn3;
147 | uint toff;
148 | local int pos2 = FTell();
149 | FSeek(head.propertiesTextArrayOff+toff);
150 | char text[];
151 | FSeek(pos2);
152 | uint unkn4;
153 | uint unkn5 ;
154 | ubyte unkn6[28];
155 |
156 | local int pos3 = FTell();
157 | FSeek(propertiesValOff[currentProp]);
158 | struct ObjectProperties{
159 | local int i;
160 | for(i=0;i;
162 | }
163 | } objectProperties;
164 | FSeek(pos3);
165 | };
166 |
167 | struct PropertiesVal{
168 | uint type;
169 | uint unkn1[3];
170 | uint toff;
171 | uint unkn2;
172 | if(type==7){
173 | local int pos1 = FTell()+4;
174 | local int j = 0;
175 | uint v;
176 | FSeek(head.propertiesTextArrayOff);
177 | for(j=0;j = FTell();
204 | FSeek(head.propertiesTextArrayOff+toff);
205 | char text[];
206 | FSeek(pos1);
207 | uint unkn7;
208 | uint unkn8;
209 | uint unkn9;
210 | uint maybeTextOff;
211 | uint unkn11;
212 |
213 | };
214 | struct UnknStruct2{
215 | uint id;
216 | uint unkn2;
217 | uint unkn3;
218 | uint unkn4;
219 | uint unkn5;
220 | uint unkn6;
221 | uint toff;
222 | local int pos1 = FTell();
223 | local int atoff = head.propertiesTextArrayOff+toff;
224 | FSeek(atoff);
225 | char text[];
226 | FSeek(pos1);
227 | uint unkn7;
228 | uint unkn8;
229 | uint unkn9;
230 | uint unknOff;
231 | uint unkn11[3];
232 |
233 | };
234 | struct UnknStruct3{
235 | uint id;
236 | uint unkn2;
237 | uint toff;
238 | local int pos1 = FTell();
239 | local int atoff = head.propertiesTextArrayOff+toff;
240 | FSeek(atoff);
241 | char text[];
242 | FSeek(pos1);
243 | uint unkn3;
244 | };
245 | local int i;
246 |
247 | local int propertiesValOff[head.count];
248 | FSeek(head.propertiesValArrayOff);
249 | struct Properties{
250 | for(i=0;i;
253 | }
254 | } allProperties;
255 |
256 | FSeek(head.objectOff);
257 | struct Objects{
258 | local int currentProp = 0;
259 | for(i=0;i;
261 | currentProp += object.propertyCount;
262 | }
263 | } objects;
264 |
265 |
266 |
267 | local int x;
268 | FSeek(head.startEnd);
269 |
270 | StartEnd startEnd;
271 |
272 | //TODO ... this does not seem right
273 | struct SubuiArr{
274 | for(x=0;x<9;x++){
275 | FSeek(head.subUI[x]);
276 | struct SubUIs{
277 | for(i=0;i;
279 | }
280 | }subuis ;
281 | }
282 | }subuiarr;
283 |
284 | for(x=0;x<4;x++){
285 | FSeek(head.unkUI[x]);
286 | struct UnkUIs{
287 | for(i=0;i;
289 | }
290 | }unknuis ;
291 | }
292 |
293 | FSeek(head.unknStructOff);
294 | struct UnknStructs{
295 | for(i=0;i;
297 | }
298 | }unknStructs1;
299 |
300 | FSeek(head.unknStructOff2);
301 | struct UnknStructs2{
302 | for(i=0;i;
304 | }
305 | }unknStructs2;
306 |
307 | FSeek(head.unknStructOff3);
308 | struct UnknStructs3{
309 | uint unkn[16];
310 | for(i=0;i;
312 | }
313 | }unknStructs3;
314 |
315 | FSeek(head.floatArrOff);
316 | if(head.floatArrOff!=head.size){
317 | struct FloatArr{
318 | float f[(head.size-head.floatArrOff)/4];
319 | }floatArr;
320 | }
--------------------------------------------------------------------------------
/010 Templates/Shader.bt:
--------------------------------------------------------------------------------
1 | //--------------------------------------
2 | //--- 010 Editor v6.0.1 Binary Template
3 | //
4 | // File:
5 | // Author: CrazyT
6 | // Revision:
7 | // Purpose:
8 | // File Mask: *.sdf
9 | //--------------------------------------
10 |
11 | struct MeshBlock;
12 | struct BlockRef;
13 | struct Material;
14 | struct UnknStructData;
15 | struct UnknStructDataSub;
16 | struct UnknStruct2Sub;
17 | struct ShaderData;
18 | struct ShaderDataShort;
19 | string readBlock(MeshBlock &b);
20 | string readSub(UnknStructDataSub &sub);
21 | string readUnkn4(uint64 unkn4);
22 | string readUnknStruct2(UnknStruct2Sub &v);
23 |
24 | //Offset of:
25 | //4E 6F 72 6D 61 6C 00 54 61 6E 67 65 6E 74 00 55 56 5F 50 72 69 6D 61 72 79 00 55 56 5F 53 65 63 6F 6E 64 61 72 79 00 57 65 69 67 68 74 00 57 65 69 67 68 74 00 4A 6F 69 6E 74 00 4A 6F 69 6E 74 00 43 6F 6C 6F 72 00 50 6F 73 69 74 69 6F 6e 50 46 00 49 41 53 6b 69 6e 38 77 74 32 55 56 00 50 6f 73 69 74 69 6f 6e 00
26 | //=0xaae2d85
27 | //-0x6f6c85 (next val of blocktype 0x81F58067 in ShaderPackageIntel.sdf) = 0xA3EC100
28 | //local uint32 textsOffset = 0xA3EC100;
29 | //local uint32 blockStart = 0x9bf9618;
30 | //local uint32 materialStart = 0x4510c;
31 |
32 | //CRC hash-sums seem to be CRC-32/JAMCRC or atleast similar to it.
33 |
34 | struct Property1{
35 | uint64 stringPointer;
36 | union FlagsU1{
37 | struct Flags1{
38 | uint64 unkn : 20;
39 | uint64 index : 8;
40 | uint64 unkn1 : 20;
41 | uint64 unkn2 : 16;
42 | } data;
43 | uint64 val;
44 | }flags;
45 | local uint64 realStringPointer;
46 | realStringPointer=stringPointer+head.textsOffset;
47 | local uint64 curPos = FTell();
48 | FSeek(realStringPointer);
49 | string text;
50 | FSeek(curPos);
51 | } ;
52 | struct Property2{
53 | uint64 stringPointer;
54 | union FlagsU2{
55 | struct Flags2{
56 | uint32 unkn : 14;
57 | uint32 index : 6;
58 | uint32 unkn1 : 32-14-6;
59 | } data;
60 | uint32 val;
61 | }flags;
62 | //for example (zlib.crc32("Position".encode()) ^ 0xffffffff) & 0x7fffffff
63 | uint nameHash : 32;
64 | local uint64 realStringPointer;
65 | realStringPointer=stringPointer+head.textsOffset;
66 | local uint64 curPos = FTell();
67 | FSeek(realStringPointer);
68 | string text;
69 | FSeek(curPos);
70 | } ;
71 | struct UnknStruct2Sub{
72 | uint32 pos;
73 | local uint32 oldpos = FTell();
74 | FSeek(pos+head.textsOffset);
75 | string text;
76 | FSeek(oldpos);
77 | uint32 unkn2;
78 | uint16 unkn3;
79 | uint16 unkn4;
80 | uint32 unkn5;
81 | };
82 | struct UnknStruct2{
83 | uint32 count;
84 | uint32 unkn1;
85 | //UnknStruct2Sub sub[count];
86 | Property2 props[count];
87 | uint32 empty[64-count*4];
88 | };
89 | struct UnknStructDataSub{
90 | uint32 hdata[4];
91 | uint64 pos;
92 | local uint32 oldpos = FTell();
93 | FSeek(pos+head.textsOffset);
94 | string text;
95 | FSeek(oldpos);
96 | uint32 data[2];
97 | };
98 | struct UnknStructData{
99 | uint64 pos;
100 | local uint32 oldpos = FTell();
101 | FSeek(pos+head.textsOffset);
102 | string text;
103 | FSeek(oldpos);
104 | uint32 data1;
105 | //for example (zlib.crc32("SSVRLinear".encode()) ^ 0xffffffff) & 0x7fffffff
106 | uint32 uniqueId;
107 | uint32 data2;
108 | uint32 countSubElements;
109 | if(countSubElements>0){
110 | UnknStructDataSub sub[countSubElements];
111 | }
112 | };
113 | struct BlockRef{
114 | uint64 pos;
115 | local uint64 curPos = FTell();
116 | FSeek(pos);
117 | MeshBlock b;
118 | FSeek(curPos);
119 | };
120 | string readShaderData(ShaderData &v){
121 | string res ="";
122 | SPrintf( res, "%s",v.text );
123 | return res;
124 | }
125 |
126 | string readUnknStruct2(UnknStruct2Sub &v){
127 | string res ="";
128 | SPrintf( res, "%s",v.text );
129 | return res;
130 | }
131 | string readSub(UnknStructDataSub &sub){
132 | string res ="";
133 | SPrintf( res, "%s",sub.text );
134 | return res;
135 | }
136 | string readUnknStructData(UnknStructData &d){
137 | string s ="";
138 | SPrintf( s, "%08x - %s", d.uniqueId,d.text );
139 | return s;
140 | }
141 | string readUnkn4(uint64 unkn4){
142 | string s ="";
143 | if((unkn4!=0)&&(unkn4!=0xFFFFFFFF)){
144 | SPrintf( s, "[%016lx] %s", unkn4+head.textsOffset,ReadString(unkn4+head.textsOffset) );
145 | }
146 | return s;
147 | }
148 | string readMaterial(Material &m){
149 | string s;
150 | SPrintf( s, "%08x - %s", m.shaderHash,m.nameStr );
151 | return s;
152 | }
153 | string readProp1(Property1 &p){
154 | string s;
155 | //SPrintf( s, "%s(%016lx)", ReadString(p.stringPointer+head.textsOffset),p.unkn );
156 | SPrintf( s, "(index:%3d offset:%3d flags.val:%08x%08x) %s", p.flags.data.index,p.flags.data.index*4,p.flags.val>>32,p.flags.val,p.text );
157 | return s;
158 | }
159 | string readProp2(Property2 &p){
160 | string s;
161 | //SPrintf( s, "%s(%016lx)", ReadString(p.stringPointer+head.textsOffset),p.unkn );
162 | SPrintf( s, "(index:%3d offset:%3d flags.val:%08x%08x) %s", p.flags.data.index, p.flags.data.index*4,p.flags.val>>32,p.flags.val,p.text );
163 | return s;
164 | }
165 |
166 | string readBlock(MeshBlock &b){
167 | string s;
168 | SPrintf( s, " %08x - %s", b.blocktype ,b.nameStr);
169 | return s;
170 | }
171 | string readBlockRef(BlockRef &b){
172 | return readBlock(b.b);
173 | }
174 | string readShaderString(short s){
175 | string str;
176 | if(s<0){
177 | SPrintf( str, "%d",s);
178 | return str;
179 | }
180 | SPrintf( str, "%d %s",s,shaderDatas.shaderData[s].text);
181 | return str;
182 | }
183 |
184 | struct Head{
185 | uint32 tag;
186 | uint32 unkn1;
187 | uint32 unknStruct1Count;
188 | uint32 materialCount;
189 | uint32 shaderCount;
190 | uint32 unkn2;
191 | uint32 blockCount;
192 | uint32 unknStruct2Count;
193 | uint32 unknStruct3Count;
194 | uint32 unknStruct4Count;
195 | uint32 unkn3[2];
196 | uint32 unknStruct1Offset;
197 | uint32 unkn5;
198 | uint64 materialOffset;
199 | uint64 shaderOffset;
200 | uint64 blockOffset;
201 | uint64 unknStruct2Offset;
202 | uint64 unknStruct3Offset;
203 | uint64 unknStruct4Offset;
204 | uint64 unknStruct5Offset;
205 | uint64 textsOffset;
206 | uint64 unkn7;
207 | };
208 | struct BlockHead{
209 | BlockRef bref[head.blockCount];
210 | };
211 | struct MeshBlock{
212 | uint64 name;
213 | local uint64 curPos = FTell();
214 | FSeek(name+head.textsOffset);
215 | string nameStr;
216 | FSeek(curPos);
217 | uint32 unkn2;
218 | //blocktype is actually just the hash of the name
219 | //for example (zlib.crc32("IANonSkin1UV".encode()) ^ 0xffffffff) & 0x7fffffff
220 | uint32 blocktype;
221 | short propCount;
222 | //props seem to contain indexes for used props
223 | //that (lastpropnum+1)*4 seems to match vertexStructSize
224 | //for example:
225 | // UV_Primary(0000000000501080)
226 | // will result in (5+1)*4 = 24
227 | //still unshure how to decode type
228 | short vertexStructSize;
229 | uint32 unkn4;
230 | Property1 props[propCount];
231 | };
232 | struct MaterialHead{
233 | uint32 unkn1;
234 | uint32 unkn2;
235 | uint32 unkn3;
236 | uint32 unkn4;
237 | };
238 | struct Material{
239 | short vertexShaderDataIdx;
240 | short pixelShaderDataIdx;
241 | uint32 unkn3;
242 | short unkn4;
243 | short shaderDataIdx2;
244 | uint16 unknStruct2Idx;
245 | uint16 unkn7;
246 | uint32 name;
247 | local uint64 curPos = FTell();
248 | FSeek(name+head.textsOffset);
249 | string nameStr;
250 | FSeek(curPos);
251 | uint32 unkn8[2];
252 | //for example (zlib.crc32("GpuRibbonFireVolume".encode()) ^ 0xffffffff) & 0x7fffffff
253 | uint32 shaderHash;
254 | };
255 | struct ShaderData{
256 | uint64 pos;
257 | uint32 length;
258 | local uint32 oldpos = FTell();
259 | FSeek(pos);
260 | ubyte data[length];
261 | FSeek(oldpos);
262 | uint32 unkn2;
263 | uint64 unkn3;
264 | uint64 unkn4;
265 | uint64 unkn5;
266 | uint32 pos2;
267 | local uint32 oldpos2 = FTell();
268 | FSeek(pos2+head.textsOffset);
269 | string text;
270 | FSeek(oldpos2);
271 | uint32 unkn7;
272 | uint32 unkn8;
273 | ushort unkn9;
274 | ushort unkn10;
275 | };
276 | struct ShaderDataShort{
277 | uint64 pos;
278 | uint32 length;
279 | local uint32 oldpos = FTell();
280 | FSeek(pos);
281 | ubyte data[length];
282 | FSeek(oldpos);
283 | uint32 unkn2;
284 | uint64 unkn3;
285 | uint64 unkn4;
286 | uint64 unkn5;
287 |
288 | };
289 | Head head;
290 | FSeek(head.unknStruct1Offset);
291 | uint64 unknStruct1[head.unknStruct1Count];
292 |
293 | struct{
294 | local int i;
295 | for(i=0;i;
298 | }
299 | }unknStruct1Datas;
300 |
301 | FSeek(head.blockOffset);
302 | struct{
303 | BlockHead blockHead;
304 | //FSeek(blockStart);
305 | MeshBlock meshBlock[head.blockCount];
306 | } meshBlocks;
307 |
308 | FSeek(head.unknStruct2Offset);
309 | struct{
310 | UnknStruct2 unknStruct2[head.unknStruct2Count];
311 | }unknStruct2s;
312 |
313 | FSeek(head.materialOffset);
314 | struct{
315 | MaterialHead materialHead;
316 | Material material[head.materialCount];
317 | } materials;
318 |
319 | //maybe also helpful:
320 | // https://github.com/tgjones/slimshader
321 | // http://timjones.io/blog/archive/2015/09/02/parsing-direct3d-shader-bytecode
322 | FSeek(head.shaderOffset+0x10);
323 | struct{
324 | ShaderData shaderData[head.shaderCount-1];
325 | ShaderDataShort shaderDataShort;
326 | } shaderDatas;
327 |
328 | FSeek(head.unknStruct3Offset);
329 | struct{
330 | struct{
331 | uint64 unkn1;
332 | uint64 unkn2;
333 | uint64 unknOffset3;
334 | }unkn[head.unknStruct3Count];
335 | }unknStruct3;
336 |
337 | FSeek(head.unknStruct4Offset);
338 | struct{
339 | struct{
340 | uint64 unkn1;
341 | uint64 unkn2;
342 | uint64 unkn3;
343 | uint64 unknOffset4;
344 | uint64 unkn5;
345 | }unkn[head.unknStruct4Count];
346 | uint64 unkn;
347 | }unknStruct4;
348 |
349 | FSeek(head.unknStruct5Offset);
350 | struct{
351 | uint64 unkn[180];
352 | }unknStruct5;
353 |
354 | FSeek(unknStruct3.unkn[0].unknOffset3);
355 | struct{
356 | local uint32 i;
357 | for(i=0;i;
363 | }
364 | }
365 | }unknStruct3_;
366 |
367 | FSeek(unknStruct4.unkn[0].unknOffset4);
368 | struct{
369 | local uint32 i;
370 | for(i=0;i;
375 | }unkn;
376 | }
377 | }
378 | }unknStruct4_;
379 |
--------------------------------------------------------------------------------
/010 Templates/IBShader.bt:
--------------------------------------------------------------------------------
1 | //--------------------------------------
2 | //--- 010 Editor v6.0.1 Binary Template
3 | //
4 | // File:
5 | // Author: CrazyT
6 | // Revision:
7 | // Purpose:
8 | // File Mask: *.sdf
9 | //--------------------------------------
10 |
11 | struct MeshBlock;
12 | struct BlockRef;
13 | struct Material;
14 | struct UnknStructData;
15 | struct UnknStructDataSub;
16 | struct UnknStruct2Sub;
17 | struct ShaderData;
18 | struct ShaderDataShort;
19 | string readBlock(MeshBlock &b);
20 | string readSub(UnknStructDataSub &sub);
21 | string readUnkn4(uint64 unkn4);
22 | string readUnknStruct2(UnknStruct2Sub &v);
23 |
24 | //Offset of:
25 | //4E 6F 72 6D 61 6C 00 54 61 6E 67 65 6E 74 00 55 56 5F 50 72 69 6D 61 72 79 00 55 56 5F 53 65 63 6F 6E 64 61 72 79 00 57 65 69 67 68 74 00 57 65 69 67 68 74 00 4A 6F 69 6E 74 00 4A 6F 69 6E 74 00 43 6F 6C 6F 72 00 50 6F 73 69 74 69 6F 6e 50 46 00 49 41 53 6b 69 6e 38 77 74 32 55 56 00 50 6f 73 69 74 69 6f 6e 00
26 | //=0xaae2d85
27 | //-0x6f6c85 (next val of blocktype 0x81F58067 in ShaderPackageIntel.sdf) = 0xA3EC100
28 | //local uint32 textsOffset = 0xA3EC100;
29 | //local uint32 blockStart = 0x9bf9618;
30 | //local uint32 materialStart = 0x4510c;
31 |
32 | //CRC hash-sums seem to be CRC-32/JAMCRC or atleast similar to it.
33 |
34 | struct Property1{
35 | uint64 stringPointer;
36 | union FlagsU1{
37 | struct Flags1{
38 | uint64 unkn : 20;
39 | uint64 index : 8;
40 | uint64 unkn1 : 20;
41 | uint64 unkn2 : 16;
42 | } data;
43 | uint64 val;
44 | }flags;
45 | local uint64 realStringPointer;
46 | realStringPointer=stringPointer+head.textsOffset;
47 | local uint64 curPos = FTell();
48 | FSeek(realStringPointer);
49 | string text;
50 | FSeek(curPos);
51 | } ;
52 | struct Property2{
53 | uint64 stringPointer;
54 | union FlagsU2{
55 | struct Flags2{
56 | uint32 unkn : 14;
57 | uint32 index : 6;
58 | uint32 unkn1 : 32-14-6;
59 | } data;
60 | uint32 val;
61 | }flags;
62 | //for example (zlib.crc32("Position".encode()) ^ 0xffffffff) & 0x7fffffff
63 | uint nameHash : 32;
64 | local uint64 realStringPointer;
65 | realStringPointer=stringPointer+head.textsOffset;
66 | local uint64 curPos = FTell();
67 | FSeek(realStringPointer);
68 | string text;
69 | FSeek(curPos);
70 | } ;
71 | struct UnknStruct2Sub{
72 | uint32 pos;
73 | local uint32 oldpos = FTell();
74 | FSeek(pos+head.textsOffset);
75 | string text;
76 | FSeek(oldpos);
77 | uint32 unkn2;
78 | uint16 unkn3;
79 | uint16 unkn4;
80 | uint32 unkn5;
81 | };
82 | struct UnknStruct2{
83 | uint32 count;
84 | uint32 unkn1;
85 | //UnknStruct2Sub sub[count];
86 | Property2 props[count];
87 | uint32 empty[64-count*4];
88 | };
89 | struct UnknStructDataSub{
90 | uint32 hdata[4];
91 | uint64 pos;
92 | local uint32 oldpos = FTell();
93 | FSeek(pos+head.textsOffset);
94 | string text;
95 | FSeek(oldpos);
96 | uint32 data[2];
97 | };
98 | struct UnknStructData{
99 | uint64 pos;
100 | local uint32 oldpos = FTell();
101 | FSeek(pos+head.textsOffset);
102 | string text;
103 | FSeek(oldpos);
104 | uint32 data1;
105 | //for example (zlib.crc32("SSVRLinear".encode()) ^ 0xffffffff) & 0x7fffffff
106 | uint32 uniqueId;
107 | uint32 data2;
108 | uint32 countSubElements;
109 | if(countSubElements>0){
110 | UnknStructDataSub sub[countSubElements];
111 | }
112 | };
113 | struct BlockRef{
114 | uint64 pos;
115 | local uint64 curPos = FTell();
116 | FSeek(pos);
117 | MeshBlock b;
118 | FSeek(curPos);
119 | };
120 | string readShaderData(ShaderData &v){
121 | string res ="";
122 | SPrintf( res, "%s",v.text );
123 | return res;
124 | }
125 |
126 | string readUnknStruct2(UnknStruct2Sub &v){
127 | string res ="";
128 | SPrintf( res, "%s",v.text );
129 | return res;
130 | }
131 | string readSub(UnknStructDataSub &sub){
132 | string res ="";
133 | SPrintf( res, "%s",sub.text );
134 | return res;
135 | }
136 | string readUnknStructData(UnknStructData &d){
137 | string s ="";
138 | SPrintf( s, "%08x - %s", d.uniqueId,d.text );
139 | return s;
140 | }
141 | string readUnkn4(uint64 unkn4){
142 | string s ="";
143 | if((unkn4!=0)&&(unkn4!=0xFFFFFFFF)){
144 | SPrintf( s, "[%016lx] %s", unkn4+head.textsOffset,ReadString(unkn4+head.textsOffset) );
145 | }
146 | return s;
147 | }
148 | string readMaterial(Material &m){
149 | string s;
150 | SPrintf( s, "%08x - %s", m.shaderHash,m.nameStr );
151 | return s;
152 | }
153 | string readProp1(Property1 &p){
154 | string s;
155 | //SPrintf( s, "%s(%016lx)", ReadString(p.stringPointer+head.textsOffset),p.unkn );
156 | SPrintf( s, "(index:%3d offset:%3d flags.val:%08x%08x) %s", p.flags.data.index,p.flags.data.index*4,p.flags.val>>32,p.flags.val,p.text );
157 | return s;
158 | }
159 | string readProp2(Property2 &p){
160 | string s;
161 | //SPrintf( s, "%s(%016lx)", ReadString(p.stringPointer+head.textsOffset),p.unkn );
162 | SPrintf( s, "(index:%3d offset:%3d flags.val:%08x%08x) %s", p.flags.data.index, p.flags.data.index*4,p.flags.val>>32,p.flags.val,p.text );
163 | return s;
164 | }
165 |
166 | string readBlock(MeshBlock &b){
167 | string s;
168 | SPrintf( s, " %08x - %s", b.blocktype ,b.nameStr);
169 | return s;
170 | }
171 | string readBlockRef(BlockRef &b){
172 | return readBlock(b.b);
173 | }
174 | string readShaderString(short s){
175 | string str;
176 | if(s<0){
177 | SPrintf( str, "%d",s);
178 | return str;
179 | }
180 | SPrintf( str, "%d %s",s,shaderDatas.shaderData[s].text);
181 | return str;
182 | }
183 |
184 | struct Head{
185 | uint32 tag;
186 | uint32 unkn1;
187 | uint32 unknStruct1Count;
188 | uint32 materialCount;
189 | uint32 shaderCount;
190 | uint32 unkn2;
191 | uint32 blockCount;
192 | uint32 unknStruct2Count;
193 | uint32 unknStruct3Count;
194 | uint32 unknStruct4Count;
195 | uint32 unkn3[4];
196 | uint32 unknStruct1Offset;
197 | uint32 unkn5;
198 | uint64 materialOffset;
199 | uint64 shaderOffset;
200 | uint64 blockOffset;
201 | uint64 unknStruct2Offset;
202 | uint64 unknStruct3Offset;
203 | uint64 unknStruct4Offset;
204 | uint64 unknStruct5Offset;
205 | uint64 textsOffset;
206 | uint64 unkn7;
207 | };
208 | struct BlockHead{
209 | BlockRef bref[head.blockCount];
210 | };
211 | struct MeshBlock{
212 | uint64 name;
213 | local uint64 curPos = FTell();
214 | FSeek(name+head.textsOffset);
215 | string nameStr;
216 | FSeek(curPos);
217 | uint32 unkn2;
218 | //blocktype is actually just the hash of the name
219 | //for example (zlib.crc32("IANonSkin1UV".encode()) ^ 0xffffffff) & 0x7fffffff
220 | uint32 blocktype;
221 | short propCount;
222 | //props seem to contain indexes for used props
223 | //that (lastpropnum+1)*4 seems to match vertexStructSize
224 | //for example:
225 | // UV_Primary(0000000000501080)
226 | // will result in (5+1)*4 = 24
227 | //still unshure how to decode type
228 | short vertexStructSize;
229 | uint32 unkn4;
230 | Property1 props[propCount];
231 | };
232 | struct MaterialHead{
233 | uint32 unkn1;
234 | uint32 unkn2;
235 | uint32 unkn3;
236 | uint32 unkn4;
237 | };
238 | struct Material{
239 | short vertexShaderDataIdx;
240 | short pixelShaderDataIdx;
241 | uint32 unkn3;
242 | short unkn4;
243 | short shaderDataIdx2;
244 | uint16 unknStruct2Idx;
245 | uint16 unkn7;
246 | uint32 name;
247 | local uint64 curPos = FTell();
248 | FSeek(name+head.textsOffset);
249 | string nameStr;
250 | FSeek(curPos);
251 | uint32 unkn8[2];
252 | //for example (zlib.crc32("GpuRibbonFireVolume".encode()) ^ 0xffffffff) & 0x7fffffff
253 | uint32 shaderHash;
254 | };
255 | struct ShaderData{
256 | uint64 pos;
257 | uint32 length;
258 | local uint32 oldpos = FTell();
259 | FSeek(pos);
260 | ubyte data[length];
261 | FSeek(oldpos);
262 | uint32 unkn2;
263 | uint64 unkn3;
264 | uint64 unkn4;
265 | uint64 unkn5;
266 | uint64 unkn6;
267 | uint64 unkn7;
268 | uint64 unkn8;
269 | uint32 pos2;
270 | local uint32 oldpos2 = FTell();
271 | FSeek(pos2+head.textsOffset);
272 | string text;
273 | FSeek(oldpos2);
274 | uint32 unkn9;
275 | uint32 unkn10;
276 | ushort unkn11;
277 | ushort unkn12;
278 | };
279 | struct ShaderDataShort{
280 | uint64 pos;
281 | uint32 length;
282 | local uint32 oldpos = FTell();
283 | FSeek(pos);
284 | ubyte data[length];
285 | FSeek(oldpos);
286 | uint32 unkn2;
287 | uint64 unkn3;
288 | uint64 unkn4;
289 | uint64 unkn5;
290 |
291 | };
292 | Head head;
293 | FSeek(head.unknStruct1Offset);
294 | uint64 unknStruct1[head.unknStruct1Count];
295 |
296 | struct{
297 | local int i;
298 | for(i=0;i;
301 | }
302 | }unknStruct1Datas;
303 |
304 | FSeek(head.blockOffset);
305 | struct{
306 | BlockHead blockHead;
307 | //FSeek(blockStart);
308 | MeshBlock meshBlock[head.blockCount];
309 | } meshBlocks;
310 |
311 | FSeek(head.unknStruct2Offset);
312 | struct{
313 | UnknStruct2 unknStruct2[head.unknStruct2Count];
314 | }unknStruct2s;
315 |
316 | FSeek(head.materialOffset);
317 | struct{
318 | MaterialHead materialHead;
319 | Material material[head.materialCount];
320 | } materials;
321 |
322 | //maybe also helpful:
323 | // https://github.com/tgjones/slimshader
324 | // http://timjones.io/blog/archive/2015/09/02/parsing-direct3d-shader-bytecode
325 | FSeek(head.shaderOffset+0x10);
326 | struct{
327 | ShaderData shaderData[head.shaderCount-1];
328 | ShaderDataShort shaderDataShort;
329 | } shaderDatas;
330 |
331 | FSeek(head.unknStruct3Offset);
332 | struct{
333 | struct{
334 | uint64 unkn1;
335 | uint64 unkn2