static void Main(string[] args)
        {
            Microsoft.Win32.SafeHandles.SafeFileHandle h;
            string    dEntry  = "\\";
            ArrayList entries = new ArrayList();

            entries.Add(dEntry);
            while (entries.Count != 0)
            {
                foreach (String entry in entries)
                {
                    var attr = new Win.OBJECT_ATTRIBUTES(entry, 0);
                    var st   = Win.NtOpenDirectoryObject(out h, 1, ref attr);
                    if (st < 0)
                    {
                        h.Dispose();
                        entries.Remove(entry);
                        break;
                    }

                    var  bufsz = 1024;
                    var  buf = Marshal.AllocHGlobal(bufsz);
                    uint context = 0, len;
                    while (true)
                    {
                        st = Win.NtQueryDirectoryObject(h, buf, bufsz, true, context == 0, ref context, out len);
                        if (st < 0)
                        {
                            entries.Remove(entry);
                            Marshal.FreeHGlobal(buf);
                            h.Dispose();
                            break;
                        }
                        var odi = (Win.OBJECT_DIRECTORY_INFORMATION)
                                  Marshal.PtrToStructure(buf, typeof(Win.OBJECT_DIRECTORY_INFORMATION));
                        if (Convert.ToString(odi.TypeName) == "Mutant")
                        {
                            Console.WriteLine("0x{0:X2}:{1,-25}{2}", context, odi.TypeName, odi.Name);
                            parseMutex(Convert.ToString(odi.Name));
                        }
                        if (Convert.ToString(odi.TypeName) == "Directory")
                        {
                            if (entry == "\\")
                            {
                                entries.Add(entry + Convert.ToString(odi.Name));
                            }
                            else
                            {
                                entries.Add(entry + "\\" + Convert.ToString(odi.Name));
                            }
                        }
                    }
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            Microsoft.Win32.SafeHandles.SafeFileHandle h;
            string dEntry = "\\";
            ArrayList entries = new ArrayList();
            entries.Add(dEntry);
            while (entries.Count != 0)
            {
                foreach (String entry in entries)
                {
                    var attr = new Win.OBJECT_ATTRIBUTES(entry, 0);
                    var st = Win.NtOpenDirectoryObject(out h, 1, ref attr);
                    if (st < 0)
                    {
                        h.Dispose();
                        entries.Remove(entry);
                        break;
                    }

                    var bufsz = 1024;
                    var buf = Marshal.AllocHGlobal(bufsz);
                    uint context = 0, len;
                    while (true)
                    {
                        st = Win.NtQueryDirectoryObject(h, buf, bufsz, true, context == 0, ref context, out len);
                        if (st < 0)
                        {
                            entries.Remove(entry);
                            Marshal.FreeHGlobal(buf);
                            h.Dispose();
                            break;
                        }
                        var odi = (Win.OBJECT_DIRECTORY_INFORMATION)
                          Marshal.PtrToStructure(buf, typeof(Win.OBJECT_DIRECTORY_INFORMATION));
                        if (Convert.ToString(odi.TypeName) == "Mutant")
                        {
                            Console.WriteLine("0x{0:X2}:{1,-25}{2}", context, odi.TypeName, odi.Name);
                            parseMutex(Convert.ToString(odi.Name));
                        }
                        if (Convert.ToString(odi.TypeName) == "Directory")
                        {
                            if (entry == "\\")
                            {
                                entries.Add(entry + Convert.ToString(odi.Name));
                            }
                            else
                            {
                                entries.Add(entry + "\\" + Convert.ToString(odi.Name));
                            }
                        }
                    }
                    break;
                }
            }
        }