Use new iohook_open_nul_fd() API

Makes error handling more consistent
This commit is contained in:
Tau
2019-11-03 11:02:54 -05:00
parent 7ee74214f7
commit 879dc0bfb4
6 changed files with 52 additions and 8 deletions

View File

@ -99,17 +99,30 @@ static void *io4_ops_ctx;
HRESULT io4_hook_init(const struct io4_ops *ops, void *ctx)
{
HRESULT hr;
assert(ops != NULL);
async_init(&io4_async, NULL);
io4_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&io4_fd);
if (FAILED(hr)) {
return hr;
}
io4_ops = ops;
io4_ops_ctx = ctx;
io4_system_status = 0x02; /* idk */
iohook_push_handler(io4_handle_irp);
return setupapi_add_phantom_dev(&hid_guid, io4_path);
hr = setupapi_add_phantom_dev(&hid_guid, io4_path);
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
static HRESULT io4_handle_irp(struct irp *irp)