FS: Kernel code.
This commit is contained in:
parent
95e11ebc33
commit
f99df982b1
25
Cxbe.vcproj
25
Cxbe.vcproj
|
@ -134,6 +134,19 @@
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Doc"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Changelog.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Thanks.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Todo.txt">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Include"
|
Name="Include"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
@ -156,6 +169,10 @@
|
||||||
RelativePath=".\Include\Core\Xbe.h">
|
RelativePath=".\Include\Core\Xbe.h">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource"
|
||||||
|
Filter="">
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source"
|
Name="Source"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
@ -172,14 +189,6 @@
|
||||||
RelativePath=".\Source\Core\Xbe.cpp">
|
RelativePath=".\Source\Core\Xbe.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="Doc"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|
39
Cxbx.vcproj
39
Cxbx.vcproj
|
@ -132,6 +132,27 @@ upxCxbx.bat
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<Files>
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Bin"
|
||||||
|
Filter="">
|
||||||
|
<Filter
|
||||||
|
Name="Debug"
|
||||||
|
Filter="">
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Doc"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Changelog.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Thanks.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Todo.txt">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Include"
|
Name="Include"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
@ -144,6 +165,9 @@ upxCxbx.bat
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Include\Cxbx.h">
|
RelativePath=".\Include\Cxbx.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Include\Win32\CxbxKrnl\CxbxKrnl.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Include\Win32\Cxbx\EmuExe.h">
|
RelativePath=".\Include\Win32\Cxbx\EmuExe.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -153,9 +177,6 @@ upxCxbx.bat
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Include\Core\Exe.h">
|
RelativePath=".\Include\Core\Exe.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Include\Win32\CxbxKrnl\CxbxKrnl.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Include\Win32\Cxbx\Prolog.h">
|
RelativePath=".\Include\Win32\Cxbx\Prolog.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -234,18 +255,6 @@ upxCxbx.bat
|
||||||
RelativePath=".\Source\Core\Xbe.cpp">
|
RelativePath=".\Source\Core\Xbe.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="Bin"
|
|
||||||
Filter="">
|
|
||||||
<Filter
|
|
||||||
Name="Debug"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Doc"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|
|
@ -129,6 +129,27 @@
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<Files>
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Bin"
|
||||||
|
Filter="">
|
||||||
|
<Filter
|
||||||
|
Name="Debug"
|
||||||
|
Filter="">
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Doc"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Changelog.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Thanks.txt">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Doc\Todo.txt">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Include"
|
Name="Include"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
@ -142,6 +163,10 @@
|
||||||
RelativePath=".\Include\Win32\CxbxKrnl\xntdll.h">
|
RelativePath=".\Include\Win32\CxbxKrnl\xntdll.h">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource"
|
||||||
|
Filter="">
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source"
|
Name="Source"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
@ -155,22 +180,6 @@
|
||||||
RelativePath="Source\Win32\CxbxKrnl\LDT.cpp">
|
RelativePath="Source\Win32\CxbxKrnl\LDT.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="Bin"
|
|
||||||
Filter="">
|
|
||||||
<Filter
|
|
||||||
Name="Debug"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Doc"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource"
|
|
||||||
Filter="">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Special Thanks to the authors of UPX file compressor (http://upx.sourceforge.net/).
|
Special thanks to the authors of UPX file compressor (http://upx.sourceforge.net/).
|
|
@ -76,6 +76,21 @@ CXBXKRNL_API void NTAPI EmuXDummy();
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
CXBXKRNL_API void NTAPI EmuXPanic();
|
CXBXKRNL_API void NTAPI EmuXPanic();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * _EMUX_KPCR
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Emulated Xbox KPCR. Includes special field(s) for emulation
|
||||||
|
// * purposes.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _EMUX_KPCR
|
||||||
|
{
|
||||||
|
struct xboxkrnl::_KPCR Pcr;
|
||||||
|
uint16 OriginalFS; // 0x025C (our cached FS register from win2k/XP)
|
||||||
|
}
|
||||||
|
EMUX_KPCR, *PEMUX_KPCR;
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,36 +65,33 @@ using namespace win32;
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
void EmuXGenerateFS()
|
void EmuXGenerateFS()
|
||||||
{
|
{
|
||||||
NT_TIB *OrgFS = 0;
|
uint16 OrgFS = 0;
|
||||||
|
|
||||||
uint32 dwFSSize = sizeof(NT_TIB);
|
uint32 dwSize = sizeof(EMUX_KPCR);
|
||||||
|
|
||||||
|
uint32 pNewFS = (uint32)new char[dwSize];
|
||||||
|
|
||||||
|
uint16 NewFS = LDTAllocate(pNewFS, pNewFS + dwSize);
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Retrieve the "old" FS
|
// * Save the "old" FS : [OrgFS = FS]
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov esi, fs:[18h]
|
mov ax, fs
|
||||||
mov OrgFS, esi
|
mov OrgFS, ax
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * Allocate and update the new FS
|
// * Update "new" FS : [FS = NewFS, FS:[0x025C] = OrgFS]
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
__asm
|
||||||
{
|
{
|
||||||
uint32 AllocFS = (uint32)new char[dwFSSize];
|
mov ax, NewFS
|
||||||
|
mov fs, ax
|
||||||
|
|
||||||
memcpy((void*)AllocFS, OrgFS, dwFSSize);
|
mov ax, OrgFS
|
||||||
|
mov fs:[0x025C], ax
|
||||||
uint16 SelectorFS = LDTAllocate(AllocFS, AllocFS+dwFSSize);
|
|
||||||
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov ax, SelectorFS
|
|
||||||
|
|
||||||
push ax
|
|
||||||
pop fs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,13 +154,16 @@ CXBXKRNL_API void NTAPI EmuXInit(uint32 DebugConsole, uint08 *XBEHeader, uint32
|
||||||
// * Initialize FS:* structure
|
// * Initialize FS:* structure
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
{
|
{
|
||||||
// Calling this function will overwrite the Win2k/XP FS: structure,
|
EmuXGenerateFS();
|
||||||
// which will cause an immediate or eventual crash. In order to avoid
|
|
||||||
// this, it is going to be necessary to store the Win2k/XP FS: in a
|
|
||||||
// special un-used slot in the XBox FS:* structure, and bring it back
|
|
||||||
// in whenever we need to use Win2k/XP functions
|
|
||||||
|
|
||||||
// EmuXGenerateFS();
|
// ******************************************************************
|
||||||
|
// * Restore "old" FS : [FS = FS:[0x025C]]
|
||||||
|
// ******************************************************************
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov ax, fs:[0x025C]
|
||||||
|
mov fs, ax
|
||||||
|
}
|
||||||
|
|
||||||
NT_TIB *dbgTIB = 0;
|
NT_TIB *dbgTIB = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue