Tuesday 4 April 2017

COM System Functions

So COM is complex and unfortantely there are many toolkits and layers that are designed to help but actually can obscure understanding.  Sometimes, it is better to know the underlying mechanism and in COM so very often this means calling a System function.  These system functions are exported by well know COM dlls like OLE32.DLL and OLEAUT32.DLL.

On this page we show all the functions that these DLLs export so they can be browsed.

Array Manipulation Functions Decimal Arithmetic Functions String Manipulation Functions
SafeArrayAccessData VarDecAbs SysAddRefString
SafeArrayAddRef VarDecAdd SysAllocString
SafeArrayAllocData VarDecCmp SysAllocStringByteLen
SafeArrayAllocDescriptor VarDecCmpR8 SysAllocStringLen
SafeArrayAllocDescriptorEx VarDecDiv SysFreeString
SafeArrayCopy VarDecFix SysReAllocString
SafeArrayCopyData VarDecInt SysReAllocStringLen
SafeArrayCreate VarDecMul SysReleaseString
SafeArrayCreateEx VarDecNeg SysStringByteLen
SafeArrayCreateVector VarDecRound SysStringLen
SafeArrayCreateVectorEx VarDecSub Type Building Functions
SafeArrayDestroy Dispatch functions CreateTypeLib
SafeArrayDestroyData CreateDispTypeInfo CreateTypeLib2
SafeArrayDestroyDescriptor CreateStdDispatch OaBuildVersion
SafeArrayGetDim DispCallFunc Type Description Functions
SafeArrayGetElement DispGetIDsOfNames LHashValOfNameSys
SafeArrayGetElemsize DispGetParam LHashValOfNameSysA
SafeArrayGetIID DispInvoke LoadRegTypeLib
SafeArrayGetLBound Error-Handling Functions LoadTypeLib
SafeArrayGetRecordInfo CreateErrorInfo LoadTypeLibEx
SafeArrayGetUBound GetErrorInfo OaEnablePerUserTLibRegistration
SafeArrayGetVartype SetErrorInfo QueryPathOfRegTypeLib
SafeArrayLock Formatting Functions RegisterTypeLib
SafeArrayPtrOfIndex VarFormat RegisterTypeLibForUser
SafeArrayPutElement VarFormatCurrency UnRegisterTypeLib
SafeArrayRedim VarFormatDateTime UnRegisterTypeLibForUser
SafeArrayReleaseData VarFormatFromTokens UDT Functions and Interfaces
SafeArrayReleaseDescriptor VarFormatNumber ClearCustData
SafeArraySetIID VarFormatPercent GetRecordInfoFromGuids
SafeArraySetRecordInfo VarMonthName GetRecordInfoFromTypeInfo
SafeArrayUnaccessData VarTokenizeFormatString Variant Arithmetic Functions
SafeArrayUnlock VarWeekdayName VarAbs
BSTR and Vector Conversion Functions Numeric Parsing Functions VarAdd
BstrFromVector VarNumFromParseNum VarAnd
SetOaNoCache VarParseNumFromStr VarCat
VarBstrCat OLE and Data Transfer VarCmp
VarBstrCmp OleCreateFontIndirect VarDiv
VectorFromBstr OleCreatePictureIndirect VarEqv
COM Fundamentals OleLoadPicture VarFix
DllCanUnloadNow OleLoadPictureEx VarIdiv
DllGetClassObject Picture Functions VarImp
DllRegisterServer OleLoadPictureFile VarInt
DllUnregisterServer OleLoadPictureFileEx VarMod
OleIconToCursor OleSavePictureFile VarMul
Controls and Property Pages Registration Functions VarNeg
OleCreatePropertyFrame GetActiveObject VarNot
OleCreatePropertyFrameIndirect RegisterActiveObject VarOr
OleLoadPicturePath RevokeActiveObject VarPow
OleTranslateColor RPC Data Marshaling Functions VarR4CmpR8
Currency Arithmetic Functions BSTR_UserFree VarR8Pow
VarCyAbs BSTR_UserFree64 VarR8Round
VarCyAdd BSTR_UserMarshal VarRound
VarCyCmp BSTR_UserMarshal64 VarSub
VarCyCmpR8 BSTR_UserSize VarXor
VarCyFix BSTR_UserSize64 Variant Manipulation Functions
VarCyInt BSTR_UserUnmarshal VariantChangeType
VarCyMul BSTR_UserUnmarshal64 VariantChangeTypeEx
VarCyMulI4 VARIANT_UserUnmarshal64 VariantClear
VarCyMulI8 VARIANT_UserUnmarshal VariantCopy
VarCyNeg VARIANT_UserSize64 VariantCopyInd
VarCyRound VARIANT_UserSize VariantInit
VarCySub VARIANT_UserMarshal64 (not documented)
Date and Time Conversion Functions VARIANT_UserMarshal OACreateTypeLib2
DosDateTimeToVariantTime VARIANT_UserFree64 OACleanup
GetAltMonthNames VARIANT_UserFree HWND_UserUnmarshal64
SystemTimeToVariantTime LPSAFEARRAY_UserUnmarshal64 HWND_UserUnmarshal
VarDateFromUdate LPSAFEARRAY_UserUnmarshal HWND_UserSize64
VarDateFromUdateEx LPSAFEARRAY_UserSize64 HWND_UserSize
VariantTimeToDosDateTime LPSAFEARRAY_UserSize HWND_UserMarshal64
VariantTimeToSystemTime LPSAFEARRAY_UserMarshal64 HWND_UserMarshal
VarUdateFromDate LPSAFEARRAY_UserMarshal HWND_UserFree64
LPSAFEARRAY_UserFree64 HWND_UserFree
LPSAFEARRAY_UserFree
LPSAFEARRAY_Unmarshal
LPSAFEARRAY_Size
LPSAFEARRAY_Marshal

