diff --git a/plugins/sdcafiine/Makefile b/plugins/sdcafiine/Makefile
index 4d2a95a..e86e51e 100644
--- a/plugins/sdcafiine/Makefile
+++ b/plugins/sdcafiine/Makefile
@@ -35,8 +35,8 @@ TARGET := $(notdir $(CURDIR)).mod
BUILD := build
SOURCES := src \
src/common \
- src/fs_wrapper \
- src/utils
+ src/myutils \
+ src/myfs
DATA :=
@@ -71,7 +71,7 @@ CFLAGS += $(COMMON_CFLAGS) -x c -std=c11
# -x c: compile as c++ code
# -std=gnu++11: use the c++11 standard
-CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
+CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11 -D_GNU_SOURCE
ifeq ($(DO_LOGGING), 1)
CFLAGS += -D__LOGGING__
@@ -99,7 +99,7 @@ MAKEFLAGS += --no-print-directory
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
-LIBS := -lutils -ldynamiclibs -liosuhax
+LIBS := -liosuhax -lfswrapper -lutils -ldynamiclibs
#
#---------------------------------------------------------------------------------
@@ -150,7 +150,8 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \
- -I$(PORTLIBS)/include/libutils -I$(WUPSDIR)/include
+ -I$(PORTLIBS)/include/libutils -I$(PORTLIBS)/include/libfswrapper \
+ -I$(WUPSDIR)/include
#---------------------------------------------------------------------------------
# build a list of library paths
diff --git a/plugins/sdcafiine/sdcafiine.cbp b/plugins/sdcafiine/sdcafiine.cbp
deleted file mode 100644
index 4d75b71..0000000
--- a/plugins/sdcafiine/sdcafiine.cbp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/sdcafiine/src/common/retain_vars.cpp b/plugins/sdcafiine/src/common/retain_vars.cpp
index 1851dd6..f37e94f 100644
--- a/plugins/sdcafiine/src/common/retain_vars.cpp
+++ b/plugins/sdcafiine/src/common/retain_vars.cpp
@@ -9,6 +9,3 @@ char gModFolder[FS_MAX_ENTNAME_SIZE] __attribute__((section(".data")));
void * ntfs_mounts __attribute__((section(".data"))) = NULL;
int ntfs_mount_count __attribute__((section(".data"))) = 0;
-
-vc_vector* g_dirhandles = NULL;
-vc_vector* g_filehandles = NULL;
diff --git a/plugins/sdcafiine/src/common/retain_vars.h b/plugins/sdcafiine/src/common/retain_vars.h
index c5c59fb..7a05e55 100644
--- a/plugins/sdcafiine/src/common/retain_vars.h
+++ b/plugins/sdcafiine/src/common/retain_vars.h
@@ -2,7 +2,6 @@
#define RETAINS_VARS_H_
#include
#include
-#include "utils/vc_vector.h"
#define ASYNC_RESULT_CACHE_SIZE 50
#define FS_QUEUE_MESSAGE_COUNT 5
@@ -17,7 +16,4 @@ extern char gModFolder[FS_MAX_ENTNAME_SIZE];
extern void * ntfs_mounts;
extern int ntfs_mount_count;
-extern vc_vector* g_dirhandles;
-extern vc_vector* g_filehandles;
-
#endif // RETAINS_VARS_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.cpp b/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.cpp
deleted file mode 100644
index 1ff4d61..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-#include "FileReplacerUtils.h"
-#include "fs_async_wrapper.h"
-#include "common/retain_vars.h"
-
-OSMessageQueue lfFSQueue __attribute__((section(".data")));
-OSMessage lfFSQueueMessages[FS_QUEUE_MESSAGE_COUNT] __attribute__((section(".data")));
-
-FSAsyncResult lfAsyncResultCache[ASYNC_RESULT_CACHE_SIZE] __attribute__((section(".data")));
-u8 lfAsyncResultCacheLock __attribute__((section(".data"))) = 0;
-u8 lfAsyncResultCacheCur __attribute__((section(".data"))) = 0;
-
-int setErrorFlag(int error){
- int result = error;
- if(error == -1){
- result = CHECKED_WITH_ALL_ERRORS;
- }else{
- result |= CHECKED_MASK;
- }
- return result;
-}
-
-int checkErrorFlag(int * error){
- if(*error == CHECKED_WITH_ALL_ERRORS){
- *error = -1;
- return true;
- }else if ((*error & CHECKED_MASK) == CHECKED_MASK){
- *error &= ~CHECKED_MASK;
- return true;
- }
- return false;
-}
-
-
-void addFileHandleInternal(int handle){
- vc_vector_push_back(g_filehandles, &handle);
-}
-
-void removeFileHandleInternal(int handle){
- int index = 0;
- for (void* i = vc_vector_begin(g_filehandles);i != vc_vector_end(g_filehandles); i = vc_vector_next(g_filehandles, i)) {
- int val = *(int*)i;
- if(val == handle){
- vc_vector_erase(g_filehandles,index);
- return;
- }
- index++;
- }
-}
-
-bool hasFileHandleInternal(int handle){
- for (void* i = vc_vector_begin(g_filehandles);i != vc_vector_end(g_filehandles); i = vc_vector_next(g_filehandles, i)) {
- if(*(int*)i == handle){
- return true;
- }
- }
- return false;
-}
-
-void addDirHandleInternal(int handle){
- vc_vector_push_back(g_dirhandles, &handle);
-}
-
-void removeDirHandleInternal(int handle){
- int index = 0;
- for (void* i = vc_vector_begin(g_dirhandles);i != vc_vector_end(g_dirhandles); i = vc_vector_next(g_dirhandles, i)) {
- int val = *(int*)i;
- if(val == handle){
- vc_vector_erase(g_dirhandles,index);
- return;
- }
- index++;
- }
-}
-
-bool hasDirHandleInternal(int handle){
- for (void* i = vc_vector_begin(g_dirhandles);i != vc_vector_end(g_dirhandles); i = vc_vector_next(g_dirhandles, i)) {
- if(*(int*)i == handle){
- return true;
- }
- }
- return false;
-}
diff --git a/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.h b/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.h
deleted file mode 100644
index 89d1c4f..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/FileReplacerUtils.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef __FILE_REPLACER_UTILS_H_
-#define __FILE_REPLACER_UTILS_H_
-
-#include
-#include
-#include
-#include "utils/vc_vector.h"
-
-#include "fs_retain_vars.h"
-
-#define CHECKED_WITH_ALL_ERRORS 0x10000
-#define CHECKED_MASK 0x01000
-
-#define FS_WRAPPER_DEBUG_LOG 0
-
-#define USE_OS_FS_FUNCTION -1337
-
-
-/**
-Returns a modified error flag.
-This will be used to save the information if a file/handle was already
-tried to be patched.
-The non-async function internally call the async functions, and this way
-we avoid testing it twice.
-If the result contains our mask, we just straight to the OS functions.
-**/
-int setErrorFlag(int error);
-
-/**
-Check if we already checked the file/handle.
-Returns true if it was already checked (+ revert the error)
-Return false if it should be (tried) to be patched.
-**/
-int checkErrorFlag(int * error);
-
-void addFileHandleInternal(int handle);
-
-void removeFileHandleInternal(int handle);
-
-bool hasFileHandleInternal(int handle);
-
-void addDirHandleInternal(int handle);
-
-void removeDirHandleInternal(int handle);
-
-bool hasDirHandleInternal(int handle);
-#endif // __FILE_REPLACER_UTILS_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.cpp b/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.cpp
deleted file mode 100644
index c431dfd..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-
-#include "fs_async_wrapper.h"
-
-//Wii U fails to allocate memory if we do the functions async. =/
-#define DO_REAL_ASYNC 0
-
-static int doFallback(CustomAsyncParamWrapper params){
- if(params.fallbackFunction != NULL){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Calling the fallback function %08X\n",params.fallbackFunction); }
- return ((FSAsyncFallback)params.fallbackFunction)(params.fallbackParams);
- }
-
- if(params.params.needToFreePath){
- free((void*)params.params.params.path);
- }
-
- DEBUG_FUNCTION_LINE("No fallback function provided\n");
- //OSFatal("No fallback given."); //We don't need to free stuff, because we'll (want to) crash anyway.
-
- return FS_STATUS_FATAL_ERROR;
-}
-
-static int sendAsyncResult(CustomAsyncParamWrapper in, int result){
- //FileReplacerUtils::sendAsyncCommand(in.params.params.pClient, in.params.params.pCmd, in.params.params.asyncParams, result);
-
- if(in.params.needToFreePath){
- free((void*)in.params.params.path);
- }
-
- return FS_STATUS_OK;
-}
-
-static int fs_wrapper_async_template(CustomAsyncParam params,FSAsyncCustomCallback callback, FSAsyncFallback fallback, void * fallbackParams){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called!\n"); }
-
- CustomAsyncParamWrapper wrapper;
- memset(&wrapper,0,sizeof(CustomAsyncParamWrapper));
-
- wrapper.params = params;
-
- wrapper.fallbackFunction = fallback;
- wrapper.fallbackParams = (void*)fallbackParams;
-
- if(!DO_REAL_ASYNC){
- return callback(wrapper);
- }
-
- //TODO:!
-
- /*OSMessage message;
- message.message = (u32) callback;
- message.data0 = (u32) &wrapper;
-
-
- //FileReplacerUtils::addFSQueueMSG(&message);*/
-
- return FS_STATUS_OK;
-}
-
-int fs_wrapper_FSCloseFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSCloseFile(p->handle)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSGetPosFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSGetPosFile(p->handle,p->posPtr)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSGetStatAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSGetStat(p->path,p->stats)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSGetStatFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSGetStatFile(p->handle,p->stats)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSIsEofAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSIsEof(p->handle)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSOpenFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSOpenFile(p->path,p->mode,p->handlePtr)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSReadFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSReadFile(p->handle,p->buffer,p->size,p->count)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSReadFileWithPosAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSReadFileWithPos(p->buffer,p->size,p->count,p->pos,p->handle)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-int fs_wrapper_FSSetPosFileAsyncCallback(CustomAsyncParamWrapper params){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! params: %08X \n",params); }
- //if(params == NULL){ DEBUG_FUNCTION_LINE("!!!WARNING: Given parameter was NULL\n"); }
-
- OSAsyncParamWrapper * p = &(params.params.params);
-
- int result = USE_OS_FS_FUNCTION;
- if((result = fs_wrapper_FSSetPosFile(p->handle,p->pos)) != USE_OS_FS_FUNCTION){
- return sendAsyncResult(params,result);
- }
-
- return doFallback(params);
-}
-
-DEFINE_FS_WRAPPER(FSCloseFileAsync)
-DEFINE_FS_WRAPPER(FSGetStatAsync)
-DEFINE_FS_WRAPPER(FSGetStatFileAsync)
-DEFINE_FS_WRAPPER(FSGetPosFileAsync)
-DEFINE_FS_WRAPPER(FSIsEofAsync)
-DEFINE_FS_WRAPPER(FSOpenFileAsync)
-DEFINE_FS_WRAPPER(FSReadFileAsync)
-DEFINE_FS_WRAPPER(FSReadFileWithPosAsync)
-DEFINE_FS_WRAPPER(FSSetPosFileAsync)
-
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.h b/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.h
deleted file mode 100644
index 21d6a09..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_async_wrapper.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef __FS_ASYNC_WRAPPER_H_
-#define __FS_ASYNC_WRAPPER_H_
-
-#include "FileReplacerUtils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include
-#include
-
-#include "fs_sync_wrapper.h"
-
-typedef int (*FSAsyncFallback)(void * params);
-
-typedef struct OSAsyncParamWrapper_{
- FSClient *pClient;
- FSCmdBlock *pCmd;
- const char *path;
- const char *mode;
- FSStat * stats;
- void * buffer;
- int handle;
- int size;
- int count;
- int pos;
- int flag;
- int *handlePtr;
- int *posPtr;
- int error;
- FSAsyncParams * asyncParams;
-} OSAsyncParamWrapper;
-
-typedef struct FallbackParamWrapper_{
- OSAsyncParamWrapper params;
- void * realFunctionAddress;
-} FallbackParamWrapper;
-
-typedef struct CustomAsyncParam_{
- OSAsyncParamWrapper params;
- bool needToFreePath;
-} CustomAsyncParam;
-
-typedef struct CustomAsyncParamWrapper_{
- CustomAsyncParam params;
- FSAsyncFallback fallbackFunction;
- void * fallbackParams;
-} CustomAsyncParamWrapper;
-
-typedef int (*FSAsyncCustomCallback)(CustomAsyncParamWrapper params);
-
-
-#define DEFINE_FS_WRAPPER(name) \
- int fs_wrapper_##name##Ex(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams){\
- return fs_wrapper_async_template(params,fs_wrapper_##name##Callback,fallback,fallbackParams);\
- }\
- int fs_wrapper_##name(CustomAsyncParam params){ \
- return fs_wrapper_##name##Ex(params,NULL,NULL);\
- }
-
-#define DECLARE_FS_WRAPPER(name) \
- int fs_wrapper_##name##Ex(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);\
- int fs_wrapper_##name(CustomAsyncParam params);
-
- int fs_wrapper_FSCloseFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSCloseFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSGetStatAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSGetStatAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSGetStatFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSGetStatFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSGetPosFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSGetPosFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSIsEofAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSIsEofAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSOpenFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSOpenFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSReadFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSReadFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSReadFileWithPosAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSReadFileWithPosAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
- int fs_wrapper_FSSetPosFileAsync(CustomAsyncParam params);
-
- int fs_wrapper_FSSetPosFileAsyncEx(CustomAsyncParam params, FSAsyncFallback fallback, void * fallbackParams);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __FS_ASYNC_WRAPPER_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.cpp b/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.cpp
deleted file mode 100644
index b7a5461..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#include
-
-#include "fs_default_os_wrapper.h"
-
-int fs_default_os_wrapper_FSCloseFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams * asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.handle = fd;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSCloseFileAsyncEx(params,&fallbackFSCloseFileAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSGetPosFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int *pos, int error, FSAsyncParams * asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.handle = fd;
- paramWrapper.params.posPtr = pos;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSGetPosFileAsyncEx(params,fallbackFSGetPosFileAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSGetStatAsync(const char *libPath, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSStat *stats, int error, FSAsyncParams * asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.path = (char*)path;
- paramWrapper.params.stats = stats;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
- params.params.path = libPath; // Use modified path.
- params.needToFreePath = 1;
-
- return fs_wrapper_FSGetPosFileAsyncEx(params,fallbackFSGetStatAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSGetStatFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, FSStat * stats, int error, FSAsyncParams * asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.handle = fd;
- paramWrapper.params.stats = stats;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSGetStatFileAsyncEx(params,fallbackFSGetStatFileAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSIsEofAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams * asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.handle = fd;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSIsEofAsyncEx(params,fallbackFSIsEofAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSOpenFileAsync(const char *libpath, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error, FSAsyncParams *asyncParams, void * realAddress){
-
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.path = path;
- paramWrapper.params.mode = mode;
- paramWrapper.params.handlePtr = handle;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
- params.params.path = libpath; // Use modified path.
- params.needToFreePath = 1;
-
- return fs_wrapper_FSOpenFileAsyncEx(params,fallbackFSOpenFileAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSReadFileAsync(FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, int fd, int flag, int error, FSAsyncParams *asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.buffer = buffer;
- paramWrapper.params.size = size;
- paramWrapper.params.count = count;
- paramWrapper.params.handle = fd;
- paramWrapper.params.flag = flag;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSReadFileAsyncEx(params,fallbackFSReadFileAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSReadFileWithPosAsync(FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, u32 pos, int fd, int flag, int error, FSAsyncParams *asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.buffer = buffer;
- paramWrapper.params.size = size;
- paramWrapper.params.count = count;
- paramWrapper.params.pos = pos;
- paramWrapper.params.handle = fd;
- paramWrapper.params.flag = flag;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSReadFileWithPosAsyncEx(params,fallbackFSReadFileWithPosAsync,¶mWrapper);
-}
-
-int fs_default_os_wrapper_FSSetPosFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int handle, u32 pos, int error, FSAsyncParams *asyncParams, void * realAddress){
- FallbackParamWrapper paramWrapper;
- memset(¶mWrapper,0,sizeof(FallbackParamWrapper));
-
- CustomAsyncParam params;
- memset(¶ms,0,sizeof(CustomAsyncParam));
-
- paramWrapper.params.pClient = pClient;
- paramWrapper.params.pCmd = pCmd;
- paramWrapper.params.handle = handle;
- paramWrapper.params.pos = pos;
- paramWrapper.params.error = error;
- paramWrapper.params.asyncParams = asyncParams;
-
- paramWrapper.realFunctionAddress = (void*) realAddress;
-
- params.params = paramWrapper.params;
-
- return fs_wrapper_FSSetPosFileAsyncEx(params,fallbackFSSetPosFileAsync,¶mWrapper);
-}
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.h b/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.h
deleted file mode 100644
index 3d8c4a5..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_default_os_wrapper.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef __FS_DEFAULT_OS_WRAPPER_H_
-#define __FS_DEFAULT_OS_WRAPPER_H_
-
-#include "fs_async_wrapper.h"
-#include "fs_sync_wrapper.h"
-#include "fs_wrapper_utils.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int fs_default_os_wrapper_FSCloseFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams * asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSGetPosFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int *pos, int error, FSAsyncParams * asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSGetStatAsync(const char *libpath, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSStat *stats, int error, FSAsyncParams * asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSGetStatFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, FSStat * stats, int error, FSAsyncParams * asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSIsEofAsync(FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams * asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSOpenFileAsync(const char *libpath, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error, FSAsyncParams *asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSReadFileAsync(FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, int fd, int flag, int error, FSAsyncParams *asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSReadFileWithPosAsync(FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, u32 pos, int fd, int flag, int error, FSAsyncParams *asyncParams, void * realAddress);
-int fs_default_os_wrapper_FSSetPosFileAsync(FSClient *pClient, FSCmdBlock *pCmd, int handle, u32 pos, int error, FSAsyncParams *asyncParams, void * realAddress);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __FS_DEFAULT_OS_WRAPPER_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.cpp b/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.cpp
deleted file mode 100644
index 142c859..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-#include
-#include "fs_retain_vars.h"
-
-OSMessageQueue fsFSQueue __attribute__((section(".data")));
-OSMessage fsFSQueueMessages[FS_QUEUE_MESSAGE_COUNT] __attribute__((section(".data")));
-
-FSAsyncResult fsAsyncResultCache[ASYNC_RESULT_CACHE_SIZE] __attribute__((section(".data")));
-u8 fsAsyncResultCacheLock __attribute__((section(".data"))) = 0;
-u8 fsAsyncResultCacheCur __attribute__((section(".data"))) = 0;
-
-u32 global_owner_id __attribute__((section(".data"))) = 0;
-u32 global_group_id __attribute__((section(".data"))) = 0;
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.h b/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.h
deleted file mode 100644
index 0fe7fac..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_retain_vars.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef FS_RETAINS_VARS_H_
-#define FS_RETAINS_VARS_H_
-
-#include
-#include
-
-#define ASYNC_RESULT_CACHE_SIZE 50
-#define FS_QUEUE_MESSAGE_COUNT 5
-
-extern OSMessageQueue fsFSQueue __attribute__((section(".data")));
-extern OSMessage fsFSQueueMessages[FS_QUEUE_MESSAGE_COUNT] __attribute__((section(".data")));
-
-extern FSAsyncResult fsAsyncResultCache[ASYNC_RESULT_CACHE_SIZE];
-
-extern u8 fsAsyncResultCacheLock;
-extern u8 fsAsyncResultCacheCur;
-
-extern u32 global_owner_id;
-extern u32 global_group_id;
-
-#endif // FS_RETAINS_VARS_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.cpp b/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.cpp
deleted file mode 100644
index 3c114fe..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-
-#include "fs_sync_wrapper.h"
-#include "fs_retain_vars.h"
-
-int fs_wrapper_FSCloseFile(int handle){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! for handle: %08X \n",handle); }
- if(hasFileHandleInternal(handle)){
- removeFileHandleInternal(handle);
- close(handle);
- DEBUG_FUNCTION_LINE("closed handle %08X\n",handle);
- return FS_STATUS_OK;
- }
- return USE_OS_FS_FUNCTION;
-}
-
-int fs_wrapper_FSGetPosFile(int handle,int * pos){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! for handle: %08X \n",handle); }
- if(hasFileHandleInternal(handle)){
- off_t currentPos = lseek(handle, (off_t)0, SEEK_CUR);
- *pos = currentPos;
-
- DEBUG_FUNCTION_LINE("pos %08X for handle %08X\n",*pos,handle);
-
- return FS_STATUS_OK;
- }
- return USE_OS_FS_FUNCTION;
-}
-
-void setCommonStats(FSStat * stats){
- if(stats == NULL){
- DEBUG_FUNCTION_LINE("STATS EMPTY\n");
- }
- stats->permission = 0x00000400;
- stats->owner_id = global_owner_id;
- stats->group_id = global_group_id;
- stats->flag |= 0x08000000;
- stats->flag |= 0x04000000;
- stats->ctime = 0x0003E8C3E677A740L;
- stats->mtime = 0x0003F8AABBEAFBC0L;
-}
-
-int fs_wrapper_FSGetStat(const char * path, FSStat * stats){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called!\n"); }
- int result = USE_OS_FS_FUNCTION;
- if(path != NULL){
- DEBUG_FUNCTION_LINE("Searching for path %s\n",path);
- struct stat path_stat;
- if(stat(path, &path_stat) < 0){
- result = USE_OS_FS_FUNCTION;
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("failed for path %s\n",path); }
- }else{
- DEBUG_FUNCTION_LINE("success! path %s\n",path);
- stats->flag = 0;
- if(S_ISDIR(path_stat.st_mode)){
- stats->flag |= 0x80000000;
- DEBUG_FUNCTION_LINE("set stats->flag: DIR\n");
- }else{
- stats->size = path_stat.st_size;
- DEBUG_FUNCTION_LINE("stats->size: %08X\n",stats->size);
- }
-
- setCommonStats(stats);
-
- result = FS_STATUS_OK;
- }
- }
- return result;
-}
-
-int fs_wrapper_FSGetStatFile(int handle, FSStat * stats){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! for handle: %08X\n",handle); }
- if(hasFileHandleInternal(handle)){
- struct stat path_stat;
- if(fstat(handle, &path_stat) < 0){
- DEBUG_FUNCTION_LINE("failed! handle: %08X\n",handle);
- return -1;
- }
-
- stats->size = path_stat.st_size;
- stats->flag = 0;
-
- setCommonStats(stats);
-
- DEBUG_FUNCTION_LINE("success! handle: %08X size: %08X\n",handle,stats->size);
-
- return FS_STATUS_OK;
- }
- return USE_OS_FS_FUNCTION;
-}
-
-int fs_wrapper_FSIsEof(int handle){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! handle: %08X\n",handle); }
- int result = USE_OS_FS_FUNCTION;
- if(hasFileHandleInternal(handle)){
- off_t currentPos = lseek(handle, (off_t) 0, SEEK_CUR);
- off_t endPos = lseek(handle, (off_t) 0, SEEK_END);
-
- if(currentPos == endPos){
- result = FS_STATUS_EOF;
- }else{
- lseek(handle, currentPos, SEEK_CUR);
- result = FS_STATUS_OK;
- }
- DEBUG_FUNCTION_LINE("handle: %08X result: %08X\n",handle,result);
- }
- return result;
-}
-
-int fs_wrapper_FSOpenFile(const char * path, const char * mode, int * handle){
- int result = USE_OS_FS_FUNCTION;
- if(path != NULL){
- result = USE_OS_FS_FUNCTION;
- DEBUG_FUNCTION_LINE("Searching for path %s\n",path);
- int fd = open(path,O_RDONLY); //TODO: remove hardcoded mode.
- if(fd != -1){
- DEBUG_FUNCTION_LINE("opened path: %s handle: %08X\n",path,fd);
- addFileHandleInternal(fd);
- *handle = fd;
- result = FS_STATUS_OK;
-
- }else{
- if(FS_WRAPPER_DEBUG_LOG){DEBUG_FUNCTION_LINE("failed path: %s\n",path);}
- }
- }
-
- return result;
-}
-
-#define MAXIMUM_READ_CHUNK 1024*1024
-
-static int readIntoBuffer(int handle,void *buffer,size_t size, size_t count){
- int sizeToRead = size*count;
- void * newBuffer = buffer;
- int curResult = -1;
- int totalSize = 0;
- int toRead = 0;
- while(sizeToRead > 0){
- if(sizeToRead < MAXIMUM_READ_CHUNK){
- toRead = sizeToRead;
- }else{
- toRead = MAXIMUM_READ_CHUNK;
- }
- curResult = read(handle, newBuffer,toRead);
- if(curResult < 0){
- DEBUG_FUNCTION_LINE("Error: Reading %08X bytes from handle %08X. result %08X \n",size*count,handle,curResult);
- return -1;
- }
- if(curResult == 0 ){
- //EOF
- break;
- }
- newBuffer = (void*)(((u32)newBuffer) + curResult);
- totalSize += curResult;
- sizeToRead -= curResult;
- if(sizeToRead > 0){
- DEBUG_FUNCTION_LINE("Reading. missing %08X bytes\n",sizeToRead);
- }
- }
- DEBUG_FUNCTION_LINE("Success: Read %08X bytes from handle %08X. result %08X \n",size*count,handle,totalSize);
- return totalSize;
-}
-
-int fs_wrapper_FSReadFile(int handle,void *buffer,size_t size, size_t count){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! for handle: %08X \n",handle); }
- int result = USE_OS_FS_FUNCTION;
- if(hasFileHandleInternal(handle)){
- result = readIntoBuffer(handle,buffer,size,count);
- }
- return result;
-}
-
-int fs_wrapper_FSReadFileWithPos(void *buffer, size_t size, size_t count, u32 pos, int handle){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! \n"); }
- int result = USE_OS_FS_FUNCTION;
- if(hasFileHandleInternal(handle)){
- off_t newOffset = -1;
- newOffset = lseek(handle, (off_t)pos, SEEK_SET);
- if(newOffset == (off_t)pos){
- result = readIntoBuffer(handle, buffer,size,count);
- DEBUG_FUNCTION_LINE("Reading %08X bytes from handle %08X at pos %08X. result %08X \n",size*count,handle,pos,result);
- }else{
- return -1;
- }
- }
- return result;
-}
-
-int fs_wrapper_FSSetPosFile(int handle,u32 pos){
- if(FS_WRAPPER_DEBUG_LOG){ DEBUG_FUNCTION_LINE("Called! \n"); }
- int result = USE_OS_FS_FUNCTION;
- if(hasFileHandleInternal(handle)){
- off_t newOffset = -1;
- result = -1;
- newOffset = lseek(handle, (off_t)pos, SEEK_SET);
- if(newOffset == (off_t)pos){
- result = FS_STATUS_OK;
- DEBUG_FUNCTION_LINE("Set position to %08X for handle %08X\n",pos,handle);
- }else{
- DEBUG_FUNCTION_LINE("Failed set position to %08X for handle %08X\n",pos,handle);
- return FS_STATUS_OK;
- }
- }
- return result;
-}
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.h b/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.h
deleted file mode 100644
index 1f95939..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_sync_wrapper.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef __FS_SYNC_WRAPPER_H_
-#define __FS_SYNC_WRAPPER_H_
-
-#include "FileReplacerUtils.h"
-
-#include
-#include
-#include
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int fs_wrapper_FSCloseFile(int handle);
-
-int fs_wrapper_FSGetPosFile(int handle,int * pos);
-
-int fs_wrapper_FSGetStat(const char * path, FSStat * stats);
-
-int fs_wrapper_FSGetStatFile(int handle, FSStat * stats);
-
-int fs_wrapper_FSIsEof(int handle);
-
-int fs_wrapper_FSOpenFile(const char * path, const char * mode, int * handle);
-
-int fs_wrapper_FSReadFile(int handle,void *buffer,size_t size,size_t count);
-
-int fs_wrapper_FSReadFileWithPos(void *buffer, size_t size, size_t count, u32 pos, int handle);
-
-int fs_wrapper_FSSetPosFile(int handle,u32 pos);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __FS_SYNC_WRAPPER_H_
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.cpp b/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.cpp
deleted file mode 100644
index cf6b64b..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-#include
-
-#include "fs_wrapper_utils.h"
-#include "fs_async_wrapper.h"
-
-typedef int (*FallbackHelperInternal)(FallbackParamWrapper*, OSAsyncParamWrapper *);
-
-static int fallbackCaller(FallbackHelperInternal _function, void * fallbackparams){
- FallbackParamWrapper * paramsWrapper = (FallbackParamWrapper *)fallbackparams;
- OSAsyncParamWrapper * params = &(paramsWrapper->params);
-
- if(paramsWrapper->realFunctionAddress == NULL){ return FS_STATUS_FATAL_ERROR; } // OSFatal("paramsWrapper->realFunctionAddress was NULL;");}
- return _function(paramsWrapper,params);
-}
-
-static int fallbackFSCloseFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSCloseFileAsyncCallback)(FSClient *, FSCmdBlock *, int, int, FSAsyncParams *);
- real_FSCloseFileAsyncCallback = (int(*)(FSClient *, FSCmdBlock *, int, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSCloseFileAsyncCallback(params->pClient, params->pCmd, params->handle, params->error,params->asyncParams);
- return res;
-}
-
-static int fallbackFSGetPosFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSGetPosFileAsyncFunc)(FSClient *, FSCmdBlock *, int, int *, int, FSAsyncParams *);
- real_FSGetPosFileAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, int, int *, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSGetPosFileAsyncFunc(params->pClient, params->pCmd, params->handle, params->posPtr, params->error,params->asyncParams);
- return res;
-}
-
-static int fallbackFSGetStatAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSGetStatAsyncFunc)(FSClient *, FSCmdBlock *, const char *, FSStat *, int, FSAsyncParams *);
- real_FSGetStatAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, const char *, FSStat *, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSGetStatAsyncFunc(params->pClient, params->pCmd, params->path, params->stats, params->error,params->asyncParams);
- return res;
-}
-
-static int fallbackFSGetStatFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSGetStatFileAsyncFunc)(FSClient *, FSCmdBlock *, int, FSStat *, int, FSAsyncParams *);
- real_FSGetStatFileAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, int, FSStat *, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSGetStatFileAsyncFunc(params->pClient, params->pCmd, params->handle, params->stats, params->error,params->asyncParams);
- return res;
-}
-
-static int fallbackFSIsEofAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSIsEofAsyncFunc)(FSClient *, FSCmdBlock *, int, int, FSAsyncParams *);
- real_FSIsEofAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, int, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSIsEofAsyncFunc(params->pClient, params->pCmd, params->handle, params->error,params->asyncParams);
- return res;
-}
-
-static int fallbackFSOpenFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSOpenFileAsyncCallback)(FSClient *, FSCmdBlock *, const char *, const char *, int *, int, FSAsyncParams *);
- real_FSOpenFileAsyncCallback = (int(*)(FSClient *, FSCmdBlock *, const char *, const char *, int *, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSOpenFileAsyncCallback(params->pClient, params->pCmd, params->path, params->mode, params->handlePtr, params->error, params->asyncParams);
- return res;
-}
-
-static int fallbackFSReadFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSReadFileAsyncFunc)(FSClient *, FSCmdBlock *, void *, int, int, int, int, int, FSAsyncParams *);
- real_FSReadFileAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, void *, int, int, int, int, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSReadFileAsyncFunc(params->pClient, params->pCmd, params->buffer, params->size, params->count, params->handle, params->flag, params->error, params->asyncParams);
- return res;
-}
-
-static int fallbackFSReadFileWithPosAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSReadFileWithPosAsyncFunc)(FSClient *, FSCmdBlock *, void *, int, int, u32, int, int, int, FSAsyncParams *);
- real_FSReadFileWithPosAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, void *, int, int, u32, int, int, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSReadFileWithPosAsyncFunc(params->pClient, params->pCmd, params->buffer, params->size, params->count, params->pos, params->handle, params->flag, params->error, params->asyncParams);
- return res;
-}
-
-static int fallbackFSSetPosFileAsyncInternal(FallbackParamWrapper * paramsWrapper, OSAsyncParamWrapper * params){
- int (*real_FSSetPosFileAsyncFunc)(FSClient *, FSCmdBlock *, int, u32, int, FSAsyncParams *);
- real_FSSetPosFileAsyncFunc = (int(*)(FSClient *, FSCmdBlock *, int, u32, int, FSAsyncParams *)) paramsWrapper->realFunctionAddress;
- int res = real_FSSetPosFileAsyncFunc(params->pClient, params->pCmd, params->handle, params->pos, params->error, params->asyncParams);
- return res;
-}
-
-#define DEFINE_FS_FALLBACK_CALLER(name) \
- int fallback##name(void * fallbackparams){\
- return fallbackCaller(fallback##name##Internal,fallbackparams);\
- }
-
-DEFINE_FS_FALLBACK_CALLER(FSCloseFileAsync)
-DEFINE_FS_FALLBACK_CALLER(FSGetStatAsync)
-DEFINE_FS_FALLBACK_CALLER(FSGetStatFileAsync)
-DEFINE_FS_FALLBACK_CALLER(FSGetPosFileAsync)
-DEFINE_FS_FALLBACK_CALLER(FSIsEofAsync)
-DEFINE_FS_FALLBACK_CALLER(FSOpenFileAsync)
-DEFINE_FS_FALLBACK_CALLER(FSReadFileAsync)
-DEFINE_FS_FALLBACK_CALLER(FSReadFileWithPosAsync)
-DEFINE_FS_FALLBACK_CALLER(FSSetPosFileAsync)
diff --git a/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.h b/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.h
deleted file mode 100644
index 3ba2a11..0000000
--- a/plugins/sdcafiine/src/fs_wrapper/fs_wrapper_utils.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
- * Copyright (C) 2017 Maschell
- *
- * This program 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 Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program. If not, see .
- ****************************************************************************/
-
-#ifndef __FS_WRAPPER_UTILS_H_
-#define __FS_WRAPPER_UTILS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include
-#include
-
- int fallbackFSCloseFileAsync(void * fallbackparams);
-
- int fallbackFSGetPosFileAsync(void * fallbackparams);
-
- int fallbackFSGetStatAsync(void * fallbackparams);
-
- int fallbackFSGetStatFileAsync(void * fallbackparams);
-
- int fallbackFSFSGetPosFileAsync(void * fallbackparams);
-
- int fallbackFSIsEofAsync(void * fallbackparams);
-
- int fallbackFSOpenFileAsync(void * fallbackparams);
-
- int fallbackFSReadFileAsync(void * fallbackparams);
-
- int fallbackFSReadFileWithPosAsync(void * fallbackparams);
-
- int fallbackFSSetPosFileAsync(void * fallbackparams);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __FS_WRAPPER_UTILS_H_
diff --git a/plugins/sdcafiine/src/main.cpp b/plugins/sdcafiine/src/main.cpp
index c601453..622469e 100644
--- a/plugins/sdcafiine/src/main.cpp
+++ b/plugins/sdcafiine/src/main.cpp
@@ -8,22 +8,21 @@
#include
#include
#include
-#include "utils/fs_utils.h"
#include "common/retain_vars.h"
#include
-#include "common/retain_vars.h"
-#include "fs_wrapper/fs_retain_vars.h"
+#include
+#include
#include "common/common.h"
#include "main.h"
+#include "modpackSelector.h"
#define DEBUG_LOG 1
-WUPS_MODULE_NAME("SDCaffiine");
+WUPS_MODULE_NAME("SDCaffiine lite");
WUPS_MODULE_VERSION("v1.0");
WUPS_MODULE_AUTHOR("Maschell");
WUPS_MODULE_LICENSE("GPL");
-static bool setGroupAndOwnerID();
void Init_SD_USB();
INITIALIZE(){
@@ -41,39 +40,20 @@ INITIALIZE(){
log_init();
gSDInitDone = 0;
- snprintf(gModFolder, FS_MAX_ENTNAME_SIZE, "sd:/sdcafiine/%016llX",OSGetTitleID());
- DEBUG_FUNCTION_LINE("Folder: %s\n",gModFolder);
DEBUG_FUNCTION_LINE("Mount SD partition\n");
Init_SD_USB();
- setGroupAndOwnerID();
+ if(FileReplacerUtils::setGroupAndOwnerID()){
+ DEBUG_FUNCTION_LINE("SUCCESS\n");
+ }
- g_dirhandles = vc_vector_create(0, sizeof(int), NULL);
- g_filehandles = vc_vector_create(0, sizeof(int), NULL);
+ HandleMultiModPacks(OSGetTitleID());
log_print("Init of sd_cafiine!\n");
}
-static bool setGroupAndOwnerID(){
- int mcpHandle = MCP_Open();
- if(mcpHandle != 0)
- {
- unsigned char titleInfo[0x80];
- memset(titleInfo, 0, sizeof(titleInfo));
-
- MCP_GetOwnTitleInfo(mcpHandle, titleInfo);
- MCP_Close(mcpHandle);
- u32 * test = (u32*)titleInfo;
- global_owner_id = test[1];
- global_group_id = test[2];
- DEBUG_FUNCTION_LINE("Set group_id to %08X and owner_id to %08X\n",global_group_id,global_owner_id);
- return true;
- }
- return false;
-}
-
void Init_SD_USB() {
//int res = IOSUHAX_Open(NULL);
//if(res < 0){
@@ -109,6 +89,7 @@ void Init_SD_USB() {
DEBUG_FUNCTION_LINE("%08X\n",gSDInitDone);
}
+
void deInit_SD_USB(){
DEBUG_FUNCTION_LINE("Called this function.\n");
@@ -152,3 +133,10 @@ void deInit_SD_USB(){
}
DEBUG_FUNCTION_LINE("Function end.\n");
}
+
+void deInitApplication(){
+ //FileReplacerUtils::getInstance()->StopAsyncThread();
+ FileReplacerUtils::destroyInstance();
+ deInit_SD_USB();
+}
+
diff --git a/plugins/sdcafiine/src/main.h b/plugins/sdcafiine/src/main.h
index 10b159d..aeab687 100644
--- a/plugins/sdcafiine/src/main.h
+++ b/plugins/sdcafiine/src/main.h
@@ -9,7 +9,7 @@
extern "C" {
#endif
-void deInit_SD_USB();
+void deInitApplication();
#ifdef __cplusplus
}
diff --git a/plugins/sdcafiine/src/modpackSelector.cpp b/plugins/sdcafiine/src/modpackSelector.cpp
new file mode 100644
index 0000000..101dacc
--- /dev/null
+++ b/plugins/sdcafiine/src/modpackSelector.cpp
@@ -0,0 +1,210 @@
+#include
+
+#include