Skip to content

Commit d7b2791

Browse files
initial commit
0 parents  commit d7b2791

33 files changed

+7088
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
################################################################################
2+
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3+
################################################################################
4+
5+
/.vs/XboxBiosTools
6+
/bios
7+
/keys
8+
/XbBiosTool/objd
9+
*.exe
10+
*.pdb
11+
*.bin
12+
*.img

XbBiosTool/XbBiosTool.rc

3.4 KB
Binary file not shown.

XbBiosTool/XbBiosTool.vcxproj

Lines changed: 429 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="..\src\rc4.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
<ClCompile Include="..\src\file.cpp">
22+
<Filter>Source Files</Filter>
23+
</ClCompile>
24+
<ClCompile Include="..\src\util.cpp">
25+
<Filter>Source Files</Filter>
26+
</ClCompile>
27+
<ClCompile Include="..\src\xbmem.cpp">
28+
<Filter>Source Files</Filter>
29+
</ClCompile>
30+
<ClCompile Include="..\src\Bios.cpp">
31+
<Filter>Source Files</Filter>
32+
</ClCompile>
33+
<ClCompile Include="..\src\XbTool.cpp">
34+
<Filter>Source Files</Filter>
35+
</ClCompile>
36+
<ClCompile Include="..\src\XcodeInterp.cpp">
37+
<Filter>Source Files</Filter>
38+
</ClCompile>
39+
<ClCompile Include="..\src\main.cpp">
40+
<Filter>Source Files</Filter>
41+
</ClCompile>
42+
<ClCompile Include="..\src\lzx.cpp">
43+
<Filter>Source Files</Filter>
44+
</ClCompile>
45+
<ClCompile Include="..\src\sha1.cpp">
46+
<Filter>Source Files</Filter>
47+
</ClCompile>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<ClInclude Include="..\inc\file.h">
51+
<Filter>Header Files</Filter>
52+
</ClInclude>
53+
<ClInclude Include="..\inc\rc4.h">
54+
<Filter>Header Files</Filter>
55+
</ClInclude>
56+
<ClInclude Include="..\inc\util.h">
57+
<Filter>Header Files</Filter>
58+
</ClInclude>
59+
<ClInclude Include="..\inc\xbmem.h">
60+
<Filter>Header Files</Filter>
61+
</ClInclude>
62+
<ClInclude Include="..\inc\cli_tbl.h">
63+
<Filter>Header Files</Filter>
64+
</ClInclude>
65+
<ClInclude Include="..\inc\type_defs.h">
66+
<Filter>Header Files</Filter>
67+
</ClInclude>
68+
<ClInclude Include="..\inc\bldr.h">
69+
<Filter>Header Files</Filter>
70+
</ClInclude>
71+
<ClInclude Include="..\inc\help_strings.h">
72+
<Filter>Header Files</Filter>
73+
</ClInclude>
74+
<ClInclude Include="..\inc\Bios.h">
75+
<Filter>Header Files</Filter>
76+
</ClInclude>
77+
<ClInclude Include="..\inc\XbTool.h">
78+
<Filter>Header Files</Filter>
79+
</ClInclude>
80+
<ClInclude Include="..\inc\XcodeInterp.h">
81+
<Filter>Header Files</Filter>
82+
</ClInclude>
83+
<ClInclude Include="..\inc\main.h">
84+
<Filter>Header Files</Filter>
85+
</ClInclude>
86+
<ClInclude Include="resource.h">
87+
<Filter>Header Files</Filter>
88+
</ClInclude>
89+
<ClInclude Include="..\inc\lzx.h">
90+
<Filter>Header Files</Filter>
91+
</ClInclude>
92+
<ClInclude Include="..\inc\nt_headers.h">
93+
<Filter>Header Files</Filter>
94+
</ClInclude>
95+
<ClInclude Include="..\inc\sha1.h">
96+
<Filter>Header Files</Filter>
97+
</ClInclude>
98+
<ClInclude Include="..\inc\version.h">
99+
<Filter>Header Files</Filter>
100+
</ClInclude>
101+
</ItemGroup>
102+
<ItemGroup>
103+
<ResourceCompile Include="XbBiosTool.rc">
104+
<Filter>Resource Files</Filter>
105+
</ResourceCompile>
106+
</ItemGroup>
107+
</Project>