What is also exported from OleAut32.dll is a whole number of Variant conversion functions which are best presented cross-tabulated.

Dec Bool Bstr Cy Date Disp I1 I2 I4 I8 R4 R8 UI1 UI2 UI4 UI8
Dec # # # # # # # # # # # # # # #
Bool # # # # # # # # # # # # # # #
Bstr # # # # # # # # # # # # # # #
Cy # # # # # # # # # # # # # # #
Date # # # # # # # # # # # # # # #
I1 # # # # # # # # # # # # # # #
I2 # # # # # # # # # # # # # # #
I4 # # # # # # # # # # # # # # #
I8 # # # # # # # # # # # # # #
R4 # # # # # # # # # # # # # # #
R8 # # # # # # # # # # # # # # #
UI1 # # # # # # # # # # # # # # #
UI2 # # # # # # # # # # # # # # #
UI4 # # # # # # # # # # # # # # #
UI8 # # # # # # # # # # # # # #

So another nice dll is OleDlg.dll which seems to be a repository of OLE and Data Transfer dialogs. Most of the entry points are duplicated with A meaning Windows 98 and W meaning Windows 2000 onwards.

oleDlg.dll
OleUIAddVerbMenuA OleUIAddVerbMenuW
OleUIBusyA OleUIBusyW
OleUICanConvertOrActivateAs
OleUIChangeIconA OleUIChangeIconW
OleUIChangeSourceA OleUIChangeSourceW
OleUIConvertA OleUIConvertW
OleUIEditLinksA OleUIEditLinksW
OleUIInsertObjectA OleUIInsertObjectW
OleUIObjectPropertiesA OleUIObjectPropertiesW
OleUIPasteSpecialA OleUIPasteSpecialW
OleUIPromptUserA OleUIPromptUserW
OleUIUpdateLinksA OleUIUpdateLinksW

And now from OLE32.DLL which is the daddy of all COM System DLLs. Breaking it down first we have the error info functions

Automation - Error Info
CreateErrorInfo GetErrorInfo SetErrorInfo

Also from OLE32.DLL a chunk of funcitons that handle OLE and Data Transfer such as clipboards, links, drag and drop.

OLE and Data Transfer
CreateDataAdviseHolder CreateDataCache CreateOleAdviseHolder
DoDragDrop OleCreate OleCreateDefaultHandler
OleCreateEmbeddingHelper OleCreateEx OleCreateFromData
OleCreateFromDataEx OleCreateFromFile OleCreateFromFileEx
OleCreateLink OleCreateLinkEx OleCreateLinkFromData
OleCreateLinkFromDataEx OleCreateLinkToFile OleCreateLinkToFileEx
OleCreateMenuDescriptor OleCreateStaticFromData OleDestroyMenuDescriptor
OleDraw OleDuplicateData OleFlushClipboard
OleGetClipboard OleInitialize OleIsCurrentClipboard
OleIsRunning OleLoad OleLoadFromStream
OleLockRunning OleMetafilePictFromIconAndLabel OleNoteObjectVisible
OleQueryCreateFromData OleQueryLinkFromData OleRegEnumFormatEtc
OleRegEnumVerbs OleRun OleSave
OleSaveToStream OleSetClipboard OleSetContainedObject
OleSetMenuDescriptor OleTranslateAccelerator OleUIAddVerbMenu
OleUninitialize RegisterDragDrop ReleaseStgMedium
RevokeDragDrop

Also in OLE32.Dll function concerning Structured Storage

