コード例 #1
0
        // Retrieve information about runtimes that are currently loaded into the target process.
        public IEnumerable <CLRRuntimeInfo> EnumerateLoadedRuntimes(Int32 processId)
        {
            List <CLRRuntimeInfo> runtimes = new List <CLRRuntimeInfo>();
            IEnumUnknown          enumRuntimes;

            using (ProcessSafeHandle hProcess = NativeMethods.OpenProcess((int)(NativeMethods.ProcessAccessOptions.ProcessVMRead |
                                                                                NativeMethods.ProcessAccessOptions.ProcessQueryInformation |
                                                                                NativeMethods.ProcessAccessOptions.ProcessDupHandle |
                                                                                NativeMethods.ProcessAccessOptions.Synchronize),
                                                                          false, // inherit handle
                                                                          processId))
            {
                if (hProcess.IsInvalid)
                {
                    throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
                }

                enumRuntimes = m_metaHost.EnumerateLoadedRuntimes(hProcess);
            }

            // 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);
        }
コード例 #2
0
 public static extern bool QueryFullProcessImageName(ProcessSafeHandle hProcess,
                                                     int dwFlags,
                                                     StringBuilder lpExeName,
                                                     ref int lpdwSize);
コード例 #3
0
 public static extern void GetVersionFromProcess(ProcessSafeHandle hProcess, StringBuilder versionString,
                                                 Int32 bufferSize, out Int32 dwLength);