Exemple #1
0
        internal static AGDnsApi.ag_upstream_options ToNativeObject(
            UpstreamOptions upstreamOptions,
            Queue <IntPtr> allocatedPointers)
        {
            AGDnsApi.ag_list bootstrapC = MarshalUtils.ListToAgList(
                upstreamOptions.Bootstrap,
                MarshalUtils.StringToPtr,
                allocatedPointers);

            byte[] addressBytes = null;
            if (upstreamOptions.ResolvedIpAddress != null)
            {
                addressBytes = upstreamOptions.ResolvedIpAddress.GetAddressBytes();
            }

            AGDnsApi.ag_buffer           addressC         = MarshalUtils.BytesToAgBuffer(addressBytes, allocatedPointers);
            AGDnsApi.ag_upstream_options upstreamOptionsC = new AGDnsApi.ag_upstream_options
            {
                bootstrap           = bootstrapC,
                resolved_ip_address = addressC
            };

            MarshalUtils.CopyPropertiesToFields(upstreamOptions, ref upstreamOptionsC);
            MarshalUtils.AllStringsToPtrs(upstreamOptions, ref upstreamOptionsC, allocatedPointers);
            return(upstreamOptionsC);
        }
Exemple #2
0
        /// <summary>
        /// Converts the managed data to unmanaged data.
        /// </summary>
        /// <param name="managedObj">The managed object to be converted. </param>
        /// <returns>A pointer to the COM view of the managed object.</returns>
        public IntPtr MarshalManagedToNative(object managedObj)
        {
            string managedString  = managedObj as string;
            IntPtr pManagedString = MarshalUtils.StringToPtr(managedString);

            return(pManagedString);
        }
        private static AGDnsApi.ag_outbound_proxy_settings ToNativeObject(
            OutboundProxySettings outboundProxySettings,
            Queue <IntPtr> allocatedPointers)
        {
            IntPtr pOutboundProxyAuthInfoC = IntPtr.Zero;

            if (outboundProxySettings.AuthInfo != null)
            {
                AGDnsApi.ag_outbound_proxy_auth_info outboundProxyAuthInfoC = ToNativeObject(
                    outboundProxySettings.AuthInfo,
                    allocatedPointers);
                pOutboundProxyAuthInfoC = MarshalUtils.StructureToPtr(
                    outboundProxyAuthInfoC,
                    allocatedPointers);
            }

            AGDnsApi.ag_outbound_proxy_settings outboundProxySettingsC =
                new AGDnsApi.ag_outbound_proxy_settings
            {
                auth_info = pOutboundProxyAuthInfoC
            };

            MarshalUtils.CopyPropertiesToFields(outboundProxySettings, ref outboundProxySettingsC);
            MarshalUtils.AllStringsToPtrs(
                outboundProxySettings,
                ref outboundProxySettingsC,
                allocatedPointers);

            return(outboundProxySettingsC);
        }
