fix g_hCurDir issue by auto-bind to D letter when symbolic link is called occur

This commit is contained in:
RadWolfie 2021-04-25 16:53:43 -05:00
parent d8eb26fbda
commit cf3655bed1
2 changed files with 8 additions and 4 deletions

View File

@ -1448,9 +1448,6 @@ __declspec(noreturn) void CxbxKrnlInit
if (CxbxTitleDeviceDriveIndex == -1 || lastFind != std::string::npos) {
#endif
CxbxCreateSymbolicLink(DriveD, relative_path);
// Arrange that the Xbe path can reside outside the partitions, and put it to g_hCurDir :
EmuNtSymbolicLinkObject* xbePathSymbolicLinkObject = FindNtSymbolicLinkObjectByDriveLetter(CxbxAutoMountDriveLetter);
g_hCurDir = xbePathSymbolicLinkObject->RootDirectoryHandle;
}
}

View File

@ -715,8 +715,12 @@ xbox::ntstatus_xt CxbxCreateSymbolicLink(std::string SymbolicLinkName, std::stri
SymbolicLinkObject = new EmuNtSymbolicLinkObject();
result = SymbolicLinkObject->Init(SymbolicLinkName, FullPath);
if (result != xbox::status_success)
if (result != xbox::status_success) {
SymbolicLinkObject->NtClose();
}
else if (SymbolicLinkObject->DriveLetter == CxbxAutoMountDriveLetter) {
g_hCurDir = SymbolicLinkObject->RootDirectoryHandle;
}
return result;
}
@ -807,6 +811,9 @@ NTSTATUS EmuNtSymbolicLinkObject::Init(std::string aSymbolicLinkName, std::strin
if (DriveLetter >= 'A' && DriveLetter <= 'Z') {
NtSymbolicLinkObjects[DriveLetter - 'A'] = NULL;
NtDll::NtClose(RootDirectoryHandle);
if (DriveLetter == CxbxAutoMountDriveLetter) {
g_hCurDir = NULL;
}
}
}