path: hook GetDiskFreeSpaceW for amGfetcher

This commit is contained in:
kyoubate-haruka
2026-05-25 11:32:35 +02:00
parent abe1a9d77e
commit 6b1f494559
+44
View File
@@ -200,6 +200,14 @@ static UINT WINAPI hook_GetDriveTypeW(
LPCWSTR lpRootPathName
);
static BOOL WINAPI hook_GetDiskFreeSpaceW(
LPCWSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfClusters
);
/* Link pointers */
static BOOL (WINAPI *next_CreateDirectoryA)(
@@ -395,6 +403,14 @@ static UINT (WINAPI *next_GetDriveTypeA)(
LPCSTR lpRootPathName
);
static BOOL (WINAPI *next_GetDiskFreeSpaceW)(
LPCWSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfClusters
);
/* Hook table */
static const struct hook_symbol path_hook_syms[] = {
@@ -538,6 +554,10 @@ static const struct hook_symbol path_hook_syms[] = {
.name = "GetDriveTypeW",
.patch = hook_GetDriveTypeW,
.link = (void **) &next_GetDriveTypeW,
}, {
.name = "GetDiskFreeSpaceW",
.patch = hook_GetDiskFreeSpaceW,
.link = (void **) &next_GetDiskFreeSpaceW,
}
};
@@ -1720,6 +1740,30 @@ static UINT WINAPI hook_GetDriveTypeW(
return result;
}
static BOOL WINAPI hook_GetDiskFreeSpaceW(
LPCWSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfClusters
) {
wchar_t *trans;
UINT result;
BOOL ok;
ok = path_transform_w(&trans, lpRootPathName);
if (!ok) {
return FALSE;
}
result = next_GetDiskFreeSpaceW(trans ? trans : lpRootPathName, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters);
free(trans);
return result;
}
char** str_split_a(char* a_str, const char a_delim) {
char** result = 0;
size_t count = 0;