diff --git a/CxbxKrnl.dsp b/CxbxKrnl.dsp index e65a7f334..de615a09a 100644 --- a/CxbxKrnl.dsp +++ b/CxbxKrnl.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="CxbxKrnl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# Microsoft Developer Studio Generated Build File, Format Version 60000 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 @@ -154,6 +154,10 @@ SOURCE=.\Include\Win32\CxbxKrnl\D3D8.1.0.4034.h # End Source File # Begin Source File +SOURCE=.\Include\Win32\CxbxKrnl\D3D8.1.0.4134.h +# End Source File +# Begin Source File + SOURCE=.\Include\Win32\CxbxKrnl\D3D8.1.0.4361.h # End Source File # Begin Source File @@ -242,6 +246,10 @@ SOURCE=.\Include\Win32\CxbxKrnl\Xapi.1.0.4034.h # End Source File # Begin Source File +SOURCE=.\Include\Win32\CxbxKrnl\Xapi.1.0.4134.h +# End Source File +# Begin Source File + SOURCE=.\Include\Win32\CxbxKrnl\Xapi.1.0.4361.h # End Source File # Begin Source File @@ -298,6 +306,10 @@ SOURCE=.\Source\Win32\CxbxKrnl\D3D8.1.0.4034.inl # End Source File # Begin Source File +SOURCE=.\Source\Win32\CxbxKrnl\D3D8.1.0.4134.inl +# End Source File +# Begin Source File + SOURCE=.\Source\Win32\CxbxKrnl\D3D8.1.0.4361.inl # End Source File # Begin Source File @@ -394,6 +406,10 @@ SOURCE=.\Source\Win32\CxbxKrnl\Xapi.1.0.4034.inl # End Source File # Begin Source File +SOURCE=.\Source\Win32\CxbxKrnl\Xapi.1.0.4134.inl +# End Source File +# Begin Source File + SOURCE=.\Source\Win32\CxbxKrnl\Xapi.1.0.4361.inl # End Source File # Begin Source File diff --git a/Include/Cxbx.h b/Include/Cxbx.h index 31ba8e39f..5532ff172 100644 --- a/Include/Cxbx.h +++ b/Include/Cxbx.h @@ -67,9 +67,9 @@ typedef signed long sint32; // * Version information // ****************************************************************** #ifndef _DEBUG_TRACE -#define _CXBX_VERSION "0.7.7b" +#define _CXBX_VERSION "0.7.8-Pre1" #else -#define _CXBX_VERSION "0.7.7b-Trace" +#define _CXBX_VERSION "0.7.8-Pre1-Trace" #endif // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/D3D8.1.0.4134.h b/Include/Win32/CxbxKrnl/D3D8.1.0.4134.h new file mode 100644 index 000000000..2a1c70f3d --- /dev/null +++ b/Include/Win32/CxbxKrnl/D3D8.1.0.4134.h @@ -0,0 +1,44 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->D3D8.1.0.4134.h +// * +// * This file is part of the Cxbx project. +// * +// * Cxbx and Cxbe are free software; you can redistribute them +// * and/or modify them under the terms of the GNU General Public +// * License as published by the Free Software Foundation; either +// * version 2 of the license, or (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have recieved a copy of the GNU General Public License +// * along with this program; see the file COPYING. +// * If not, write to the Free Software Foundation, Inc., +// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. +// * +// * (c) 2002-2003 Aaron Robinson +// * +// * All rights reserved +// * +// ****************************************************************** +#ifndef D3D8_1_0_4134_H +#define D3D8_1_0_4134_H + +#include "OOVPA.h" + +extern SOOVPA<13> IDirect3DDevice8_SetRenderState_CullMode_1_0_4134; + +extern OOVPATable D3D8_1_0_4134[]; +extern uint32 D3D8_1_0_4134_SIZE; + +#endif diff --git a/Include/Win32/CxbxKrnl/D3D8.1.0.4361.h b/Include/Win32/CxbxKrnl/D3D8.1.0.4361.h index 97349f856..400c03f11 100644 --- a/Include/Win32/CxbxKrnl/D3D8.1.0.4361.h +++ b/Include/Win32/CxbxKrnl/D3D8.1.0.4361.h @@ -36,7 +36,6 @@ #include "OOVPA.h" -extern SOOVPA<13> IDirect3DDevice8_SetRenderState_CullMode_1_0_4361; extern SOOVPA<10> IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_4361; extern OOVPATable D3D8_1_0_4361[]; diff --git a/Include/Win32/CxbxKrnl/Emu.h b/Include/Win32/CxbxKrnl/Emu.h index f60ffda8e..a83c77a55 100644 --- a/Include/Win32/CxbxKrnl/Emu.h +++ b/Include/Win32/CxbxKrnl/Emu.h @@ -95,5 +95,6 @@ extern Xbe::Header *g_pXbeHeader; extern HANDLE g_hCurDir; extern HANDLE g_hTDrive; extern HANDLE g_hUDrive; +extern HANDLE g_hZDrive; #endif diff --git a/Include/Win32/CxbxKrnl/EmuXapi.h b/Include/Win32/CxbxKrnl/EmuXapi.h index 7cde987b1..4943768be 100644 --- a/Include/Win32/CxbxKrnl/EmuXapi.h +++ b/Include/Win32/CxbxKrnl/EmuXapi.h @@ -320,6 +320,14 @@ BOOL WINAPI EmuQueryPerformanceFrequency PLARGE_INTEGER lpFrequency ); +// ****************************************************************** +// * func: EmuXMountUtilityDrive +// ****************************************************************** +BOOL WINAPI EmuXMountUtilityDrive +( + BOOL fFormatClean +); + // ****************************************************************** // * func: EmuXInitDevices // ****************************************************************** @@ -414,6 +422,15 @@ BOOL WINAPI EmuCloseHandle HANDLE hObject ); +// ****************************************************************** +// * func: EmuSetThreadPriority +// ****************************************************************** +BOOL WINAPI EmuSetThreadPriority +( + HANDLE hThread, + int nPriority +); + // ****************************************************************** // * func: EmuXapiInitProcess // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/HLEDataBase.h b/Include/Win32/CxbxKrnl/HLEDataBase.h index 3528ed291..2e101d7d7 100644 --- a/Include/Win32/CxbxKrnl/HLEDataBase.h +++ b/Include/Win32/CxbxKrnl/HLEDataBase.h @@ -36,10 +36,12 @@ #include "Xapi.1.0.3911.h" #include "Xapi.1.0.4034.h" +#include "Xapi.1.0.4134.h" #include "Xapi.1.0.4361.h" #include "Xapi.1.0.4627.h" #include "D3D8.1.0.3925.h" #include "D3D8.1.0.4034.h" +#include "D3D8.1.0.4134.h" #include "D3D8.1.0.4361.h" #include "D3D8.1.0.4627.h" #include "DSound.1.0.4361.h" diff --git a/Include/Win32/CxbxKrnl/Xapi.1.0.3911.h b/Include/Win32/CxbxKrnl/Xapi.1.0.3911.h index 1db223c1f..cd63ebc91 100644 --- a/Include/Win32/CxbxKrnl/Xapi.1.0.3911.h +++ b/Include/Win32/CxbxKrnl/Xapi.1.0.3911.h @@ -36,7 +36,7 @@ #include "OOVPA.h" -extern SOOVPA<9> __cinit_1_0_3911; +extern SOOVPA<7> XapiInitProcess_1_0_3911; extern OOVPATable XAPI_1_0_3911[]; extern uint32 XAPI_1_0_3911_SIZE; diff --git a/Include/Win32/CxbxKrnl/Xapi.1.0.4034.h b/Include/Win32/CxbxKrnl/Xapi.1.0.4034.h index a40ae4d3c..26d243f7e 100644 --- a/Include/Win32/CxbxKrnl/Xapi.1.0.4034.h +++ b/Include/Win32/CxbxKrnl/Xapi.1.0.4034.h @@ -36,7 +36,7 @@ #include "OOVPA.h" -extern OOVPATable XAPI_1_0_4361[]; -extern uint32 XAPI_1_0_4361_SIZE; +extern OOVPATable XAPI_1_0_4034[]; +extern uint32 XAPI_1_0_4034_SIZE; #endif diff --git a/Include/Win32/CxbxKrnl/Xapi.1.0.4134.h b/Include/Win32/CxbxKrnl/Xapi.1.0.4134.h new file mode 100644 index 000000000..b8f15101c --- /dev/null +++ b/Include/Win32/CxbxKrnl/Xapi.1.0.4134.h @@ -0,0 +1,42 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->Xapi.1.0.4134.h +// * +// * This file is part of the Cxbx project. +// * +// * Cxbx and Cxbe are free software; you can redistribute them +// * and/or modify them under the terms of the GNU General Public +// * License as published by the Free Software Foundation; either +// * version 2 of the license, or (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have recieved a copy of the GNU General Public License +// * along with this program; see the file COPYING. +// * If not, write to the Free Software Foundation, Inc., +// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. +// * +// * (c) 2002-2003 Aaron Robinson +// * +// * All rights reserved +// * +// ****************************************************************** +#ifndef XAPI_1_0_4134_H +#define XAPI_1_0_4134_H + +#include "OOVPA.h" + +extern OOVPATable XAPI_1_0_4134[]; +extern uint32 XAPI_1_0_4134_SIZE; + +#endif diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4134.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4134.inl new file mode 100644 index 000000000..5cf71c8c0 --- /dev/null +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4134.inl @@ -0,0 +1,101 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->D3D8.1.0.4134.cpp +// * +// * This file is part of the Cxbx project. +// * +// * Cxbx and Cxbe are free software; you can redistribute them +// * and/or modify them under the terms of the GNU General Public +// * License as published by the Free Software Foundation; either +// * version 2 of the license, or (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have recieved a copy of the GNU General Public License +// * along with this program; see the file COPYING. +// * If not, write to the Free Software Foundation, Inc., +// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. +// * +// * (c) 2002-2003 Aaron Robinson +// * +// * All rights reserved +// * +// ****************************************************************** + + +// ****************************************************************** +// * IDirect3DDevice8_SetRenderState_CullMode +// ****************************************************************** +SOOVPA<13> IDirect3DDevice8_SetRenderState_CullMode_1_0_4134 = +{ + 0, // Large == 0 + 13, // Count == 13 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // IDirect3DDevice8_SetRenderState_CullMode+0x19 : mov dword ptr [eax], 0x40308 + { 0x19, 0xC7 }, // (Offset,Value)-Pair #1 + { 0x1B, 0x08 }, // (Offset,Value)-Pair #2 + { 0x1C, 0x03 }, // (Offset,Value)-Pair #3 + { 0x1D, 0x04 }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_SetRenderState_CullMode+0x24 : add eax, 8 + { 0x24, 0x83 }, // (Offset,Value)-Pair #5 + { 0x25, 0xC0 }, // (Offset,Value)-Pair #6 + { 0x26, 0x08 }, // (Offset,Value)-Pair #7 + + // IDirect3DDevice8_SetRenderState_CullMode+0x30 : retn 4 + { 0x30, 0xC2 }, // (Offset,Value)-Pair #8 + { 0x31, 0x04 }, // (Offset,Value)-Pair #9 + + // IDirect3DDevice8_SetRenderState_CullMode+0x53 : add edx, 0x404 + { 0x53, 0x81 }, // (Offset,Value)-Pair #10 + { 0x54, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x55, 0x04 }, // (Offset,Value)-Pair #12 + { 0x56, 0x04 }, // (Offset,Value)-Pair #13 + } +}; + +// ****************************************************************** +// * D3D8_1_0_4134 +// ****************************************************************** +OOVPATable D3D8_1_0_4134[] = +{ + // IDirect3D8::CreateDevice (* unchanged since 1.0.3925 *) + { + (OOVPA*)&IDirect3D8_CreateDevice_1_0_3925, + + XTL::EmuIDirect3D8_CreateDevice, + + #ifdef _DEBUG_TRACE + "EmuIDirect3D8_CreateDevice" + #endif + }, + // IDirect3DDevice8::SetRenderState_CullMode + { + (OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4134, + + XTL::EmuIDirect3DDevice8_SetRenderState_CullMode, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_SetRenderState_CullMode" + #endif + }, +}; + +// ****************************************************************** +// * D3D8_1_0_4134_SIZE +// ****************************************************************** +uint32 D3D8_1_0_4134_SIZE = sizeof(D3D8_1_0_4134); diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl index a8684f33a..7cafc6e81 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl @@ -1092,41 +1092,6 @@ SOOVPA<11> IDirect3DDevice8_SetRenderState_VertexBlend_1_0_4361 = } }; -// ****************************************************************** -// * IDirect3DDevice8_SetRenderState_CullMode -// ****************************************************************** -SOOVPA<13> IDirect3DDevice8_SetRenderState_CullMode_1_0_4361 = -{ - 0, // Large == 0 - 13, // Count == 13 - - -1, // XRef Not Saved - 0, // XRef Not Used - - { - // IDirect3DDevice8_SetRenderState_CullMode+0x19 : mov dword ptr [eax], 0x40308 - { 0x19, 0xC7 }, // (Offset,Value)-Pair #1 - { 0x1B, 0x08 }, // (Offset,Value)-Pair #2 - { 0x1C, 0x03 }, // (Offset,Value)-Pair #3 - { 0x1D, 0x04 }, // (Offset,Value)-Pair #4 - - // IDirect3DDevice8_SetRenderState_CullMode+0x24 : add eax, 8 - { 0x24, 0x83 }, // (Offset,Value)-Pair #5 - { 0x25, 0xC0 }, // (Offset,Value)-Pair #6 - { 0x26, 0x08 }, // (Offset,Value)-Pair #7 - - // IDirect3DDevice8_SetRenderState_CullMode+0x30 : retn 4 - { 0x30, 0xC2 }, // (Offset,Value)-Pair #8 - { 0x31, 0x04 }, // (Offset,Value)-Pair #9 - - // IDirect3DDevice8_SetRenderState_CullMode+0x53 : add edx, 0x404 - { 0x53, 0x81 }, // (Offset,Value)-Pair #10 - { 0x54, 0xC2 }, // (Offset,Value)-Pair #11 - { 0x55, 0x04 }, // (Offset,Value)-Pair #12 - { 0x56, 0x04 }, // (Offset,Value)-Pair #13 - } -}; - // ****************************************************************** // * IDirect3DDevice8_SetRenderState_TextureFactor // ****************************************************************** @@ -2429,9 +2394,9 @@ OOVPATable D3D8_1_0_4361[] = "EmuIDirect3DDevice8_SetRenderState_VertexBlend" #endif }, - // IDirect3DDevice8::SetRenderState_CullMode + // IDirect3DDevice8::SetRenderState_CullMode (* unchanged since 4134 *) { - (OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4361, + (OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4134, XTL::EmuIDirect3DDevice8_SetRenderState_CullMode, diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl index 470407c6c..7d8b441ab 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl @@ -1812,9 +1812,9 @@ OOVPATable D3D8_1_0_4627[] = "EmuIDirect3DDevice8_SetTextureState_TexCoordIndex" #endif }, - // IDirect3DDevice8::SetRenderState_CullMode (* unchanged since 4361 *) + // IDirect3DDevice8::SetRenderState_CullMode (* unchanged since 4134 *) { - (OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4361, + (OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4134, XTL::EmuIDirect3DDevice8_SetRenderState_CullMode, diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 858d4ab96..56efeec4a 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -67,6 +67,7 @@ Xbe::Header *g_pXbeHeader = NULL; HANDLE g_hCurDir = NULL; HANDLE g_hTDrive = NULL; HANDLE g_hUDrive = NULL; +HANDLE g_hZDrive = NULL; // ****************************************************************** // * static @@ -301,6 +302,22 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit if(g_hUDrive == INVALID_HANDLE_VALUE) EmuCleanup("Could not map U:\\\n"); } + + // Create ZData Directory + { + strcpy(&szBuffer[spot], "\\CxbxCache"); + + CreateDirectory(szBuffer, NULL); + + sprintf(&szBuffer[spot+6], "\\%08x", pCertificate->dwTitleId); + + CreateDirectory(szBuffer, NULL); + + g_hZDrive = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if(g_hUDrive == INVALID_HANDLE_VALUE) + EmuCleanup("Could not map Z:\\\n"); + } } // ****************************************************************** @@ -376,7 +393,7 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit if(bXRefFirstPass) { - if(strcmp("XAPILIB", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 4627 || BuildVersion == 4361 || BuildVersion == 4034 || BuildVersion == 3911)) + if(strcmp("XAPILIB", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 3911 || BuildVersion == 4034 || BuildVersion == 4134 || BuildVersion == 4361 || BuildVersion == 4627)) { uint32 lower = pXbeHeader->dwBaseAddr; uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; @@ -384,9 +401,13 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit // ****************************************************************** // * Locate XapiProcessHeap // ****************************************************************** - if(BuildVersion == 4361 || BuildVersion == 4627) - { - void *pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_4361, lower, upper); + { + void *pFunc = 0; + + if(BuildVersion >= 4361) + pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_4361, lower, upper); + else // 3911, 4034, 4134 + pFunc = EmuLocateFunction((OOVPA*)&XapiInitProcess_1_0_3911, lower, upper); if(pFunc != 0) { @@ -400,19 +421,21 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit } } } - else if(strcmp("D3D8", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 4361 || BuildVersion == 4627)) + else if(strcmp("D3D8", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 4134 || BuildVersion == 4361 || BuildVersion == 4627)) { uint32 lower = pXbeHeader->dwBaseAddr; uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; - void *pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4361, lower, upper); + void *pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_4134, lower, upper); // ****************************************************************** // * Locate D3DDeferredRenderState // ****************************************************************** - if(pFunc != 0 && (BuildVersion == 4361 || BuildVersion == 4627)) + if(pFunc != 0 && (BuildVersion == 4134 || BuildVersion == 4361 || BuildVersion == 4627)) { - if(BuildVersion == 4361) + if(BuildVersion == 4134) + XTL::EmuD3DDeferredRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x248 + 82*4); // TODO: Verify + else if(BuildVersion == 4361) XTL::EmuD3DDeferredRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x200 + 82*4); else if(BuildVersion == 4627) XTL::EmuD3DDeferredRenderState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x2B) - 0x24C + 92*4); @@ -432,7 +455,9 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit // * Locate D3DDeferredTextureState // ****************************************************************** { - if(BuildVersion == 4361) + if(BuildVersion == 4134) + EmuCleanup("Oops, I didnt do this part yet either"); + else if(BuildVersion == 4361) pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_4361, lower, upper); else if(BuildVersion == 4627) pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_4627, lower, upper); diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index a57a1d69b..31a15f3ef 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -619,7 +619,7 @@ XBSYSAPI EXPORTNUM(149) xboxkrnl::BOOLEAN NTAPI xboxkrnl::KeSetTimer // ****************************************************************** // * 0x009C - KeTickCount // ****************************************************************** -XBSYSAPI EXPORTNUM(156) xboxkrnl::DWORD xboxkrnl::KeTickCount = 0; +XBSYSAPI EXPORTNUM(156) volatile xboxkrnl::DWORD xboxkrnl::KeTickCount = 0; // ****************************************************************** // * 0x00A4 - LaunchDataPage (actually a pointer) @@ -699,6 +699,40 @@ XBSYSAPI EXPORTNUM(166) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateContiguousMemo return pRet; } +// ****************************************************************** +// * 0x00A7 - MmAllocateSystemMemory +// ****************************************************************** +XBSYSAPI EXPORTNUM(167) xboxkrnl::PVOID NTAPI xboxkrnl::MmAllocateSystemMemory +( + ULONG NumberOfBytes, + ULONG Protect +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuKrnl (0x%X): MmAllocateContiguousMemoryEx\n" + "(\n" + " NumberOfBytes : 0x%.08X\n" + " Protect : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), NumberOfBytes, Protect); + } + #endif + + // TODO: Make this much more efficient and correct if necessary! + // HACK: Should be aligned!! + PVOID pRet = (PVOID)new unsigned char[NumberOfBytes]; + + EmuSwapFS(); // Xbox FS + + return pRet; +} + // ****************************************************************** // * 0x00AB - MmFreeContiguousMemory // ****************************************************************** @@ -729,6 +763,38 @@ XBSYSAPI EXPORTNUM(171) VOID NTAPI xboxkrnl::MmFreeContiguousMemory return; } +// ****************************************************************** +// * 0x00AC - MmFreeSystemMemory +// ****************************************************************** +XBSYSAPI EXPORTNUM(172) NTSTATUS NTAPI xboxkrnl::MmFreeSystemMemory +( + PVOID BaseAddress, + ULONG NumberOfBytes +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuKrnl (0x%X): MmFreeSystemMemory\n" + "(\n" + " BaseAddress : 0x%.08X\n" + " NumberOfBytes : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), BaseAddress, NumberOfBytes); + } + #endif + + delete[] BaseAddress; + + EmuSwapFS(); // Xbox FS + + return STATUS_SUCCESS; +} + // ****************************************************************** // * 0x00B2 - MmPersistContiguousMemory // ****************************************************************** @@ -1003,10 +1069,11 @@ XBSYSAPI EXPORTNUM(190) NTSTATUS NTAPI xboxkrnl::NtCreateFile szBuffer += 3; ObjectAttributes->RootDirectory = g_hTDrive; + #ifdef _DEBUG_TRACE printf("EmuKrnl (0x%X): NtCreateFile Corrected path...\n", GetCurrentThreadId()); printf(" Org:\"%s\"\n", ObjectAttributes->ObjectName->Buffer); - printf(" New:\"$CxbxPath\\%s\"\n", szBuffer); + printf(" New:\"$CxbxPath\\TDATA\\%s\"\n", szBuffer); #endif } else if( (szBuffer[0] == 'U' || szBuffer[0] == 'u') && szBuffer[1] == ':' && szBuffer[2] == '\\') @@ -1014,10 +1081,23 @@ XBSYSAPI EXPORTNUM(190) NTSTATUS NTAPI xboxkrnl::NtCreateFile szBuffer += 3; ObjectAttributes->RootDirectory = g_hUDrive; + #ifdef _DEBUG_TRACE printf("EmuKrnl (0x%X): NtCreateFile Corrected path...\n", GetCurrentThreadId()); printf(" Org:\"%s\"\n", ObjectAttributes->ObjectName->Buffer); - printf(" New:\"$CxbxPath\\%s\"\n", szBuffer); + printf(" New:\"$CxbxPath\\UDATA\\%s\"\n", szBuffer); + #endif + } + else if( (szBuffer[0] == 'Z' || szBuffer[0] == 'z') && szBuffer[1] == ':' && szBuffer[2] == '\\') + { + szBuffer += 3; + + ObjectAttributes->RootDirectory = g_hZDrive; + + #ifdef _DEBUG_TRACE + printf("EmuKrnl (0x%X): NtCreateFile Corrected path...\n", GetCurrentThreadId()); + printf(" Org:\"%s\"\n", ObjectAttributes->ObjectName->Buffer); + printf(" New:\"$CxbxPath\\CxbxCache\\%s\"\n", szBuffer); #endif } diff --git a/Source/Win32/CxbxKrnl/EmuXapi.cpp b/Source/Win32/CxbxKrnl/EmuXapi.cpp index 345191a3c..ae449c415 100644 --- a/Source/Win32/CxbxKrnl/EmuXapi.cpp +++ b/Source/Win32/CxbxKrnl/EmuXapi.cpp @@ -293,6 +293,32 @@ BOOL WINAPI XTL::EmuQueryPerformanceFrequency return bRet; } +// ****************************************************************** +// * func: EmuXMountUtilityDrive +// ****************************************************************** +BOOL WINAPI XTL::EmuXMountUtilityDrive +( + BOOL fFormatClean +) +{ + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + EmuSwapFS(); // Win2k/XP FS + printf("EmuXapi (0x%X): EmuXMountUtilityDrive\n" + "(\n" + " fFormatClean : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), fFormatClean); + EmuSwapFS(); // XBox FS + } + #endif + + return TRUE; +} + // ****************************************************************** // * func: EmuXInitDevices // ****************************************************************** @@ -618,11 +644,43 @@ BOOL WINAPI XTL::EmuCloseHandle } #endif - BOOL Ret = CloseHandle(hObject); + BOOL bRet = CloseHandle(hObject); EmuSwapFS(); // XBox FS - return Ret; + return bRet; +} + +// ****************************************************************** +// * func: EmuSetThreadPriority +// ****************************************************************** +BOOL WINAPI XTL::EmuSetThreadPriority +( + HANDLE hThread, + int nPriority +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuXapi (0x%X): EmuSetThreadPriority\n" + "(\n" + " hThread : 0x%.08X\n" + " nPriority : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), hThread, nPriority); + } + #endif + + BOOL bRet = SetThreadPriority(hThread, nPriority); + + EmuSwapFS(); // XBox FS + + return bRet; } // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/HLEDataBase.cpp b/Source/Win32/CxbxKrnl/HLEDataBase.cpp index 141580fc8..b78e17fe4 100644 --- a/Source/Win32/CxbxKrnl/HLEDataBase.cpp +++ b/Source/Win32/CxbxKrnl/HLEDataBase.cpp @@ -51,10 +51,12 @@ namespace XTL #include "Xapi.1.0.3911.inl" #include "Xapi.1.0.4034.inl" +#include "Xapi.1.0.4134.inl" #include "Xapi.1.0.4361.inl" #include "Xapi.1.0.4627.inl" #include "D3D8.1.0.3925.inl" #include "D3D8.1.0.4034.inl" +#include "D3D8.1.0.4134.inl" #include "D3D8.1.0.4361.inl" #include "D3D8.1.0.4627.inl" #include "DSound.1.0.4361.inl" @@ -75,13 +77,6 @@ HLEData HLEDataBase[] = XAPI_1_0_3911, XAPI_1_0_3911_SIZE }, - // Xapilib Version 1.0.4361 - { - "XAPILIB", - 1, 0, 4361, - XAPI_1_0_4361, - XAPI_1_0_4361_SIZE - }, // Xapilib Version 1.0.4034 { "XAPILIB", @@ -89,6 +84,20 @@ HLEData HLEDataBase[] = XAPI_1_0_4034, XAPI_1_0_4034_SIZE }, + // Xapilib Version 1.0.4134 + { + "XAPILIB", + 1, 0, 4134, + XAPI_1_0_4134, + XAPI_1_0_4134_SIZE + }, + // Xapilib Version 1.0.4361 + { + "XAPILIB", + 1, 0, 4361, + XAPI_1_0_4361, + XAPI_1_0_4361_SIZE + }, // Xapilib Version 1.0.4627 { "XAPILIB", diff --git a/Source/Win32/CxbxKrnl/KernelThunk.cpp b/Source/Win32/CxbxKrnl/KernelThunk.cpp index fad272190..4bfc3d288 100644 --- a/Source/Win32/CxbxKrnl/KernelThunk.cpp +++ b/Source/Win32/CxbxKrnl/KernelThunk.cpp @@ -232,12 +232,12 @@ extern "C" CXBXKRNL_API uint32 KernelThunkTable[367] = (uint32)&xboxkrnl::LaunchDataPage, // 0x00A4 (164) (uint32)&xboxkrnl::MmAllocateContiguousMemory, // 0x00A5 (165) (uint32)&xboxkrnl::MmAllocateContiguousMemoryEx,// 0x00A6 (166) - (uint32)PANIC(0x00A7), // 0x00A7 (167) + (uint32)&xboxkrnl::MmAllocateSystemMemory, // 0x00A7 (167) (uint32)PANIC(0x00A8), // 0x00A8 (168) (uint32)PANIC(0x00A9), // 0x00A9 (169) (uint32)PANIC(0x00AA), // 0x00AA (170) (uint32)&xboxkrnl::MmFreeContiguousMemory, // 0x00AB (171) - (uint32)PANIC(0x00AC), // 0x00AC (172) + (uint32)&xboxkrnl::MmFreeSystemMemory, // 0x00AC (172) (uint32)PANIC(0x00AD), // 0x00AD (173) (uint32)PANIC(0x00AE), // 0x00AE (174) (uint32)PANIC(0x00AF), // 0x00AF (175) diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.3911.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.3911.inl index 74175a9cc..29a35eb05 100644 --- a/Source/Win32/CxbxKrnl/Xapi.1.0.3911.inl +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.3911.inl @@ -72,7 +72,7 @@ SOOVPA<7> XapiInitProcess_1_0_3911 = 0, // XRef Not Used { - // XapiInitProcess+0x00 : sub esp, 30h + // XapiInitProcess+0x03 : sub esp, 30h { 0x05, 0x30 }, // (Offset,Value)-Pair #1 // XapiInitProcess+0x0F : push 0x0C diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.4134.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.4134.inl new file mode 100644 index 000000000..af5d9975a --- /dev/null +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.4134.inl @@ -0,0 +1,139 @@ +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->Win32->CxbxKrnl->Xapi.1.0.4134.cpp +// * +// * This file is part of the Cxbx project. +// * +// * Cxbx and Cxbe are free software; you can redistribute them +// * and/or modify them under the terms of the GNU General Public +// * License as published by the Free Software Foundation; either +// * version 2 of the license, or (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have recieved a copy of the GNU General Public License +// * along with this program; see the file COPYING. +// * If not, write to the Free Software Foundation, Inc., +// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. +// * +// * (c) 2002-2003 Aaron Robinson +// * +// * All rights reserved +// * +// ****************************************************************** + +// ****************************************************************** +// * SetThreadPriority +// ****************************************************************** +SOOVPA<10> SetThreadPriority_1_0_4134 = +{ + 0, // Large == 0 + 10, // Count == 10 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // SetThreadPriority+0x0D : push [ebp+0x08] + { 0x0D, 0xFF }, // (Offset,Value)-Pair #1 + { 0x0E, 0x75 }, // (Offset,Value)-Pair #2 + { 0x0F, 0x08 }, // (Offset,Value)-Pair #3 + + // SetThreadPriority+0x18 : jl +0x2C + { 0x18, 0x7C }, // (Offset,Value)-Pair #4 + { 0x19, 0x2C }, // (Offset,Value)-Pair #5 + + // SetThreadPriority+0x22 : push 0x10 + { 0x22, 0x6A }, // (Offset,Value)-Pair #6 + { 0x23, 0x10 }, // (Offset,Value)-Pair #7 + + // SetThreadPriority+0x26 : cmp eax, 0xFFFFFFF1 + { 0x26, 0x83 }, // (Offset,Value)-Pair #8 + { 0x27, 0xF8 }, // (Offset,Value)-Pair #9 + { 0x28, 0xF1 }, // (Offset,Value)-Pair #10 + } +}; + +// ****************************************************************** +// * XMountUtilityDrive +// ****************************************************************** +SOOVPA<10> XMountUtilityDrive_1_0_4134 = +{ + 0, // Large == 0 + 10, // Count == 10 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // XMountUtilityDrive+0x03 : sub esp, 0x0114 + { 0x03, 0x81 }, // (Offset,Value)-Pair #1 + { 0x04, 0xEC }, // (Offset,Value)-Pair #2 + { 0x05, 0x14 }, // (Offset,Value)-Pair #3 + { 0x06, 0x01 }, // (Offset,Value)-Pair #4 + + // XMountUtilityDrive+0x45 : push 0x0104 + { 0x45, 0x68 }, // (Offset,Value)-Pair #5 + { 0x46, 0x04 }, // (Offset,Value)-Pair #6 + { 0x47, 0x01 }, // (Offset,Value)-Pair #7 + + // XMountUtilityDrive+0xAA : lea eax, [ebp-0x10] + { 0xAA, 0x8D }, // (Offset,Value)-Pair #8 + { 0xAB, 0x45 }, // (Offset,Value)-Pair #9 + { 0xAC, 0xF0 }, // (Offset,Value)-Pair #10 + } +}; + +// ****************************************************************** +// * XAPI_1_0_4134 +// ****************************************************************** +OOVPATable XAPI_1_0_4134[] = +{ + //* Too High Level + // XapiInitProcess (* unchanged since 3911 *) + { + (OOVPA*)&XapiInitProcess_1_0_3911, + + XTL::EmuXapiInitProcess, + + #ifdef _DEBUG_TRACE + "EmuXapiInitProcess" + #endif + }, + //*/ + // SetThreadPriority + { + (OOVPA*)&SetThreadPriority_1_0_4134, + + XTL::EmuSetThreadPriority, + + #ifdef _DEBUG_TRACE + "EmuSetThreadPriority" + #endif + }, + // XMountUtilityDrive + { + (OOVPA*)&XMountUtilityDrive_1_0_4134, + + XTL::EmuXMountUtilityDrive, + + #ifdef _DEBUG_TRACE + "EmuXMountUtilityDrive" + #endif + } +}; + +// ****************************************************************** +// * XAPI_1_0_4134_SIZE +// ****************************************************************** +uint32 XAPI_1_0_4134_SIZE = sizeof(XAPI_1_0_4134); diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl index 2cedd98bc..1bdd4882f 100644 --- a/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl @@ -565,7 +565,7 @@ SOOVPA<7> XapiInitProcess_1_0_4361 = 0, // XRef Not Used { - // XapiInitProcess+0x00 : sub esp, 30h + // XapiInitProcess+0x03 : sub esp, 30h { 0x05, 0x30 }, // (Offset,Value)-Pair #1 // XapiInitProcess+0x0F : push 0x0C