XbBiosTool/XbBiosTool.vcxproj.user

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

XbBiosTool/resource.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//{{NO_DEPENDENCIES}}
2+
// Microsoft Visual C++ generated include file.
3+
// Used by XbBiosTool.rc
4+
5+
// Next default values for new objects
6+
//
7+
#ifdef APSTUDIO_INVOKED
8+
#ifndef APSTUDIO_READONLY_SYMBOLS
9+
#define _APS_NEXT_RESOURCE_VALUE 101
10+
#define _APS_NEXT_COMMAND_VALUE 40001
11+
#define _APS_NEXT_CONTROL_VALUE 1001
12+
#define _APS_NEXT_SYMED_VALUE 101
13+
#endif
14+
#endif

XboxBiosTools.sln

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.9.34728.123
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XbBiosTool", "XbBiosTool\XbBiosTool.vcxproj", "{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
bld-inittbl|x86 = bld-inittbl|x86
11+
build bios|x86 = build bios|x86
12+
cmb_banks|x86 = cmb_banks|x86
13+
Debug|x86 = Debug|x86
14+
decode|x86 = decode|x86
15+
decomp|x86 = decomp|x86
16+
extract|x86 = extract|x86
17+
help|x86 = help|x86
18+
ls|x86 = ls|x86
19+
Release|x86 = Release|x86
20+
xcode-sim|x86 = xcode-sim|x86
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.bld-inittbl|x86.ActiveCfg = bld-inittbl|Win32
24+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.bld-inittbl|x86.Build.0 = bld-inittbl|Win32
25+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.build bios|x86.ActiveCfg = build bios|Win32
26+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.build bios|x86.Build.0 = build bios|Win32
27+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.cmb_banks|x86.ActiveCfg = cmb_banks|Win32
28+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.cmb_banks|x86.Build.0 = cmb_banks|Win32
29+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.Debug|x86.ActiveCfg = Debug|Win32
30+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.Debug|x86.Build.0 = Debug|Win32
31+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.decode|x86.ActiveCfg = decode|Win32
32+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.decode|x86.Build.0 = decode|Win32
33+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.decomp|x86.ActiveCfg = decomp|Win32
34+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.decomp|x86.Build.0 = decomp|Win32
35+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.extract|x86.ActiveCfg = extract|Win32
36+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.extract|x86.Build.0 = extract|Win32
37+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.help|x86.ActiveCfg = help|Win32
38+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.help|x86.Build.0 = help|Win32
39+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.ls|x86.ActiveCfg = ls|Win32
40+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.ls|x86.Build.0 = ls|Win32
41+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.Release|x86.ActiveCfg = Release|Win32
42+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.Release|x86.Build.0 = Release|Win32
43+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.xcode-sim|x86.ActiveCfg = xcode-sim|Win32
44+
{7845CC9D-7D7E-4C08-BCF9-7033B337BA91}.xcode-sim|x86.Build.0 = xcode-sim|Win32
45+
EndGlobalSection
46+
GlobalSection(SolutionProperties) = preSolution
47+
HideSolutionNode = FALSE
48+
EndGlobalSection
49+
GlobalSection(ExtensibilityGlobals) = postSolution
50+
SolutionGuid = {D4771D08-046A-4CCE-A096-CF90E5AC47A6}
51+
EndGlobalSection
52+
EndGlobal

inc/Bios.h

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Bios.h
2+
3+
// Author: tommojphillips
4+
// GitHub: https:\\github.com\tommojphillips
5+
6+
#ifndef XB_BIOS_H
7+
#define XB_BIOS_H
8+
9+
#include "type_defs.h"
10+
#include "xbmem.h"
11+
12+
#include "bldr.h"
13+
14+
#define BIOS_LOAD_STATUS_SUCCESS 0 // The bios was loaded successfully and the bldr is valid.
15+
#define BIOS_LOAD_STATUS_INVALID_BLDR 1 // The bios was loaded successfully but the bldr is invalid.
16+
#define BIOS_LOAD_STATUS_FAILED 2 // The bios failed to load.
17+
18+
#define PRELDR_STATUS_FOUND 2 // bios contains a preldr
19+
#define PRELDR_STATUS_NOT_FOUND 0 // bios does not contain a preldr
20+
#define PRELDR_STATUS_ERROR 1 // preldr error; cannot continue.
21+
22+
class Bios
23+
{
24+
public:
25+
Bios()
26+
{
27+
// allocated memory
28+
_bios = NULL;
29+
decompressedKrnl = NULL;
30+
31+
// pointers, offsets
32+
reset();
33+
};
34+
~Bios()
35+
{
36+
deconstruct();
37+
};
38+
void deconstruct();
39+
40+
int create(UCHAR* in_bl, UINT in_blSize, UCHAR* in_tbl, UINT in_tblSize, UCHAR* in_k, UINT in_kSize, UCHAR* in_kData, UINT in_kDataSize);
41+
42+
int loadFromFile(const char* path);
43+
int loadFromData(const UCHAR* data, const UINT size);
44+
45+
int saveBiosToFile(const char* path);
46+
47+
int saveBldrBlockToFile(const char* filename);
48+
int saveBldrToFile(const char* filename, const UINT size);
49+
int saveKernelToFile(const char* filename);
50+
int saveKernelDataToFile(const char* path);
51+
int saveKernelImgToFile(const char* path);
52+
int saveInitTblToFile(const char* filename);
53+
54+
void symmetricEncDecBldr(const UCHAR* key, const UINT keyLen);
55+
56+
void printBldrInfo();
57+
void printKernelInfo();
58+
void printInitTblInfo();
59+
void printNv2aInfo();
60+
61+
void printXcodes();
62+
void printDataTbl();
63+
64+
int decompressKrnl();
65+
66+
int checkForPreldr();
67+
68+
UCHAR* getBiosData() const { return _bios; };
69+
UINT getBiosSize() const { return _size; };
70+
71+
UCHAR* getDecompressedKrnl() const { return decompressedKrnl; };
72+
UINT getDecompressedKrnlSize() const { return _decompressedKrnlSize; };
73+
74+
UINT getAvailableSpace() const { return _availableSpace; };
75+
UINT getTotalSpaceAvailable() const { return _totalSpaceAvailable; };
76+
77+
bool isBootParamsValid() const { return _isBootParamsValid; };
78+
79+
80+
bool isLoaded() const { return _bios != NULL; };
81+
82+
bool isBldrEncrypted() const { return _isBldrEncrypted; };
83+
bool isKernelEncrypted() const { return _isKernelEncrypted; };
84+
85+
private:
86+
UCHAR* _bios; // The allocated bios data
87+
88+
UCHAR* decompressedKrnl; // The allocated decompressed kernel
89+
90+
UCHAR* bldr; // pointer to the bldr _bios
91+
BLDR_ENTRY* bldrEntry; // pointer to the bldr entry struct in the bldr
92+
BLDR_KEYS* bldrKeys; // pointer to the keys struct in the bldr
93+
94+
BOOT_PARAMS* bootParams; // pointer to the boot parameters in the bldr
95+
BOOT_LDR_PARAM* ldrParams; // pointer to the boot loader parameters in the bldr
96+
97+
INIT_TBL* initTbl; // pointer to the init tbl in _bios (nv2a, mcpx, xcodes)
98+
99+
ROM_DATA_TBL* dataTbl; // pointer to the drv slw data tbl in _bios
100+
101+
UCHAR* krnl; // pointer to the compressed kernel in _bios
102+
UCHAR* krnlData; // pointer to the uncompressed kernel data in _bios
103+
104+
UINT _size; // the size of the bios.
105+
UINT _decompressedKrnlSize; // The size of the decompressed kernel
106+
ULONG _totalSpaceAvailable; // the total space available in the bios. this is the size of the bios minus the bldr BLOCK
107+
ULONG _availableSpace; // the available space in the bios.
108+
109+
bool _isBldrEncrypted; // true if the bldr is encrypted.
110+
bool _isKernelEncrypted; // true if the kernel is encrypted.
111+
112+
bool _isBldrSignatureValid; // true if the bldr signature is valid.
113+
bool _isBootParamsValid; // true if the bldr is valid.
114+
115+
int load(UCHAR* data, UINT size); // load the bios data
116+
117+
void getOffsets();
118+
void getOffsets2(const UINT krnlSize, const UINT krnlDataSize);
119+
120+
int validateBldr();
121+
122+
int decryptKernel();
123+
124+
void reset();
125+
};
126+
127+
#endif // !XB_BIOS_H

0 commit comments

Comments
 (0)