mirror of
https://gitea.tendokyu.moe/Hay1tsme/segatools.git
synced 2024-11-24 17:30:11 +01:00
hooklib/path.c: Hook RemoveDirectory
- A certain game uses RemoveDirectory to clear out some data in the Y:
This commit is contained in:
parent
da6879606a
commit
25f5ca944e
@ -93,6 +93,10 @@ static BOOL WINAPI hook_GetFileAttributesExW(
|
|||||||
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
||||||
void *lpFileInformation);
|
void *lpFileInformation);
|
||||||
|
|
||||||
|
static BOOL WINAPI hook_RemoveDirectoryA(const char *lpFileName);
|
||||||
|
|
||||||
|
static BOOL WINAPI hook_RemoveDirectoryW(const wchar_t *lpFileName);
|
||||||
|
|
||||||
/* Link pointers */
|
/* Link pointers */
|
||||||
|
|
||||||
static BOOL (WINAPI *next_CreateDirectoryA)(
|
static BOOL (WINAPI *next_CreateDirectoryA)(
|
||||||
@ -169,6 +173,10 @@ static BOOL (WINAPI *next_GetFileAttributesExW)(
|
|||||||
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
||||||
void *lpFileInformation);
|
void *lpFileInformation);
|
||||||
|
|
||||||
|
static BOOL (WINAPI *next_RemoveDirectoryA)(const char *lpFileName);
|
||||||
|
|
||||||
|
static BOOL (WINAPI *next_RemoveDirectoryW)(const wchar_t *lpFileName);
|
||||||
|
|
||||||
/* Hook table */
|
/* Hook table */
|
||||||
|
|
||||||
static const struct hook_symbol path_hook_syms[] = {
|
static const struct hook_symbol path_hook_syms[] = {
|
||||||
@ -228,6 +236,14 @@ static const struct hook_symbol path_hook_syms[] = {
|
|||||||
.name = "GetFileAttributesExW",
|
.name = "GetFileAttributesExW",
|
||||||
.patch = hook_GetFileAttributesExW,
|
.patch = hook_GetFileAttributesExW,
|
||||||
.link = (void **) &next_GetFileAttributesExW,
|
.link = (void **) &next_GetFileAttributesExW,
|
||||||
|
}, {
|
||||||
|
.name = "RemoveDirectoryA",
|
||||||
|
.patch = hook_RemoveDirectoryA,
|
||||||
|
.link = (void **) &next_RemoveDirectoryA,
|
||||||
|
}, {
|
||||||
|
.name = "RemoveDirectoryW",
|
||||||
|
.patch = hook_RemoveDirectoryW,
|
||||||
|
.link = (void **) &next_RemoveDirectoryW,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -802,3 +818,39 @@ static BOOL WINAPI hook_GetFileAttributesExW(
|
|||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI hook_RemoveDirectoryA(const char *lpFileName)
|
||||||
|
{
|
||||||
|
char *trans;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
|
ok = path_transform_a(&trans, lpFileName);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = next_RemoveDirectoryA(trans ? trans : lpFileName);
|
||||||
|
|
||||||
|
free(trans);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI hook_RemoveDirectoryW(const wchar_t *lpFileName)
|
||||||
|
{
|
||||||
|
wchar_t *trans;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
|
ok = path_transform_w(&trans, lpFileName);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = next_RemoveDirectoryW(trans ? trans : lpFileName);
|
||||||
|
|
||||||
|
free(trans);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user