private unsafe static int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids)
            {
                try
                {
                    var shadow   = ToShadow <InspectableShadow>(thisPtr);
                    var callback = (IInspectable)shadow.Callback;

                    var container = callback.Shadow;

                    var countGuids = container.Guids.Length;

                    // Copy GUIDs deduced from Callback
                    iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids);
                    *iidCount = countGuids;

                    for (int i = 0; i < countGuids; i++)
                    {
                        iids[i] = container.Guids[i];
                    }
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Example #2
0
 private static int GetTrustLevel(IntPtr thisPtr, IntPtr trustLevel)
 {
     try
     {
         InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
         IInspectable      callback = (IInspectable)shadow.Callback;
         // Write full trust
         Marshal.WriteInt32(trustLevel, (int)TrustLevel.FullTrust);
     }
     catch (Exception exception)
     {
         return((int)Result.GetResultFromException(exception));
     }
     return(Result.Ok.Code);
 }
Example #3
0
            private static unsafe int GetRuntimeClassName(IntPtr thisPtr, IntPtr *className)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;
                    // Use the name of the callback class

                    string name = callback.GetType().FullName;
                    Win32.WinRTStrings.WindowsCreateString(name, (uint)name.Length, out IntPtr str);
                    *className = str;
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Example #4
0
            private static unsafe int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;

                    ShadowContainer container = callback.Shadow;

                    int countGuids = container.Guids.Length;

                    // Copy GUIDs deduced from Callback
                    iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids);
                    *iidCount = countGuids;

                    MemoryHelpers.CopyMemory((IntPtr)iids, new ReadOnlySpan <IntPtr>(container.Guids));
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }