Skip to content

Instantly share code, notes, and snippets.

@shelld0n
Created February 1, 2020 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shelld0n/405ea7ad34309d56becd6c807fcdd91d to your computer and use it in GitHub Desktop.
Save shelld0n/405ea7ad34309d56becd6c807fcdd91d to your computer and use it in GitHub Desktop.
OpenProcessToken_codeblock
// Duplicate Tokens for system process and store them in tokenHandle
Console.WriteLine("your journey just started");
IntPtr test = myAPI.OpenProcess(myAPI.ProcessAccessFlags.QueryInformation, true, pid);
if (test == IntPtr.Zero) Console.WriteLine("No Handle to process !");
IntPtr tokenHandle;
bool result_token = myAPI.OpenProcessToken(test, myAPI.TOKEN_READ | myAPI.TOKEN_IMPERSONATE | myAPI.TOKEN_DUPLICATE, out tokenHandle);
Console.WriteLine(result_token);
//End of getting the handle of token of SYSTEM process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment