public override int GetDocumentation(int memid, IntPtr strName, IntPtr strDocString, IntPtr dwHelpContext, IntPtr strHelpFile) { if (memid == (int)KnownDispatchMemberIDs.MEMBERID_NIL) { if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, Marshal.StringToBSTR("_ArtificialContainer")); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, IntPtr.Zero); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, 0); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, IntPtr.Zero); } return((int)KnownComHResults.S_OK); } return((int)KnownComHResults.TYPE_E_ELEMENTNOTFOUND); }
public override int GetLibAttr(IntPtr ppTLibAttr) { var output = RdMarshal.AllocHGlobal(Marshal.SizeOf(typeof(ComTypes.TYPELIBATTR))); RdMarshal.StructureToPtr(_libAttribs, output, false); RdMarshal.WriteIntPtr(ppTLibAttr, output); return((int)KnownComHResults.S_OK); }
public override int GetTypeInfo(int index, IntPtr ppTI) { if (index >= _containedTypeInfos.Count) { return((int)KnownComHResults.TYPE_E_ELEMENTNOTFOUND); } var ti = _containedTypeInfos[index]; RdMarshal.WriteIntPtr(ppTI, ti.GetCOMReferencePtr()); return((int)KnownComHResults.S_OK); }
public override int GetRefTypeInfo(int hRef, IntPtr ppTI) { var hr = GetSafeRefTypeInfo(hRef, out var ti); if (ComHelper.HRESULT_FAILED(hr)) { return(HandleBadHRESULT(hr)); } RdMarshal.WriteIntPtr(ppTI, ti.GetCOMReferencePtr()); return(hr); }
public override int GetDocumentation(int memid, IntPtr strName, IntPtr strDocString, IntPtr dwHelpContext, IntPtr strHelpFile) { if (IsDispatchMemberIDInOurConstantsRange(memid)) { // this is very likely one of our simulated names from GetVarDesc() var fieldId = memid & _ourConstantsDispatchMemberIDIndexBitmask; if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, Marshal.StringToBSTR("_constantFieldId" + fieldId)); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, IntPtr.Zero); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, 0); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, IntPtr.Zero); } return((int)KnownComHResults.S_OK); } if (memid == (int)KnownDispatchMemberIDs.MEMBERID_NIL) { // return the cached information here, to workaround the VBE bug for unnamed UserForm base classes causing an access violation if (strName != IntPtr.Zero) { RdMarshal.WriteIntPtr(strName, RdMarshal.StringToBSTR(Name)); } if (strDocString != IntPtr.Zero) { RdMarshal.WriteIntPtr(strDocString, RdMarshal.StringToBSTR(DocString)); } if (dwHelpContext != IntPtr.Zero) { RdMarshal.WriteInt32(dwHelpContext, HelpContext); } if (strHelpFile != IntPtr.Zero) { RdMarshal.WriteIntPtr(strHelpFile, RdMarshal.StringToBSTR(HelpFile)); } return((int)KnownComHResults.S_OK); } else { var hr = _target_ITypeInfo.GetDocumentation(memid, strName, strDocString, dwHelpContext, strHelpFile); return(ComHelper.HRESULT_FAILED(hr) ? HandleBadHRESULT(hr) : hr); } }
public override int GetTypeInfo(int index, IntPtr ppTI) { // We have to wrap the ITypeInfo returned by GetTypeInfo var hr = GetSafeTypeInfoByIndex(index, out var ti); if (ComHelper.HRESULT_FAILED(hr)) { return(HandleBadHRESULT(hr)); } RdMarshal.WriteIntPtr(ppTI, ti.GetCOMReferencePtr()); return(hr); }
public override int GetTypeInfoOfGuid(ref Guid guid, IntPtr ppTInfo) { var inGuid = guid; var ti = _containedTypeInfos.Find(x => x.GUID == inGuid); if (ti == null) { return((int)KnownComHResults.TYPE_E_ELEMENTNOTFOUND); } RdMarshal.WriteIntPtr(ppTInfo, ti.GetCOMReferencePtr()); return((int)KnownComHResults.S_OK); }
public override int GetContainingTypeLib(IntPtr ppTLB, IntPtr pIndex) { // even though pIndex is described as a non-optional OUT argument, mscorlib sometimes calls this with a nullptr from the C++ side. if (pIndex == IntPtr.Zero) { RdMarshal.WriteIntPtr(ppTLB, IntPtr.Zero); return((int)KnownComHResults.E_INVALIDARG); } RdMarshal.WriteIntPtr(ppTLB, RdMarshal.GetComInterfaceForObject(_container, typeof(ITypeLibInternal))); if (pIndex != IntPtr.Zero) { RdMarshal.WriteInt32(pIndex, ContainerIndex); } return((int)KnownComHResults.S_OK); }
public override int GetTypeInfoOfGuid(ref Guid guid, IntPtr ppTInfo) { var hr = _target_ITypeLib.GetTypeInfoOfGuid(guid, ppTInfo); if (ComHelper.HRESULT_FAILED(hr)) { return(HandleBadHRESULT(hr)); } var pTInfo = RdMarshal.ReadIntPtr(ppTInfo); using (var outVal = TypeApiFactory.GetTypeInfoWrapper(pTInfo)) // takes ownership of the COM reference [pTInfo] { RdMarshal.WriteIntPtr(ppTInfo, outVal.GetCOMReferencePtr()); _cachedTypeInfos = _cachedTypeInfos ?? new DisposableList <ITypeInfoWrapper>(); _cachedTypeInfos.Add(outVal); } return(hr); }
public override int GetNames(int memid, IntPtr rgBstrNames, int cMaxNames, IntPtr pcNames) { if (IsDispatchMemberIDInOurConstantsRange(memid)) { // this is most likely one of our simulated names from GetVarDesc() var fieldId = memid & _ourConstantsDispatchMemberIDIndexBitmask; if ((rgBstrNames != IntPtr.Zero) && (cMaxNames >= 1)) { // output 1 string to the array RdMarshal.WriteIntPtr(rgBstrNames, RdMarshal.StringToBSTR("_constantFieldId" + fieldId)); if (pcNames != IntPtr.Zero) { RdMarshal.WriteInt32(pcNames, 1); } return((int)KnownComHResults.S_OK); } } var hr = _target_ITypeInfo.GetNames(memid, rgBstrNames, cMaxNames, pcNames); return(ComHelper.HRESULT_FAILED(hr) ? HandleBadHRESULT(hr) : hr); }