Export file system functions and remove save/rest register stubs

This commit is contained in:
Sajid 2024-10-01 15:26:31 +06:00
parent 040e3228e1
commit b2f92ff2a9
3 changed files with 29 additions and 277 deletions

View file

@ -11,7 +11,7 @@ bool FindHandleCloser(void* handle)
return false;
}
static uint32_t CreateFileImpl(
SWA_API uint32_t XCreateFileA(
LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
@ -34,7 +34,7 @@ static uint32_t CreateFileImpl(
return handle;
}
static DWORD GetFileSizeImpl(
static DWORD XGetFileSizeA(
uint32_t hFile,
LPDWORD lpFileSizeHigh)
{
@ -45,7 +45,7 @@ static DWORD GetFileSizeImpl(
return fileSize;
}
BOOL GetFileSizeExImpl(
BOOL XGetFileSizeExA(
uint32_t hFile,
PLARGE_INTEGER lpFileSize)
{
@ -56,7 +56,7 @@ BOOL GetFileSizeExImpl(
return result;
}
BOOL ReadFileImpl(
BOOL XReadFile(
uint32_t hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
@ -93,7 +93,7 @@ BOOL ReadFileImpl(
return result;
}
DWORD SetFilePointerImpl(
DWORD XSetFilePointer(
uint32_t hFile,
LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh,
@ -107,7 +107,7 @@ DWORD SetFilePointerImpl(
return result;
}
BOOL SetFilePointerExImpl(
BOOL XSetFilePointerEx(
uint32_t hFile,
LONG lDistanceToMove,
PLARGE_INTEGER lpNewFilePointer,
@ -123,7 +123,7 @@ BOOL SetFilePointerExImpl(
return result;
}
uint32_t FindFirstFileImpl(
uint32_t XFindFirstFileA(
LPCSTR lpFileName,
LPWIN32_FIND_DATAA lpFindFileData)
{
@ -144,7 +144,7 @@ uint32_t FindFirstFileImpl(
return GUEST_HANDLE(ObInsertObject(handle, FindHandleCloser));
}
uint32_t FindNextFileImpl(uint32_t Handle, LPWIN32_FIND_DATAA lpFindFileData)
uint32_t XFindNextFileA(uint32_t Handle, LPWIN32_FIND_DATAA lpFindFileData)
{
auto* handle = ObQueryObject(HOST_HANDLE(Handle));
auto& data = *lpFindFileData;
@ -159,7 +159,7 @@ uint32_t FindNextFileImpl(uint32_t Handle, LPWIN32_FIND_DATAA lpFindFileData)
return result;
}
BOOL ReadFileExImpl(
BOOL XReadFileEx(
uint32_t hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
@ -186,12 +186,12 @@ BOOL ReadFileExImpl(
return result;
}
DWORD GetFileAttributesAImpl(LPCSTR lpFileName)
DWORD XGetFileAttributesA(LPCSTR lpFileName)
{
return GetFileAttributesA(FileSystem::TransformPath(lpFileName));
}
BOOL WriteFileImpl(
BOOL XWriteFile(
uint32_t hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
@ -230,15 +230,20 @@ const char* FileSystem::TransformPath(const char* path)
return relativePath != nullptr ? relativePath + 2 : path;
}
GUEST_FUNCTION_HOOK(sub_82BD4668, CreateFileImpl);
GUEST_FUNCTION_HOOK(sub_82BD4600, GetFileSizeImpl);
GUEST_FUNCTION_HOOK(sub_82BD5608, GetFileSizeExImpl);
GUEST_FUNCTION_HOOK(sub_82BD4478, ReadFileImpl);
GUEST_FUNCTION_HOOK(sub_831CD3E8, SetFilePointerImpl);
GUEST_FUNCTION_HOOK(sub_831CE888, SetFilePointerExImpl);
GUEST_FUNCTION_HOOK(sub_831CDC58, FindFirstFileImpl);
GUEST_FUNCTION_HOOK(sub_831CDC00, FindNextFileImpl);
GUEST_FUNCTION_HOOK(sub_831CDF40, ReadFileExImpl);
GUEST_FUNCTION_HOOK(sub_831CD6E8, GetFileAttributesAImpl);
GUEST_FUNCTION_HOOK(sub_831CE3F8, CreateFileImpl);
GUEST_FUNCTION_HOOK(sub_82BD4860, WriteFileImpl);
SWA_API const char* XExpandFilePathA(const char* path)
{
return FileSystem::TransformPath(path);
}
GUEST_FUNCTION_HOOK(sub_82BD4668, XCreateFileA);
GUEST_FUNCTION_HOOK(sub_82BD4600, XGetFileSizeA);
GUEST_FUNCTION_HOOK(sub_82BD5608, XGetFileSizeExA);
GUEST_FUNCTION_HOOK(sub_82BD4478, XReadFile);
GUEST_FUNCTION_HOOK(sub_831CD3E8, XSetFilePointer);
GUEST_FUNCTION_HOOK(sub_831CE888, XSetFilePointerEx);
GUEST_FUNCTION_HOOK(sub_831CDC58, XFindFirstFileA);
GUEST_FUNCTION_HOOK(sub_831CDC00, XFindNextFileA);
GUEST_FUNCTION_HOOK(sub_831CDF40, XReadFileEx);
GUEST_FUNCTION_HOOK(sub_831CD6E8, XGetFileAttributesA);
GUEST_FUNCTION_HOOK(sub_831CE3F8, XCreateFileA);
GUEST_FUNCTION_HOOK(sub_82BD4860, XWriteFile);

View file

@ -28,18 +28,6 @@ BOOL QueryPerformanceFrequencyImpl(LARGE_INTEGER* lpFrequency)
return result;
}
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-memorystatus
typedef struct _XMEMORYSTATUS {
XDWORD dwLength;
XDWORD dwMemoryLoad;
XDWORD dwTotalPhys;
XDWORD dwAvailPhys;
XDWORD dwTotalPageFile;
XDWORD dwAvailPageFile;
XDWORD dwTotalVirtual;
XDWORD dwAvailVirtual;
} XMEMORYSTATUS, *XLPMEMORYSTATUS;
void GlobalMemoryStatusImpl(XLPMEMORYSTATUS lpMemoryStatus)
{
lpMemoryStatus->dwLength = sizeof(XMEMORYSTATUS);
@ -75,244 +63,3 @@ GUEST_FUNCTION_HOOK(sub_82BD4AC8, QueryPerformanceCounterImpl);
GUEST_FUNCTION_HOOK(sub_831CD040, QueryPerformanceFrequencyImpl);
GUEST_FUNCTION_HOOK(sub_82BD4BC0, GlobalMemoryStatusImpl);
#if defined(PPC_CONFIG_NON_VOLATILE_AS_LOCAL) && defined(PPC_CONFIG_NON_ARGUMENT_AS_LOCAL)
GUEST_FUNCTION_STUB(sub_831B1400);
GUEST_FUNCTION_STUB(__savefpr_15);
GUEST_FUNCTION_STUB(__savefpr_16);
GUEST_FUNCTION_STUB(__savefpr_17);
GUEST_FUNCTION_STUB(__savefpr_18);
GUEST_FUNCTION_STUB(__savefpr_19);
GUEST_FUNCTION_STUB(__savefpr_20);
GUEST_FUNCTION_STUB(__savefpr_21);
GUEST_FUNCTION_STUB(__savefpr_22);
GUEST_FUNCTION_STUB(__savefpr_23);
GUEST_FUNCTION_STUB(__savefpr_24);
GUEST_FUNCTION_STUB(__savefpr_25);
GUEST_FUNCTION_STUB(__savefpr_26);
GUEST_FUNCTION_STUB(__savefpr_27);
GUEST_FUNCTION_STUB(__savefpr_28);
GUEST_FUNCTION_STUB(__savefpr_29);
GUEST_FUNCTION_STUB(__savefpr_30);
GUEST_FUNCTION_STUB(__savefpr_31);
GUEST_FUNCTION_STUB(sub_831B144C);
GUEST_FUNCTION_STUB(__restfpr_15);
GUEST_FUNCTION_STUB(__restfpr_16);
GUEST_FUNCTION_STUB(__restfpr_17);
GUEST_FUNCTION_STUB(__restfpr_18);
GUEST_FUNCTION_STUB(__restfpr_19);
GUEST_FUNCTION_STUB(__restfpr_20);
GUEST_FUNCTION_STUB(__restfpr_21);
GUEST_FUNCTION_STUB(__restfpr_22);
GUEST_FUNCTION_STUB(__restfpr_23);
GUEST_FUNCTION_STUB(__restfpr_24);
GUEST_FUNCTION_STUB(__restfpr_25);
GUEST_FUNCTION_STUB(__restfpr_26);
GUEST_FUNCTION_STUB(__restfpr_27);
GUEST_FUNCTION_STUB(__restfpr_28);
GUEST_FUNCTION_STUB(__restfpr_29);
GUEST_FUNCTION_STUB(__restfpr_30);
GUEST_FUNCTION_STUB(__restfpr_31);
GUEST_FUNCTION_STUB(sub_831B0AF0);
GUEST_FUNCTION_STUB(__savegprlr_15);
GUEST_FUNCTION_STUB(__savegprlr_16);
GUEST_FUNCTION_STUB(__savegprlr_17);
GUEST_FUNCTION_STUB(__savegprlr_18);
GUEST_FUNCTION_STUB(__savegprlr_19);
GUEST_FUNCTION_STUB(__savegprlr_20);
GUEST_FUNCTION_STUB(__savegprlr_21);
GUEST_FUNCTION_STUB(__savegprlr_22);
GUEST_FUNCTION_STUB(__savegprlr_23);
GUEST_FUNCTION_STUB(__savegprlr_24);
GUEST_FUNCTION_STUB(__savegprlr_25);
GUEST_FUNCTION_STUB(__savegprlr_26);
GUEST_FUNCTION_STUB(__savegprlr_27);
GUEST_FUNCTION_STUB(__savegprlr_28);
GUEST_FUNCTION_STUB(__savegprlr_29);
GUEST_FUNCTION_STUB(__savegprlr_30);
GUEST_FUNCTION_STUB(__savegprlr_31);
GUEST_FUNCTION_STUB(sub_831B0B40);
GUEST_FUNCTION_STUB(__restgprlr_15);
GUEST_FUNCTION_STUB(__restgprlr_16);
GUEST_FUNCTION_STUB(__restgprlr_17);
GUEST_FUNCTION_STUB(__restgprlr_18);
GUEST_FUNCTION_STUB(__restgprlr_19);
GUEST_FUNCTION_STUB(__restgprlr_20);
GUEST_FUNCTION_STUB(__restgprlr_21);
GUEST_FUNCTION_STUB(__restgprlr_22);
GUEST_FUNCTION_STUB(__restgprlr_23);
GUEST_FUNCTION_STUB(__restgprlr_24);
GUEST_FUNCTION_STUB(__restgprlr_25);
GUEST_FUNCTION_STUB(__restgprlr_26);
GUEST_FUNCTION_STUB(__restgprlr_27);
GUEST_FUNCTION_STUB(__restgprlr_28);
GUEST_FUNCTION_STUB(__restgprlr_29);
GUEST_FUNCTION_STUB(__restgprlr_30);
GUEST_FUNCTION_STUB(__restgprlr_31);
GUEST_FUNCTION_STUB(sub_831B3450);
GUEST_FUNCTION_STUB(__savevmx_15);
GUEST_FUNCTION_STUB(__savevmx_16);
GUEST_FUNCTION_STUB(__savevmx_17);
GUEST_FUNCTION_STUB(__savevmx_18);
GUEST_FUNCTION_STUB(__savevmx_19);
GUEST_FUNCTION_STUB(__savevmx_20);
GUEST_FUNCTION_STUB(__savevmx_21);
GUEST_FUNCTION_STUB(__savevmx_22);
GUEST_FUNCTION_STUB(__savevmx_23);
GUEST_FUNCTION_STUB(__savevmx_24);
GUEST_FUNCTION_STUB(__savevmx_25);
GUEST_FUNCTION_STUB(__savevmx_26);
GUEST_FUNCTION_STUB(__savevmx_27);
GUEST_FUNCTION_STUB(__savevmx_28);
GUEST_FUNCTION_STUB(__savevmx_29);
GUEST_FUNCTION_STUB(__savevmx_30);
GUEST_FUNCTION_STUB(__savevmx_31);
GUEST_FUNCTION_STUB(__savevmx_64);
GUEST_FUNCTION_STUB(__savevmx_65);
GUEST_FUNCTION_STUB(__savevmx_66);
GUEST_FUNCTION_STUB(__savevmx_67);
GUEST_FUNCTION_STUB(__savevmx_68);
GUEST_FUNCTION_STUB(__savevmx_69);
GUEST_FUNCTION_STUB(__savevmx_70);
GUEST_FUNCTION_STUB(__savevmx_71);
GUEST_FUNCTION_STUB(__savevmx_72);
GUEST_FUNCTION_STUB(__savevmx_73);
GUEST_FUNCTION_STUB(__savevmx_74);
GUEST_FUNCTION_STUB(__savevmx_75);
GUEST_FUNCTION_STUB(__savevmx_76);
GUEST_FUNCTION_STUB(__savevmx_77);
GUEST_FUNCTION_STUB(__savevmx_78);
GUEST_FUNCTION_STUB(__savevmx_79);
GUEST_FUNCTION_STUB(__savevmx_80);
GUEST_FUNCTION_STUB(__savevmx_81);
GUEST_FUNCTION_STUB(__savevmx_82);
GUEST_FUNCTION_STUB(__savevmx_83);
GUEST_FUNCTION_STUB(__savevmx_84);
GUEST_FUNCTION_STUB(__savevmx_85);
GUEST_FUNCTION_STUB(__savevmx_86);
GUEST_FUNCTION_STUB(__savevmx_87);
GUEST_FUNCTION_STUB(__savevmx_88);
GUEST_FUNCTION_STUB(__savevmx_89);
GUEST_FUNCTION_STUB(__savevmx_90);
GUEST_FUNCTION_STUB(__savevmx_91);
GUEST_FUNCTION_STUB(__savevmx_92);
GUEST_FUNCTION_STUB(__savevmx_93);
GUEST_FUNCTION_STUB(__savevmx_94);
GUEST_FUNCTION_STUB(__savevmx_95);
GUEST_FUNCTION_STUB(__savevmx_96);
GUEST_FUNCTION_STUB(__savevmx_97);
GUEST_FUNCTION_STUB(__savevmx_98);
GUEST_FUNCTION_STUB(__savevmx_99);
GUEST_FUNCTION_STUB(__savevmx_100);
GUEST_FUNCTION_STUB(__savevmx_101);
GUEST_FUNCTION_STUB(__savevmx_102);
GUEST_FUNCTION_STUB(__savevmx_103);
GUEST_FUNCTION_STUB(__savevmx_104);
GUEST_FUNCTION_STUB(__savevmx_105);
GUEST_FUNCTION_STUB(__savevmx_106);
GUEST_FUNCTION_STUB(__savevmx_107);
GUEST_FUNCTION_STUB(__savevmx_108);
GUEST_FUNCTION_STUB(__savevmx_109);
GUEST_FUNCTION_STUB(__savevmx_110);
GUEST_FUNCTION_STUB(__savevmx_111);
GUEST_FUNCTION_STUB(__savevmx_112);
GUEST_FUNCTION_STUB(__savevmx_113);
GUEST_FUNCTION_STUB(__savevmx_114);
GUEST_FUNCTION_STUB(__savevmx_115);
GUEST_FUNCTION_STUB(__savevmx_116);
GUEST_FUNCTION_STUB(__savevmx_117);
GUEST_FUNCTION_STUB(__savevmx_118);
GUEST_FUNCTION_STUB(__savevmx_119);
GUEST_FUNCTION_STUB(__savevmx_120);
GUEST_FUNCTION_STUB(__savevmx_121);
GUEST_FUNCTION_STUB(__savevmx_122);
GUEST_FUNCTION_STUB(__savevmx_123);
GUEST_FUNCTION_STUB(__savevmx_124);
GUEST_FUNCTION_STUB(__savevmx_125);
GUEST_FUNCTION_STUB(__savevmx_126);
GUEST_FUNCTION_STUB(__savevmx_127);
GUEST_FUNCTION_STUB(sub_831B36E8);
GUEST_FUNCTION_STUB(__restvmx_15);
GUEST_FUNCTION_STUB(__restvmx_16);
GUEST_FUNCTION_STUB(__restvmx_17);
GUEST_FUNCTION_STUB(__restvmx_18);
GUEST_FUNCTION_STUB(__restvmx_19);
GUEST_FUNCTION_STUB(__restvmx_20);
GUEST_FUNCTION_STUB(__restvmx_21);
GUEST_FUNCTION_STUB(__restvmx_22);
GUEST_FUNCTION_STUB(__restvmx_23);
GUEST_FUNCTION_STUB(__restvmx_24);
GUEST_FUNCTION_STUB(__restvmx_25);
GUEST_FUNCTION_STUB(__restvmx_26);
GUEST_FUNCTION_STUB(__restvmx_27);
GUEST_FUNCTION_STUB(__restvmx_28);
GUEST_FUNCTION_STUB(__restvmx_29);
GUEST_FUNCTION_STUB(__restvmx_30);
GUEST_FUNCTION_STUB(__restvmx_31);
GUEST_FUNCTION_STUB(__restvmx_64);
GUEST_FUNCTION_STUB(__restvmx_65);
GUEST_FUNCTION_STUB(__restvmx_66);
GUEST_FUNCTION_STUB(__restvmx_67);
GUEST_FUNCTION_STUB(__restvmx_68);
GUEST_FUNCTION_STUB(__restvmx_69);
GUEST_FUNCTION_STUB(__restvmx_70);
GUEST_FUNCTION_STUB(__restvmx_71);
GUEST_FUNCTION_STUB(__restvmx_72);
GUEST_FUNCTION_STUB(__restvmx_73);
GUEST_FUNCTION_STUB(__restvmx_74);
GUEST_FUNCTION_STUB(__restvmx_75);
GUEST_FUNCTION_STUB(__restvmx_76);
GUEST_FUNCTION_STUB(__restvmx_77);
GUEST_FUNCTION_STUB(__restvmx_78);
GUEST_FUNCTION_STUB(__restvmx_79);
GUEST_FUNCTION_STUB(__restvmx_80);
GUEST_FUNCTION_STUB(__restvmx_81);
GUEST_FUNCTION_STUB(__restvmx_82);
GUEST_FUNCTION_STUB(__restvmx_83);
GUEST_FUNCTION_STUB(__restvmx_84);
GUEST_FUNCTION_STUB(__restvmx_85);
GUEST_FUNCTION_STUB(__restvmx_86);
GUEST_FUNCTION_STUB(__restvmx_87);
GUEST_FUNCTION_STUB(__restvmx_88);
GUEST_FUNCTION_STUB(__restvmx_89);
GUEST_FUNCTION_STUB(__restvmx_90);
GUEST_FUNCTION_STUB(__restvmx_91);
GUEST_FUNCTION_STUB(__restvmx_92);
GUEST_FUNCTION_STUB(__restvmx_93);
GUEST_FUNCTION_STUB(__restvmx_94);
GUEST_FUNCTION_STUB(__restvmx_95);
GUEST_FUNCTION_STUB(__restvmx_96);
GUEST_FUNCTION_STUB(__restvmx_97);
GUEST_FUNCTION_STUB(__restvmx_98);
GUEST_FUNCTION_STUB(__restvmx_99);
GUEST_FUNCTION_STUB(__restvmx_100);
GUEST_FUNCTION_STUB(__restvmx_101);
GUEST_FUNCTION_STUB(__restvmx_102);
GUEST_FUNCTION_STUB(__restvmx_103);
GUEST_FUNCTION_STUB(__restvmx_104);
GUEST_FUNCTION_STUB(__restvmx_105);
GUEST_FUNCTION_STUB(__restvmx_106);
GUEST_FUNCTION_STUB(__restvmx_107);
GUEST_FUNCTION_STUB(__restvmx_108);
GUEST_FUNCTION_STUB(__restvmx_109);
GUEST_FUNCTION_STUB(__restvmx_110);
GUEST_FUNCTION_STUB(__restvmx_111);
GUEST_FUNCTION_STUB(__restvmx_112);
GUEST_FUNCTION_STUB(__restvmx_113);
GUEST_FUNCTION_STUB(__restvmx_114);
GUEST_FUNCTION_STUB(__restvmx_115);
GUEST_FUNCTION_STUB(__restvmx_116);
GUEST_FUNCTION_STUB(__restvmx_117);
GUEST_FUNCTION_STUB(__restvmx_118);
GUEST_FUNCTION_STUB(__restvmx_119);
GUEST_FUNCTION_STUB(__restvmx_120);
GUEST_FUNCTION_STUB(__restvmx_121);
GUEST_FUNCTION_STUB(__restvmx_122);
GUEST_FUNCTION_STUB(__restvmx_123);
GUEST_FUNCTION_STUB(__restvmx_124);
GUEST_FUNCTION_STUB(__restvmx_125);
GUEST_FUNCTION_STUB(__restvmx_126);
GUEST_FUNCTION_STUB(__restvmx_127);
#endif

@ -1 +1 @@
Subproject commit 183027d563779fd437496521b55dbbd09169e00a
Subproject commit 1f5d7c32e8205ef10dab458394ebc760fb5a0bdc