如何通过 api 钩子在 winword 中拒绝“另存为”
how can I refuse “save as” in winword by api hook
当winword进程打开一个文件想执行另存为操作时,我想拒绝另存为操作如果文件要保存到另一个目录。
我想通过api hook来使用C++,怎么办?
这取决于,如果你想挂钩一个外部进程,你需要先进入这个进程的地址space,例如(dll注入)。然后你需要准确地知道这个进程使用哪个 API 函数来执行保存文件这样的任务,以便能够挂钩一个正确的文件。
在所有这些步骤之后,我建议使用 detours 来挂钩 API 函数。例如:
typedef void savefunc_t(const char *fn); // api function prototype
savefunc_t *original_savefunc;
void savefunc_hook(const char *fn)
{
if(strstr(fn, "dir")) // check path and deny if otherwise execute original func
return;
original_savefunc(fn);
}
DetourFunction(DesiredFunctionPointer, savefunc_hook);
当winword进程打开一个文件想执行另存为操作时,我想拒绝另存为操作如果文件要保存到另一个目录。 我想通过api hook来使用C++,怎么办?
这取决于,如果你想挂钩一个外部进程,你需要先进入这个进程的地址space,例如(dll注入)。然后你需要准确地知道这个进程使用哪个 API 函数来执行保存文件这样的任务,以便能够挂钩一个正确的文件。 在所有这些步骤之后,我建议使用 detours 来挂钩 API 函数。例如:
typedef void savefunc_t(const char *fn); // api function prototype
savefunc_t *original_savefunc;
void savefunc_hook(const char *fn)
{
if(strstr(fn, "dir")) // check path and deny if otherwise execute original func
return;
original_savefunc(fn);
}
DetourFunction(DesiredFunctionPointer, savefunc_hook);