// Token: 0x06004FF3 RID: 20467 RVA: 0x00119454 File Offset: 0x00117654 internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest == null || applicationComponentManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown enumUnknown = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum; uint num = 0U; object[] array = new object[1]; if (enumUnknown.Next(1U, array, ref num) == 0 && num == 1U) { IEntryPointEntry entryPointEntry = (IEntryPointEntry)array[0]; EntryPointEntry allData = entryPointEntry.AllData; if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0) { fileName = allData.CommandLine_File; } else { object obj = null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out obj); IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)obj; fileName = assemblyReferenceEntry.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; } }
// Token: 0x06004FF4 RID: 20468 RVA: 0x00119534 File Offset: 0x00117734 internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] array = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest == null) { return(null); } ISection assemblyReferenceSection = applicationComponentManifest.AssemblyReferenceSection; uint num = (assemblyReferenceSection != null) ? assemblyReferenceSection.Count : 0U; if (num > 0U) { uint num2 = 0U; array = new IAssemblyReferenceEntry[num]; IEnumUnknown enumUnknown = (IEnumUnknown)assemblyReferenceSection._NewEnum; int num3 = enumUnknown.Next(num, array, ref num2); if (num2 != num || num3 < 0) { return(null); } } return(array); }
static Guid[] GetAllPixelFormats() { List <Guid> res = new List <Guid>(); IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IEnumUnknown eu = factory.CreateComponentEnumerator(WICComponentType.WICPixelFormat, WICComponentEnumerateOptions.WICComponentEnumerateRefresh); int hr = 0; object[] o = new object[1]; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); if (fetched == 1) { IWICPixelFormatInfo info = (IWICPixelFormatInfo)o[0]; Guid guid; info.GetFormatGUID(out guid); res.Add(guid); info.ReleaseComObject(); } o.ReleaseComObject(); } return(res.ToArray()); }
internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] entries = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null) { return(null); } ISection dependencySection = appManifest.AssemblyReferenceSection; uint count = (dependencySection != null) ? dependencySection.Count : 0; if (count > 0) { uint fetched = 0; entries = new IAssemblyReferenceEntry[count]; IEnumUnknown dependencyEnum = (IEnumUnknown)dependencySection._NewEnum; int hr = dependencyEnum.Next(count, entries, ref fetched); if (fetched != count || hr < 0) { return(null); // } } return(entries); }
public static IClrRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version) { Object[] temparr = new Object[3]; UInt32 fetchedNum; do { runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum); for (Int32 i = 0; i < fetchedNum; i++) { IClrRuntimeInfo t = (IClrRuntimeInfo)temparr[i]; // version not specified we return the first one if (String.IsNullOrEmpty(version)) { return t; } // initialize buffer for the runtime version string StringBuilder sb = new StringBuilder(16); UInt32 len = Convert.ToUInt32(sb.Capacity); t.GetVersionString(sb, ref len); "version: {0}".info(sb.str()); if (sb.ToString().StartsWith(version, StringComparison.Ordinal)) { return t; } } } while (fetchedNum == temparr.Length); return null; }
private static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, string version) { var tempObjects = new object[3]; uint fetchedCount; do { runtimes.Next((uint)tempObjects.Length, tempObjects, out fetchedCount); for (int i = 0; i < fetchedCount; i++) { var runtimeInfo = (ICLRRuntimeInfo)tempObjects[i]; if (string.IsNullOrEmpty(version)) { return(runtimeInfo); } var builder = new StringBuilder(16); var builderLength = (uint)builder.Capacity; runtimeInfo.GetVersionString(builder, ref builderLength); if (builder.ToString().StartsWith(version, StringComparison.Ordinal)) { return(runtimeInfo); } } } while (fetchedCount == tempObjects.Length); return(null); }
public static IClrRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version) { Object[] temparr = new Object[3]; UInt32 fetchedNum; do { runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum); for (Int32 i = 0; i < fetchedNum; i++) { IClrRuntimeInfo t = (IClrRuntimeInfo)temparr[i]; // version not specified we return the first one if (String.IsNullOrEmpty(version)) { return(t); } // initialize buffer for the runtime version string StringBuilder sb = new StringBuilder(16); UInt32 len = Convert.ToUInt32(sb.Capacity); t.GetVersionString(sb, ref len); "version: {0}".info(sb.str()); if (sb.ToString().StartsWith(version, StringComparison.Ordinal)) { return(t); } } } while (fetchedNum == temparr.Length); return(null); }
public static IEnumerable <T> Cast <T>(this IEnumUnknown enumerator) { var e = enumerator.GetEnumerator(); while (e.MoveNext()) { yield return((T)e.Current); } }
public static List <object> EnumareateAllAndRelease(this IEnumUnknown enumerator, int requestSize = 128) { try { return(EnumerateAll(enumerator, requestSize)); } finally { if (enumerator != null) { Marshal.ReleaseComObject(enumerator); } } }
/// <remarks/> public void Clone(out IEnumUnknown ppenum) { lock (m_lock) { try { ppenum = new EnumUnknown(m_unknowns); } catch (Exception e) { throw ComUtils.CreateComException(e); } } }
/// <summary> /// Creates new process under the debugger. /// </summary> /// <param name="exepath">executable path</param> /// <param name="desiredVersion">the desired version of the runtime - you don't need to /// provide the whole version string as only the first n letters /// are compared, for example version string: "v2.0" will match /// runtimes versioned "v2.0.1234" or "v2.0.50727". If <code>null</code> /// is given, the first found runtime will be returned.</param> /// <param name="options">The options.</param> /// <returns></returns> public static CorDebugger CreateDebuggerForExecutable(String exepath, String desiredVersion = null, CorDebuggerOptions options = null) { ICLRMetaHost metahost = NativeMethods.CLRCreateInstance(ref CLSID_ICLRMetahost, ref IID_ICLRMetahost); IEnumUnknown runtimes = metahost.EnumerateInstalledRuntimes(); ICLRRuntimeInfo runtime = GetRuntime(runtimes, desiredVersion); if (runtime == null) { throw new RuntimeNotFoundException(); } return(CreateDebugger(runtime, options ?? new CorDebuggerOptions())); }
// Retrieve information about runtimes installed on the machine (i.e. in %WINDIR%\Microsoft.NET\) public IEnumerable <CLRRuntimeInfo> EnumerateInstalledRuntimes() { List <CLRRuntimeInfo> runtimes = new List <CLRRuntimeInfo>(); IEnumUnknown enumRuntimes = m_metaHost.EnumerateInstalledRuntimes(); // Since we're only getting one at a time, we can pass NULL for count. // S_OK also means we got the single element we asked for. for (object oIUnknown; enumRuntimes.Next(1, out oIUnknown, IntPtr.Zero) == 0; /* empty */) { runtimes.Add(new CLRRuntimeInfo(oIUnknown)); } return(runtimes); }
// Token: 0x06000197 RID: 407 RVA: 0x000137E4 File Offset: 0x000127E4 public void Clone(out IEnumUnknown ppenum) { lock (this) { try { ppenum = new EnumUnknown(this.m_unknowns); } catch (Exception e) { throw Server.CreateException(e); } } }
public static IEnumerable <object> AsEnumerable(this IEnumUnknown enumUnknown) { var buffer = new object[1]; for (;;) { int length; enumUnknown.Next(1, buffer, out length); if (length != 1) { break; } yield return(buffer[0]); } }
/// <summary> /// Attaches debugger to the running process. /// </summary> /// <param name="pid">Process id</param> /// <param name="desiredVersion">the desired version of the runtime - you don't need to /// provide the whole version string as only the first n letters /// are compared, for example version string: "v2.0" will match /// runtimes versioned "v2.0.1234" or "v2.0.50727". If <code>null</code> /// is given, the first found runtime will be returned.</param> /// <param name="options">The options.</param> /// <returns></returns> public static CorDebugger CreateDebuggerForProcess(Int32 pid, String desiredVersion = null, CorDebuggerOptions options = null) { ICLRMetaHost metahost = NativeMethods.CLRCreateInstance(ref CLSID_ICLRMetahost, ref IID_ICLRMetahost); Process proc = Process.GetProcessById(pid); IEnumUnknown runtimes = metahost.EnumerateLoadedRuntimes(proc.Handle); ICLRRuntimeInfo runtime = GetRuntime(runtimes, desiredVersion); if (runtime == null) { throw new RuntimeNotFoundException(); } return(CreateDebugger(runtime, options ?? new CorDebuggerOptions())); }
void _buttonDropC_ExecuteEvent(object sender, ExecuteEventArgs e) { // enumerate over items IEnumUnknown itemsSource = (IEnumUnknown)_comboBox1.ItemsSource; itemsSource.Reset(); object[] items = new object[1]; uint fetchedItem; while (itemsSource.Next(1, items, out fetchedItem) == HRESULT.S_OK) { IUISimplePropertySet uiItem = (IUISimplePropertySet)items[0]; PropVariant itemLabel; uiItem.GetValue(ref RibbonProperties.Label, out itemLabel); MessageBox.Show("Label = " + (string)itemLabel.Value); } }
// Checks if device supports Content Directory service and opens a browser on it private void BrowseDevice(IUPnPDevice device) { // Get service enumerator IntPtr pE = device.Services._NewEnum; IEnumUnknown pEnum = (IEnumUnknown)Marshal.GetObjectForIUnknown(pE); Marshal.Release(pE); // Enumerate services. Look for one that has ContentDirectory in its description uint cItems; IUPnPService svc = null; IUPnPService svcContent = null; bool couldBrowse = false; while (pEnum.Next(1, out pE, out cItems) == 0 && cItems == 1) { svc = (IUPnPService)Marshal.GetObjectForIUnknown(pE); Marshal.Release(pE); object results;// = new object[3]; object retVal; if (svc.ServiceTypeIdentifier.IndexOf("ContentDirectory", StringComparison.OrdinalIgnoreCase) >= 0) { // Check if the service supports Browse verb // This is not really neccessary, but just a precaution svcContent = svc; int hr = svc.InvokeAction("Browse", new object[] { "0", "BrowseDirectChildren", "*", 0, 0, "" }, out results, out retVal); if (hr == 0) { couldBrowse = true; } hr = 0; } } if (!couldBrowse || svcContent == null) { MessageBox.Show("Found no browsable content"); } else { // We have found the Content Directory Browser browser = new Browser(svcContent); browser.ShowDialog(); } }
public static bool isRuntime(this Process process, string version) { if (process.isNull()) { "in process.isRuntime , process value was null".error(); return(false); } Guid clsid = new Guid("9280188D-0E8E-4867-B30C-7FA83884E8DE"); Guid riid = new Guid("D332DB9E-B9B3-4125-8207-A14884F53216"); var metahost = (IClrMetaHost)_NativeMethods.nCLRCreateInstance(clsid, riid); IEnumUnknown runtimes = metahost.EnumerateLoadedRuntimes(process.Handle); IClrRuntimeInfo runtime = _NativeMethods.GetRuntime(runtimes, version); //IClrRuntimeInfo runtime = _NativeMethods.GetRuntime(runtimes, "v2.0"); return(runtime.notNull()); }
public void Clone(out IEnumUnknown ppenum) { EnumUnknown unknown; Monitor.Enter(unknown = this); try { ppenum = new EnumUnknown(this.m_unknowns); } catch (Exception exception) { throw Server.CreateException(exception); } finally { Monitor.Exit(unknown); } }
public static List <object> EnumerateAll(this IEnumUnknown enumerator, int requestSize = 128) { if (enumerator == null) { return(new List <object>()); } var result = new List <object>(); var fetched = 0; var items = new object[requestSize]; do { enumerator.RemoteNext(items.Length, items, out fetched); result.AddRange(items.Take(fetched)); } while (fetched != 0); return(result); }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = (string)null; fileName = (string)null; ICMS componentManifest = activationContext.ApplicationComponentManifest; if (componentManifest == null || componentManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown enumUnknown = (IEnumUnknown)componentManifest.EntryPointSection._NewEnum; uint num1 = 0; object[] objArray = new object[1]; int num2 = 1; object[] rgelt = objArray; // ISSUE: explicit reference operation // ISSUE: variable of a reference type uint& celtFetched = @num1; if (enumUnknown.Next((uint)num2, rgelt, celtFetched) != 0 || (int)num1 != 1) { return; } EntryPointEntry allData = ((IEntryPointEntry)objArray[0]).AllData; if (allData.CommandLine_File != null && allData.CommandLine_File.Length > 0) { fileName = allData.CommandLine_File; } else { object ppUnknown = (object)null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)componentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown); IAssemblyReferenceEntry assemblyReferenceEntry = (IAssemblyReferenceEntry)ppUnknown; fileName = assemblyReferenceEntry.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; }
public static IEnumerator <object> GetEnumerator(this IEnumUnknown enumerator) { if (enumerator == null) { throw new ArgumentNullException(nameof(enumerator)); } uint count; do { object element; enumerator.RemoteNext(1, out element, out count); if (count == 1) { yield return(element); } }while (count > 0); }
public static void AttachToProcess(Int32 pid) { Process proc = Process.GetProcessById(pid); ICLRMetaHost metahost = NativeMethods.CLRCreateInstance(ref metahost_clsid, ref metahost_riid); IEnumUnknown runtimes = metahost.EnumerateLoadedRuntimes(proc.Handle); ICLRRuntimeInfo runtime = RTHelper.GetRuntime(runtimes, "v4.0"); ICorDebug codebugger = CreateDebugger(runtime); codebugger.Initialize(); codebugger.SetManagedHandler(new ManagedCallback()); ICorDebugProcess coproc; codebugger.DebugActiveProcess(Convert.ToUInt32(pid), 0, out coproc); Console.ReadKey(); }
public static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, String version) { Object[] temparr = new Object[3]; uint fetchedNum; String highestVersion = null; ICLRRuntimeInfo result = null; do { runtimes.Next(Convert.ToUInt32(temparr.Length), temparr, out fetchedNum); for (int i = 0; i < fetchedNum; i++) { ICLRRuntimeInfo t = (ICLRRuntimeInfo)temparr[i]; // initialize buffer for the runtime version string StringBuilder sb = new StringBuilder(16); UInt32 len = Convert.ToUInt32(sb.Capacity); t.GetVersionString(sb, ref len); // version not specified we return the first one if (!String.IsNullOrEmpty(version)) { if (sb.ToString().StartsWith(version, StringComparison.Ordinal)) { return(t); } } else { if (highestVersion == null || String.CompareOrdinal(version, highestVersion) > 0) { highestVersion = version; result = t; } } } } while (fetchedNum == temparr.Length); return(result); }
private static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactoryCoClass(); IEnumUnknown eu = null; object[] o = new object[1]; try { eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateDefault); int hr = 0; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); Marshal.ThrowExceptionForHR(hr); if (fetched == 1) { IWICComponentInfo ci = (IWICComponentInfo)o[0]; try { yield return(ci); } finally { Marshal.ReleaseComObject(ci); } } } } finally { if (eu != null) { Marshal.ReleaseComObject(eu); } Marshal.ReleaseComObject(factory); } }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null || appManifest.EntryPointSection == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown refEnum = (IEnumUnknown)appManifest.EntryPointSection._NewEnum; uint count = 0; Object[] entries = new Object[1]; // Look for the first entry point. ClickOnce semantic validation ensures exactly one entry point is present. if (refEnum.Next(1, entries, ref count) == 0 && count == 1) { IEntryPointEntry iref = (IEntryPointEntry)entries[0]; EntryPointEntry reference = iref.AllData; if (reference.CommandLine_File != null && reference.CommandLine_File.Length > 0) { fileName = reference.CommandLine_File; } else { // Locate the dependent assembly that is being refered to. Well-formed manifests should have an identity. IAssemblyReferenceEntry refEntry = null; object assemblyObj = null; if (reference.Identity != null) { ((ISectionWithReferenceIdentityKey)appManifest.AssemblyReferenceSection).Lookup(reference.Identity, out assemblyObj); refEntry = (IAssemblyReferenceEntry)assemblyObj; fileName = refEntry.DependentAssembly.Codebase; } } parameters = reference.CommandLine_Parameters; } }
/// <summary> /// Retrieves an array of the sub-conditions. /// </summary> public IEnumerable <SearchCondition> GetSubConditions() { // Our list that we'll return List <SearchCondition> subConditionsList = new List <SearchCondition>(); // Get the sub-conditions from the native API object subConditionObj; Guid guid = new Guid(ShellIIDGuid.IEnumUnknown); HResult hr = NativeSearchCondition.GetSubConditions(ref guid, out subConditionObj); if (!CoreErrorHelper.Succeeded(hr)) { throw new ShellException(hr); } // Convert each ICondition to SearchCondition if (subConditionObj != null) { IEnumUnknown enumUnknown = subConditionObj as IEnumUnknown; IntPtr buffer = IntPtr.Zero; uint fetched = 0; while (hr == HResult.Ok) { hr = enumUnknown.Next(1, ref buffer, ref fetched); if (hr == HResult.Ok && fetched == 1) { subConditionsList.Add(new SearchCondition((ICondition)Marshal.GetObjectForIUnknown(buffer))); } } } return(subConditionsList); }
public static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IEnumUnknown eu = null; object[] o = new object[1]; try { eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateRefresh | WICComponentEnumerateOptions.WICComponentEnumerateDisabled); int hr = 0; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); Marshal.ThrowExceptionForHR(hr); if (fetched == 1) { IWICComponentInfo ci = (IWICComponentInfo)o[0]; try { yield return(ci); } finally { ci.ReleaseComObject(); } } } } finally { factory.ReleaseComObject(); eu.ReleaseComObject(); } }
internal static void GetEntryPoint(ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if ((applicationComponentManifest == null) || (applicationComponentManifest.EntryPointSection == null)) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } IEnumUnknown unknown = (IEnumUnknown)applicationComponentManifest.EntryPointSection._NewEnum; uint celtFetched = 0; object[] rgelt = new object[1]; if ((unknown.Next(1, rgelt, ref celtFetched) == 0) && (celtFetched == 1)) { IEntryPointEntry entry = (IEntryPointEntry)rgelt[0]; EntryPointEntry allData = entry.AllData; if ((allData.CommandLine_File != null) && (allData.CommandLine_File.Length > 0)) { fileName = allData.CommandLine_File; } else { IAssemblyReferenceEntry entry3 = null; object ppUnknown = null; if (allData.Identity != null) { ((ISectionWithReferenceIdentityKey)applicationComponentManifest.AssemblyReferenceSection).Lookup(allData.Identity, out ppUnknown); entry3 = (IAssemblyReferenceEntry)ppUnknown; fileName = entry3.DependentAssembly.Codebase; } } parameters = allData.CommandLine_Parameters; } }
public static IEnumerable <string> GetProcessRuntimes(ICLRMetaHost host, SafeHandle hProcess) { if (host != null) { var buffer = new StringBuilder(1024); IEnumUnknown ppEnumerator = host.EnumerateLoadedRuntimes(hProcess.DangerousGetHandle()); return(ppEnumerator.Cast <ICLRRuntimeInfo>().Select(rti => { var bufferLength = (uint)buffer.Capacity; rti.GetVersionString(buffer, ref bufferLength); return buffer.ToString(0, (int)bufferLength - 1); }).ToList()); } else { string buffer = GetVersionFromProcess(hProcess); if (buffer != null) { return(new[] { buffer }); } } return(Enumerable.Empty <string>()); }
unsafe HRESULT IVBGetControl.EnumControls(OLECONTF dwOleContF, GC_WCH dwWhich, out IEnumUnknown ppenum) { Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "in EnumControls"); ppenum = host.GetParentContainer().EnumControls(host, dwOleContF, dwWhich); return(HRESULT.S_OK); }
public HRESULT Clone(out IEnumUnknown result) { result = new EnumUnknownClass(this.conditionList.ToArray()); return HRESULT.S_OK; }
public HResult Clone(out IEnumUnknown result) { result = new EnumUnknownClass(this.conditionList.ToArray()); return HResult.Ok; }
public int EnumObjects(int grfFlags, out IEnumUnknown ppenum) { ComDebug.ReportInfo("{0}.EnumObjects", this.GetType().Name); throw new NotImplementedException(); }
public void GetEnumerator(out IEnumUnknown ppIEnumMetadata) { Log.Error("Frame IWICMetadataBlockReader.GetEnumerator called"); throw new NotImplementedException(); }
private static ICLRRuntimeInfo GetRuntime(IEnumUnknown runtimes, string version) { var tempObjects = new object[3]; uint fetchedCount; do { runtimes.Next((uint)tempObjects.Length, tempObjects, out fetchedCount); for (int i = 0; i < fetchedCount; i++) { var runtimeInfo = (ICLRRuntimeInfo)tempObjects[i]; if (string.IsNullOrEmpty(version)) { return runtimeInfo; } var builder = new StringBuilder(16); var builderLength = (uint)builder.Capacity; runtimeInfo.GetVersionString(builder, ref builderLength); if (builder.ToString().StartsWith(version, StringComparison.Ordinal)) { return runtimeInfo; } } } while (fetchedCount == tempObjects.Length); return null; }
public void GetEnumerator(out IEnumUnknown ppIEnumMetadata) { Log.Trace("IWICMetadataBlockReader.GetEnumerator called"); ppIEnumMetadata = new MetadataEnumerator(exif); Log.Trace("IWICMetadataBlockReader.GetEnumerator finished"); }