{"id":18830710,"url":"https://github.com/nextronsystems/go-handle","last_synced_at":"2025-04-14T03:43:18.092Z","repository":{"id":44764699,"uuid":"224836323","full_name":"NextronSystems/go-handle","owner":"NextronSystems","description":"Iterate over Windows Handles","archived":false,"fork":false,"pushed_at":"2023-09-19T14:39:43.000Z","size":81,"stargazers_count":13,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T17:47:00.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NextronSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-29T10:56:18.000Z","updated_at":"2024-09-30T16:36:37.000Z","dependencies_parsed_at":"2024-06-19T10:07:27.709Z","dependency_job_id":null,"html_url":"https://github.com/NextronSystems/go-handle","commit_stats":null,"previous_names":["codehardt/go-handle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextronSystems%2Fgo-handle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextronSystems%2Fgo-handle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextronSystems%2Fgo-handle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextronSystems%2Fgo-handle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NextronSystems","download_url":"https://codeload.github.com/NextronSystems/go-handle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819111,"owners_count":21166470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T01:50:00.613Z","updated_at":"2025-04-14T03:43:18.072Z","avatar_url":"https://github.com/NextronSystems.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-handle\nIterate over Windows Handles\n\n## Usage\n\nBefore querying the handles, create a buffer that can hold all process handles. On most machines, ~5MB should be fine.\n\nThen call the function `handle.QueryHandles(...)`. This function takes the following arguments:\n\n - `buf`: A buffer that can hold all process handles\n - `processFilter` _(optional)_: Only show process handles of process with this id\n - `handleTypes` _(optional)_: Only return handles of the specified types, e.g. `File`, `Event` or `Mutant`\n - `queryTimeout`: Some handles can not be queried and cause a freeze. This timeout will be used to prevent freezes\n\nThe function returns a list of handles.\n\n## Example\nThe following example iterates over all handles of this process.\n\n```golang\n// create an example global and local event\neventHandle, err := createEvent(`Global\\TestHandleEvent`)\nif err != nil {\n\tpanic(err)\n}\ndefer windows.CloseHandle(eventHandle)\neventHandle2, err := createEvent(`Local\\TestHandleEvent2`)\nif err != nil {\n\tpanic(err)\n}\ndefer windows.CloseHandle(eventHandle2)\n// create an example global and local mutex\nmutexHandle, err := createMutex(`Global\\TestHandleMutex`)\nif err != nil {\n\tpanic(err)\n}\ndefer windows.CloseHandle(mutexHandle)\nmutexHandle2, err := createMutex(`Local\\TestHandleMutex2`)\nif err != nil {\n\tpanic(err)\n}\ndefer windows.CloseHandle(mutexHandle2)\n// create an example file\nf, err := os.OpenFile(\"TestFile\", os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0600)\nif err != nil {\n\tpanic(err)\n}\ndefer os.Remove(\"TestFile\")\ndefer f.Close()\n// create 6MB buffer\nbuf := make([]byte, 6000000)\npid := uint16(os.Getpid())\nhandles, err := handle.QueryHandles(buf, \u0026pid, []string{\"File\", \"Event\", \"Mutant\"}, time.Second*20)\nif err != nil {\n\tpanic(err)\n}\nfor _, fh := range handles {\n\tfmt.Printf(\"PID %05d | %8.8s | HANDLE %04X | '%s'\\n\", fh.Process, fh.Type, fh.Handle, fh.Name)\n}\n```\n\n`Z:\\go\\src\\github.com\\Codehardt\\go-handle\u003ego run examples/example.go`\n```\nPID 08108 |     File | HANDLE 0004 | '\\Device\\ConDrv'\nPID 08108 |    Event | HANDLE 0008 | ''\nPID 08108 |    Event | HANDLE 000C | ''\nPID 08108 |    Event | HANDLE 003C | ''\nPID 08108 |    Event | HANDLE 0040 | ''\nPID 08108 |     File | HANDLE 0044 | '\\Device\\Mup\\VBoxSvr\\win10\\'\nPID 08108 |     File | HANDLE 0048 | '\\Device\\ConDrv'\nPID 08108 |     File | HANDLE 00A0 | '\\Device\\DeviceApi'\nPID 08108 |     File | HANDLE 00AC | '\\Device\\KsecDD'\nPID 08108 |     File | HANDLE 00B0 | '\\Device\\CNG'\nPID 08108 |    Event | HANDLE 00B4 | ''\nPID 08108 |    Event | HANDLE 00C4 | ''\nPID 08108 |    Event | HANDLE 00DC | ''\nPID 08108 |    Event | HANDLE 00E8 | ''\nPID 08108 |    Event | HANDLE 00F0 | ''\nPID 08108 |    Event | HANDLE 00FC | ''\nPID 08108 |    Event | HANDLE 0104 | ''\nPID 08108 |    Event | HANDLE 0110 | '\\BaseNamedObjects\\TestHandleEvent'\nPID 08108 |    Event | HANDLE 0114 | '\\Sessions\\1\\BaseNamedObjects\\TestHandleEvent2'\nPID 08108 |   Mutant | HANDLE 0118 | '\\BaseNamedObjects\\TestHandleMutex'\nPID 08108 |   Mutant | HANDLE 011C | '\\Sessions\\1\\BaseNamedObjects\\TestHandleMutex2'\nPID 08108 |     File | HANDLE 0120 | '\\Device\\Mup\\VBoxSvr\\win10\\TestFile'\nPID 08108 |    Event | HANDLE 0124 | ''\nPID 08108 |     File | HANDLE 018C | '\\Device\\ConDrv'\nPID 08108 |     File | HANDLE 01BC | '\\Device\\ConDrv'\nPID 08108 |     File | HANDLE 01DC | '\\Device\\ConDrv'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextronsystems%2Fgo-handle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextronsystems%2Fgo-handle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextronsystems%2Fgo-handle/lists"}