diff options
author | Simon Rozman <simon@rozman.si> | 2019-09-10 08:26:32 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-09-10 08:28:32 +0200 |
commit | e8b6982ca5da35b33e82536ea9033cb4f7cf78e9 (patch) | |
tree | d2d8aa0026dda4b6d1fe1fa30e82fe8a6503fae1 | |
parent | Merge pull request #88 from zx2c4-forks/jd/noglobalinit (diff) | |
download | wireguard-windows-e8b6982ca5da35b33e82536ea9033cb4f7cf78e9.tar.xz wireguard-windows-e8b6982ca5da35b33e82536ea9033cb4f7cf78e9.zip |
Add CoInitializeEx and CoUninitialize
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | ole32.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -38,6 +38,13 @@ const ( CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER ) +const ( + COINIT_APARTMENTTHREADED = 0x2 // Apartment model + COINIT_MULTITHREADED = 0x0 // OLE calls objects on any thread. + COINIT_DISABLE_OLE1DDE = 0x4 // Don't use DDE for Ole1 support. + COINIT_SPEED_OVER_MEMORY = 0x8 // Trade memory for speed. +) + // Verbs for IOleObject.DoVerb const ( OLEIVERB_PRIMARY = 0 @@ -425,7 +432,9 @@ var ( // Functions coCreateInstance *windows.LazyProc coGetClassObject *windows.LazyProc + coInitializeEx *windows.LazyProc coTaskMemFree *windows.LazyProc + coUninitialize *windows.LazyProc oleInitialize *windows.LazyProc oleSetContainedObject *windows.LazyProc oleUninitialize *windows.LazyProc @@ -438,7 +447,9 @@ func init() { // Functions coCreateInstance = libole32.NewProc("CoCreateInstance") coGetClassObject = libole32.NewProc("CoGetClassObject") + coInitializeEx = libole32.NewProc("CoInitializeEx") coTaskMemFree = libole32.NewProc("CoTaskMemFree") + coUninitialize = libole32.NewProc("CoUninitialize") oleInitialize = libole32.NewProc("OleInitialize") oleSetContainedObject = libole32.NewProc("OleSetContainedObject") oleUninitialize = libole32.NewProc("OleUninitialize") @@ -468,6 +479,22 @@ func CoGetClassObject(rclsid REFCLSID, dwClsContext uint32, pServerInfo *COSERVE return HRESULT(ret) } +func CoInitializeEx(reserved unsafe.Pointer, coInit uint32) HRESULT { + ret, _, _ := syscall.Syscall(coInitializeEx.Addr(), 2, + uintptr(reserved), + uintptr(coInit), + 0) + + return HRESULT(ret) +} + +func CoUninitialize() { + syscall.Syscall(coUninitialize.Addr(), 0, + 0, + 0, + 0) +} + func CoTaskMemFree(pv uintptr) { syscall.Syscall(coTaskMemFree.Addr(), 1, pv, |