Exemple #4
0
        internal static DnsProxySettings FromNativeObject(
            AGDnsApi.ag_dnsproxy_settings dnsProxySettingsC)
        {
            List <UpstreamOptions> upstreams = MarshalUtils.AgListToList <AGDnsApi.ag_upstream_options, UpstreamOptions>(
                dnsProxySettingsC.upstreams,
                FromNativeObject);

            List <UpstreamOptions> fallbacks = MarshalUtils.AgListToList <AGDnsApi.ag_upstream_options, UpstreamOptions>(
                dnsProxySettingsC.fallbacks,
                FromNativeObject);

            Dns64Settings           dns64        = FromNativeObject(dnsProxySettingsC.pDns64);
            EngineParams            engineParams = FromNativeObject(dnsProxySettingsC.FilterParams);
            List <ListenerSettings> listeners    =
                MarshalUtils.AgListToList <AGDnsApi.ag_listener_settings, ListenerSettings>(
                    dnsProxySettingsC.listeners,
                    FromNativeObject);
            DnsProxySettings dnsProxySettings = new DnsProxySettings
            {
                Upstreams    = upstreams,
                Fallbacks    = fallbacks,
                Dns64        = dns64,
                EngineParams = engineParams,
                Listeners    = listeners,
            };

            MarshalUtils.CopyFieldsToProperties(dnsProxySettingsC, dnsProxySettings);
            MarshalUtils.AllPtrsToStrings(dnsProxySettingsC, dnsProxySettings);
            return(dnsProxySettings);
        }
        /// <summary>
        /// Converts the managed <see cref="dnsProxySettings"/>
        /// (<seealso cref="DnsProxySettings"/>) to the native <see cref="AGDnsApi.ag_dnsproxy_settings"/> object
        /// </summary>
        /// <param name="dnsProxySettings"><see cref="DnsProxySettings"/> instance to convert</param>
        /// <param name="allocatedPointers">List of pointers, which were allocated.
        /// Pointers, which will be referred to a newly allocated memory
        /// (within the process of marshaling the string to the pointer)
        /// will be added to this list.
        /// If this list is not specified (null),
        /// a new created pointer will not be added anywhere</param>
        /// The resulting pointer (<seealso cref="IntPtr"/>) must be freed
        /// with <see cref="MarshalUtils.SafeFreeHGlobal(IntPtr)"/>>
        /// <returns>An instance of <see cref="AGDnsApi.ag_dnsproxy_settings"/></returns>
        internal static AGDnsApi.ag_dnsproxy_settings ToNativeObject(
            DnsProxySettings dnsProxySettings,
            Queue <IntPtr> allocatedPointers)
        {
            MarshalUtils.ag_list upstreamsC = MarshalUtils.ListToAgList(
                dnsProxySettings.Upstreams,
                ToNativeObject,
                allocatedPointers);

            MarshalUtils.ag_list fallbacksC = MarshalUtils.ListToAgList(
                dnsProxySettings.Fallbacks,
                ToNativeObject,
                allocatedPointers);

            MarshalUtils.ag_list fallbackDomains = MarshalUtils.ListToAgList(
                dnsProxySettings.FallbackDomains,
                MarshalUtils.StringToPtr,
                allocatedPointers);

            IntPtr pDns64C = IntPtr.Zero;

            if (dnsProxySettings.Dns64 != null)
            {
                AGDnsApi.ag_dns64_settings dns64C =
                    ToNativeObject(dnsProxySettings.Dns64, allocatedPointers);
                pDns64C = MarshalUtils.StructureToPtr(dns64C, allocatedPointers);
            }

            AGDnsApi.ag_filter_engine_params filterEngineParamsC =
                ToNativeObject(dnsProxySettings.EngineParams, allocatedPointers);
            MarshalUtils.ag_list listenersC = MarshalUtils.ListToAgList(
                dnsProxySettings.Listeners,
                ToNativeObject,
                allocatedPointers);

            IntPtr pOutboundProxySessionC = IntPtr.Zero;

            if (dnsProxySettings.OutboundProxySettings != null)
            {
                AGDnsApi.ag_outbound_proxy_settings outboundProxySettingsC =
                    ToNativeObject(dnsProxySettings.OutboundProxySettings, allocatedPointers);
                pOutboundProxySessionC = MarshalUtils.StructureToPtr(outboundProxySettingsC, allocatedPointers);
            }

            AGDnsApi.ag_dnsproxy_settings dnsProxySettingsC = new AGDnsApi.ag_dnsproxy_settings
            {
                upstreams       = upstreamsC,
                fallbacks       = fallbacksC,
                pDns64          = pDns64C,
                FilterParams    = filterEngineParamsC,
                listeners       = listenersC,
                outbound_proxy  = pOutboundProxySessionC,
                fallbackDomains = fallbackDomains,
            };

            MarshalUtils.CopyPropertiesToFields(dnsProxySettings, ref dnsProxySettingsC);
            MarshalUtils.AllStringsToPtrs(dnsProxySettings, ref dnsProxySettingsC, allocatedPointers);
            return(dnsProxySettingsC);
        }
Exemple #6
0
        private static FilterParams FromNativeObject(AGDnsApi.ag_filter_params filterParamsC)
        {
            FilterParams filterParams = new FilterParams();

            MarshalUtils.AllPtrsToStrings(filterParamsC, filterParams);
            MarshalUtils.CopyFieldsToProperties(filterParamsC, filterParams);
            return(filterParams);
        }
