Created
July 23, 2018 09:39
-
-
Save adon90/2dceb8e6597d1e5daee29a84111d9279 to your computer and use it in GitHub Desktop.
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
"@ | |
Add-Type -TypeDefinition @" | |
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
public static class GetAddress | |
{ | |
[DllImport("kernel32", SetLastError=true, CharSet = CharSet.Ansi)] | |
public static extern IntPtr LoadLibrary( | |
[MarshalAs(UnmanagedType.LPStr)]string lpFileName); | |
[DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)] | |
public static extern IntPtr GetProcAddress( | |
IntPtr hModule, | |
string procName); | |
} | |
"@ | |
$library = [GetAddress]::LoadLibrary("c:\windows\system32\kernel32") | |
$address = [GetAddress]::GetProcAddress($library, "WinExec") | |
"0x$("{0:X16}" -f $address.ToInt64())" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment