diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-09-10 09:35:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-10 09:35:58 +0200 |
commit | bde85b8737e8fbe88bc295b3e2e40f5d9407424f (patch) | |
tree | d4fce28022a2441f9ea82c3a1746f6e4efcf350e | |
parent | Merge pull request #89 from Amebis/pending/dynamic-annotation (diff) | |
parent | Add CoInitializeEx and CoUninitialize (diff) | |
download | wireguard-windows-bde85b8737e8fbe88bc295b3e2e40f5d9407424f.tar.xz wireguard-windows-bde85b8737e8fbe88bc295b3e2e40f5d9407424f.zip |
Merge pull request #90 from Amebis/pending/CoInitializeEx
Add CoInitializeEx and CoUninitialize
-rw-r--r-- | ole32.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -41,6 +41,13 @@ const ( CLSCTX_SERVER = CLSCTX_INPROC_SERVER | 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 @@ -428,7 +435,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 @@ -441,7 +450,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") @@ -471,6 +482,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, |