Exemple #7
0
        internal static DnsStamp FromNativeObject(AGDnsApi.ag_dns_stamp agDnsStampC)
        {
            DnsStamp dnsStamp = new DnsStamp();

            MarshalUtils.AllPtrsToStrings(agDnsStampC, dnsStamp);
            MarshalUtils.CopyFieldsToProperties(agDnsStampC, dnsStamp);
            return(dnsStamp);
        }
        private static OutboundProxyAuthInfo FromNativeObject(
            AGDnsApi.ag_outbound_proxy_auth_info outboundProxyAuthInfoC)
        {
            OutboundProxyAuthInfo outboundProxyAuthInfo = new OutboundProxyAuthInfo();

            MarshalUtils.CopyFieldsToProperties(outboundProxyAuthInfoC, outboundProxyAuthInfo);
            MarshalUtils.AllPtrsToStrings(outboundProxyAuthInfoC, outboundProxyAuthInfo);
            return(outboundProxyAuthInfo);
        }
Exemple #9
0
 private static AGDnsApi.ag_filter_params ToNativeObject(
     FilterParams filterParams,
     Queue <IntPtr> allocatedPointers)
 {
     AGDnsApi.ag_filter_params filterParamsC = new AGDnsApi.ag_filter_params();
     MarshalUtils.CopyPropertiesToFields(filterParams, ref filterParamsC);
     MarshalUtils.AllStringsToPtrs(filterParams, ref filterParamsC, allocatedPointers);
     return(filterParamsC);
 }
Exemple #10
0
        /// <summary>
        /// Creates the <see cref="IPAddress"/> object from the specified pointer to address string
        /// </summary>
        /// <param name="pAddress">The pointer to the address string
        /// (<seealso cref="IntPtr"/>)</param>
        /// <exception cref="ArgumentException">Thrown,
        /// if passed <see cref="AGDnsApi.ag_buffer.size"/> is not acceptable</exception>
        /// <returns><see cref="IPAddress"/> object or null if the pointer is null or addressLength is zero</returns>
        private static IPAddress CreateIpAddress(IntPtr pAddress)
        {
            if (pAddress == IntPtr.Zero)
            {
                return(null);
            }

            string    address   = MarshalUtils.PtrToString(pAddress);
            IPAddress ipAddress = IPAddress.Parse(address);

            return(ipAddress);
        }
Exemple #11
0
        private static ListenerSettings FromNativeObject(AGDnsApi.ag_listener_settings listenerSettingsC)
        {
            IPAddress        address          = CreateIpAddress(listenerSettingsC.address);
            int              port             = listenerSettingsC.port;
            IPEndPoint       endPoint         = CreateEndPoint(address, port);
            ListenerSettings listenerSettings = new ListenerSettings
            {
                EndPoint = endPoint
            };

            MarshalUtils.CopyFieldsToProperties(listenerSettingsC, listenerSettings);
            return(listenerSettings);
        }
 private static AGDnsApi.ag_outbound_proxy_auth_info ToNativeObject(
     OutboundProxyAuthInfo outboundProxyAuthInfo,
     Queue <IntPtr> allocatedPointers)
 {
     AGDnsApi.ag_outbound_proxy_auth_info outboundProxyAuthInfoC =
         new AGDnsApi.ag_outbound_proxy_auth_info();
     MarshalUtils.CopyPropertiesToFields(outboundProxyAuthInfo, ref outboundProxyAuthInfoC);
     MarshalUtils.AllStringsToPtrs(
         outboundProxyAuthInfo,
         ref outboundProxyAuthInfoC,
         allocatedPointers);
     return(outboundProxyAuthInfoC);
 }
 /// <summary>
 /// <see cref="AGDnsApi.AGDnsProxyServerCallbacks.ag_dns_request_processed_cb"/> adapter
 /// </summary>
 /// <param name="pInfo">The pointer to an instance of
 /// <see cref="AGDnsApi.ag_dns_request_processed_event"/></param>
 private void AGCOnDnsRequestProcessed(IntPtr pInfo)
 {
     try
     {
         AGDnsApi.ag_dns_request_processed_event coreArgs =
             MarshalUtils.PtrToStructure <AGDnsApi.ag_dns_request_processed_event>(pInfo);
         DnsRequestProcessedEventArgs args = DnsApiConverter.FromNativeObject(coreArgs);
         m_DnsServerCallbackConfiguration.OnDnsRequestProcessed(m_ProxyServer, args);
     }
     catch (Exception ex)
     {
         DnsExceptionHandler.HandleManagedException(ex);
     }
 }
Exemple #14
0
        private static EngineParams FromNativeObject(AGDnsApi.ag_filter_engine_params filterEngineParamsC)
        {
            List <FilterParams> filterParams =
                MarshalUtils.AgListToList <AGDnsApi.ag_filter_params, FilterParams>(
                    filterEngineParamsC.filters,
                    FromNativeObject);

            EngineParams engineParams = new EngineParams
            {
                FilterParams = filterParams
            };

            return(engineParams);
        }
