{"id":27101392,"url":"https://github.com/markablov/win_ioctl","last_synced_at":"2025-04-06T14:36:43.859Z","repository":{"id":53491228,"uuid":"106502008","full_name":"markablov/win_ioctl","owner":"markablov","description":"Node.js add-on to allow calls of DeviceIoControl() on Windows machines","archived":false,"fork":false,"pushed_at":"2024-07-08T08:57:57.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T20:02:27.470Z","etag":null,"topics":["deviceiocontrol","ioctl","windows"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/markablov.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}},"created_at":"2017-10-11T03:39:52.000Z","updated_at":"2024-07-08T08:58:01.000Z","dependencies_parsed_at":"2022-08-19T03:11:10.785Z","dependency_job_id":null,"html_url":"https://github.com/markablov/win_ioctl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markablov%2Fwin_ioctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markablov%2Fwin_ioctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markablov%2Fwin_ioctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markablov%2Fwin_ioctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markablov","download_url":"https://codeload.github.com/markablov/win_ioctl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247497198,"owners_count":20948375,"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":["deviceiocontrol","ioctl","windows"],"created_at":"2025-04-06T14:36:43.327Z","updated_at":"2025-04-06T14:36:43.833Z","avatar_url":"https://github.com/markablov.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"win_ioctl\n==========\n\nNode.js add-on to allow calls of DeviceIoControl() on Windows machines\n\nInstallation\n------------\n\nInstall with `npm`:\n\n``` bash\n$ npm install win_ioctl\n```\n\nAPI\n--------\n\n### win_ioctl(fd, code, input, outBufSize, cb)\n**Parameters**\n- **fd**: `Integer` file descriptor, must be open.\n- **code**: `Integer` Device specific control code.\n- **input** *optional*: `Buffer` Input data to send to device\n- **outBufSize** *optional*: `Integer` Size of output buffer to allocate\n- **cb** *optional*: `Function` Callback to be called after operation finish\nSignature is `function (err, data)` where **err** is instance of `Error` and **data** is `Buffer`\n\n**Returns**: `Buffer` Allocated buffer of **outBufSize** size with data returned by device or undefined if **cb** is passed\n\n**Throws**: Throws if **cb** is unset\n\nExamples\n--------\n\n### Get compression status of file\n```\nconst comp_names =\n{\n    0: 'COMPRESSION_FORMAT_NONE',\n    1: 'COMPRESSION_FORMAT_DEFAULT',\n    2: 'COMPRESSION_FORMAT_LZNT1',\n};\n\nlet comp = win_ioctl(fd, FSCTL_GET_COMPRESSION, undefined, 2);\nconsole.log('Compression: ' + comp_names[comp.readUInt16LE(0)]);\n```\n\n### Async variant\n```\nconst comp_names =\n{\n    0: 'COMPRESSION_FORMAT_NONE',\n    1: 'COMPRESSION_FORMAT_DEFAULT',\n    2: 'COMPRESSION_FORMAT_LZNT1',\n};\n\nwin_ioctl(fd, FSCTL_GET_COMPRESSION, undefined, 2, (err, d) =\u003e\n    console.log(err ? err : 'Compression: ' + comp_names[d.readUInt16LE(0)]));\n```\n\n### Read variable-length data in case of ERR_MORE_DATA driver return:\n```\nwin_ioctl(fd, FSCTL_FILESYSTEM_GET_STATISTICS, undefined, SIZE_OF_FILESYSTEM_STATISTICS, (err, data) =\u003e\n{\n    if (err)\n    {\n        if (err.code == 'ERANGE' \u0026\u0026 data)\n        {\n            let structSize = data.readUInt32LE(4), fullSize = os.cpus().length * structSize;\n            let fullData = win_ioctl(fd, FSCTL_FILESYSTEM_GET_STATISTICS, undefined, fullSize);\n            console.log('File has been read '+fullData.readUInt32LE(8)+' times');\n        } else\n            console.log('Error: '+err.message);\n    } else\n        console.log('Error: unexpected success of first request with small buffer!');\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkablov%2Fwin_ioctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkablov%2Fwin_ioctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkablov%2Fwin_ioctl/lists"}