41 lines
982 B
PowerShell
41 lines
982 B
PowerShell
Add-Type -TypeDefinition @"
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public class MI {
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct MOUSEINPUT {
|
|
public int dx;
|
|
public int dy;
|
|
public uint mouseData;
|
|
public uint dwFlags;
|
|
public uint time;
|
|
public IntPtr dwExtraInfo;
|
|
}
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct INPUT {
|
|
public uint type;
|
|
public MOUSEINPUT mi;
|
|
}
|
|
}
|
|
"@
|
|
|
|
$type = [MI+INPUT]
|
|
Write-Host "Type: $($type.FullName)"
|
|
Write-Host "IsValueType: $($type.IsValueType)"
|
|
|
|
try {
|
|
$s = [Runtime.InteropServices.Marshal]::SizeOf($type)
|
|
Write-Host "SizeOf(type): $s"
|
|
} catch {
|
|
Write-Host "SizeOf(type) failed: $($_.Exception.Message)"
|
|
}
|
|
|
|
$inst = [Activator]::CreateInstance($type)
|
|
try {
|
|
$s2 = [Runtime.InteropServices.Marshal]::SizeOf($inst)
|
|
Write-Host "SizeOf(inst): $s2"
|
|
} catch {
|
|
Write-Host "SizeOf(inst) failed: $($_.Exception.Message)"
|
|
}
|