Exemple #15
0
        private static AGDnsApi.ag_filter_engine_params ToNativeObject(
            EngineParams engineParams,
            Queue <IntPtr> allocatedPointers)
        {
            AGDnsApi.ag_list filterParamsC = MarshalUtils.ListToAgList(
                engineParams.FilterParams,
                ToNativeObject,
                allocatedPointers);
            AGDnsApi.ag_filter_engine_params filterEngineParamsC = new AGDnsApi.ag_filter_engine_params
            {
                filters = filterParamsC
            };

            return(filterEngineParamsC);
        }
Exemple #16
0
        internal static CertificateVerificationEventArgs FromNativeObject(
            AGDnsApi.ag_certificate_verification_event coreArgsС)
        {
            byte[]        certBytes = MarshalUtils.AgBufferToBytes(coreArgsС.pCertificate);
            List <byte[]> chain     = MarshalUtils.AgListToList <AGDnsApi.ag_buffer, byte[]>(
                coreArgsС.chain,
                MarshalUtils.AgBufferToBytes);
            CertificateVerificationEventArgs eventArgs = new CertificateVerificationEventArgs
            {
                Certificate = certBytes,
                Chain       = chain
            };

            return(eventArgs);
        }
        private static Dns64Settings FromNativeObject(AGDnsApi.ag_dns64_settings dns64C)
        {
            List <UpstreamOptions> dns64Upstreams =
                MarshalUtils.AgListToList <AGDnsApi.ag_upstream_options, UpstreamOptions>(
                    dns64C.upstreams,
                    FromNativeObject);

            Dns64Settings dns64 = new Dns64Settings
            {
                Upstreams = dns64Upstreams
            };

            MarshalUtils.CopyFieldsToProperties(dns64C, dns64);
            return(dns64);
        }
        internal static DnsStamp FromNativeObject(AGDnsApi.ag_dns_stamp agDnsStampC)
        {
            byte[]        publicKey = MarshalUtils.AgBufferToBytes(agDnsStampC.server_public_key);
            List <byte[]> hashes    = MarshalUtils.AgListToList <MarshalUtils.ag_buffer, byte[]>(
                agDnsStampC.hashes,
                MarshalUtils.AgBufferToBytes);
            DnsStamp dnsStamp = new DnsStamp
            {
                PublicKey = publicKey,
                Hashes    = hashes
            };

            MarshalUtils.AllPtrsToStrings(agDnsStampC, dnsStamp);
            MarshalUtils.CopyFieldsToProperties(agDnsStampC, dnsStamp);
            return(dnsStamp);
        }
Exemple #19
0
 /// <summary>
 /// <see cref="AGDnsApi.cbd_onCertificateVerification"/> adapter
 /// </summary>
 /// <param name="pInfo">The pointer to an instance of
 /// <see cref="AGDnsApi.ag_certificate_verification_event"/></param>
 /// <returns>Certificate verification result
 /// (<seealso cref="AGDnsApi.ag_certificate_verification_result"/>)</returns>
 private AGDnsApi.ag_certificate_verification_result AGCOnCertificateVerification(IntPtr pInfo)
 {
     try
     {
         AGDnsApi.ag_certificate_verification_event coreArgs =
             MarshalUtils.PtrToStructure <AGDnsApi.ag_certificate_verification_event>(pInfo);
         CertificateVerificationEventArgs            args = DnsApiConverter.FromNativeObject(coreArgs);
         AGDnsApi.ag_certificate_verification_result certificateVerificationResult =
             m_CertificateVerificationCallback.OnCertificateVerification(this, args);
         return(certificateVerificationResult);
     }
     catch (Exception ex)
     {
         DnsExceptionHandler.HandleManagedException(ex);
         return(AGDnsApi.ag_certificate_verification_result.AGCVR_ERROR_CERT_VERIFICATION);
     }
 }
