mirror of
https://gitea.tendokyu.moe/TeamTofuShop/capnhook.git
synced 2026-09-22 22:38:12 +03:00
hook/iohook.c: Add iohook_open_nul_fd()
This provides a replacement for iohook_open_dummy_fd() whose error handling is more consistent with the rest of this library.
This commit is contained in:
@@ -277,6 +277,7 @@ static void iohook_init(void)
|
||||
iohook_initted = true;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
HANDLE iohook_open_dummy_fd(void)
|
||||
{
|
||||
iohook_init();
|
||||
@@ -291,6 +292,33 @@ HANDLE iohook_open_dummy_fd(void)
|
||||
NULL);
|
||||
}
|
||||
|
||||
HRESULT iohook_open_nul_fd(HANDLE *out)
|
||||
{
|
||||
HANDLE fd;
|
||||
|
||||
assert(out != NULL);
|
||||
|
||||
*out = NULL;
|
||||
iohook_init();
|
||||
|
||||
fd = next_CreateFileW(
|
||||
L"NUL",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
|
||||
if (fd == NULL) {
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
*out = fd;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT iohook_push_handler(iohook_fn_t fn)
|
||||
{
|
||||
iohook_fn_t *new_array;
|
||||
|
||||
+7
-1
@@ -39,6 +39,12 @@ struct irp {
|
||||
|
||||
typedef HRESULT (*iohook_fn_t)(struct irp *irp);
|
||||
|
||||
HANDLE iohook_open_dummy_fd(void);
|
||||
HANDLE iohook_open_dummy_fd(void)
|
||||
#ifdef __GNUC__
|
||||
__attribute__((deprecated("Use iohook_open_nul_fd instead")))
|
||||
#endif
|
||||
;
|
||||
|
||||
HRESULT iohook_open_nul_fd(HANDLE *fd);
|
||||
HRESULT iohook_push_handler(iohook_fn_t fn);
|
||||
HRESULT iohook_invoke_next(struct irp *irp);
|
||||
|
||||
Reference in New Issue
Block a user