progress
This commit is contained in:
parent
412237ada1
commit
3080fdf2d0
|
@ -285,6 +285,11 @@ XCALCSIG_SIGNATURE, *PXCALCSIG_SIGNATURE;
|
|||
// ******************************************************************
|
||||
VOID WINAPI EmuXapiApplyKernelPatches();
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuXFormatUtilityDrive
|
||||
// ******************************************************************
|
||||
BOOL WINAPI EmuXFormatUtilityDrive();
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuRtlCreateHeap
|
||||
// ******************************************************************
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "OOVPA.h"
|
||||
|
||||
extern SOOVPA<7> XapiInitProcess_1_0_4928;
|
||||
extern OOVPATable XAPI_1_0_4627[];
|
||||
extern uint32 XAPI_1_0_4627_SIZE;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ extern class ResourceTracker : public Mutex
|
|||
}
|
||||
g_VBTrackTotal, g_VBTrackDisable,
|
||||
g_PBTrackTotal, g_PBTrackDisable, g_PBTrackShowOnce,
|
||||
g_PatchedStreamsCache, g_DataToTexture;
|
||||
g_PatchedStreamsCache, g_DataToTexture, g_AlignCache;
|
||||
|
||||
struct RTNode
|
||||
{
|
||||
|
|
|
@ -378,9 +378,18 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
|||
uint16 MajorVersion = pLibraryVersion[v].wMajorVersion;
|
||||
uint16 MinorVersion = pLibraryVersion[v].wMinorVersion;
|
||||
uint16 BuildVersion = pLibraryVersion[v].wBuildVersion;
|
||||
uint16 OrigBuildVersion = BuildVersion;
|
||||
|
||||
//
|
||||
// Aliases
|
||||
//
|
||||
{
|
||||
if(BuildVersion == 4928)
|
||||
BuildVersion = 4627;
|
||||
|
||||
if(BuildVersion == 5659)
|
||||
BuildVersion = 5558;
|
||||
}
|
||||
|
||||
char szLibraryName[9] = {0};
|
||||
|
||||
|
@ -438,10 +447,19 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
|||
}
|
||||
else if(BuildVersion >= 4361)
|
||||
{
|
||||
if(OrigBuildVersion == 4928)
|
||||
{
|
||||
pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_4928, lower, upper);
|
||||
ProcessHeapOffs = 0x44;
|
||||
RtlCreateHeapOffs = 0x3B;
|
||||
}
|
||||
else
|
||||
{
|
||||
pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_4361, lower, upper);
|
||||
ProcessHeapOffs = 0x3E;
|
||||
RtlCreateHeapOffs = 0x37;
|
||||
}
|
||||
}
|
||||
else // 3911, 4034, 4134
|
||||
{
|
||||
pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_3911, lower, upper);
|
||||
|
@ -608,7 +626,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit
|
|||
// _USE_XGMATH Disabled in mesh :[
|
||||
// halo : dword_0_2E2D18
|
||||
// halo : 1744F0 (bink)
|
||||
//_asm int 3;
|
||||
_asm int 3;
|
||||
|
||||
/*
|
||||
for(int v=0;v<sizeof(funcAddr)/sizeof(uint32);v++)
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace NtDll
|
|||
#include "EmuFile.h"
|
||||
#include "EmuAlloc.h"
|
||||
#include "EmuXTL.h"
|
||||
#include "ResourceTracker.h"
|
||||
|
||||
// PsCreateSystemThread proxy parameters
|
||||
typedef struct _PCSTProxyParam
|
||||
|
@ -70,16 +71,6 @@ PCSTProxyParam;
|
|||
// Global Variable(s)
|
||||
extern PVOID g_pfnThreadNotification = NULL;
|
||||
|
||||
// MmAllocateContiguousMemory[Ex] allocate unaligned data and then manually align the pointer,
|
||||
// returning this to the Xbe. The original pointer must be retained in order to properly free.
|
||||
#define ALIGN_CACHE_SIZE 1024
|
||||
struct _AlignCache
|
||||
{
|
||||
PVOID pOrigPtr;
|
||||
PVOID pAligPtr;
|
||||
}
|
||||
g_pAlignCache[ALIGN_CACHE_SIZE] = {0};
|
||||
|
||||
// PsCreateSystemThread proxy procedure
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4731) // disable ebp modification warning
|
||||
|
@ -675,21 +666,6 @@ XBSYSAPI EXPORTNUM(165) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo
|
|||
");\n",
|
||||
GetCurrentThreadId(), NumberOfBytes);
|
||||
|
||||
DWORD dwAlignIndex = -1;
|
||||
|
||||
for(int v=0;v<ALIGN_CACHE_SIZE;v++)
|
||||
{
|
||||
if(g_pAlignCache[v].pOrigPtr == 0)
|
||||
{
|
||||
dwAlignIndex = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// verify we have enough align cache entries
|
||||
if(dwAlignIndex = -1)
|
||||
EmuCleanup("Out of AlignCache slots!");
|
||||
|
||||
//
|
||||
// NOTE: Kludgey (but necessary) solution:
|
||||
//
|
||||
|
@ -699,17 +675,15 @@ XBSYSAPI EXPORTNUM(165) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo
|
|||
|
||||
PVOID pRet = CxbxMalloc(NumberOfBytes + 0x1000);
|
||||
|
||||
g_pAlignCache[dwAlignIndex].pOrigPtr = pRet;
|
||||
|
||||
// align to page boundary
|
||||
{
|
||||
DWORD dwRet = (DWORD)pRet;
|
||||
|
||||
dwRet += 0x1000 - dwRet%0x1000;
|
||||
|
||||
pRet = (PVOID)dwRet;
|
||||
g_AlignCache.insert(dwRet, pRet);
|
||||
|
||||
g_pAlignCache[dwAlignIndex].pAligPtr = pRet;
|
||||
pRet = (PVOID)dwRet;
|
||||
}
|
||||
|
||||
DbgPrintf("EmuKrnl (0x%X): MmAllocateContiguous returned 0x%.08X\n", GetCurrentThreadId(), pRet);
|
||||
|
@ -744,21 +718,6 @@ XBSYSAPI EXPORTNUM(166) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo
|
|||
GetCurrentThreadId(), NumberOfBytes, LowestAcceptableAddress, HighestAcceptableAddress,
|
||||
Alignment, ProtectionType);
|
||||
|
||||
DWORD dwAlignIndex = -1;
|
||||
|
||||
for(int v=0;v<ALIGN_CACHE_SIZE;v++)
|
||||
{
|
||||
if(g_pAlignCache[v].pOrigPtr == 0)
|
||||
{
|
||||
dwAlignIndex = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// verify we have enough align cache entries
|
||||
if(dwAlignIndex == -1)
|
||||
EmuCleanup("Out of AlignCache slots!");
|
||||
|
||||
//
|
||||
// NOTE: Kludgey (but necessary) solution:
|
||||
//
|
||||
|
@ -768,17 +727,15 @@ XBSYSAPI EXPORTNUM(166) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo
|
|||
|
||||
PVOID pRet = CxbxMalloc(NumberOfBytes + 0x1000);
|
||||
|
||||
g_pAlignCache[dwAlignIndex].pOrigPtr = pRet;
|
||||
|
||||
// align to page boundary
|
||||
{
|
||||
DWORD dwRet = (DWORD)pRet;
|
||||
|
||||
dwRet += 0x1000 - dwRet%0x1000;
|
||||
|
||||
pRet = (PVOID)dwRet;
|
||||
g_AlignCache.insert(dwRet, pRet);
|
||||
|
||||
g_pAlignCache[dwAlignIndex].pAligPtr = pRet;
|
||||
pRet = (PVOID)dwRet;
|
||||
}
|
||||
|
||||
static int count = 0;
|
||||
|
@ -835,24 +792,18 @@ XBSYSAPI EXPORTNUM(171) VOID NTAPI xboxkrnl::MmFreeContiguousMemory
|
|||
");\n",
|
||||
GetCurrentThreadId(), BaseAddress);
|
||||
|
||||
// retrieve correct allocation base address (since MmAllocContiguousMemory[Ex] aligns upward)
|
||||
PVOID OrigBaseAddress = BaseAddress;
|
||||
|
||||
if(g_AlignCache.exists(BaseAddress))
|
||||
{
|
||||
int v=0;
|
||||
for(v=0;v<ALIGN_CACHE_SIZE;v++)
|
||||
{
|
||||
if(g_pAlignCache[v].pAligPtr == BaseAddress)
|
||||
{
|
||||
BaseAddress = g_pAlignCache[v].pOrigPtr;
|
||||
g_pAlignCache[v].pAligPtr = 0;
|
||||
g_pAlignCache[v].pOrigPtr = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OrigBaseAddress = g_AlignCache.get(BaseAddress);
|
||||
|
||||
g_AlignCache.remove(BaseAddress);
|
||||
}
|
||||
|
||||
if(BaseAddress != &xLaunchDataPage)
|
||||
if(OrigBaseAddress != &xLaunchDataPage)
|
||||
{
|
||||
CxbxFree(BaseAddress);
|
||||
CxbxFree(OrigBaseAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -74,6 +74,22 @@ VOID WINAPI XTL::EmuXapiApplyKernelPatches()
|
|||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuXFormatUtilityDrive
|
||||
// ******************************************************************
|
||||
BOOL WINAPI XTL::EmuXFormatUtilityDrive()
|
||||
{
|
||||
#ifdef _DEBUG_TRACE
|
||||
EmuSwapFS(); // Win2k/XP FS
|
||||
DbgPrintf("EmuXapi (0x%X): EmuXFormatUtilityDrive()\n", GetCurrentThreadId());
|
||||
EmuSwapFS(); // XBox FS
|
||||
#endif
|
||||
|
||||
// TODO: yeah... we'll format... riiiiight
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: EmuRtlCreateHeap
|
||||
// ******************************************************************
|
||||
|
|
|
@ -445,7 +445,6 @@ SOOVPA<7> XapiInitProcess_1_0_4361 =
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
// * XapiThreadStartup
|
||||
// ******************************************************************
|
||||
|
|
|
@ -32,6 +32,73 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
// NOTE: This function actually came in with 4928
|
||||
// ******************************************************************
|
||||
// * XapiApplyKernelPatches
|
||||
// ******************************************************************
|
||||
SOOVPA<7> XapiApplyKernelPatches_1_0_4928 =
|
||||
{
|
||||
0, // Large == 0
|
||||
7, // Count == 7
|
||||
|
||||
-1, // Xref Not Saved
|
||||
0, // Xref Not Used
|
||||
|
||||
{
|
||||
{ 0x17, 0x81 },
|
||||
{ 0x2A, 0x81 },
|
||||
{ 0x4B, 0x05 },
|
||||
{ 0x5F, 0x1B },
|
||||
{ 0x7C, 0xFF },
|
||||
{ 0x88, 0x6A },
|
||||
{ 0x92, 0xC7 },
|
||||
}
|
||||
};
|
||||
|
||||
// NOTE: This function actually came in with 4928
|
||||
// ******************************************************************
|
||||
// * XapiInitProcess
|
||||
// ******************************************************************
|
||||
SOOVPA<7> XapiInitProcess_1_0_4928 =
|
||||
{
|
||||
0, // Large == 0
|
||||
7, // Count == 7
|
||||
|
||||
-1, // XRef Not Saved
|
||||
0, // XRef Not Used
|
||||
|
||||
{
|
||||
{ 0x22, 0xC7 }, // (Offset,Value)-Pair #1
|
||||
{ 0x23, 0x45 }, // (Offset,Value)-Pair #2
|
||||
{ 0x24, 0xCC }, // (Offset,Value)-Pair #3
|
||||
{ 0x25, 0x30 }, // (Offset,Value)-Pair #4
|
||||
{ 0x4A, 0xA1 }, // (Offset,Value)-Pair #5
|
||||
{ 0x4B, 0x18 }, // (Offset,Value)-Pair #6
|
||||
{ 0x4C, 0x01 }, // (Offset,Value)-Pair #7
|
||||
}
|
||||
};
|
||||
|
||||
// ******************************************************************
|
||||
// * XFormatUtilityDrive
|
||||
// ******************************************************************
|
||||
SOOVPA<7> XFormatUtilityDrive_1_0_4627 =
|
||||
{
|
||||
0, // Large == 0
|
||||
7, // Count == 7
|
||||
|
||||
-1, // Xref Not Saved
|
||||
0, // Xref Not Used
|
||||
|
||||
{
|
||||
{ 0x10, 0x50 },
|
||||
{ 0x23, 0xFF },
|
||||
{ 0x34, 0xC0 },
|
||||
{ 0x46, 0x45 },
|
||||
{ 0x58, 0xFF },
|
||||
{ 0x6D, 0x33 },
|
||||
{ 0x7C, 0x40 },
|
||||
}
|
||||
};
|
||||
// ******************************************************************
|
||||
// * SetThreadPriorityBoost
|
||||
// ******************************************************************
|
||||
|
@ -162,6 +229,36 @@ SOOVPA<10> RtlReAllocateHeap_1_0_4627 =
|
|||
// ******************************************************************
|
||||
OOVPATable XAPI_1_0_4627[] =
|
||||
{
|
||||
// XapiApplyKernelPatches
|
||||
{
|
||||
(OOVPA*)&XapiApplyKernelPatches_1_0_4928,
|
||||
|
||||
XTL::EmuXapiApplyKernelPatches,
|
||||
|
||||
#ifdef _DEBUG_TRACE
|
||||
"EmuXapiApplyKernelPatches"
|
||||
#endif
|
||||
},
|
||||
// XapiInitProcess
|
||||
{
|
||||
(OOVPA*)&XapiInitProcess_1_0_4928,
|
||||
|
||||
XTL::EmuXapiInitProcess,
|
||||
|
||||
#ifdef _DEBUG_TRACE
|
||||
"EmuXapiInitProcess"
|
||||
#endif
|
||||
},
|
||||
// XFormatUtilityDrive
|
||||
{
|
||||
(OOVPA*)&XFormatUtilityDrive_1_0_4627,
|
||||
|
||||
XTL::EmuXFormatUtilityDrive,
|
||||
|
||||
#ifdef _DEBUG_TRACE
|
||||
"EmuXFormatUtilityDrive"
|
||||
#endif
|
||||
},
|
||||
// SetThreadPriorityBoost
|
||||
{
|
||||
(OOVPA*)&SetThreadPriorityBoost_1_0_4627,
|
||||
|
|
|
@ -38,16 +38,18 @@
|
|||
bool g_bVBSkipStream = false;
|
||||
bool g_bVBSkipPusher = false;
|
||||
|
||||
//
|
||||
// all of our resource trackers
|
||||
//
|
||||
|
||||
ResourceTracker g_VBTrackTotal;
|
||||
ResourceTracker g_VBTrackDisable;
|
||||
|
||||
ResourceTracker g_PBTrackTotal;
|
||||
ResourceTracker g_PBTrackDisable;
|
||||
ResourceTracker g_PBTrackShowOnce;
|
||||
|
||||
ResourceTracker g_PatchedStreamsCache;
|
||||
|
||||
ResourceTracker g_DataToTexture;
|
||||
ResourceTracker g_AlignCache;
|
||||
|
||||
ResourceTracker::~ResourceTracker()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue