diff --git a/hooklib/path.c b/hooklib/path.c index fd07729..08d5f20 100644 --- a/hooklib/path.c +++ b/hooklib/path.c @@ -219,6 +219,20 @@ static BOOL WINAPI hook_PathFileExistsW(LPCWSTR pszPath); static BOOL WINAPI hook_MakeSureDirectoryPathExists(LPCSTR DirPath); +static BOOL WINAPI hook_WritePrivateProfileStringA( + LPCSTR lpAppName, + LPCSTR lpKeyName, + LPCSTR lpString, + LPCSTR lpFileName +); + +static BOOL WINAPI hook_WritePrivateProfileStringW( + LPCWSTR lpAppName, + LPCWSTR lpKeyName, + LPCWSTR lpString, + LPCWSTR lpFileName +); + /* Link pointers */ static BOOL (WINAPI *next_CreateDirectoryA)( @@ -433,6 +447,20 @@ static BOOL (WINAPI *next_PathFileExistsW)(LPCWSTR pszPath); static BOOL (WINAPI *next_MakeSureDirectoryPathExists)(LPCSTR DirPath); +static BOOL (WINAPI *next_WritePrivateProfileStringA)( + LPCSTR lpAppName, + LPCSTR lpKeyName, + LPCSTR lpString, + LPCSTR lpFileName +); + +static BOOL (WINAPI *next_WritePrivateProfileStringW)( + LPCWSTR lpAppName, + LPCWSTR lpKeyName, + LPCWSTR lpString, + LPCWSTR lpFileName +); + /* Hook table */ static const struct hook_symbol path_hook_syms[] = { @@ -580,7 +608,15 @@ static const struct hook_symbol path_hook_syms[] = { .name = "GetFullPathNameW", .patch = hook_GetFullPathNameW, .link = (void **) &next_GetFullPathNameW, - }, + }, { + .name = "WritePrivateProfileStringA", + .patch = hook_WritePrivateProfileStringA, + .link = (void **) &next_WritePrivateProfileStringA, + }, { + .name = "WritePrivateProfileStringW", + .patch = hook_WritePrivateProfileStringW, + .link = (void **) &next_WritePrivateProfileStringW, + } }; static const struct hook_symbol path_hook_shlwapi_syms[] = { @@ -2058,3 +2094,59 @@ static DWORD WINAPI hook_GetFullPathNameW( return result; } + +static BOOL WINAPI hook_WritePrivateProfileStringA( + LPCSTR lpAppName, + LPCSTR lpKeyName, + LPCSTR lpString, + LPCSTR lpFileName +) +{ + char *trans; + DWORD result; + BOOL ok; + + ok = path_transform_a(&trans, lpFileName); + + if (!ok) { + return 0; + } + + result = next_WritePrivateProfileStringA( + lpAppName, + lpKeyName, + lpString, + trans ? trans : lpFileName); + + free(trans); + + return result; +} + +static BOOL WINAPI hook_WritePrivateProfileStringW( + LPCWSTR lpAppName, + LPCWSTR lpKeyName, + LPCWSTR lpString, + LPCWSTR lpFileName +) { + wchar_t *trans; + DWORD result; + BOOL ok; + + ok = path_transform_w(&trans, lpFileName); + + if (!ok) { + return 0; + } + + result = next_WritePrivateProfileStringW( + lpAppName, + lpKeyName, + lpString, + trans ? trans : lpFileName); + + free(trans); + + return result; +} +