Created
October 30, 2022 03:42
-
-
Save tmplinshi/ff268eecfc055792ca749ef359866a0f to your computer and use it in GitHub Desktop.
This file contains 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.Runtime; | |
using System.Runtime.InteropServices; | |
public static class Marshal | |
{ | |
internal const String OLEAUT32 = "oleaut32.dll"; | |
public static Object GetActiveObject(Guid clsid) | |
{ | |
Object obj = null; | |
GetActiveObject(ref clsid, IntPtr.Zero, out obj); | |
return obj; | |
} | |
//[DllImport(Microsoft.Win32.Win32Native.OLEAUT32, PreserveSig = false)] | |
[DllImport(OLEAUT32, PreserveSig = false)] | |
private static extern void GetActiveObject(ref Guid rclsid, IntPtr reserved, [MarshalAs(UnmanagedType.Interface)] out Object ppunk); | |
} | |
'@ | |
$clsid = "{E123917B-8D61-4CCF-A1BB-F15551EAF442}" | |
$test = [Marshal]::GetActiveObject($clsid) | |
$test.hello() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment