1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-12 04:40:46 +01:00

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

@ -85,7 +85,11 @@ HRESULT ds_hook_init(const struct ds_config *cfg)
return hr;
}
ds_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&ds_fd);
if (FAILED(hr)) {
return hr;
}
return S_OK;
}

View File

@ -89,7 +89,12 @@ HRESULT gpio_hook_init(const struct gpio_config *cfg)
memcpy(&gpio_config, cfg, sizeof(*cfg));
gpio_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&gpio_fd);
if (FAILED(hr)) {
return hr;
}
hr = iohook_push_handler(gpio_handle_irp);
if (FAILED(hr)) {

View File

@ -50,7 +50,12 @@ HRESULT jvs_hook_init(const struct jvs_config *cfg)
return S_FALSE;
}
jvs_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&jvs_fd);
if (FAILED(hr)) {
return hr;
}
hr = iohook_push_handler(jvs_handle_irp);
if (FAILED(hr)) {

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)

View File

@ -26,15 +26,27 @@ static HANDLE hwmon_fd;
HRESULT hwmon_hook_init(const struct hwmon_config *cfg)
{
HRESULT hr;
assert(cfg != NULL);
if (!cfg->enable) {
return S_FALSE;
}
hwmon_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&hwmon_fd);
return iohook_push_handler(hwmon_handle_irp);
if (FAILED(hr)) {
return hr;
}
hr = iohook_push_handler(hwmon_handle_irp);
if (FAILED(hr)) {
return hr;
}
return S_OK;
}
static HRESULT hwmon_handle_irp(struct irp *irp)

View File

@ -139,7 +139,12 @@ HRESULT nusec_hook_init(
nusec_nearfull = 0x00010200;
nusec_play_count = 0;
nusec_play_limit = 1024;
nusec_fd = iohook_open_dummy_fd();
hr = iohook_open_nul_fd(&nusec_fd);
if (FAILED(hr)) {
return hr;
}
hr = iohook_push_handler(nusec_handle_irp);