From f53321b0ceed75de9ffe34e850e1c4e259153371 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 9 Jan 2013 05:24:31 +0100 Subject: [PATCH] (Xbox 1) Iosupport.cpp code integrated into platform_xdk.c --- console/griffin/griffin.c | 2 - frontend/platform/platform_xdk.c | 117 ++++++++++++++++ .../platform/platform_xdk.h | 4 +- xbox1/frontend/RetroLaunch/IoSupport.cpp | 132 ------------------ xbox1/frontend/RetroLaunch/IoSupport.h | 30 ---- xbox1/frontend/RetroLaunch/titleimage.bmp | Bin 49274 -> 0 bytes 6 files changed, 120 insertions(+), 165 deletions(-) rename xbox1/frontend/RetroLaunch/Undocumented.h => frontend/platform/platform_xdk.h (99%) delete mode 100644 xbox1/frontend/RetroLaunch/IoSupport.cpp delete mode 100644 xbox1/frontend/RetroLaunch/IoSupport.h delete mode 100644 xbox1/frontend/RetroLaunch/titleimage.bmp 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 a7d3e62ff64e363f86c23a41432ab7f99441e8cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49274 zcmeI51&|%Z7KRgC6WlEich^D}2@ePo3U{}lL4ySeTDVgoXyNV_!h@g>cU|1wo%g=I zfA-MTJ=1sg-npB*+3u>HJ=4>D`agg7^t9iWeuEzDQE`K~4&ZO_sK1^)rbEI#*rUhD zUiz!tb7|?@e_*>@^#531!2cze7)T5x1`-2_fy6*!ATf{_NDL$f5(9~W#6V&oF_0KY z3?v2;1BrpeKw=;LnP7roySI{EpK?t@Gw#nn|K$49Pd|O~$tTY|^UULqKmNoMPyDytJ@wR6AAR)E zx8HtCFy#Y*5z0l<`PyX8k3atS)?063FES#{M_TUuHWR$6H#t{ZQ>@eVueaOIU(5)ykcy!1k%lK0pb_S%{yFBDV|9y{TL6MBhe-VPo-Sp0X<`bYNK#}pgg z`X|$5Jny{oPF?}xmYxN|L;0U{(n<4Dcl~d;;f9d^MgS|9wMMo!KXxL9Z_0)NsyZ*cHzB?Kei>n0rAbZN2E-|j@=<&8$tO=Y-KfRbF598J$Rdkm!axsB24)5rU7kS7Oq!nl z3opEYf${IJo>KV`K2uMfp5pE1n{VD@k3B-RGkum`dg;RtKb+2bYisMh_uk95>ALH# z6Aa7HI#JabJ>>kZyY9OB>Z`B6{`vI4=>2P*I5 zv(G*YHWCsN507^{`|PvRH>YF1-+udTv&}YJZ@u-Vn{Im8VTZl)$}69J_8A!(rqcO7 zvWs*foUa=r41mOKx7~I-?X=Sd8*DJ^th1WEmJyi(H3NFWJgwg-bc(KDe);A1-+$NO z&q50=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