diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 38ab8091a4..fb1507b7ef 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -412,8 +412,6 @@ MENU #if defined(_XBOX360) #include "../../360/frontend-xdk/menu.cpp" -#elif defined(_XBOX1) -#include "../../xbox1/frontend/RetroLaunch/IoSupport.cpp" #endif #ifdef __cplusplus diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 3194ef53a0..95a466784f 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -20,6 +20,7 @@ #include #include +#include "platform_xdk.h" #include "platform_inl.h" #if defined(_XBOX360) @@ -145,6 +146,122 @@ static void salamander_init_settings(void) #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[]) { HRESULT ret; diff --git a/xbox1/frontend/RetroLaunch/Undocumented.h b/frontend/platform/platform_xdk.h similarity index 99% rename from xbox1/frontend/RetroLaunch/Undocumented.h rename to frontend/platform/platform_xdk.h index 927280241d..ca97a440ca 100644 --- a/xbox1/frontend/RetroLaunch/Undocumented.h +++ b/frontend/platform/platform_xdk.h @@ -10,6 +10,8 @@ #ifndef __XBOX_INTERNAL_H__ #define __XBOX_INTERNAL_H__ +#ifdef _XBOX1 + #include // Do extern "C" for C++ @@ -1368,6 +1370,6 @@ extern "C" extern DWORD* LaunchDataPage; } - +#endif #endif // __XBOX_INTERNAL_H__ diff --git a/xbox1/frontend/RetroLaunch/IoSupport.cpp b/xbox1/frontend/RetroLaunch/IoSupport.cpp deleted file mode 100644 index 2e9984fd93..0000000000 --- a/xbox1/frontend/RetroLaunch/IoSupport.cpp +++ /dev/null @@ -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 . -*/ - -#include "iosupport.h" -#include "undocumented.h" - -#include - -#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; -} diff --git a/xbox1/frontend/RetroLaunch/IoSupport.h b/xbox1/frontend/RetroLaunch/IoSupport.h deleted file mode 100644 index 084277c7e9..0000000000 --- a/xbox1/frontend/RetroLaunch/IoSupport.h +++ /dev/null @@ -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 . -*/ - -#ifndef _XBOX_IO_SUPPORT_H -#define _XBOX_IO_SUPPORT_H - -#ifdef _XBOX -#include - -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 diff --git a/xbox1/frontend/RetroLaunch/titleimage.bmp b/xbox1/frontend/RetroLaunch/titleimage.bmp deleted file mode 100644 index a7d3e62ff6..0000000000 Binary files a/xbox1/frontend/RetroLaunch/titleimage.bmp and /dev/null differ