HRESULT xbox_io_mount(const char* szDrive, char* szDevice) { STRING DeviceName, LinkName; CHAR szDestinationDrive[PATH_MAX_LENGTH]; sprintf_s(szDestinationDrive, PATH_MAX_LENGTH, "\\??\\%s", szDrive); RtlInitAnsiString(&DeviceName, szDevice); RtlInitAnsiString(&LinkName, szDestinationDrive); ObDeleteSymbolicLink(&LinkName); return (HRESULT)ObCreateSymbolicLink(&LinkName, &DeviceName); }
HRESULT Drive::Mount() { // Get our serial LoadSerial(); // Get our serial as a string CHAR serialStr[41]; serialStr[40] = 0; UINT outLen = 0x40; GetBytesString(m_Serial, 0x14, serialStr, &outLen); m_SerialStr = (string)serialStr; if (m_DriveType == DEVICE_USBMEMORY_UNIT0 || m_DriveType == DEVICE_USBMEMORY_UNIT1 || m_DriveType == DEVICE_USBMEMORY_UNIT2 ) m_SerialStr = m_SerialStr + "_USBMU"; if (m_DriveType == DEVICE_USBMEMORY_Cache0 || m_DriveType == DEVICE_USBMEMORY_Cache1 || m_DriveType == DEVICE_USBMEMORY_Cache2 ) m_SerialStr = m_SerialStr + "_USBMUC"; //DebugMsg("Mounting %s",m_MountPoint.c_str()); char MountConv[260]; sprintf_s( MountConv, "\\??\\%s", m_MountPoint.c_str() ); char SysPath[260]; sprintf_s( SysPath,"%s", m_SystemPath.c_str() ); STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath }; STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv }; //don't try to mount 'Game:' as it's already there if (stricmp(m_MountPoint.c_str(), "Game:") != 0) { int res = ObCreateSymbolicLink( &sMountConv, &sSysPath ); if (res != 0) { //DebugMsg("Mount failed : %d",res); return res; } } HRESULT ret = IsMounted(); if(ret == 1) { GetDiskFreeSpaceEx(getRootPath().c_str(),&m_FreeBytesAvailable,&m_TotalNumberOfBytes,&m_TotalNumberOfFreeBytes); } else { m_FreeBytesAvailable.QuadPart = 0; m_TotalNumberOfBytes.QuadPart =0; m_TotalNumberOfFreeBytes.QuadPart=0; } return ret; }
static int Mount( int Device, char* MountPoint ) { char MountConv[260]; char * SysPath = NULL; snprintf( MountConv, sizeof(MountConv), "\\??\\%s", MountPoint ); switch( Device ) { case DEVICE_MEMORY_UNIT0: SysPath = "\\Device\\Mu0"; break; case DEVICE_MEMORY_UNIT1: SysPath = "\\Device\\Mu1"; break; case DEVICE_MEMORY_ONBOARD: SysPath = "\\Device\\BuiltInMuSfc"; break; case DEVICE_CDROM0: SysPath = "\\Device\\Cdrom0"; break; case DEVICE_HARDISK0_PART1: SysPath = "\\Device\\Harddisk0\\Partition1"; break; case DEVICE_HARDISK0_SYSPART: SysPath = "\\Device\\Harddisk0\\SystemPartition"; break; case DEVICE_USB0: SysPath = "\\Device\\Mass0"; break; case DEVICE_USB1: SysPath = "\\Device\\Mass1"; break; case DEVICE_USB2: SysPath = "\\Device\\Mass2"; break; case DEVICE_CACHE: SysPath = "\\Device\\Harddisk0\\Cache0"; break; } STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath }; STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv }; int res = ObCreateSymbolicLink( &sMountConv, &sSysPath ); if (res != 0) return res; return DriveMounted(MountPoint); }
HRESULT MountPath( const PCHAR szDrive, const PCHAR szDevice ) { PCHAR szSysStr = NULL; if ( KeGetCurrentProcessType() == SYSTEM_PROC ) szSysStr = "\\System??\\%s"; else szSysStr = "\\??\\%s"; CHAR szDestinationDrive[ MAX_PATH ]; sprintf_s( szDestinationDrive, MAX_PATH, szSysStr, szDrive ); STRING strDeviceName = MAKE_STRING( szDevice ); STRING strLinkName = MAKE_STRING( szDestinationDrive ); ObDeleteSymbolicLink( &strLinkName ); return ObCreateSymbolicLink( &strLinkName, &strDeviceName ); }