12 Commits
Author SHA1 Message Date
kyoubate-haruka a3443a8b5b Add iohook for GetFileType (#7)
Unity (or mono in that case) is a bit special when it comes to handling file I/O, as before any operation (read, write) it will do a call to `GetFileType` to determine how to set the parameters for the following winapi calls. Handles that we replace with `iohook_open_nul_fd` however don't return the expected `FILE_TYPE_DISK`, as a null handle is a `FILE_TYPE_CHAR` which works by chance for serial ports, but not for files:

Related: https://gitea.tendokyu.moe/TeamTofuShop/segatools/issues/116
Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/7
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-07-05 15:33:19 +00:00
Dniel97 1e31f76d3e Fix 32bit SetFilePointer 2025-12-21 18:31:02 +01:00
Hay1tsme dafd0aa336 Implement ilufang's ERROR_IO_PENDING for empty serial reads 2025-02-09 04:50:10 -05:00
Kevin Trocolli 6b732bfbd6 add io and serial to procaddr table 2023-12-10 18:59:02 -05:00
Kevin Trocolli 888d068d58 allow iohook and serial_hook to land on DLLs loaded after initialization 2023-11-30 02:18:50 -05:00
Matt Bilker f0e5f82028 hook/iohook.c: Fix race condition at during iohook initialization
- If another DLL being loaded spawns a thread that begins doing I/O,
  then there is a race condition where `hook_table_apply` is still
  applying the hooks and has not returned yet but the hooked functions
  are called by those other threads. This causes the assert on
  `iohook_initted` to trigger.

- The easy fix is to always enter the mutex to ensure the hooks have
  been applied and function addresses for `CreateFileW` and
  `SetFilePointerEx` have been resolved.
2021-10-25 11:20:48 -04:00
Decaf Code 69f7e3b48c 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.
2019-11-03 10:57:33 -05:00
Decaf Code 1b99fb16b8 hook/iohook.c: Remove ioctl asserts
These assertions don't seem to hold for certain real ioctl errors.
2018-11-23 13:58:25 -05:00
Decaf Code bfee3db861 Fix MSVC compatibility issues
Project now builds in Visual Studio 2017, probably earlier versions
too as long as they support enough of C99.
2018-11-23 13:58:25 -05:00
Decaf Code d985965639 Fix non-PCH build 2018-11-23 13:46:49 -05:00
Decaf Code 2f7df12fc8 hook/iohook.c: Fix DeviceIoControl error path 2018-11-20 19:49:38 -05:00
Decaf Code 73c893168c hook/iohook.c: Add Win32 I/O interception mechanism 2018-11-10 11:24:57 -05:00