forked from TeamTofuShop/segatools
Vfs: Hook .ini reader functions to fix DLI reading (#75)
Pretty simple, DLI reading (more commonly known as DownloadOrder) calls GetPrivateProfile* with a file path with E:\tmpDli*.ini. This fails right now. I have only hooked the functions that appear in the latest amdaemon. Reviewed-on: TeamTofuShop/segatools#75 Reviewed-by: Dniel97 <dniel97@noreply.gitea.tendokyu.moe> Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
This commit is contained in:
@ -136,6 +136,31 @@ static BOOL WINAPI hook_DeleteFileA(const char *lpFileName);
|
|||||||
|
|
||||||
static BOOL WINAPI hook_DeleteFileW(const wchar_t *lpFileName);
|
static BOOL WINAPI hook_DeleteFileW(const wchar_t *lpFileName);
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileStringA(
|
||||||
|
LPCSTR lpAppName,
|
||||||
|
LPCSTR lpKeyName,
|
||||||
|
LPCSTR lpDefault,
|
||||||
|
LPSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileStringW(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPCWSTR lpKeyName,
|
||||||
|
LPCWSTR lpDefault,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileSectionW(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
/* Link pointers */
|
/* Link pointers */
|
||||||
|
|
||||||
static BOOL (WINAPI *next_CreateDirectoryA)(
|
static BOOL (WINAPI *next_CreateDirectoryA)(
|
||||||
@ -253,6 +278,31 @@ static BOOL (WINAPI *next_DeleteFileA)(const char *lpFileName);
|
|||||||
|
|
||||||
static BOOL (WINAPI *next_DeleteFileW)(const wchar_t *lpFileName);
|
static BOOL (WINAPI *next_DeleteFileW)(const wchar_t *lpFileName);
|
||||||
|
|
||||||
|
static DWORD (WINAPI *next_GetPrivateProfileStringA)(
|
||||||
|
LPCSTR lpAppName,
|
||||||
|
LPCSTR lpKeyName,
|
||||||
|
LPCSTR lpDefault,
|
||||||
|
LPSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
|
static DWORD (WINAPI *next_GetPrivateProfileStringW)(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPCWSTR lpKeyName,
|
||||||
|
LPCWSTR lpDefault,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
|
static DWORD (WINAPI *next_GetPrivateProfileSectionW)(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
);
|
||||||
|
|
||||||
/* Hook table */
|
/* Hook table */
|
||||||
|
|
||||||
static const struct hook_symbol path_hook_syms[] = {
|
static const struct hook_symbol path_hook_syms[] = {
|
||||||
@ -356,6 +406,18 @@ static const struct hook_symbol path_hook_syms[] = {
|
|||||||
.name = "DeleteFileW",
|
.name = "DeleteFileW",
|
||||||
.patch = hook_DeleteFileW,
|
.patch = hook_DeleteFileW,
|
||||||
.link = (void **) &next_DeleteFileW,
|
.link = (void **) &next_DeleteFileW,
|
||||||
|
}, {
|
||||||
|
.name = "GetPrivateProfileStringA",
|
||||||
|
.patch = hook_GetPrivateProfileStringA,
|
||||||
|
.link = (void **) &next_GetPrivateProfileStringA,
|
||||||
|
}, {
|
||||||
|
.name = "GetPrivateProfileStringW",
|
||||||
|
.patch = hook_GetPrivateProfileStringW,
|
||||||
|
.link = (void **) &next_GetPrivateProfileStringW,
|
||||||
|
}, {
|
||||||
|
.name = "GetPrivateProfileSectionW",
|
||||||
|
.patch = hook_GetPrivateProfileSectionW,
|
||||||
|
.link = (void **) &next_GetPrivateProfileSectionW,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1218,3 +1280,61 @@ static BOOL WINAPI hook_DeleteFileW(const wchar_t *lpFileName)
|
|||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileStringA(
|
||||||
|
LPCSTR lpAppName,
|
||||||
|
LPCSTR lpKeyName,
|
||||||
|
LPCSTR lpDefault,
|
||||||
|
LPSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCSTR lpFileName
|
||||||
|
) {
|
||||||
|
char *trans;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
|
ok = path_transform_a(&trans, lpFileName);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_GetPrivateProfileStringA(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, trans ? trans: lpFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileStringW(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPCWSTR lpKeyName,
|
||||||
|
LPCWSTR lpDefault,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
) {
|
||||||
|
wchar_t *trans;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
|
ok = path_transform_w(&trans, lpFileName);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_GetPrivateProfileStringW(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, trans ? trans: lpFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI hook_GetPrivateProfileSectionW(
|
||||||
|
LPCWSTR lpAppName,
|
||||||
|
LPWSTR lpReturnedString,
|
||||||
|
DWORD nSize,
|
||||||
|
LPCWSTR lpFileName
|
||||||
|
) {
|
||||||
|
wchar_t *trans;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
|
ok = path_transform_w(&trans, lpFileName);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_GetPrivateProfileSectionW(lpAppName, lpReturnedString, nSize, trans ? trans: lpFileName);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user