Merge pull request #2342 from NZJenkins/unc-xbes

Better support for UNC paths
This commit is contained in:
PatrickvL 2022-04-12 12:58:16 +02:00 committed by GitHub
commit 696d49820c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -100,7 +100,11 @@ Xbe::Certificate *g_pCertificate = NULL;
char szFilePath_CxbxReloaded_Exe[MAX_PATH] = { 0 };
std::string g_DataFilePath;
char szFilePath_EEPROM_bin[MAX_PATH] = { 0 };
char szFilePath_Xbe[xbox::max_path*2] = { 0 }; // NOTE: LAUNCH_DATA_HEADER's szLaunchPath is xbox::max_path*2 = 520
// Hybrid host/xbox path to the xbe.
// A semicolon in the path indicates the Xbox mount point.
// Replacing the ';' with '\' gives a regular host path.
// NOTE: LAUNCH_DATA_HEADER's szLaunchPath is xbox::max_path*2 = 520
char szFilePath_Xbe[xbox::max_path*2] = { 0 };
Xbe* CxbxKrnl_Xbe = NULL;
bool g_bIsChihiro = false;
@ -613,7 +617,7 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags, unsigned& reserved_systems
// Get title path :
std::string xbePath;
cli_config::GetValue(cli_config::load, &xbePath);
xbePath = std::filesystem::absolute(std::filesystem::path(xbePath)).string();
xbePath = std::filesystem::absolute(xbePath).string();
// NOTE: This is a safety to clean the file path for any malicious file path attempt.
// Might want to move this into a utility function.
@ -630,7 +634,8 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags, unsigned& reserved_systems
// Once clean up process is done, proceed set to global variable string.
strncpy(szFilePath_Xbe, xbePath.c_str(), xbox::max_path - 1);
std::replace(xbePath.begin(), xbePath.end(), ';', '/');
// Convert to host path by replacing special mount point character if present
std::replace(xbePath.begin(), xbePath.end(), ';', '\\');
// Load Xbe (this one will reside above WinMain's virtual_memory_placeholder)
std::filesystem::path xbeDirectory = std::filesystem::path(xbePath).parent_path();

View File

@ -799,11 +799,6 @@ std::string CxbxConvertXboxToHostPath(const std::string_view XboxDevicePath)
char directoryPathBuffer[MAX_PATH];
GetFinalPathNameByHandle(rootDirectoryHandle, directoryPathBuffer, MAX_PATH, VOLUME_NAME_DOS);
XbePath = directoryPathBuffer + std::string("\\") + XbePath;
// Trim \\?\ from the output string, as we want the raw DOS path, not NT path
// We can do this always because GetFinalPathNameByHandle ALWAYS returns this format
// Without exception
XbePath.erase(0, 4);
}
return XbePath;