Replies: 1 comment 4 replies
-
Windhawk wasn't designed for this, a better solution would be to just write a program and set it to run at startup. But it can be done. You can try something like this: // ==WindhawkMod==
// @id run-code-in-windhawk-service
// @version 0.1
// @author You
// @include windhawk.exe
// ==/WindhawkMod==
#include <stdio.h>
BOOL Wh_ModInit() {
Wh_Log(L"Init " WH_MOD_ID L" version " WH_MOD_VERSION);
int argc;
PWSTR* argv = CommandLineToArgvW(GetCommandLine(), &argc);
bool isService = argv && argc >= 2 && wcscmp(argv[1], L"-service") == 0;
if (argv) {
LocalFree(argv);
}
if (!isService) {
// Not in the service, unload mod.
return FALSE;
}
// Run some code.
FILE* fp;
if (fopen_s(&fp, R"(C:\Windows\hello.txt)", "w") == 0) {
char message[] = "Hello world";
Wh_Log(L"Writing \"%S\"", message);
fwrite(message, sizeof(message) - 1, 1, fp);
fclose(fp);
}
// Unload mod.
return FALSE;
}
The code will run in the context of the Windhawk service. Note that any instability or crash will affect the Windhawk service, so use with care. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way for a mod to have some code to be executed only at start of WindHawk, with admin rights? There is no need to inject it in every process.
Beta Was this translation helpful? Give feedback.
All reactions