FS emulation : KThread

This commit is contained in:
Aaron Robinson 2003-01-31 18:10:38 +00:00
parent 965e44af59
commit 6f08cd4ed2
2 changed files with 32 additions and 6 deletions

View File

@ -2,10 +2,7 @@ Cxbx Todo:
General Code Cleanup [caustik]
Use KeGetCurrentThread for fs:28h (May not be able to w/out kernel mode)
If not, fake it by constructing a fake KTHREAD possibly. In any event,
the current crashing method is an attempt to locate TLSData inside of a
KTHREAD object returned by fs:28h.
Find out where NewPcr->PrcbData.CurrentThread->TlsData should point.
Exe->Xbe should use an "OpenXDK" logo bitmap by default. This can be done
by having a debug version of Cxbx output the necessary raw data. Then, you

View File

@ -127,9 +127,14 @@ void EmuXGenerateFS()
// * Generate TIB
// ******************************************************************
{
xboxkrnl::KTHREAD *KThread = new xboxkrnl::KTHREAD();
memcpy(&NewPcr->NtTib, OrgNtTib, sizeof(NT_TIB));
NewPcr->NtTib.Self = &NewPcr->NtTib;
NewPcr->PrcbData.CurrentThread = KThread;
KThread->TlsData = (void*)0xCDCDCDCD;
}
// ******************************************************************
@ -222,13 +227,13 @@ CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, ui
// ******************************************************************
{
EmuXGenerateFS();
// TODO: Initialize "new" FS structure
}
printf("CxbxKrnl [0x%.08X]: Initial thread starting.\n", GetCurrentThreadId());
EmuXSwapFS(); // XBox FS
Entry();
EmuXSwapFS(); // Win2k/XP FS
printf("CxbxKrnl [0x%.08X]: Initial thread ended.\n", GetCurrentThreadId());
@ -244,7 +249,11 @@ CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, ui
// ******************************************************************
CXBXKRNL_API void NTAPI EmuXDummy()
{
EmuXSwapFS(); // Win2k/XP FS
MessageBox(NULL, "EmuXDummy()", "CxbxKrnl", MB_OK);
EmuXSwapFS(); // XBox FS
}
// ******************************************************************
@ -252,10 +261,14 @@ CXBXKRNL_API void NTAPI EmuXDummy()
// ******************************************************************
CXBXKRNL_API void NTAPI EmuXPanic()
{
EmuXSwapFS(); // Win2k/XP FS
printf("CxbxKrnl [0x%.08X]: EmuXPanic()\n", GetCurrentThreadId());
MessageBox(NULL, "Kernel Panic! Process will now terminate.", "CxbxKrnl", MB_OK | MB_ICONEXCLAMATION);
EmuXSwapFS(); // XBox FS
exit(1);
}
@ -288,6 +301,10 @@ DWORD WINAPI PsCreateSystemThreadExProxy
delete iPsCreateSystemThreadExProxyParam;
EmuXGenerateFS();
EmuXSwapFS(); // XBox FS
__asm
{
mov esi, StartRoutine
@ -312,6 +329,8 @@ XBSYSAPI EXPORTNUM(187) NTSTATUS NTAPI xboxkrnl::NtClose
IN HANDLE Handle
)
{
EmuXSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
@ -328,6 +347,8 @@ XBSYSAPI EXPORTNUM(187) NTSTATUS NTAPI xboxkrnl::NtClose
if(CloseHandle(Handle) != TRUE)
return STATUS_UNSUCCESSFUL;
EmuXSwapFS(); // XBox FS
return STATUS_SUCCESS;
}
@ -348,6 +369,8 @@ XBSYSAPI EXPORTNUM(255) NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadEx
IN PKSTART_ROUTINE StartRoutine
)
{
EmuXSwapFS(); // Win2k/XP FS
// ******************************************************************
// * debug trace
// ******************************************************************
@ -385,6 +408,8 @@ XBSYSAPI EXPORTNUM(255) NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadEx
if(ThreadId != NULL)
*ThreadId = dwThreadId;
EmuXSwapFS(); // XBox FS
return STATUS_SUCCESS;
}
@ -396,6 +421,8 @@ XBSYSAPI EXPORTNUM(49) VOID DECLSPEC_NORETURN xboxkrnl::HalReturnToFirmware
RETURN_FIRMWARE Routine
)
{
EmuXSwapFS(); // Win2k/XP FS
MessageBox(NULL, "HalReturnToFirmware()", "CxbxKrnl", MB_OK);
/*
ReturnFirmwareHalt = 0x0,
@ -406,5 +433,7 @@ XBSYSAPI EXPORTNUM(49) VOID DECLSPEC_NORETURN xboxkrnl::HalReturnToFirmware
ReturnFirmwareAll = 0x5
*/
EmuXSwapFS(); // XBox FS
exit(1);
}