Exemple #20
0
        private static UpstreamOptions FromNativeObject(AGDnsApi.ag_upstream_options upstreamOptionsC)
        {
            List <string> bootstrap = MarshalUtils.AgListToList <IntPtr, string>(
                upstreamOptionsC.bootstrap,
                MarshalUtils.PtrToString);

            IPAddress       serverAddress   = CreateIpAddress(upstreamOptionsC.resolved_ip_address);
            UpstreamOptions upstreamOptions = new UpstreamOptions
            {
                Bootstrap         = bootstrap,
                ResolvedIpAddress = serverAddress
            };

            MarshalUtils.CopyFieldsToProperties(upstreamOptionsC, upstreamOptions);
            MarshalUtils.AllPtrsToStrings(upstreamOptionsC, upstreamOptions);
            return(upstreamOptions);
        }
        private static OutboundProxySettings FromNativeObject(
            AGDnsApi.ag_outbound_proxy_settings outboundProxySettingsC)
        {
            AGDnsApi.ag_outbound_proxy_auth_info outboundProxyAuthInfoC =
                MarshalUtils.PtrToStructure <AGDnsApi.ag_outbound_proxy_auth_info>(
                    outboundProxySettingsC.auth_info);

            OutboundProxyAuthInfo authInfo = FromNativeObject(outboundProxyAuthInfoC);
            OutboundProxySettings outboundProxySettings = new OutboundProxySettings
            {
                AuthInfo = authInfo
            };

            MarshalUtils.CopyFieldsToProperties(outboundProxySettingsC, outboundProxySettings);
            MarshalUtils.AllPtrsToStrings(outboundProxySettingsC, outboundProxySettings);
            return(outboundProxySettings);
        }
Exemple #22
0
        private static AGDnsApi.ag_dns64_settings ToNativeObject(
            Dns64Settings dns64,
            Queue <IntPtr> allocatedPointers)
        {
            AGDnsApi.ag_list dns64upstreamsC = MarshalUtils.ListToAgList(
                dns64.Upstreams,
                ToNativeObject,
                allocatedPointers);

            AGDnsApi.ag_dns64_settings dns64C = new AGDnsApi.ag_dns64_settings
            {
                upstreams = dns64upstreamsC
            };

            MarshalUtils.CopyPropertiesToFields(dns64, ref dns64C);
            return(dns64C);
        }
