FS: Kernel code.

This commit is contained in:
Aaron Robinson 2003-01-28 09:19:56 +00:00
parent 95e11ebc33
commit f99df982b1
6 changed files with 106 additions and 64 deletions

View File

@ -134,6 +134,19 @@
</File>
</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
Name="Include"
Filter="">
@ -156,6 +169,10 @@
RelativePath=".\Include\Core\Xbe.h">
</File>
</Filter>
<Filter
Name="Resource"
Filter="">
</Filter>
<Filter
Name="Source"
Filter="">
@ -172,14 +189,6 @@
RelativePath=".\Source\Core\Xbe.cpp">
</File>
</Filter>
<Filter
Name="Doc"
Filter="">
</Filter>
<Filter
Name="Resource"
Filter="">
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -132,6 +132,27 @@ upxCxbx.bat
</Configuration>
</Configurations>
<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
Name="Include"
Filter="">
@ -144,6 +165,9 @@ upxCxbx.bat
<File
RelativePath=".\Include\Cxbx.h">
</File>
<File
RelativePath=".\Include\Win32\CxbxKrnl\CxbxKrnl.h">
</File>
<File
RelativePath=".\Include\Win32\Cxbx\EmuExe.h">
</File>
@ -153,9 +177,6 @@ upxCxbx.bat
<File
RelativePath=".\Include\Core\Exe.h">
</File>
<File
RelativePath=".\Include\Win32\CxbxKrnl\CxbxKrnl.h">
</File>
<File
RelativePath=".\Include\Win32\Cxbx\Prolog.h">
</File>
@ -234,18 +255,6 @@ upxCxbx.bat
RelativePath=".\Source\Core\Xbe.cpp">
</File>
</Filter>
<Filter
Name="Bin"
Filter="">
<Filter
Name="Debug"
Filter="">
</Filter>
</Filter>
<Filter
Name="Doc"
Filter="">
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -129,6 +129,27 @@
</Configuration>
</Configurations>
<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
Name="Include"
Filter="">
@ -142,6 +163,10 @@
RelativePath=".\Include\Win32\CxbxKrnl\xntdll.h">
</File>
</Filter>
<Filter
Name="Resource"
Filter="">
</Filter>
<Filter
Name="Source"
Filter="">
@ -155,22 +180,6 @@
RelativePath="Source\Win32\CxbxKrnl\LDT.cpp">
</File>
</Filter>
<Filter
Name="Bin"
Filter="">
<Filter
Name="Debug"
Filter="">
</Filter>
</Filter>
<Filter
Name="Doc"
Filter="">
</Filter>
<Filter
Name="Resource"
Filter="">
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -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/).

View File

@ -76,6 +76,21 @@ CXBXKRNL_API void NTAPI EmuXDummy();
// ******************************************************************
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)
}
#endif

View File

@ -65,36 +65,33 @@ using namespace win32;
// ******************************************************************
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
{
mov esi, fs:[18h]
mov OrgFS, esi
mov ax, fs
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);
uint16 SelectorFS = LDTAllocate(AllocFS, AllocFS+dwFSSize);
__asm
{
mov ax, SelectorFS
push ax
pop fs
}
mov ax, OrgFS
mov fs:[0x025C], ax
}
}
@ -157,13 +154,16 @@ CXBXKRNL_API void NTAPI EmuXInit(uint32 DebugConsole, uint08 *XBEHeader, uint32
// * Initialize FS:* structure
// ******************************************************************
{
// Calling this function will overwrite the Win2k/XP FS: structure,
// 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();
// EmuXGenerateFS();
// ******************************************************************
// * Restore "old" FS : [FS = FS:[0x025C]]
// ******************************************************************
__asm
{
mov ax, fs:[0x025C]
mov fs, ax
}
NT_TIB *dbgTIB = 0;