diff --git a/Cxbx.sln b/Cxbx.sln
index 94c9796da..360396442 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", "{A3340C57-9832-425B-AB63-5698AC7C57B3}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbe", "Cxbe.vcproj", "{0F4725FF-D671-49C0-A7E5-54DBC18226D1}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbx", "Cxbx.vcproj", "{37520F3E-8596-49D7-9014-E03E42C60B99}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cxbx", "Cxbx.vcproj", "{56F746E9-DCE6-441E-867C-594C8028A54C}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxbxKrnl", "CxbxKrnl.vcproj", "{7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxbxKrnl", "CxbxKrnl.vcproj", "{251B0184-1631-4203-9667-B98EB55E7458}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
@@ -11,21 +11,21 @@ Global
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
- {37520F3E-8596-49D7-9014-E03E42C60B99}.0 = {7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}
+ {56F746E9-DCE6-441E-867C-594C8028A54C}.0 = {251B0184-1631-4203-9667-B98EB55E7458}
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
- {A3340C57-9832-425B-AB63-5698AC7C57B3}.Debug.ActiveCfg = Debug|Win32
- {A3340C57-9832-425B-AB63-5698AC7C57B3}.Debug.Build.0 = Debug|Win32
- {A3340C57-9832-425B-AB63-5698AC7C57B3}.Release.ActiveCfg = Release|Win32
- {A3340C57-9832-425B-AB63-5698AC7C57B3}.Release.Build.0 = Release|Win32
- {37520F3E-8596-49D7-9014-E03E42C60B99}.Debug.ActiveCfg = Debug|Win32
- {37520F3E-8596-49D7-9014-E03E42C60B99}.Debug.Build.0 = Debug|Win32
- {37520F3E-8596-49D7-9014-E03E42C60B99}.Release.ActiveCfg = Release|Win32
- {37520F3E-8596-49D7-9014-E03E42C60B99}.Release.Build.0 = Release|Win32
- {7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}.Debug.ActiveCfg = Debug|Win32
- {7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}.Debug.Build.0 = Debug|Win32
- {7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}.Release.ActiveCfg = Release|Win32
- {7CD4604D-BB5F-4ED2-BC20-6A882D3812DC}.Release.Build.0 = Release|Win32
+ {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
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
diff --git a/CxbxKrnl.dsp b/CxbxKrnl.dsp
index c86ca8373..887684393 100644
--- a/CxbxKrnl.dsp
+++ b/CxbxKrnl.dsp
@@ -173,6 +173,10 @@ SOURCE=.\Include\Win32\CxbxKrnl\EmuDInput.h
# End Source File
# Begin Source File
+SOURCE=.\Include\Win32\CxbxKrnl\EmuFile.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Include\Win32\CxbxKrnl\EmuFS.h
# End Source File
# Begin Source File
@@ -277,6 +281,10 @@ SOURCE=.\Source\Win32\CxbxKrnl\EmuDInput.cpp
# End Source File
# Begin Source File
+SOURCE=.\Source\Win32\CxbxKrnl\EmuFile.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Source\Win32\CxbxKrnl\EmuFS.cpp
# End Source File
# Begin Source File
diff --git a/CxbxKrnl.vcproj b/CxbxKrnl.vcproj
index 4528f8564..32b897a41 100644
--- a/CxbxKrnl.vcproj
+++ b/CxbxKrnl.vcproj
@@ -202,6 +202,9 @@
+
+
@@ -294,6 +297,9 @@
+
+
diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt
index 1ca86a1df..650ac23f0 100644
--- a/Doc/Changelog.txt
+++ b/Doc/Changelog.txt
@@ -23,6 +23,8 @@ version: 0.7.0 (??/??/??)
- Fixed GUI color issues
+- Much better emulation exception handling
+
version: 0.6.0-pre12 (02/23/03)
--------------------------------
diff --git a/Include/Win32/CxbxKrnl/EmuFile.h b/Include/Win32/CxbxKrnl/EmuFile.h
new file mode 100644
index 000000000..94f7abba3
--- /dev/null
+++ b/Include/Win32/CxbxKrnl/EmuFile.h
@@ -0,0 +1,38 @@
+// ******************************************************************
+// *
+// * .,-::::: .,:: .::::::::. .,:: .:
+// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
+// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
+// * $$$ Y$$$P $$""""Y$$ Y$$$P
+// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
+// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
+// *
+// * Cxbx->Win32->CxbxKrnl->EmuFile.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 EMUFILE_H
+#define EMUFILE_H
+
+
+#endif
diff --git a/Include/Win32/CxbxKrnl/xntdll.h b/Include/Win32/CxbxKrnl/xntdll.h
index 60561aed0..bbfd68ad1 100644
--- a/Include/Win32/CxbxKrnl/xntdll.h
+++ b/Include/Win32/CxbxKrnl/xntdll.h
@@ -320,6 +320,24 @@ NTSYSAPI NTSTATUS NTAPI ZwOpenFile
IN ULONG OpenOptions
);
+// ******************************************************************
+// * ZwCreateFile
+// ******************************************************************
+NTSYSAPI NTSTATUS NTAPI ZwCreateFile
+(
+ OUT PHANDLE FileHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ OUT PIO_STATUS_BLOCK IoStatusBlock,
+ IN PLARGE_INTEGER AllocationSize OPTIONAL,
+ IN ULONG FileAttributes,
+ IN ULONG ShareAccess,
+ IN ULONG CreateDisposition,
+ IN ULONG CreateOptions,
+ IN PVOID EaBuffer OPTIONAL,
+ IN ULONG EaLength
+);
+
// ******************************************************************
// * KeDelayExecutionThread
// ******************************************************************
diff --git a/Source/Win32/CxbxKrnl/EmuFile.cpp b/Source/Win32/CxbxKrnl/EmuFile.cpp
new file mode 100644
index 000000000..790a9dd90
--- /dev/null
+++ b/Source/Win32/CxbxKrnl/EmuFile.cpp
@@ -0,0 +1,38 @@
+// ******************************************************************
+// *
+// * .,-::::: .,:: .::::::::. .,:: .:
+// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
+// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
+// * $$$ Y$$$P $$""""Y$$ Y$$$P
+// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
+// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
+// *
+// * Cxbx->Win32->CxbxKrnl->EmuFile.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
+// *
+// ******************************************************************
+#define _CXBXKRNL_INTERNAL
+#define _XBOXKRNL_LOCAL_
+
+#include "EmuFile.h"
+
diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp
index 659d47950..096bada2d 100644
--- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp
+++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp
@@ -54,11 +54,13 @@ namespace xntdll
#include "Emu.h"
#include "EmuFS.h"
+#include "EmuFile.h"
// ******************************************************************
// * Loaded at run-time to avoid linker conflicts
// ******************************************************************
HMODULE hNtDll = GetModuleHandle("ntdll");
+
xntdll::FPTR_RtlInitAnsiString NT_RtlInitAnsiString = (xntdll::FPTR_RtlInitAnsiString)GetProcAddress(hNtDll, "RtlInitAnsiString");
xntdll::FPTR_RtlNtStatusToDosError NT_RtlNtStatusToDosError = (xntdll::FPTR_RtlNtStatusToDosError)GetProcAddress(hNtDll, "RtlNtStatusToDosError");
xntdll::FPTR_NtAllocateVirtualMemory NT_NtAllocateVirtualMemory = (xntdll::FPTR_NtAllocateVirtualMemory)GetProcAddress(hNtDll, "NtAllocateVirtualMemory");
@@ -67,6 +69,11 @@ xntdll::FPTR_RtlInitializeCriticalSection NT_RtlInitializeCriticalSection = (xnt
xntdll::FPTR_RtlEnterCriticalSection NT_RtlEnterCriticalSection = (xntdll::FPTR_RtlEnterCriticalSection)GetProcAddress(hNtDll, "RtlEnterCriticalSection");
xntdll::FPTR_RtlLeaveCriticalSection NT_RtlLeaveCriticalSection = (xntdll::FPTR_RtlLeaveCriticalSection)GetProcAddress(hNtDll, "RtlLeaveCriticalSection");
+// ******************************************************************
+// * Special macros for our "special" file handles
+// ******************************************************************
+#define IS_EMU_HANDLE(x) (!(((uint32)x) & 0x80000000))
+
// ******************************************************************
// * (Helper) PCSTProxyParam
// ******************************************************************
@@ -281,11 +288,30 @@ XBSYSAPI EXPORTNUM(66) NTSTATUS NTAPI xboxkrnl::IoCreateFile
}
#endif
- _asm int 3
+ NTSTATUS ret = STATUS_SUCCESS;
+
+ // TODO: HACK: We are just handling specific cases for now
+ if(strcmp(ObjectAttributes->ObjectName->Buffer, "\\Device\\Harddisk0\\partition1\\") == 0)
+ {
+ // TODO: return a 'special' file handle for partition1
+ }
+ 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
- return STATUS_SUCCESS;
+ return ret;
}
// ******************************************************************