Structured Storage
CreateILockBytesOnHGlobal CreateStreamOnHGlobal
FmtIdToPropStgName FreePropVariantArray
GetConvertStg GetHGlobalFromILockBytes
GetHGlobalFromStream OleConvertIStorageToOLESTREAM
OleConvertIStorageToOLESTREAMEx OleConvertOLESTREAMToIStorage
OleConvertOLESTREAMToIStorageEx PropStgNameToFmtId
PropVariantClear PropVariantCopy
ReadClassStg ReadClassStm
ReadFmtUserTypeStg StgConvertPropertyToVariant
SetConvertStg StgConvertVariantToProperty
StgCreateDocfile StgCreateDocfileOnILockBytes
StgCreatePropSetStg StgCreatePropStg
StgCreateStorageEx StgGetIFillLockBytesOnFile
StgGetIFillLockBytesOnILockBytes StgIsStorageFile
StgIsStorageILockBytes StgOpenAsyncDocfileOnIFillLockBytes
StgOpenPropStg StgOpenStorage
StgOpenStorageEx StgOpenStorageOnILockBytes
StgPropertyLengthAsVariant StgSetTimes
WriteClassStg WriteClassStm
WriteFmtUserTypeStg

Finally, the canonical functions described as COM Fundamentals.

COM Fundamentals
BindMoniker CLSIDFromProgID
CLSIDFromProgIDEx CLSIDFromString
CoAddRefServerProcess CoAllowSetForegroundWindow
CoAllowUnmarshalerCLSID CoCancelCall
CoCopyProxy CoCreateFreeThreadedMarshaler
CoCreateGuid CoCreateInstance
CoCreateInstanceEx CoCreateInstanceFromApp
CoDisableCallCancellation CoDisconnectContext
CoDisconnectObject CoDosDateTimeToFileTime
CoEnableCallCancellation CoEnterApplicationThreadLifetimeLoop
CoFileTimeNow CoFileTimeToDosDateTime
CoFreeAllLibraries CoFreeLibrary
CoFreeUnusedLibraries CoFreeUnusedLibrariesEx
CoGetApartmentType CoGetCallContext
CoGetCallerTID CoGetCancelObject
CoGetClassObject CoGetContextToken
CoGetCurrentLogicalThreadId CoGetCurrentProcess
CoGetInstanceFromFile CoGetInstanceFromIStorage
CoGetInterceptor CoGetInterfaceAndReleaseStream
CoGetMalloc CoGetMarshalSizeMax
CoGetObject CoGetObjectContext
CoGetPSClsid CoGetStandardMarshal
CoGetStdMarshalEx CoGetSystemSecurityPermissions
CoGetTreatAsClass CoHandlePriorityEventsFromMessagePump
CoImpersonateClient CoIncrementMTAUsage
CoInitialize CoInitializeEx
CoInitializeSecurity CoInstall
CoInvalidateRemoteMachineBindings CoIsHandlerConnected
CoIsOle1Class CoLoadLibrary
CoLockObjectExternal CoMarshalHresult
CoMarshalInterface CoMarshalInterThreadInterfaceInStream
CoQueryAuthenticationServices CoQueryClientBlanket
CoQueryProxyBlanket CoRegisterActivationFilter
CoRegisterChannelHook CoRegisterClassObject
CoRegisterInitializeSpy CoRegisterMallocSpy
CoRegisterMessageFilter CoRegisterPSClsid
CoRegisterSurrogate CoRegisterSurrogateEx
CoReleaseMarshalData CoReleaseServerProcess
CoResumeClassObjects CoRevertToSelf
CoRevokeClassObject CoRevokeInitializeSpy
CoRevokeMallocSpy CoSetCancelObject
CoSetMessageDispatcher CoSetProxyBlanket
CoSuspendClassObjects CoSwitchCallContext
CoTaskMemAlloc CoTaskMemFree
CoTaskMemRealloc CoTestCancel
CoTreatAsClass CoUninitialize
CoUnmarshalHresult CoUnmarshalInterface
CoWaitForMultipleHandles CoWaitForMultipleObjects
CreateAntiMoniker CreateBindCtx
CreateClassMoniker CreateFileMoniker
CreateGenericComposite CreateItemMoniker
CreateObjrefMoniker CreatePointerMoniker
DllDebugObjectRPCHook DllGetClassObject
DllRegisterServer GetClassFile
GetRunningObjectTable IIDFromString
IsAccelerator IsEqualGUID
MkParseDisplayName MonikerCommonPrefixWith
MonikerRelativePathTo OleDoAutoConvert
OleGetAutoConvert OleGetIconOfClass
OleGetIconOfFile OleRegGetMiscStatus
OleRegGetUserType OleSetAutoConvert
ProgIDFromCLSID StringFromCLSID
StringFromGUID2 StringFromIID

No comments:

Post a Comment