Created
November 15, 2019 05:43
-
-
Save kernullist/e84e5c2b45b12b9a88b528e0ed2161cd to your computer and use it in GitHub Desktop.
PowerShell Win32 API Usage #01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $FunctionSig = @" | |
| [DllImport("kernel32.dll")] | |
| public static extern IntPtr OpenProcess(uint access, bool inherit, uint pid); | |
| "@ | |
| $kernel32 = Add-Type -MemberDefinition $FunctionSig -Name "Process" -Namespace Win32Functions -PassThru | |
| $kernel32::OpenProcess(0x1000, $false, 7520) |
Author
Author
$FunctionSig = @"
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(uint access, bool inherit, uint pid);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr handle);
"@
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$handle = $kernel32::OpenProcess(0x1000, $false, 7520)
$handle.ToString("X8")