(Xbox 1) Iosupport.cpp code integrated into platform_xdk.c
This commit is contained in:
parent
6d755ae193
commit
f53321b0ce
|
@ -412,8 +412,6 @@ MENU
|
||||||
|
|
||||||
#if defined(_XBOX360)
|
#if defined(_XBOX360)
|
||||||
#include "../../360/frontend-xdk/menu.cpp"
|
#include "../../360/frontend-xdk/menu.cpp"
|
||||||
#elif defined(_XBOX1)
|
|
||||||
#include "../../xbox1/frontend/RetroLaunch/IoSupport.cpp"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "platform_xdk.h"
|
||||||
#include "platform_inl.h"
|
#include "platform_inl.h"
|
||||||
|
|
||||||
#if defined(_XBOX360)
|
#if defined(_XBOX360)
|
||||||
|
@ -145,6 +146,122 @@ static void salamander_init_settings(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
|
||||||
|
#define CTLCODE(DeviceType, Function, Method, Access) ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) )
|
||||||
|
#define FSCTL_DISMOUNT_VOLUME CTLCODE( FILE_DEVICE_FILE_SYSTEM, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS )
|
||||||
|
|
||||||
|
static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
|
||||||
|
{
|
||||||
|
char szSourceDevice[48];
|
||||||
|
char szDestinationDrive[16];
|
||||||
|
|
||||||
|
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
|
||||||
|
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
|
||||||
|
RARCH_LOG("xbox_io_mount() - source device: %s.\n", szSourceDevice);
|
||||||
|
RARCH_LOG("xbox_io_mount() - destination drive: %s.\n", szDestinationDrive);
|
||||||
|
|
||||||
|
STRING DeviceName =
|
||||||
|
{
|
||||||
|
strlen(szSourceDevice),
|
||||||
|
strlen(szSourceDevice) + 1,
|
||||||
|
szSourceDevice
|
||||||
|
};
|
||||||
|
|
||||||
|
STRING LinkName =
|
||||||
|
{
|
||||||
|
strlen(szDestinationDrive),
|
||||||
|
strlen(szDestinationDrive) + 1,
|
||||||
|
szDestinationDrive
|
||||||
|
};
|
||||||
|
|
||||||
|
IoCreateSymbolicLink(&LinkName, &DeviceName);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT xbox_io_unmount(char *szDrive)
|
||||||
|
{
|
||||||
|
char szDestinationDrive[16];
|
||||||
|
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
|
||||||
|
|
||||||
|
STRING LinkName =
|
||||||
|
{
|
||||||
|
strlen(szDestinationDrive),
|
||||||
|
strlen(szDestinationDrive) + 1,
|
||||||
|
szDestinationDrive
|
||||||
|
};
|
||||||
|
|
||||||
|
IoDeleteSymbolicLink(&LinkName);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT xbox_io_remount(char *szDrive, char *szDevice)
|
||||||
|
{
|
||||||
|
char szSourceDevice[48];
|
||||||
|
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
|
||||||
|
|
||||||
|
xbox_io_unmount(szDrive);
|
||||||
|
|
||||||
|
ANSI_STRING filename;
|
||||||
|
OBJECT_ATTRIBUTES attributes;
|
||||||
|
IO_STATUS_BLOCK status;
|
||||||
|
HANDLE hDevice;
|
||||||
|
NTSTATUS error;
|
||||||
|
DWORD dummy;
|
||||||
|
|
||||||
|
RtlInitAnsiString(&filename, szSourceDevice);
|
||||||
|
InitializeObjectAttributes(&attributes, &filename, OBJ_CASE_INSENSITIVE, NULL);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(error = NtCreateFile(&hDevice, GENERIC_READ |
|
||||||
|
SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attributes, &status, NULL, 0,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
|
||||||
|
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT)))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DeviceIoControl(hDevice, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dummy, NULL))
|
||||||
|
{
|
||||||
|
CloseHandle(hDevice);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hDevice);
|
||||||
|
xbox_io_mount(szDrive, szDevice);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT xbox_io_remap(char *szMapping)
|
||||||
|
{
|
||||||
|
char szMap[32];
|
||||||
|
strlcpy(szMap, szMapping, sizeof(szMap));
|
||||||
|
|
||||||
|
char *pComma = strstr(szMap, ",");
|
||||||
|
|
||||||
|
if (pComma)
|
||||||
|
{
|
||||||
|
*pComma = 0;
|
||||||
|
|
||||||
|
// map device to drive letter
|
||||||
|
xbox_io_unmount(szMap);
|
||||||
|
xbox_io_mount(szMap, &pComma[1]);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT xbox_io_shutdown(void)
|
||||||
|
{
|
||||||
|
HalInitiateShutdown();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void get_environment_settings(int argc, char *argv[])
|
static void get_environment_settings(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef __XBOX_INTERNAL_H__
|
#ifndef __XBOX_INTERNAL_H__
|
||||||
#define __XBOX_INTERNAL_H__
|
#define __XBOX_INTERNAL_H__
|
||||||
|
|
||||||
|
#ifdef _XBOX1
|
||||||
|
|
||||||
#include <pshpack4.h>
|
#include <pshpack4.h>
|
||||||
|
|
||||||
// Do extern "C" for C++
|
// Do extern "C" for C++
|
||||||
|
@ -1368,6 +1370,6 @@ extern "C"
|
||||||
extern DWORD* LaunchDataPage;
|
extern DWORD* LaunchDataPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __XBOX_INTERNAL_H__
|
#endif // __XBOX_INTERNAL_H__
|
|
@ -1,132 +0,0 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "iosupport.h"
|
|
||||||
#include "undocumented.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define CTLCODE(DeviceType, Function, Method, Access) ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) )
|
|
||||||
#define FSCTL_DISMOUNT_VOLUME CTLCODE( FILE_DEVICE_FILE_SYSTEM, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS )
|
|
||||||
|
|
||||||
HRESULT xbox_io_mount(char *szDrive, char *szDevice)
|
|
||||||
{
|
|
||||||
char szSourceDevice[48];
|
|
||||||
char szDestinationDrive[16];
|
|
||||||
|
|
||||||
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
|
|
||||||
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
|
|
||||||
RARCH_LOG("xbox_io_mount() - source device: %s.\n", szSourceDevice);
|
|
||||||
RARCH_LOG("xbox_io_mount() - destination drive: %s.\n", szDestinationDrive);
|
|
||||||
|
|
||||||
STRING DeviceName =
|
|
||||||
{
|
|
||||||
strlen(szSourceDevice),
|
|
||||||
strlen(szSourceDevice) + 1,
|
|
||||||
szSourceDevice
|
|
||||||
};
|
|
||||||
|
|
||||||
STRING LinkName =
|
|
||||||
{
|
|
||||||
strlen(szDestinationDrive),
|
|
||||||
strlen(szDestinationDrive) + 1,
|
|
||||||
szDestinationDrive
|
|
||||||
};
|
|
||||||
|
|
||||||
IoCreateSymbolicLink(&LinkName, &DeviceName);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT xbox_io_unmount(char *szDrive)
|
|
||||||
{
|
|
||||||
char szDestinationDrive[16];
|
|
||||||
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
|
|
||||||
|
|
||||||
STRING LinkName =
|
|
||||||
{
|
|
||||||
strlen(szDestinationDrive),
|
|
||||||
strlen(szDestinationDrive) + 1,
|
|
||||||
szDestinationDrive
|
|
||||||
};
|
|
||||||
|
|
||||||
IoDeleteSymbolicLink(&LinkName);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT xbox_io_remount(char *szDrive, char *szDevice)
|
|
||||||
{
|
|
||||||
char szSourceDevice[48];
|
|
||||||
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
|
|
||||||
|
|
||||||
xbox_io_unmount(szDrive);
|
|
||||||
|
|
||||||
ANSI_STRING filename;
|
|
||||||
OBJECT_ATTRIBUTES attributes;
|
|
||||||
IO_STATUS_BLOCK status;
|
|
||||||
HANDLE hDevice;
|
|
||||||
NTSTATUS error;
|
|
||||||
DWORD dummy;
|
|
||||||
|
|
||||||
RtlInitAnsiString(&filename, szSourceDevice);
|
|
||||||
InitializeObjectAttributes(&attributes, &filename, OBJ_CASE_INSENSITIVE, NULL);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(error = NtCreateFile(&hDevice, GENERIC_READ |
|
|
||||||
SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attributes, &status, NULL, 0,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
|
|
||||||
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT)))
|
|
||||||
{
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DeviceIoControl(hDevice, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dummy, NULL))
|
|
||||||
{
|
|
||||||
CloseHandle(hDevice);
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hDevice);
|
|
||||||
xbox_io_mount(szDrive, szDevice);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT xbox_io_remap(char *szMapping)
|
|
||||||
{
|
|
||||||
char szMap[32];
|
|
||||||
strlcpy(szMap, szMapping, sizeof(szMap));
|
|
||||||
|
|
||||||
char *pComma = strstr(szMap, ",");
|
|
||||||
|
|
||||||
if (pComma)
|
|
||||||
{
|
|
||||||
*pComma = 0;
|
|
||||||
|
|
||||||
// map device to drive letter
|
|
||||||
xbox_io_unmount(szMap);
|
|
||||||
xbox_io_mount(szMap, &pComma[1]);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT xbox_io_shutdown(void)
|
|
||||||
{
|
|
||||||
HalInitiateShutdown();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _XBOX_IO_SUPPORT_H
|
|
||||||
#define _XBOX_IO_SUPPORT_H
|
|
||||||
|
|
||||||
#ifdef _XBOX
|
|
||||||
#include <xtl.h>
|
|
||||||
|
|
||||||
HRESULT xbox_io_mount(char *szdrive, char *szdevice);
|
|
||||||
HRESULT xbox_io_unmount(char *szdrive, char *szdevice);
|
|
||||||
HRESULT xbox_io_remount(char *szdrive, char *szdevice);
|
|
||||||
HRESULT xbox_io_remap(char *szmapping);
|
|
||||||
HRESULT xbox_io_shutdown(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
Before Width: | Height: | Size: 48 KiB |
Loading…
Reference in New Issue