Repair EmuXLaunchNewImage
Symbolic links cannot be relied upon, but devices are always present, so use those.
This commit is contained in:
parent
74b13b7d65
commit
bebcff71e8
|
@ -96,12 +96,6 @@ const char CxbxDefaultXbeDriveLetter = 'D';
|
|||
|
||||
int CxbxDefaultXbeDriveIndex = -1;
|
||||
EmuNtSymbolicLinkObject* NtSymbolicLinkObjects[26];
|
||||
|
||||
struct XboxDevice {
|
||||
std::string XboxDevicePath;
|
||||
std::string HostDevicePath;
|
||||
HANDLE HostRootHandle;
|
||||
};
|
||||
std::vector<XboxDevice> Devices;
|
||||
|
||||
EmuHandle::EmuHandle(EmuNtObject* ntObject)
|
||||
|
@ -353,6 +347,24 @@ NTSTATUS CxbxObjectAttributesToNT(
|
|||
return result;
|
||||
}
|
||||
|
||||
int CxbxDeviceIndexByDevicePath(const char *XboxDevicePath)
|
||||
{
|
||||
for (size_t i = 0; i < Devices.size(); i++)
|
||||
if (_strnicmp(XboxDevicePath, Devices[i].XboxDevicePath.c_str(), Devices[i].XboxDevicePath.length()) == 0)
|
||||
return(i);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
XboxDevice *CxbxDeviceByDevicePath(const std::string XboxDevicePath)
|
||||
{
|
||||
int DeviceIndex = CxbxDeviceIndexByDevicePath(XboxDevicePath.c_str());
|
||||
if (DeviceIndex >= 0)
|
||||
return &Devices[DeviceIndex];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CxbxRegisterDeviceHostPath(std::string XboxDevicePath, std::string HostDevicePath, bool IsFile)
|
||||
{
|
||||
int result = -1;
|
||||
|
@ -426,16 +438,7 @@ NTSTATUS EmuNtSymbolicLinkObject::Init(std::string aSymbolicLinkName, std::strin
|
|||
if (IsHostBasedPath)
|
||||
DeviceIndex = CxbxDefaultXbeDriveIndex;
|
||||
else
|
||||
{
|
||||
DeviceIndex = -1;
|
||||
for (size_t i = 0; i < Devices.size(); i++) {
|
||||
if (_strnicmp(aFullPath.c_str(), Devices[i].XboxDevicePath.c_str(), Devices[i].XboxDevicePath.length()) == 0)
|
||||
{
|
||||
DeviceIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DeviceIndex = CxbxDeviceIndexByDevicePath(aFullPath.c_str());
|
||||
|
||||
if (DeviceIndex >= 0)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace xboxkrnl
|
|||
#include <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
@ -210,6 +211,12 @@ public:
|
|||
~EmuNtSymbolicLinkObject();
|
||||
};
|
||||
|
||||
struct XboxDevice {
|
||||
std::string XboxDevicePath;
|
||||
std::string HostDevicePath;
|
||||
HANDLE HostRootHandle;
|
||||
};
|
||||
|
||||
// ******************************************************************
|
||||
// * is Handle a 'special' emulated handle?
|
||||
// ******************************************************************
|
||||
|
@ -219,13 +226,17 @@ HANDLE EmuHandleToHandle(EmuHandle* emuHandle);
|
|||
|
||||
CHAR* NtStatusToString(IN NTSTATUS Status);
|
||||
|
||||
int CxbxRegisterDeviceHostPath(std::string XboxFullPath, std::string HostDevicePath, bool IsFile = false);
|
||||
int CxbxDeviceIndexByDevicePath(const char *XboxDevicePath);
|
||||
XboxDevice *CxbxDeviceByDevicePath(const std::string XboxDevicePath);
|
||||
|
||||
char SymbolicLinkToDriveLetter(std::string aSymbolicLinkName);
|
||||
EmuNtSymbolicLinkObject* FindNtSymbolicLinkObjectByDriveLetter(const char DriveLetter);
|
||||
EmuNtSymbolicLinkObject* FindNtSymbolicLinkObjectByName(std::string SymbolicLinkName);
|
||||
EmuNtSymbolicLinkObject* FindNtSymbolicLinkObjectByDevice(std::string DeviceName);
|
||||
EmuNtSymbolicLinkObject* FindNtSymbolicLinkObjectByRootHandle(HANDLE Handle);
|
||||
void CleanupSymbolicLinks();
|
||||
int CxbxRegisterDeviceHostPath(std::string XboxFullPath, std::string HostDevicePath, bool IsFile = false);
|
||||
|
||||
HANDLE CxbxGetDeviceNativeRootHandle(std::string XboxFullPath);
|
||||
NTSTATUS CxbxCreateSymbolicLink(std::string SymbolicLinkName, std::string FullPath);
|
||||
bool CxbxMountUtilityDrive(bool formatClean);
|
||||
|
|
|
@ -968,15 +968,15 @@ DWORD WINAPI XTL::EmuXLaunchNewImage
|
|||
|
||||
// If no path is specified, then the xbe is rebooting to dashboard
|
||||
if (!lpTitlePath) {
|
||||
char szDashboardPath[MAX_PATH];
|
||||
EmuNtSymbolicLinkObject* symbolicLinkObject = FindNtSymbolicLinkObjectByDevice(DeviceHarddisk0Partition2);
|
||||
sprintf(szDashboardPath, "%s\\xboxdash.xbe", symbolicLinkObject->HostSymbolicLinkPath.c_str());
|
||||
char szDashboardPath[MAX_PATH] = { 0 };
|
||||
XboxDevice* rootDevice = CxbxDeviceByDevicePath(DeviceHarddisk0Partition2);
|
||||
if(rootDevice != nullptr)
|
||||
sprintf(szDashboardPath, "%s\\xboxdash.xbe", rootDevice->HostDevicePath.c_str());
|
||||
|
||||
if (PathFileExists(szDashboardPath)) {
|
||||
if (PathFileExists(szDashboardPath))
|
||||
{
|
||||
MessageBox(CxbxKrnl_hEmuParent, "The title is rebooting to dashboard", "Cxbx-Reloaded", 0);
|
||||
char szXboxDashboardPath[MAX_PATH];
|
||||
sprintf(szXboxDashboardPath, "%c:\\xboxdash.xbe", symbolicLinkObject->DriveLetter);
|
||||
EmuXLaunchNewImage(szXboxDashboardPath, pLaunchData);
|
||||
EmuXLaunchNewImage("C:\xboxdash.xbe", pLaunchData);
|
||||
}
|
||||
|
||||
CxbxKrnlCleanup("The xbe rebooted to Dashboard and xboxdash.xbe could not be found");
|
||||
|
|
Loading…
Reference in New Issue