Exemple #23
0
        /// <summary>
        /// Converts the managed <see cref="listenerSettings"/>
        /// (<seealso cref="ListenerSettings"/>) to the native <see cref="AGDnsApi.ag_listener_settings"/> object
        /// </summary>
        /// <param name="listenerSettings"><see cref="ListenerSettings"/> instance to convert</param>
        /// <param name="allocatedPointers">List of pointers, which were allocated.
        /// Pointers, which will be referred to a newly allocated memory
        /// (within the process of marshaling the string to the pointer)
        /// will be added to this list.
        /// If this list is not specified (null),
        /// a new created pointer will not be added anywhere</param>
        /// The resulting pointer (<seealso cref="IntPtr"/>) must be freed
        /// with <see cref="MarshalUtils.SafeFreeHGlobal(IntPtr)"/>>
        /// <returns>An instance of <see cref="AGDnsApi.ag_listener_settings"/></returns>
        private static AGDnsApi.ag_listener_settings ToNativeObject(
            ListenerSettings listenerSettings,
            Queue <IntPtr> allocatedPointers)
        {
            ushort port    = (ushort)listenerSettings.EndPoint.Port;
            IntPtr address = MarshalUtils.StringToPtr(
                listenerSettings.EndPoint.Address.ToString(),
                allocatedPointers);

            AGDnsApi.ag_listener_settings listenerSettingsC = new AGDnsApi.ag_listener_settings
            {
                address = address,
                port    = port
            };

            MarshalUtils.CopyPropertiesToFields(listenerSettings, ref listenerSettingsC);
            return(listenerSettingsC);
        }
        internal static DnsProxySettings FromNativeObject(
            AGDnsApi.ag_dnsproxy_settings dnsProxySettingsC)
        {
            List <UpstreamOptions> upstreams = MarshalUtils.AgListToList <AGDnsApi.ag_upstream_options, UpstreamOptions>(
                dnsProxySettingsC.upstreams,
                FromNativeObject);

            List <UpstreamOptions> fallbacks = MarshalUtils.AgListToList <AGDnsApi.ag_upstream_options, UpstreamOptions>(
                dnsProxySettingsC.fallbacks,
                FromNativeObject);

            List <string> fallbackDomains = MarshalUtils.AgListToList <IntPtr, string>(
                dnsProxySettingsC.fallbackDomains,
                MarshalUtils.PtrToString);

            AGDnsApi.ag_dns64_settings dns64C =
                MarshalUtils.PtrToStructure <AGDnsApi.ag_dns64_settings>(dnsProxySettingsC.pDns64);
            Dns64Settings           dns64        = FromNativeObject(dns64C);
            EngineParams            engineParams = FromNativeObject(dnsProxySettingsC.FilterParams);
            List <ListenerSettings> listeners    =
                MarshalUtils.AgListToList <AGDnsApi.ag_listener_settings, ListenerSettings>(
                    dnsProxySettingsC.listeners,
                    FromNativeObject);

            AGDnsApi.ag_outbound_proxy_settings outboundProxySettingsC =
                MarshalUtils.PtrToStructure <AGDnsApi.ag_outbound_proxy_settings>(dnsProxySettingsC.outbound_proxy);
            OutboundProxySettings outboundProxySettings =
                FromNativeObject(outboundProxySettingsC);
            DnsProxySettings dnsProxySettings = new DnsProxySettings
            {
                Upstreams             = upstreams,
                Fallbacks             = fallbacks,
                FallbackDomains       = fallbackDomains,
                Dns64                 = dns64,
                EngineParams          = engineParams,
                Listeners             = listeners,
                OutboundProxySettings = outboundProxySettings
            };

            MarshalUtils.CopyFieldsToProperties(dnsProxySettingsC, dnsProxySettings);
            MarshalUtils.AllPtrsToStrings(dnsProxySettingsC, dnsProxySettings);
            return(dnsProxySettings);
        }
 public static AGDnsApi.ag_dns_stamp ToNativeObject(
     DnsStamp dnsStamp,
     Queue <IntPtr> allocatedPointers)
 {
     MarshalUtils.ag_buffer publicKeyC = MarshalUtils.BytesToAgBuffer(dnsStamp.PublicKey);
     MarshalUtils.ag_list   hashesC    = MarshalUtils.ListToAgList(
         dnsStamp.Hashes,
         (x, y) => MarshalUtils.BytesToAgBuffer(x),
         allocatedPointers);
     AGDnsApi.ag_dns_stamp dnsStampС = new AGDnsApi.ag_dns_stamp
     {
         ProtoType         = dnsStamp.ProtoType,
         ServerAddress     = MarshalUtils.StringToPtr(dnsStamp.ServerAddress),
         ProviderName      = MarshalUtils.StringToPtr(dnsStamp.ProviderName),
         DoHPath           = MarshalUtils.StringToPtr(dnsStamp.DoHPath),
         server_public_key = publicKeyC,
         hashes            = hashesC,
         Properties        = dnsStamp.Properties
     };
     return(dnsStampС);
 }
Exemple #26
0
        internal static DnsRequestProcessedEventArgs FromNativeObject(
            AGDnsApi.ag_dns_request_processed_event coreArgsС)
        {
            List <string> rules = MarshalUtils.AgListToList <IntPtr, string>(
                coreArgsС.rules,
                MarshalUtils.PtrToString);

            List <int> filterListIds = MarshalUtils.AgListToList <IntPtr, int>(
                coreArgsС.filter_list_ids,
                filterId =>
                (int)filterId);

            int?upstreamId = MarshalUtils.PtrToNullableInt(coreArgsС.pUpstreamId);
            DnsRequestProcessedEventArgs eventArgs = new DnsRequestProcessedEventArgs
            {
                UpstreamId    = upstreamId,
                Rules         = rules,
                FilterListIds = filterListIds
            };

            MarshalUtils.AllPtrsToStrings(coreArgsС, eventArgs);
            MarshalUtils.CopyFieldsToProperties(coreArgsС, eventArgs);
            return(eventArgs);
        }
Exemple #27
0
 /// <summary>
 /// Performs necessary cleanup of the unmanaged data when it is no longer needed.
 /// </summary>
 /// <param name="pNativeData">A pointer to the unmanaged data to be destroyed. </param>
 public void CleanUpNativeData(IntPtr pNativeData)
 {
     MarshalUtils.SafeFreeHGlobal(pNativeData);
 }
Exemple #28
0
        /// <summary>
        /// Converts the unmanaged data to managed data.
        /// </summary>
        /// <param name="pNativeData">A pointer to the unmanaged data to be wrapped. </param>
        /// <returns>An object that represents the managed view of the COM data.</returns>
        public object MarshalNativeToManaged(IntPtr pNativeData)
        {
            string managedString = MarshalUtils.PtrToString(pNativeData);

            return(managedString);
        }