forked from katalash/DSLuaDecompiler
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hash resolving, added BO3 to memory loading, fixed crashes for …
…havok, ...
- Loading branch information
1 parent
523e3c7
commit 3b55ab4
Showing
48 changed files
with
21,176 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using CoDLuaDecompiler.AssetExporter.Util; | ||
|
||
namespace CoDLuaDecompiler.AssetExporter.Games | ||
{ | ||
public class BlackOps3 : IGame | ||
{ | ||
public override string ExportFolder => "BO3/"; | ||
|
||
public static long[] GameOffsets = | ||
{ | ||
0x88788D0, | ||
}; | ||
|
||
struct AssetPool | ||
{ | ||
public long PoolPointer { get; set; } | ||
public int AssetSize { get; set; } | ||
public int PoolSize { get; set; } | ||
public bool IsSingleton { get; set; } | ||
public int ItemAllocCount { get; set; } | ||
public long FreeHead { get; set; } | ||
} | ||
|
||
private struct LuaFile | ||
{ | ||
|
||
public long NamePtr { get; set; } | ||
public Int32 AssetSize { get; set; } | ||
public long RawDataPtr { get; set; } | ||
} | ||
public override unsafe List<LuaFileData> LoadLuaFiles(bool isMP = true) | ||
{ | ||
// Get Base Address for ASLR and Scans | ||
long baseAddress = AssetExport.Reader.GetBaseAddress(); | ||
|
||
foreach (var gameOffset in GameOffsets) | ||
{ | ||
var xmodelPoolData = AssetExport.Reader.ReadStruct<AssetPool>(baseAddress + gameOffset + sizeof(AssetPool) * 0x4); | ||
|
||
// Check XModel Hash | ||
if (AssetExport.Reader.ReadNullTerminatedString(AssetExport.Reader.ReadInt64(xmodelPoolData.PoolPointer)) == "void") | ||
{ | ||
var luaPoolData = AssetExport.Reader.ReadStruct<AssetPool>(baseAddress + gameOffset + sizeof(AssetPool) * 47); | ||
|
||
return FetchFiles(luaPoolData); | ||
} | ||
} | ||
|
||
var dbAssetsScan = AssetExport.Reader.FindBytes(new byte?[] { 0x63, 0xC1, 0x48, 0x8D, 0x05, null, null, null, null, 0x49, 0xC1, 0xE0, null, 0x4C, 0x03, 0xC0 }, baseAddress, baseAddress + AssetExport.Reader.GetModuleMemorySize(), true); | ||
|
||
// Check that we had hits | ||
if (dbAssetsScan.Length > 0) | ||
{ | ||
var assetPoolAddress = AssetExport.Reader.ReadUInt32(dbAssetsScan[0] + 0x5) + dbAssetsScan[0] + 0x9; | ||
var xmodelPoolData = AssetExport.Reader.ReadStruct<AssetPool>(assetPoolAddress + sizeof(AssetPool) * 0x4); | ||
|
||
// Check XModel Hash | ||
if (AssetExport.Reader.ReadNullTerminatedString(AssetExport.Reader.ReadInt64(xmodelPoolData.PoolPointer)) == "void") | ||
{ | ||
var luaPoolData = AssetExport.Reader.ReadStruct<AssetPool>(assetPoolAddress + sizeof(AssetPool) * 47); | ||
|
||
return FetchFiles(luaPoolData); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private List<LuaFileData> FetchFiles(AssetPool luaPoolData) | ||
{ | ||
var filesList = new List<LuaFileData>(); | ||
for (int i = 0; i < luaPoolData.PoolSize; i++) | ||
{ | ||
var luaFile = AssetExport.Reader.ReadStruct<LuaFile>(luaPoolData.PoolPointer + (i * luaPoolData.AssetSize)); | ||
|
||
if (luaFile.AssetSize == 0 || luaFile.RawDataPtr == 0) | ||
continue; | ||
|
||
var name = AssetExport.Reader.ReadNullTerminatedString(luaFile.NamePtr); | ||
if (!name.EndsWith(".lua")) | ||
continue; | ||
|
||
var luaFileData = AssetExport.Reader.ReadBytes(luaFile.RawDataPtr, luaFile.AssetSize); | ||
|
||
filesList.Add(new LuaFileData() | ||
{ | ||
Reader = new BinaryReader(new MemoryStream(luaFileData)), | ||
Name = name, | ||
}); | ||
} | ||
|
||
return filesList; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
{ | ||
public interface IAssetExport | ||
{ | ||
void ExportAssets(); | ||
void ExportAssets(bool dumpRaw = false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
CoDLuaDecompiler.Decompiler/Analyzers/HavokFileAnalyzerList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
using CoDLuaDecompiler.Decompiler.Analyzers.Havok; | ||
using CoDLuaDecompiler.Decompiler.Analyzers.Shared; | ||
|
||
namespace CoDLuaDecompiler.Decompiler.Analyzers | ||
{ | ||
public class HavokFileAnalyzerList : IAnalyzerList | ||
{ | ||
public List<IAnalyzer> GetAnalyzers() | ||
{ | ||
return new List<IAnalyzer>() | ||
{ | ||
new PrePostLoadFuncAnalyzer(), | ||
new PostRequireStatementsNewLine(), | ||
new UIModelFunctionValueVarNamesAnalyzer(), | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.