review remarks

This commit is contained in:
RadWolfie 2021-04-27 06:21:11 -05:00
parent cf3655bed1
commit 08dd615d37
4 changed files with 17 additions and 16 deletions

View File

@ -1398,7 +1398,7 @@ __declspec(noreturn) void CxbxKrnlInit
CxbxResolveHostToFullPath(relative_path, "xbe's directory"); CxbxResolveHostToFullPath(relative_path, "xbe's directory");
CxbxBasePathHandle = CreateFile(CxbxBasePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); CxbxBasePathHandle = CreateFile(CxbxBasePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
int CxbxTitleDeviceDriveIndex = -1; int CxbxCdrom0DeviceIndex = -1;
bool isEmuDisk = _strnicmp(relative_path.c_str(), CxbxBasePath.c_str(), CxbxBasePath.size() - 1) == 0; bool isEmuDisk = _strnicmp(relative_path.c_str(), CxbxBasePath.c_str(), CxbxBasePath.size() - 1) == 0;
// Check if title mounth path is already set. This may occur from early boot of Chihiro title. // Check if title mounth path is already set. This may occur from early boot of Chihiro title.
char title_mount_path[sizeof(szFilePath_Xbe)]; char title_mount_path[sizeof(szFilePath_Xbe)];
@ -1415,9 +1415,10 @@ __declspec(noreturn) void CxbxKrnlInit
// TODO: Find a place to make permanent placement for DeviceCdrom0 that does not have disc loaded. // TODO: Find a place to make permanent placement for DeviceCdrom0 that does not have disc loaded.
if (tmp_buffer[0] != '\0') { if (tmp_buffer[0] != '\0') {
CxbxTitleDeviceDriveIndex = CxbxRegisterDeviceHostPath(DeviceCdrom0, tmp_buffer); CxbxCdrom0DeviceIndex = CxbxRegisterDeviceHostPath(DeviceCdrom0, tmp_buffer);
// Since Chihiro also map Mbfs to the same path as Cdrom0, we'll map it the same way.
if (g_bIsChihiro) { if (g_bIsChihiro) {
CxbxRegisterDeviceHostPath(DriveMbfs, tmp_buffer); (void)CxbxRegisterDeviceHostPath(DriveMbfs, tmp_buffer);
} }
} }
@ -1445,7 +1446,7 @@ __declspec(noreturn) void CxbxKrnlInit
#else #else
// HACK: It is a hack to override XDK's default mount to CdRom0 which may not exist when launch to dashboard directly. // HACK: It is a hack to override XDK's default mount to CdRom0 which may not exist when launch to dashboard directly.
// Otherwise, titles may launch to dashboard, more specifically xbox live title, and back. // Otherwise, titles may launch to dashboard, more specifically xbox live title, and back.
if (CxbxTitleDeviceDriveIndex == -1 || lastFind != std::string::npos) { if (CxbxCdrom0DeviceIndex == -1 || lastFind != std::string::npos) {
#endif #endif
CxbxCreateSymbolicLink(DriveD, relative_path); CxbxCreateSymbolicLink(DriveD, relative_path);
} }

View File

@ -42,8 +42,6 @@ CRITICAL_SECTION dbgCritical;
#endif #endif
// Global Variable(s) // Global Variable(s)
HANDLE g_hCurDir = NULL;
CHAR *g_strCurDrive= NULL;
volatile thread_local bool g_bEmuException = false; volatile thread_local bool g_bEmuException = false;
static thread_local bool bOverrideEmuException; static thread_local bool bOverrideEmuException;
volatile bool g_bEmuSuspended = false; volatile bool g_bEmuSuspended = false;

View File

@ -63,9 +63,6 @@ extern volatile bool g_bEmuSuspended;
// global exception patching address // global exception patching address
extern void * funcExclude[2048]; extern void * funcExclude[2048];
// partition emulation directory handles
extern HANDLE g_hCurDir;
extern CHAR *g_strCurDrive;
extern HWND g_hEmuWindow; extern HWND g_hEmuWindow;
#define GET_FRONT_WINDOW_HANDLE ((CxbxKrnl_hEmuParent != nullptr) ? CxbxKrnl_hEmuParent : g_hEmuWindow) #define GET_FRONT_WINDOW_HANDLE ((CxbxKrnl_hEmuParent != nullptr) ? CxbxKrnl_hEmuParent : g_hEmuWindow)

View File

@ -46,6 +46,9 @@
#include <filesystem> #include <filesystem>
// partition emulation directory handles
HANDLE g_hCurDir_hack = NULL; // HACK: We should not be depending on this variable. Instead, we should fix/implement Ob/Io objects such as IoCreateDevice.
// Default Xbox Partition Table // Default Xbox Partition Table
#define PE_PARTFLAGS_IN_USE 0x80000000 #define PE_PARTFLAGS_IN_USE 0x80000000
#define XBOX_SWAPPART1_LBA_START 0x400 #define XBOX_SWAPPART1_LBA_START 0x400
@ -433,7 +436,7 @@ NTSTATUS CxbxConvertFilePath(
else if (RelativePath[0] == '$') { else if (RelativePath[0] == '$') {
if (RelativePath.compare(0, 5, "$HOME") == 0) // "xbmp" needs this if (RelativePath.compare(0, 5, "$HOME") == 0) // "xbmp" needs this
{ {
NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir); NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir_hack);
RelativePath.erase(0, 5); // Remove '$HOME' RelativePath.erase(0, 5); // Remove '$HOME'
} }
else else
@ -441,7 +444,7 @@ NTSTATUS CxbxConvertFilePath(
} }
// Check if the path starts with a relative path indicator : // Check if the path starts with a relative path indicator :
else if (RelativePath[0] == '.') {// "4x4 Evo 2" needs this else if (RelativePath[0] == '.') {// "4x4 Evo 2" needs this
NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir); NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir_hack);
RelativePath.erase(0, 1); // Remove the '.' RelativePath.erase(0, 1); // Remove the '.'
} }
else { else {
@ -467,7 +470,7 @@ NTSTATUS CxbxConvertFilePath(
} }
if (NtSymbolicLinkObject != nullptr || !find_path.HostDirPath.empty()) { if (NtSymbolicLinkObject != nullptr || !find_path.HostDirPath.empty()) {
/// If found, then we can skip misc checks below. // If found, then we can skip misc checks below.
} }
// Check if the path accesses a partition from Harddisk0 : // Check if the path accesses a partition from Harddisk0 :
else if (_strnicmp(RelativePath.c_str(), DeviceHarddisk0PartitionPrefix.c_str(), DeviceHarddisk0PartitionPrefix.length()) == 0) { else if (_strnicmp(RelativePath.c_str(), DeviceHarddisk0PartitionPrefix.c_str(), DeviceHarddisk0PartitionPrefix.length()) == 0) {
@ -481,13 +484,13 @@ NTSTATUS CxbxConvertFilePath(
// NOTE: RootDirectory cannot be ignored. // NOTE: RootDirectory cannot be ignored.
// Any special handling for it should be done below. // Any special handling for it should be done below.
else if (*RootDirectory == nullptr) { else if (*RootDirectory == nullptr) {
NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir); NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir_hack);
} }
else if (*RootDirectory == ObDosDevicesDirectory()) { else if (*RootDirectory == ObDosDevicesDirectory()) {
// This is a special handle that tells the API that this is a DOS device // This is a special handle that tells the API that this is a DOS device
// We can safely remove it and forward to the Xbe directory. // We can safely remove it and forward to the Xbe directory.
// Test case GTA3 // Test case GTA3
NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir); NtSymbolicLinkObject = FindNtSymbolicLinkObjectByRootHandle(g_hCurDir_hack);
} }
else if (*RootDirectory == ObWin32NamedObjectsDirectory()) { else if (*RootDirectory == ObWin32NamedObjectsDirectory()) {
// NOTE: A handle of -4 on the Xbox signifies the path should be in the BaseNamedObjects namespace. // NOTE: A handle of -4 on the Xbox signifies the path should be in the BaseNamedObjects namespace.
@ -718,8 +721,9 @@ xbox::ntstatus_xt CxbxCreateSymbolicLink(std::string SymbolicLinkName, std::stri
if (result != xbox::status_success) { if (result != xbox::status_success) {
SymbolicLinkObject->NtClose(); SymbolicLinkObject->NtClose();
} }
// TODO: Remove whole else if statement below, see g_hCurDir_hack's comment for remark.
else if (SymbolicLinkObject->DriveLetter == CxbxAutoMountDriveLetter) { else if (SymbolicLinkObject->DriveLetter == CxbxAutoMountDriveLetter) {
g_hCurDir = SymbolicLinkObject->RootDirectoryHandle; g_hCurDir_hack = SymbolicLinkObject->RootDirectoryHandle;
} }
return result; return result;
@ -811,8 +815,9 @@ NTSTATUS EmuNtSymbolicLinkObject::Init(std::string aSymbolicLinkName, std::strin
if (DriveLetter >= 'A' && DriveLetter <= 'Z') { if (DriveLetter >= 'A' && DriveLetter <= 'Z') {
NtSymbolicLinkObjects[DriveLetter - 'A'] = NULL; NtSymbolicLinkObjects[DriveLetter - 'A'] = NULL;
NtDll::NtClose(RootDirectoryHandle); NtDll::NtClose(RootDirectoryHandle);
// TODO: Remove whole if statement below, see g_hCurDir_hack's comment for remark.
if (DriveLetter == CxbxAutoMountDriveLetter) { if (DriveLetter == CxbxAutoMountDriveLetter) {
g_hCurDir = NULL; g_hCurDir_hack = NULL;
} }
} }
} }