示例#1
0
        private static bool HasPython(int processId) {
            // calling CreateToolhelp32Snapshot directly is significantly (~5x) faster than accessing 
            // Process.Modules.  This gets called during the Debug->attach to process API so that ends
            // up being a difference of less than 1 sec vs. 5 seconds.
            IntPtr h = NativeMethods.CreateToolhelp32Snapshot(SnapshotFlags.Module, (uint)processId);
            if (h != NativeMethods.INVALID_HANDLE_VALUE) {
                uint marshalSize = (uint)Marshal.SizeOf(typeof(MODULEENTRY32));
                var me = new MODULEENTRY32();
                me.dwSize = (uint)marshalSize;
                if (NativeMethods.Module32First(h, ref me)) {
                    do {
                        if (IsPythonModule(me.szModule)) {
                            return true;
                        }

                        me.dwSize = marshalSize;
                    } while (NativeMethods.Module32Next(h, ref me));
                }
                NativeMethods.CloseHandle(h);
            }
            return false;
        }
示例#2
0
 public static extern bool Module32Next(IntPtr hSnapshot, ref MODULEENTRY32 lpme);
示例#3
0
 public static extern bool Module32Next(IntPtr hSnapshot, ref MODULEENTRY32 lpme);