diff --git a/Cxbx.sln b/Cxbx.sln index 360396442..e524d8143 100644 --- a/Cxbx.sln +++ b/Cxbx.sln @@ -1,9 +1,9 @@ Microsoft Visual Studio Solution File, Format Version 7.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbe", "Cxbe.vcproj", "{0F4725FF-D671-49C0-A7E5-54DBC18226D1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbe", "Cxbe.vcproj", "{EDA06923-F975-4B5F-A61C-C50989D4F0A2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbx", "Cxbx.vcproj", "{56F746E9-DCE6-441E-867C-594C8028A54C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbx", "Cxbx.vcproj", "{27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxbxKrnl", "CxbxKrnl.vcproj", "{251B0184-1631-4203-9667-B98EB55E7458}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxbxKrnl", "CxbxKrnl.vcproj", "{61ABBF02-FB2C-4004-AADD-E5A667B76C9E}" EndProject Global GlobalSection(SolutionConfiguration) = preSolution @@ -11,21 +11,21 @@ Global ConfigName.1 = Release EndGlobalSection GlobalSection(ProjectDependencies) = postSolution - {56F746E9-DCE6-441E-867C-594C8028A54C}.0 = {251B0184-1631-4203-9667-B98EB55E7458} + {27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}.0 = {61ABBF02-FB2C-4004-AADD-E5A667B76C9E} EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution - {0F4725FF-D671-49C0-A7E5-54DBC18226D1}.Debug.ActiveCfg = Debug|Win32 - {0F4725FF-D671-49C0-A7E5-54DBC18226D1}.Debug.Build.0 = Debug|Win32 - {0F4725FF-D671-49C0-A7E5-54DBC18226D1}.Release.ActiveCfg = Release|Win32 - {0F4725FF-D671-49C0-A7E5-54DBC18226D1}.Release.Build.0 = Release|Win32 - {56F746E9-DCE6-441E-867C-594C8028A54C}.Debug.ActiveCfg = Debug|Win32 - {56F746E9-DCE6-441E-867C-594C8028A54C}.Debug.Build.0 = Debug|Win32 - {56F746E9-DCE6-441E-867C-594C8028A54C}.Release.ActiveCfg = Release|Win32 - {56F746E9-DCE6-441E-867C-594C8028A54C}.Release.Build.0 = Release|Win32 - {251B0184-1631-4203-9667-B98EB55E7458}.Debug.ActiveCfg = Debug|Win32 - {251B0184-1631-4203-9667-B98EB55E7458}.Debug.Build.0 = Debug|Win32 - {251B0184-1631-4203-9667-B98EB55E7458}.Release.ActiveCfg = Release|Win32 - {251B0184-1631-4203-9667-B98EB55E7458}.Release.Build.0 = Release|Win32 + {EDA06923-F975-4B5F-A61C-C50989D4F0A2}.Debug.ActiveCfg = Debug|Win32 + {EDA06923-F975-4B5F-A61C-C50989D4F0A2}.Debug.Build.0 = Debug|Win32 + {EDA06923-F975-4B5F-A61C-C50989D4F0A2}.Release.ActiveCfg = Release|Win32 + {EDA06923-F975-4B5F-A61C-C50989D4F0A2}.Release.Build.0 = Release|Win32 + {27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}.Debug.ActiveCfg = Debug|Win32 + {27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}.Debug.Build.0 = Debug|Win32 + {27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}.Release.ActiveCfg = Release|Win32 + {27D286C4-D1B8-4D4F-88B8-ABEF85F96CFB}.Release.Build.0 = Release|Win32 + {61ABBF02-FB2C-4004-AADD-E5A667B76C9E}.Debug.ActiveCfg = Debug|Win32 + {61ABBF02-FB2C-4004-AADD-E5A667B76C9E}.Debug.Build.0 = Debug|Win32 + {61ABBF02-FB2C-4004-AADD-E5A667B76C9E}.Release.ActiveCfg = Release|Win32 + {61ABBF02-FB2C-4004-AADD-E5A667B76C9E}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/Doc/RemovedCode.txt b/Doc/RemovedCode.txt index 3be87c6a6..7931cd907 100644 --- a/Doc/RemovedCode.txt +++ b/Doc/RemovedCode.txt @@ -1 +1,36 @@ -Flushed \ No newline at end of file + ret = xntdll::ZwCreateFile + ( + FileHandle, DesiredAccess, (xntdll::_OBJECT_ATTRIBUTES*)ObjectAttributes, (xntdll::_IO_STATUS_BLOCK *)IoStatusBlock, + (xntdll::_LARGE_INTEGER *)AllocationSize, FileAttributes, ShareAccess, Disposition, + CreateOptions, 0, 0 + ); + +/* +Data Start Address : 0x00000000 +Data End Address : 0x00000000 +TLS Index Address : 0x00030DC4 +TLS Callback Address : 0x00000000 +Size of Zero Fill : 0x0000000C -> 12 +Characteristics : 0x00000000 -> 16 + +Data Start Address : 0x00010494 | +Data End Address : 0x000104A0 |-> 12 +TLS Index Address : 0x00030D5C +TLS Callback Address : 0x00000000 +Size of Zero Fill : 0x00000008 -> 8 +Characteristics : 0x00000000 -> 26 + +Data Start Address : 0x00010494 | +Data End Address : 0x000104A4 |-> 16 +TLS Index Address : 0x00030D5C +TLS Callback Address : 0x00000000 +Size of Zero Fill : 0x00000008 -> 8 +Characteristics : 0x00000000 -> 36 + +Data Start Address : 0x00010494 | +Data End Address : 0x000104A8 |-> 20 +TLS Index Address : 0x00030D5C +TLS Callback Address : 0x00000000 +Size of Zero Fill : 0x00000008 -> 8 +Characteristics : 0x00000000 -> 52 +*/ \ No newline at end of file diff --git a/Include/Win32/CxbxKrnl/EmuFS.h b/Include/Win32/CxbxKrnl/EmuFS.h index c97beaf54..e458a3e25 100644 --- a/Include/Win32/CxbxKrnl/EmuFS.h +++ b/Include/Win32/CxbxKrnl/EmuFS.h @@ -53,6 +53,17 @@ static inline void EmuSwapFS() } } +// ****************************************************************** +// * func: EmuIsXboxFS +// ****************************************************************** +// * +// * This function will return true if the current FS register is +// * the Xbox emulation variety. Alternatively, false means the +// * Win2k/XP FS register is currently loaded. +// * +// ****************************************************************** +bool EmuIsXboxFS(); + // ****************************************************************** // * func: EmuGenerateFS // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuFile.h b/Include/Win32/CxbxKrnl/EmuFile.h index c6fac596a..fab1ced4d 100644 --- a/Include/Win32/CxbxKrnl/EmuFile.h +++ b/Include/Win32/CxbxKrnl/EmuFile.h @@ -42,14 +42,70 @@ namespace xboxkrnl #include }; +#include + +// ****************************************************************** +// * prevent name collisions +// ****************************************************************** +namespace xntdll +{ + #include "xntdll.h" +}; + #include "Emu.h" // ****************************************************************** -// * emulated "special" file handle +// * Maximum number of open handles in the system // ****************************************************************** -struct EmuHandle +#define EMU_MAX_HANDLES 1024 + +// ****************************************************************** +// * Wrapper of a handle object +// ****************************************************************** +class EmuHandle { - enum _EmuHandleType m_Type; + public: + // Type of handle + volatile enum _EmuHandleType m_Type; + + // To keep the size 8 bytes, these 2 items are in a union + union + { + // Pointer to actual object (when handle is valid) + volatile class EmuNtObject *m_Object; + + // Pointer to next free handle + volatile EmuHandle *m_NextFree; + }; + + // Close this handle + xntdll::NTSTATUS Close(void); + + // Initialize the EmuHandle system + static bool Initialize(); + + // Close all open handles + static void CloseAll(void); + + // Allocate an empty handle + static volatile EmuHandle *Allocate(void); + + private: + // Array of EmuHandles in the system + static EmuHandle Handles[EMU_MAX_HANDLES]; + + // Pointer to first free handle in array, or NULL if none + volatile static EmuHandle *FirstFree; + + // Pointer to last free handle in array, or NULL if none + volatile static EmuHandle *LastFree; + + // Lock on the handle system + static CRITICAL_SECTION HandleLock; + + // Quick functions to lock/unlock + inline static void Lock(void); + inline static void Unlock(void); }; // ****************************************************************** @@ -57,11 +113,70 @@ struct EmuHandle // ****************************************************************** typedef enum _EmuHandleType { - EMUHANDLE_TYPE_PARTITION1 = 0, - EMUHANDLE_TYPE_TDATA + // Unallocated handle + EMUHANDLE_TYPE_EMPTY = 0, + + // Allocated but so far unused handle + EMUHANDLE_TYPE_ALLOCATED, + + // File handle with no really special features + EMUHANDLE_TYPE_FILE, + + // Fake file/directory/directory object/partition handle + EMUHANDLE_TYPE_OBJECT } EmuHandleType; +// ****************************************************************** +// * An NT fake object +// ****************************************************************** +class EmuNtObject +{ + public: + // Decrements the reference count of this object (never override) + void NtClose(void); + + // These functions mimic the Nt* calls + + // Increments the reference count of this object + // For file handles, a whole new EmuFile structure is returned. + // For other objects (the default implementation), "this" is returned. + virtual EmuNtObject *NtDuplicateObject(void); + + protected: + // Object name (Unicode, because we handle after-conversion strings) + const WCHAR *Name; + ULONG NameLength; + // Permanent status + bool PermanentFlag; + + // Called by close() when the reference count reaches zero + virtual void Free(void) = 0; + // Constructor + EmuNtObject(void); + // Destructor + virtual ~EmuNtObject() = 0; + + private: + // Reference count + ULONG RefCount; +}; + +// ****************************************************************** +// * Emulated file handle +// ****************************************************************** +class EmuNtFile : public EmuNtObject +{ + public: + // We need to override NtDuplicateObject in this case + + private: + // The Windows file handle + HANDLE File; + // Pointer to the volume from which this came + //EmuNtVolume *Volume; +}; + // ****************************************************************** // * is hFile a 'special' emulated handle? // ****************************************************************** diff --git a/Include/Win32/InputConfig.h b/Include/Win32/InputConfig.h index 988178612..640a38e7e 100644 --- a/Include/Win32/InputConfig.h +++ b/Include/Win32/InputConfig.h @@ -77,9 +77,9 @@ enum InputDeviceComponent }; // ****************************************************************** -// * Input Device Title Lookup Table +// * Input Device Name Lookup Table // ****************************************************************** -extern const char *g_InputDeviceTitle[INPUT_DEVICE_COMPONENT_COUNT]; +extern const char *g_InputDeviceName[INPUT_DEVICE_COMPONENT_COUNT]; // ****************************************************************** // * InputMapping Flags diff --git a/Source/Win32/Cxbx/WndMain.cpp b/Source/Win32/Cxbx/WndMain.cpp index ab827627c..6924dfd80 100644 --- a/Source/Win32/Cxbx/WndMain.cpp +++ b/Source/Win32/Cxbx/WndMain.cpp @@ -448,6 +448,12 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP case ID_FILE_RXBE_8: case ID_FILE_RXBE_9: { + if(m_Xbe != 0) + CloseXbe(); + + if(m_Xbe != 0) + break; + HMENU menu = GetMenu(m_hwnd); HMENU file_menu = GetSubMenu(menu, 0); HMENU rxbe_menu = GetSubMenu(file_menu, 9); @@ -473,6 +479,12 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP case ID_FILE_REXE_8: case ID_FILE_REXE_9: { + if(m_Xbe != 0) + CloseXbe(); + + if(m_Xbe != 0) + break; + HMENU menu = GetMenu(m_hwnd); HMENU file_menu = GetSubMenu(menu, 0); HMENU rexe_menu = GetSubMenu(file_menu, 10); @@ -1199,7 +1211,7 @@ void WndMain::RefreshMenus() int max = m_dwRecentXbe; for(int v=0;v0;v--) + if(strcmp(m_szRecentXbe[c], m_XbeFilename) == 0) { - if(m_szRecentXbe[v-1] == 0) - m_szRecentXbe[v] = 0; - else - { - if(m_szRecentXbe[v] == 0) - m_szRecentXbe[v] = (char*)calloc(1, 260); - strncpy(m_szRecentXbe[v], m_szRecentXbe[v-1], 259); - } + found = true; + r++; } - // add new item as first index + if(r != c) { - if(m_szRecentXbe[0] == 0) - m_szRecentXbe[0] = (char*)calloc(1, 260); - - strcpy(m_szRecentXbe[0], m_XbeFilename); - - m_dwRecentXbe++; + if(m_szRecentXbe[r] == 0 || r > m_dwRecentXbe - 1) + m_szRecentXbe[c] = 0; + else + strncpy(m_szRecentXbe[c], m_szRecentXbe[r], 259); } } + + if(found) + m_dwRecentXbe--; + + // move all items down one, removing the last one if necessary + for(int v=RECENT_XBE_SIZE-1;v>0;v--) + { + if(m_szRecentXbe[v-1] == 0) + m_szRecentXbe[v] = 0; + else + { + if(m_szRecentXbe[v] == 0) + m_szRecentXbe[v] = (char*)calloc(1, 260); + strncpy(m_szRecentXbe[v], m_szRecentXbe[v-1], 259); + } + } + + // add new item as first index + { + if(m_szRecentXbe[0] == 0) + m_szRecentXbe[0] = (char*)calloc(1, 260); + + strcpy(m_szRecentXbe[0], m_XbeFilename); + } + + if(m_dwRecentXbe < RECENT_XBE_SIZE) + m_dwRecentXbe++; } UpdateRecentFiles(); @@ -1620,39 +1646,54 @@ void WndMain::ImportExe(const char *x_filename) // ****************************************************************** // * save this Exe to the list of recent files // ****************************************************************** + if(m_ExeFilename[0] != '\0') { - bool exists = false; + bool found = false; - // check if this filename already exists - for(int c=0;c0;v--) + if(strcmp(m_szRecentExe[c], m_ExeFilename) == 0) { - if(m_szRecentExe[v-1] == 0) - m_szRecentExe[v] = 0; - else - { - if(m_szRecentExe[v] == 0) - m_szRecentExe[v] = (char*)calloc(1, 260); - strncpy(m_szRecentExe[v], m_szRecentExe[v-1], 259); - } + found = true; + r++; } - // add new item as first index + if(r != c) { - if(m_szRecentExe[0] == 0) - m_szRecentExe[0] = (char*)calloc(1, 260); - - strcpy(m_szRecentExe[0], x_filename); - - m_dwRecentExe++; + if(m_szRecentExe[r] == 0 || r > m_dwRecentExe - 1) + m_szRecentExe[c] = 0; + else + strncpy(m_szRecentExe[c], m_szRecentExe[r], 259); } } + + if(found) + m_dwRecentExe--; + + // move all items down one, removing the last one if necessary + for(int v=RECENT_EXE_SIZE-1;v>0;v--) + { + if(m_szRecentExe[v-1] == 0) + m_szRecentExe[v] = 0; + else + { + if(m_szRecentExe[v] == 0) + m_szRecentExe[v] = (char*)calloc(1, 260); + strncpy(m_szRecentExe[v], m_szRecentExe[v-1], 259); + } + } + + // add new item as first index + { + if(m_szRecentExe[0] == 0) + m_szRecentExe[0] = (char*)calloc(1, 260); + + strcpy(m_szRecentExe[0], m_ExeFilename); + } + + if(m_dwRecentExe < RECENT_EXE_SIZE) + m_dwRecentExe++; } UpdateRecentFiles(); diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 2fdc824ae..908afb0a2 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -259,7 +259,8 @@ extern "C" CXBXKRNL_API void NTAPI EmuInit(uint32 TlsAdjust, Xbe::LibraryVersion // ****************************************************************** extern "C" CXBXKRNL_API void NTAPI EmuPanic() { - EmuSwapFS(); // Win2k/XP FS + if(EmuIsXboxFS()) + EmuSwapFS(); // Win2k/XP FS printf("Emu (0x%.08X): EmuPanic()\n", GetCurrentThreadId()); @@ -269,6 +270,9 @@ extern "C" CXBXKRNL_API void NTAPI EmuPanic() #else MessageBox(NULL, "Kernel Panic! Process will now terminate.", "CxbxKrnl", MB_OK | MB_ICONEXCLAMATION); #endif + + ExitProcess(1); + EmuSwapFS(); // XBox FS } diff --git a/Source/Win32/CxbxKrnl/EmuFS.cpp b/Source/Win32/CxbxKrnl/EmuFS.cpp index d09f280db..dfdc490e8 100644 --- a/Source/Win32/CxbxKrnl/EmuFS.cpp +++ b/Source/Win32/CxbxKrnl/EmuFS.cpp @@ -48,6 +48,9 @@ namespace xboxkrnl #undef FIELD_OFFSET // prevent macro redefinition warnings #include +static uint16 g_NewFS = -1; +static uint16 g_OrgFS = -1; + // ****************************************************************** // * func: EmuInitFS // ****************************************************************** @@ -64,9 +67,6 @@ void EmuGenerateFS(int TlsAdjust) NT_TIB *OrgNtTib; xboxkrnl::KPCR *NewPcr; - uint16 NewFS=0; - uint16 OrgFS=0; - void *TLSPtr = 0; // ****************************************************************** @@ -79,7 +79,7 @@ void EmuGenerateFS(int TlsAdjust) memset(NewPcr, 0, sizeof(*NewPcr)); - NewFS = EmuAllocateLDT((uint32)NewPcr, (uint32)NewPcr + dwSize); + g_NewFS = EmuAllocateLDT((uint32)NewPcr, (uint32)NewPcr + dwSize); } // ****************************************************************** @@ -89,14 +89,14 @@ void EmuGenerateFS(int TlsAdjust) { // Obtain "OrgFS" mov ax, fs - mov OrgFS, ax + mov g_OrgFS, ax // Obtain "OrgNtTib" mov eax, fs:[0x18] mov OrgNtTib, eax // Save "NewFS" inside OrgFS.ArbitraryUserPointer - mov ax, NewFS + mov ax, g_NewFS mov fs:[0x14], ax } @@ -133,35 +133,7 @@ void EmuGenerateFS(int TlsAdjust) NewPcr->PrcbData.CurrentThread->TlsData = TLSPtr; } -/* -Data Start Address : 0x00000000 -Data End Address : 0x00000000 -TLS Index Address : 0x00030DC4 -TLS Callback Address : 0x00000000 -Size of Zero Fill : 0x0000000C -> 12 -Characteristics : 0x00000000 -> 16 -Data Start Address : 0x00010494 | -Data End Address : 0x000104A0 |-> 12 -TLS Index Address : 0x00030D5C -TLS Callback Address : 0x00000000 -Size of Zero Fill : 0x00000008 -> 8 -Characteristics : 0x00000000 -> 26 - -Data Start Address : 0x00010494 | -Data End Address : 0x000104A4 |-> 16 -TLS Index Address : 0x00030D5C -TLS Callback Address : 0x00000000 -Size of Zero Fill : 0x00000008 -> 8 -Characteristics : 0x00000000 -> 36 - -Data Start Address : 0x00010494 | -Data End Address : 0x000104A8 |-> 20 -TLS Index Address : 0x00030D5C -TLS Callback Address : 0x00000000 -Size of Zero Fill : 0x00000008 -> 8 -Characteristics : 0x00000000 -> 52 -*/ // ****************************************************************** // * Swap into the "NewFS" // ****************************************************************** @@ -172,7 +144,7 @@ Characteristics : 0x00000000 -> 52 // ****************************************************************** __asm { - mov ax, OrgFS + mov ax, g_OrgFS mov fs:[0x14], ax // NewFS.ArbitraryUserPointer } @@ -189,4 +161,20 @@ Characteristics : 0x00000000 -> 52 // * Swap back into the "OrgFS" // ****************************************************************** EmuSwapFS(); +} + +// ****************************************************************** +// * func: EmuIsXboxFS +// ****************************************************************** +bool EmuIsXboxFS() +{ + uint16 chk = 0; + + __asm + { + mov ax, fs:[0x04] + mov chk, ax + } + + return (g_NewFS == chk); } \ No newline at end of file diff --git a/Source/Win32/CxbxKrnl/EmuFile.cpp b/Source/Win32/CxbxKrnl/EmuFile.cpp index 790a9dd90..9d38f27da 100644 --- a/Source/Win32/CxbxKrnl/EmuFile.cpp +++ b/Source/Win32/CxbxKrnl/EmuFile.cpp @@ -36,3 +36,91 @@ #include "EmuFile.h" +// Array of EmuHandles in the system +EmuHandle EmuHandle::Handles[EMU_MAX_HANDLES]; + +// Pointer to first free handle in array, or NULL if none +volatile EmuHandle *EmuHandle::FirstFree; + +// Pointer to last free handle in array, or NULL if none +volatile EmuHandle *EmuHandle::LastFree; + +// Lock on the handle system +CRITICAL_SECTION EmuHandle::HandleLock; + +// ****************************************************************** +// * Initialize the handle database +// ****************************************************************** +bool EmuHandle::Initialize() +{ + size_t x; + + // Initialize the critical section + InitializeCriticalSection(&HandleLock); + + // Mark all handles as free. We also set up the linked list of + // free handles here. + for (x = 0; x < EMU_MAX_HANDLES; x++) + { + Handles[x].m_Type = EMUHANDLE_TYPE_EMPTY; + Handles[x].m_NextFree = &Handles[x + 1]; + } + + // The last entry should have a NULL next entry + Handles[EMU_MAX_HANDLES - 1].m_NextFree = NULL; + + // Set up the head and tail pointers + FirstFree = &Handles[0]; + LastFree = &Handles[EMU_MAX_HANDLES]; + + return true; +} + +// ****************************************************************** +// * func: EmuHandle::Lock +// * Locks the handle database +// ****************************************************************** +inline void EmuHandle::Lock(void) +{ + EnterCriticalSection(&HandleLock); +} + +// ****************************************************************** +// * func: EmuHandle::Unlock +// * Unlocks the handle database +// ****************************************************************** +inline void EmuHandle::Unlock(void) +{ + LeaveCriticalSection(&HandleLock); +} + +// ****************************************************************** +// * func: EmuHandle::Allocate +// * Allocates a new handle +// ****************************************************************** +EmuHandle volatile *EmuHandle::Allocate(void) +{ + volatile EmuHandle *Handle; + + // Lock the database + Lock(); + + // Get the first free entry + Handle = FirstFree; + + // Remove it from the list + FirstFree = Handle->m_NextFree; + + // If it was the last handle, clear LastFree + if (!Handle->m_NextFree) + LastFree = NULL; + + // Initialize the handle's fields + Handle->m_Type = EMUHANDLE_TYPE_ALLOCATED; + Handle->m_Object = NULL; + + // Unlock the database + Unlock(); + + return Handle; +} diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index be4b58a8b..00db6bd1b 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -278,6 +278,9 @@ XBSYSAPI EXPORTNUM(66) NTSTATUS NTAPI xboxkrnl::IoCreateFile NTSTATUS ret = STATUS_SUCCESS; + EmuPanic(); + /* TODO: Use new handle wrapping code + // ****************************************************************** // * For now, just check for 'special' cases // ****************************************************************** @@ -288,8 +291,6 @@ XBSYSAPI EXPORTNUM(66) NTSTATUS NTAPI xboxkrnl::IoCreateFile iEmuHandle->m_Type = EMUHANDLE_TYPE_PARTITION1; *FileHandle = PtrToEmuHandle(iEmuHandle); - - // TODO: Update IoStatusBlock if necessary } else if(strcmp(ObjectAttributes->ObjectName->Buffer, "\\Device\\Harddisk0\\partition1\\TDATA") == 0) { @@ -304,16 +305,8 @@ XBSYSAPI EXPORTNUM(66) NTSTATUS NTAPI xboxkrnl::IoCreateFile else { EmuPanic(); - - /* TODO: In the future, this will look something like... - ret = xntdll::ZwCreateFile - ( - FileHandle, DesiredAccess, (xntdll::_OBJECT_ATTRIBUTES*)ObjectAttributes, (xntdll::_IO_STATUS_BLOCK *)IoStatusBlock, - (xntdll::_LARGE_INTEGER *)AllocationSize, FileAttributes, ShareAccess, Disposition, - CreateOptions, 0, 0 - ); - */ } + */ EmuSwapFS(); // Xbox FS @@ -695,6 +688,10 @@ XBSYSAPI EXPORTNUM(218) NTSTATUS NTAPI xboxkrnl::NtQueryVolumeInformationFile } #endif + EmuPanic(); + + /* TODO: Use new handle wrapping code + // ****************************************************************** // * For now, handle 'special' case // ****************************************************************** @@ -723,6 +720,7 @@ XBSYSAPI EXPORTNUM(218) NTSTATUS NTAPI xboxkrnl::NtQueryVolumeInformationFile { EmuPanic(); } + */ EmuSwapFS(); // Xbox FS diff --git a/Source/Win32/EmuShared.cpp b/Source/Win32/EmuShared.cpp index bd6ef56c4..80360f5e7 100644 --- a/Source/Win32/EmuShared.cpp +++ b/Source/Win32/EmuShared.cpp @@ -184,7 +184,7 @@ CXBXKRNL_API void EmuShared::LoadInputConfiguration() { int RawData[3] = {-1, -1, 0}; // dwDevice, dwInfo, dwFlags - sprintf(szBuffer, "Component : %s", g_InputDeviceTitle[c]); + sprintf(szBuffer, "Component : %s", g_InputDeviceName[c]); dwType = REG_BINARY; dwSize = sizeof(RawData); RegQueryValueEx(hKey, szBuffer, NULL, &dwType, (PBYTE)&RawData[0], &dwSize); @@ -241,7 +241,7 @@ CXBXKRNL_API void EmuShared::SaveInputConfiguration() m_InputConfig.Get((InputDeviceComponent)c, &RawData[0], &RawData[1], &RawData[2]); - sprintf(szBuffer, "Component : %s", g_InputDeviceTitle[c]); + sprintf(szBuffer, "Component : %s", g_InputDeviceName[c]); dwType = REG_BINARY; dwSize = sizeof(RawData); RegSetValueEx(hKey, szBuffer, 0, dwType, (PBYTE)&RawData, dwSize); diff --git a/Source/Win32/InputConfig.cpp b/Source/Win32/InputConfig.cpp index 184353659..3fe8b25e5 100644 --- a/Source/Win32/InputConfig.cpp +++ b/Source/Win32/InputConfig.cpp @@ -37,37 +37,26 @@ #include #include -const char *g_InputDeviceTitle[INPUT_DEVICE_COMPONENT_COUNT]= +// ****************************************************************** +// * Input Device Name Lookup Table +// ****************************************************************** +const char *g_InputDeviceName[INPUT_DEVICE_COMPONENT_COUNT]= { // ****************************************************************** // * Analog Axis // ****************************************************************** - "LThumbX", - "LThumbY", - "RThumbX", - "RThumbY", + "LThumbX", "LThumbY", "RThumbX", "RThumbY", + // ****************************************************************** // * Analog Buttons // ****************************************************************** - "X", - "Y", - "A", - "B", - "White", - "Black", - "LTrigger", - "RTrigger", + "X", "Y", "A", "B", "White", "Black", "LTrigger", "RTrigger", + // ****************************************************************** // * Digital Buttons // ****************************************************************** - "DPadUp", - "DPadDown", - "DPadLeft", - "DPadRight", - "Back", - "Start", - "LThumb", - "RThumb", + "DPadUp", "DPadDown", "DPadLeft", "DPadRight", + "Back", "Start", "LThumb", "RThumb", }; // ****************************************************************** diff --git a/Source/Win32/Mutex.cpp b/Source/Win32/Mutex.cpp index 8b1d8f97e..08894279e 100644 --- a/Source/Win32/Mutex.cpp +++ b/Source/Win32/Mutex.cpp @@ -53,7 +53,7 @@ void Mutex::Lock() { // Grab the lock, letting us look at the variables // while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0)) - while(InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0)) + while(InterlockedCompareExchange((LPLONG)&m_MutexLock, (LONG)1, (LONG)0)) Sleep(1); // Are we the the new owner? @@ -100,7 +100,7 @@ void Mutex::Unlock() { // Grab the lock, letting us look at the variables // while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0)) - while (InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0)) + while (InterlockedCompareExchange((LPLONG)&m_MutexLock, (LONG)1, (LONG)0)) Sleep(1); // Decrement the lock count