mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-28 00:10:51 +01:00
Adapt everything in BT5 to new capnhook API
This includes: - Renaming of functions (iohook_invoke_next) - Slight interface changes (com_proxy_wrap, iohook_push_handler) - De-duplicate stuff from utils (iobuf, hr)
This commit is contained in:
parent
a016f27652
commit
f9c0733af3
@ -30,8 +30,16 @@ void ac_io_emu_init(struct ac_io_emu *emu, const wchar_t *filename)
|
||||
log_assert(emu != NULL);
|
||||
log_assert(filename != NULL);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
memset(emu, 0, sizeof(*emu));
|
||||
emu->fd = iohook_open_dummy_fd();
|
||||
|
||||
hr = iohook_open_nul_fd(&emu->fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
|
||||
emu->wfilename = wstr_dup(filename);
|
||||
wstr_narrow(filename, &emu->filename);
|
||||
ac_io_in_init(&emu->in);
|
||||
|
@ -69,7 +69,7 @@ bio2emu_port_dispatch_irp(struct irp *irp)
|
||||
}
|
||||
|
||||
if (!selected_emu) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
struct ac_io_emu *emu = &selected_emu->acio;
|
||||
|
@ -52,7 +52,7 @@ ac_io_bus_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -20,10 +20,6 @@
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
|
||||
static const irp_handler_t bsthook_handlers[] = {
|
||||
ac_io_bus_dispatch_irp,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
@ -116,7 +112,7 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
args_free(argc, argv);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
iohook_init(bsthook_handlers, lengthof(bsthook_handlers));
|
||||
iohook_push_handler(ac_io_bus_dispatch_irp);
|
||||
rs232_hook_init();
|
||||
|
||||
gfx_init();
|
||||
|
@ -41,7 +41,7 @@ static HRESULT STDCALL my_CreateDevice(
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev)
|
||||
{
|
||||
IDirect3D9 *real = COM_PROXY_UNWRAP(self);
|
||||
IDirect3D9 *real = com_proxy_downcast(self)->real;
|
||||
HRESULT hr;
|
||||
|
||||
log_misc("IDirect3D9::CreateDevice hook hit");
|
||||
@ -61,11 +61,17 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
||||
IDirect3D9 *api;
|
||||
IDirect3D9Vtbl *api_vtbl;
|
||||
struct com_proxy *api_proxy;
|
||||
HRESULT res;
|
||||
|
||||
log_info("Direct3DCreate9 hook hit");
|
||||
|
||||
api = real_Direct3DCreate9(sdk_ver);
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
res = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (res != S_OK) {
|
||||
log_fatal("Wrapping com proxy failed: 0x%ld", res);
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
api_vtbl->CreateDevice = my_CreateDevice;
|
||||
|
@ -341,7 +341,14 @@ static HRESULT my_MFEnumDeviceSources(
|
||||
|
||||
for (UINT32 i = 0; i < nsrcs; ++i) {
|
||||
api = (*pppSourceActivate)[i];
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
|
||||
ret = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (ret != S_OK) {
|
||||
log_warning("Wrapping com proxy failed: %08lx", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
real_GetAllocatedString = api_vtbl->GetAllocatedString;
|
||||
|
@ -242,7 +242,7 @@ static HRESULT STDCALL my_CreateDeviceEx(
|
||||
D3DDISPLAYMODEEX *fdm,
|
||||
IDirect3DDevice9Ex **pdev)
|
||||
{
|
||||
IDirect3D9Ex *real = COM_PROXY_UNWRAP(self);
|
||||
IDirect3D9Ex *real = com_proxy_downcast(self)->real;
|
||||
HRESULT hr;
|
||||
|
||||
if (d3d9ex_device_adapter >= 0) {
|
||||
@ -337,7 +337,14 @@ static HRESULT STDCALL my_Direct3DCreate9Ex(UINT sdk_ver, IDirect3D9Ex **api)
|
||||
|
||||
hr = real_Direct3DCreate9Ex(sdk_ver, api);
|
||||
api_ = *api;
|
||||
api_proxy = com_proxy_wrap(api_, sizeof(*api_->lpVtbl));
|
||||
|
||||
hr = com_proxy_wrap(&api_proxy, api_, sizeof(*api_->lpVtbl));
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Wrapping com proxy failed: %08lx", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
api_vtbl->CreateDeviceEx = my_CreateDeviceEx;
|
||||
|
@ -107,7 +107,7 @@ com4_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&com4_ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -72,10 +72,18 @@ static HRESULT STDCALL my_DirectInput8Create(
|
||||
|
||||
res = real_DirectInput8Create(
|
||||
hinst, dwVersion, riidltf, (LPVOID *) &api, punkOuter);
|
||||
|
||||
if (res != DI_OK) {
|
||||
return res;
|
||||
}
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
|
||||
res = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (res != S_OK) {
|
||||
log_warning("Wrapping com proxy failed: %08lx", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
api_vtbl->EnumDevices = my_EnumDevices;
|
||||
|
@ -32,24 +32,6 @@ static bool my_dll_entry_main(void);
|
||||
bool standard_def;
|
||||
bool _15khz;
|
||||
|
||||
static const irp_handler_t ddrhook_com4_handlers[] = {
|
||||
p3io_emu_dispatch_irp,
|
||||
extio_dispatch_irp,
|
||||
spike_dispatch_irp,
|
||||
usbmem_dispatch_irp,
|
||||
com4_dispatch_irp,
|
||||
};
|
||||
|
||||
static const irp_handler_t ddrhook_handlers[] = {
|
||||
/* Same as above, but without COM4 emulation.
|
||||
See ddrhook/p3io.c for details. */
|
||||
|
||||
p3io_emu_dispatch_irp,
|
||||
extio_dispatch_irp,
|
||||
spike_dispatch_irp,
|
||||
usbmem_dispatch_irp,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
{
|
||||
int argc;
|
||||
@ -90,10 +72,14 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
args_free(argc, argv);
|
||||
|
||||
iohook_push_handler(p3io_emu_dispatch_irp);
|
||||
iohook_push_handler(extio_dispatch_irp);
|
||||
iohook_push_handler(spike_dispatch_irp);
|
||||
iohook_push_handler(usbmem_dispatch_irp);
|
||||
|
||||
if (com4) {
|
||||
iohook_init(ddrhook_com4_handlers, lengthof(ddrhook_com4_handlers));
|
||||
} else {
|
||||
iohook_init(ddrhook_handlers, lengthof(ddrhook_handlers));
|
||||
/* See ddrhook/p3io.c for details. */
|
||||
iohook_push_handler(com4_dispatch_irp);
|
||||
}
|
||||
|
||||
rs232_hook_init();
|
||||
|
@ -33,7 +33,13 @@ void extio_init(void)
|
||||
{
|
||||
log_assert(extio_fd == NULL);
|
||||
|
||||
extio_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&extio_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
}
|
||||
|
||||
void extio_fini(void)
|
||||
@ -51,7 +57,7 @@ extio_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != extio_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
@ -75,7 +81,7 @@ static HRESULT extio_open(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"COM1")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
log_info("EXTIO RS232 port opened");
|
||||
|
@ -43,7 +43,7 @@ static HRESULT STDCALL my_CreateDevice(
|
||||
{
|
||||
IDirect3D9 *real;
|
||||
|
||||
real = COM_PROXY_UNWRAP(self);
|
||||
real = com_proxy_downcast(self)->real;
|
||||
|
||||
if (gfx_windowed) {
|
||||
pp->Windowed = TRUE;
|
||||
@ -58,11 +58,18 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
||||
IDirect3D9 *api;
|
||||
IDirect3D9Vtbl *api_vtbl;
|
||||
struct com_proxy *api_proxy;
|
||||
HRESULT hr;
|
||||
|
||||
log_info("Direct3DCreate9 hook hit");
|
||||
|
||||
api = real_Direct3DCreate9(sdk_ver);
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
|
||||
hr = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Wrapping com proxy failed: %08lx", hr);
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
api_vtbl->CreateDevice = my_CreateDevice;
|
||||
|
@ -47,7 +47,7 @@ spike_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&spike_ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -34,7 +34,13 @@ void usbmem_init(void)
|
||||
{
|
||||
log_assert(usbmem_fd == NULL);
|
||||
|
||||
usbmem_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&usbmem_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
}
|
||||
|
||||
void usbmem_fini(void)
|
||||
@ -52,7 +58,7 @@ usbmem_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != usbmem_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
@ -76,7 +82,7 @@ static HRESULT usbmem_open(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"COM3")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
irp->fd = usbmem_fd;
|
||||
|
@ -53,7 +53,14 @@ void ezusb_emu_device_hook_init(struct ezusb_emu_msg_hook *msg_hook)
|
||||
{
|
||||
log_assert(ezusb_emu_fd == NULL);
|
||||
|
||||
ezusb_emu_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&ezusb_emu_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
|
||||
ezusb_emu_dev_fx_msg_hook = msg_hook;
|
||||
}
|
||||
|
||||
@ -70,7 +77,7 @@ HRESULT
|
||||
ezusb_emu_device_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != ezusb_emu_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
/* read/write are not supported, and the game-side EZUSB code constantly
|
||||
@ -98,7 +105,7 @@ static HRESULT ezusb_open(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"\\\\.\\Ezusb-0")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
irp->fd = ezusb_emu_fd;
|
||||
|
@ -67,7 +67,14 @@ void ezusb2_emu_device_hook_init(struct ezusb_emu_msg_hook *msg_hook)
|
||||
{
|
||||
log_assert(ezusb_fd == NULL);
|
||||
|
||||
ezusb_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&ezusb_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
|
||||
ezusb_emu_dev_fx2_msg_hook = msg_hook;
|
||||
}
|
||||
|
||||
@ -88,7 +95,7 @@ HRESULT
|
||||
ezusb2_emu_device_dispatch_irp(struct irp *irp)
|
||||
{
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != ezusb_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
/* read/write are not supported, and the game-side EZUSB code constantly
|
||||
@ -112,7 +119,7 @@ static HRESULT ezusb_open(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"\\\\.\\Ezusb-0")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
irp->fd = ezusb_fd;
|
||||
|
@ -517,6 +517,7 @@ static HRESULT hook_d3d9_irp_handler_real_ctx_create(struct hook_d3d9_irp *irp)
|
||||
IDirect3D9 *api;
|
||||
IDirect3D9Vtbl *api_vtbl;
|
||||
struct com_proxy *api_proxy;
|
||||
HRESULT res;
|
||||
|
||||
log_assert(irp);
|
||||
|
||||
@ -526,7 +527,12 @@ static HRESULT hook_d3d9_irp_handler_real_ctx_create(struct hook_d3d9_irp *irp)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
res = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (res != S_OK) {
|
||||
log_fatal("Wrapping com proxy failed: %08lx", res);
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
real_CreateDevice = api_vtbl->CreateDevice;
|
||||
@ -624,7 +630,13 @@ hook_d3d9_irp_handler_real_dev_create_device(struct hook_d3d9_irp *irp)
|
||||
}
|
||||
|
||||
api = *irp->args.ctx_create_device.pdev;
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
hr = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Wrapping com proxy failed: %08lx", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
real_CreateTexture = api_vtbl->CreateTexture;
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "hook/hr.h"
|
||||
#include "hook/iohook.h"
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "util/array.h"
|
||||
#include "util/hr.h"
|
||||
#include "util/log.h"
|
||||
|
||||
/* RS232 API hooks */
|
||||
@ -178,7 +178,7 @@ my_ClearCommError(HANDLE fd, uint32_t *errors, COMSTAT *status)
|
||||
irp.read.bytes = (uint8_t *) &llstatus;
|
||||
irp.read.nbytes = sizeof(llstatus);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning(
|
||||
@ -303,7 +303,7 @@ static BOOL STDCALL my_EscapeCommFunction(HANDLE fd, uint32_t cmd)
|
||||
irp.fd = fd;
|
||||
irp.ioctl = ioctl;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: ioctl failed: %lx", __func__, hr);
|
||||
@ -364,7 +364,7 @@ static BOOL STDCALL my_GetCommState(HANDLE fd, DCB *dcb)
|
||||
irp.read.nbytes = sizeof(baud);
|
||||
memset(&baud, 0, sizeof(baud));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_GET_BAUD_RATE failed: %lx", __func__, hr);
|
||||
@ -380,7 +380,7 @@ static BOOL STDCALL my_GetCommState(HANDLE fd, DCB *dcb)
|
||||
irp.read.nbytes = sizeof(handflow);
|
||||
memset(&handflow, 0, sizeof(handflow));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_GET_HANDFLOW failed: %lx", __func__, hr);
|
||||
@ -396,7 +396,7 @@ static BOOL STDCALL my_GetCommState(HANDLE fd, DCB *dcb)
|
||||
irp.read.nbytes = sizeof(line_control);
|
||||
memset(&line_control, 0, sizeof(line_control));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning(
|
||||
@ -413,7 +413,7 @@ static BOOL STDCALL my_GetCommState(HANDLE fd, DCB *dcb)
|
||||
irp.read.nbytes = sizeof(chars);
|
||||
memset(&chars, 0, sizeof(chars));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_GET_CHARS failed: %lx", __func__, hr);
|
||||
@ -508,7 +508,7 @@ static BOOL STDCALL my_PurgeComm(HANDLE fd, uint32_t flags)
|
||||
irp.write.bytes = (uint8_t *) &flags;
|
||||
irp.write.nbytes = sizeof(flags);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_PURGE failed: %lx", __func__, hr);
|
||||
@ -533,7 +533,7 @@ static BOOL STDCALL my_SetCommMask(HANDLE fd, uint32_t mask)
|
||||
irp.write.bytes = (uint8_t *) &mask;
|
||||
irp.write.nbytes = sizeof(mask);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_WAIT_MASK failed: %lx", __func__, hr);
|
||||
@ -666,7 +666,7 @@ static BOOL STDCALL my_SetCommState(HANDLE fd, const DCB *dcb)
|
||||
irp.write.bytes = (uint8_t *) &baud;
|
||||
irp.write.nbytes = sizeof(baud);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_BAUD_RATE failed: %lx", __func__, hr);
|
||||
@ -681,7 +681,7 @@ static BOOL STDCALL my_SetCommState(HANDLE fd, const DCB *dcb)
|
||||
irp.write.bytes = (uint8_t *) &handflow;
|
||||
irp.write.nbytes = sizeof(handflow);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_HANDFLOW failed: %lx", __func__, hr);
|
||||
@ -696,7 +696,7 @@ static BOOL STDCALL my_SetCommState(HANDLE fd, const DCB *dcb)
|
||||
irp.write.bytes = (uint8_t *) &line_control;
|
||||
irp.write.nbytes = sizeof(line_control);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning(
|
||||
@ -712,7 +712,7 @@ static BOOL STDCALL my_SetCommState(HANDLE fd, const DCB *dcb)
|
||||
irp.write.bytes = (uint8_t *) &chars;
|
||||
irp.write.nbytes = sizeof(chars);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_CHARS failed: %lx", __func__, hr);
|
||||
@ -748,7 +748,7 @@ static BOOL STDCALL my_SetCommTimeouts(HANDLE fd, COMMTIMEOUTS *src)
|
||||
irp.write.bytes = (uint8_t *) &dest;
|
||||
irp.write.nbytes = sizeof(dest);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_TIMEOUTS failed: %lx", __func__, hr);
|
||||
@ -777,7 +777,7 @@ static BOOL STDCALL my_SetupComm(HANDLE fd, uint32_t in_q, uint32_t out_q)
|
||||
irp.write.bytes = (uint8_t *) &qs;
|
||||
irp.write.nbytes = sizeof(qs);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning(
|
||||
@ -801,7 +801,7 @@ static BOOL STDCALL my_SetCommBreak(HANDLE fd)
|
||||
irp.fd = fd;
|
||||
irp.ioctl = IOCTL_SERIAL_SET_BREAK_ON;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_BREAK_ON failed: %lx", __func__, hr);
|
||||
@ -824,7 +824,7 @@ static BOOL STDCALL my_ClearCommBreak(HANDLE fd)
|
||||
irp.fd = fd;
|
||||
irp.ioctl = IOCTL_SERIAL_SET_BREAK_OFF;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("%s: IOCTL_SERIAL_SET_BREAK_OFF failed: %lx", __func__, hr);
|
||||
|
@ -78,7 +78,7 @@ iidxhook_util_acio_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&iidxhook_util_acio_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -81,7 +81,7 @@ static bool chart_patch_file_load(
|
||||
irp.open_access = GENERIC_READ;
|
||||
irp.open_creation = OPEN_EXISTING;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
@ -95,7 +95,7 @@ static bool chart_patch_file_load(
|
||||
irp.seek_origin = FILE_END;
|
||||
irp.seek_offset = 0;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_fatal("Seeking end failed");
|
||||
@ -110,7 +110,7 @@ static bool chart_patch_file_load(
|
||||
irp.seek_origin = FILE_BEGIN;
|
||||
irp.seek_offset = 0;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_fatal("Seeking begin failed");
|
||||
@ -123,7 +123,7 @@ static bool chart_patch_file_load(
|
||||
irp.read.nbytes = nbytes;
|
||||
irp.read.pos = 0;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_fatal("Reading failed");
|
||||
@ -139,13 +139,18 @@ static bool chart_patch_file_load(
|
||||
irp.op = IRP_OP_CLOSE;
|
||||
irp.fd = fd;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_fatal("Closing failed");
|
||||
}
|
||||
|
||||
file->fd = iohook_open_dummy_fd();
|
||||
hr = iohook_open_nul_fd(&file->fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
|
||||
memset(&file->state, 0, sizeof(struct const_iobuf));
|
||||
file->state.bytes = bytes;
|
||||
file->state.nbytes = nbytes;
|
||||
@ -383,7 +388,7 @@ chart_patch_file_close_irp(struct chart_patch_file *file, struct irp *irp_close)
|
||||
memcpy(&irp, irp_close, sizeof(struct irp));
|
||||
irp.fd = chart_patch_file_1.fd;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Closing dummy .1 file handle failed");
|
||||
@ -397,7 +402,7 @@ chart_patch_file_close_irp(struct chart_patch_file *file, struct irp *irp_close)
|
||||
memcpy(&irp, irp_close, sizeof(struct irp));
|
||||
irp.fd = chart_patch_file_checksum.fd;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_warning("Closing dummy checksum file handle failed");
|
||||
@ -525,7 +530,7 @@ iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
if (chart_patch_file_trap(irp)) {
|
||||
hr = S_OK;
|
||||
} else {
|
||||
hr = irp_invoke_next(irp);
|
||||
hr = iohook_invoke_next(irp);
|
||||
}
|
||||
} else {
|
||||
if (irp->fd != INVALID_HANDLE_VALUE && irp->fd != NULL) {
|
||||
@ -536,7 +541,7 @@ iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
hr = chart_patch_file_dispatch_irp(
|
||||
&chart_patch_file_checksum, irp);
|
||||
} else {
|
||||
hr = irp_invoke_next(irp);
|
||||
hr = iohook_invoke_next(irp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -545,6 +550,6 @@ iidxhook_util_chart_patch_dispatch_irp(struct irp *irp)
|
||||
|
||||
return hr;
|
||||
} else {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
}
|
@ -97,8 +97,8 @@ settings_hook_dispatch_irp(struct irp *irp)
|
||||
}
|
||||
}
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
@ -49,12 +49,6 @@
|
||||
#define IIDXHOOK1_CMD_USAGE \
|
||||
"Usage: inject.exe iidxhook1.dll <bm2dx.exe> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb_emu_device_dispatch_irp,
|
||||
iidxhook_util_chart_patch_dispatch_irp,
|
||||
settings_hook_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -229,7 +223,9 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
|
||||
iohook_push_handler(settings_hook_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb_emu_desc_device.setupapi);
|
||||
ezusb_emu_device_hook_init(ezusb_iidx_emu_msg_init());
|
||||
|
@ -49,13 +49,6 @@
|
||||
#define IIDXHOOK2_CMD_USAGE \
|
||||
"Usage: inject.exe iidxhook2.dll <bm2dx.exe> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
iidxhook_util_chart_patch_dispatch_irp,
|
||||
settings_hook_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -223,7 +216,10 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
|
||||
iohook_push_handler(settings_hook_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb_emu_desc_device.setupapi);
|
||||
ezusb_emu_device_hook_init(ezusb_iidx_emu_msg_init());
|
||||
|
@ -48,13 +48,6 @@
|
||||
#define IIDXHOOK3_CMD_USAGE \
|
||||
"Usage: inject.exe iidxhook3.dll <bm2dx.exe> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb2_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
iidxhook_util_chart_patch_dispatch_irp,
|
||||
settings_hook_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -214,7 +207,10 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
|
||||
iohook_push_handler(settings_hook_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
|
||||
ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
|
||||
|
@ -44,13 +44,6 @@
|
||||
#define IIDXHOOK4_CMD_USAGE \
|
||||
"Usage: launcher.exe -K iidxhook4.dll <bm2dx.dll> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb2_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
iidxhook_util_chart_patch_dispatch_irp,
|
||||
settings_hook_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -150,7 +143,10 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
|
||||
iohook_push_handler(settings_hook_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
|
||||
ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
|
||||
|
@ -43,12 +43,6 @@
|
||||
#define IIDXHOOK5_CMD_USAGE \
|
||||
"Usage: launcher.exe -K iidxhook5.dll <bm2dx.dll> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb2_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
settings_hook_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -131,7 +125,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
iohook_push_handler(settings_hook_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
|
||||
ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
|
||||
|
@ -42,11 +42,6 @@
|
||||
#define IIDXHOOK6_CMD_USAGE \
|
||||
"Usage: launcher.exe -K iidxhook6.dll <bm2dx.dll> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb2_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -129,7 +124,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
|
||||
ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
|
||||
|
@ -42,11 +42,6 @@
|
||||
#define IIDXHOOK7_CMD_USAGE \
|
||||
"Usage: launcher.exe -K iidxhook7.dll <bm2dx.dll> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
ezusb2_emu_device_dispatch_irp,
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -129,7 +124,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
|
||||
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
|
||||
ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
|
||||
|
@ -42,11 +42,6 @@
|
||||
#define IIDXHOOK8_CMD_USAGE \
|
||||
"Usage: launcher.exe -K iidxhook8.dll <bm2dx.dll> [options...]"
|
||||
|
||||
static const irp_handler_t iidxhook_handlers[] = {
|
||||
iidxhook_util_acio_dispatch_irp,
|
||||
bio2emu_port_dispatch_irp,
|
||||
};
|
||||
|
||||
static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
|
||||
iidxhook_util_d3d9_irp_handler,
|
||||
};
|
||||
@ -152,7 +147,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
* used */
|
||||
/* Set up IO emulation hooks _after_ IO API setup to allow
|
||||
API implementations with real IO devices */
|
||||
iohook_init(iidxhook_handlers, lengthof(iidxhook_handlers));
|
||||
iohook_push_handler(iidxhook_util_acio_dispatch_irp);
|
||||
iohook_push_handler(bio2emu_port_dispatch_irp);
|
||||
|
||||
rs232_hook_init();
|
||||
rs232_hook_limit_hooks();
|
||||
|
||||
|
@ -53,7 +53,7 @@ ac_io_port_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -32,11 +32,6 @@
|
||||
|
||||
static struct options options;
|
||||
|
||||
static const irp_handler_t jbhook_handlers[] = {
|
||||
p4ioemu_dispatch_irp,
|
||||
ac_io_port_dispatch_irp,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
{
|
||||
bool eam_io_ok;
|
||||
@ -132,7 +127,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
|
||||
options_init_from_cmdline(&options);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
iohook_init(jbhook_handlers, lengthof(jbhook_handlers));
|
||||
|
||||
iohook_push_handler(p4ioemu_dispatch_irp);
|
||||
iohook_push_handler(ac_io_port_dispatch_irp);
|
||||
|
||||
if (!options.disable_adapteremu) {
|
||||
adapter_hook_init();
|
||||
|
@ -53,7 +53,7 @@ ac_io_port_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -37,11 +37,6 @@
|
||||
#define JBHOOK1_CMD_USAGE \
|
||||
"Usage: inject.exe jbhook1.dll <jubeat.exe> [options...]"
|
||||
|
||||
static const irp_handler_t jbhook1_handlers[] = {
|
||||
p3io_emu_dispatch_irp,
|
||||
ac_io_port_dispatch_irp,
|
||||
};
|
||||
|
||||
static HWND CDECL
|
||||
my_mwindow_create(HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
|
||||
static HWND(CDECL *real_mwindow_create)(
|
||||
@ -124,7 +119,8 @@ static HWND CDECL my_mwindow_create(
|
||||
log_fatal("Initializing card reader backend failed");
|
||||
}
|
||||
|
||||
iohook_init(jbhook1_handlers, lengthof(jbhook1_handlers));
|
||||
iohook_push_handler(p3io_emu_dispatch_irp);
|
||||
iohook_push_handler(ac_io_port_dispatch_irp);
|
||||
|
||||
rs232_hook_init();
|
||||
ac_io_port_init();
|
||||
|
@ -70,6 +70,8 @@ void p3io_emu_init(const struct p3io_ops *ops, void *ctx)
|
||||
log_assert(p3io_emu_fd == NULL);
|
||||
log_assert(ops != NULL);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
p3io_emu_resp.bytes = p3io_emu_resp_bytes;
|
||||
p3io_emu_resp.nbytes = sizeof(p3io_emu_resp_bytes);
|
||||
p3io_emu_resp.pos = 0;
|
||||
@ -77,7 +79,11 @@ void p3io_emu_init(const struct p3io_ops *ops, void *ctx)
|
||||
p3io_ops = ops;
|
||||
p3io_ops_ctx = ctx;
|
||||
|
||||
p3io_emu_fd = iohook_open_dummy_fd();
|
||||
hr = iohook_open_nul_fd(&p3io_emu_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
}
|
||||
|
||||
void p3io_emu_fini(void)
|
||||
@ -100,7 +106,7 @@ p3io_emu_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != p3io_emu_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
@ -122,7 +128,7 @@ p3io_emu_dispatch_irp(struct irp *irp)
|
||||
static HRESULT p3io_emu_handle_open(struct irp *irp)
|
||||
{
|
||||
if (!p3io_setupapi_match_path(irp->open_filename)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
log_info("P3IO device opened");
|
||||
|
@ -201,7 +201,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
irp.open_flags = 0;
|
||||
irp.open_tmpl = NULL;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -217,7 +217,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
irp.write.nbytes = sizeof(comm_mask);
|
||||
comm_mask = EV_RXCHAR;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -232,7 +232,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
qs.InSize = 0x4000;
|
||||
qs.OutSize = 0x4000;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -246,7 +246,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
irp.write.nbytes = sizeof(flags);
|
||||
flags = PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -264,7 +264,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
timeouts.WriteTotalTimeoutMultiplier = 100;
|
||||
timeouts.WriteTotalTimeoutConstant = 0;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -280,7 +280,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
lc.Parity = NO_PARITY;
|
||||
lc.StopBits = STOP_BIT_1;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -294,7 +294,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
irp.write.nbytes = sizeof(baud);
|
||||
baud.BaudRate = baud_rate;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -311,7 +311,7 @@ p3io_uart_open(const wchar_t *path, uint32_t baud_rate, HANDLE *fd)
|
||||
handflow.XonLimit = 0;
|
||||
handflow.XoffLimit = 0;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
@ -324,7 +324,7 @@ fail:
|
||||
irp.op = IRP_OP_CLOSE;
|
||||
irp.fd = *fd;
|
||||
|
||||
irp_invoke_next(&irp);
|
||||
iohook_invoke_next(&irp);
|
||||
|
||||
*fd = NULL;
|
||||
}
|
||||
@ -342,7 +342,7 @@ static HRESULT p3io_uart_close(HANDLE fd)
|
||||
irp.op = IRP_OP_CLOSE;
|
||||
irp.fd = fd;
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("Error closing port: %x", (int) hr);
|
||||
@ -376,7 +376,7 @@ static HRESULT p3io_uart_read(HANDLE fd, struct iobuf *iobuf)
|
||||
irp.read.bytes = (uint8_t *) &status;
|
||||
irp.read.nbytes = sizeof(status);
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("UART FIFO peek failed: %x", (int) hr);
|
||||
@ -397,7 +397,7 @@ static HRESULT p3io_uart_read(HANDLE fd, struct iobuf *iobuf)
|
||||
irp.fd = fd;
|
||||
memcpy(&irp.read, iobuf, sizeof(*iobuf));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
log_warning("Read error: %x", (int) hr);
|
||||
@ -426,7 +426,7 @@ static HRESULT p3io_uart_write(HANDLE fd, struct const_iobuf *iobuf)
|
||||
irp.fd = fd;
|
||||
memcpy(&irp.write, iobuf, sizeof(*iobuf));
|
||||
|
||||
hr = irp_invoke_next(&irp);
|
||||
hr = iohook_invoke_next(&irp);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
memcpy(iobuf, &irp.write, sizeof(*iobuf));
|
||||
|
@ -344,7 +344,7 @@ static HRESULT p4ioemu_device_open(struct irp *irp)
|
||||
game also adds the node \\p4io to that -> result: \\p4io\\p4io */
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"\\p4io\\p4io")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
irp->fd = p4ioemu_p4io_fd;
|
||||
@ -466,7 +466,14 @@ void p4ioemu_init(const struct p4ioemu_device_msg_hook *msg_hook)
|
||||
{
|
||||
log_assert(p4ioemu_p4io_fd == NULL);
|
||||
|
||||
p4ioemu_p4io_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&p4ioemu_p4io_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
|
||||
p4ioemu_device_msg_hook = msg_hook;
|
||||
}
|
||||
|
||||
@ -485,7 +492,7 @@ p4ioemu_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != p4ioemu_p4io_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
|
@ -51,7 +51,7 @@ ac_io_bus_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -22,11 +22,6 @@
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
static const irp_handler_t sdvxhook_handlers[] = {
|
||||
ac_io_bus_dispatch_irp,
|
||||
lcd_dispatch_irp,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *config)
|
||||
{
|
||||
bool ok;
|
||||
@ -123,7 +118,10 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
|
||||
args_free(argc, argv);
|
||||
|
||||
app_hook_init(my_dll_entry_init, my_dll_entry_main);
|
||||
iohook_init(sdvxhook_handlers, lengthof(sdvxhook_handlers));
|
||||
|
||||
iohook_push_handler(ac_io_bus_dispatch_irp);
|
||||
iohook_push_handler(lcd_dispatch_irp);
|
||||
|
||||
rs232_hook_init();
|
||||
|
||||
gfx_init();
|
||||
|
@ -91,7 +91,7 @@ static HRESULT STDCALL my_CreateDevice(
|
||||
D3DPRESENT_PARAMETERS *pp,
|
||||
IDirect3DDevice9 **pdev)
|
||||
{
|
||||
IDirect3D9 *real = COM_PROXY_UNWRAP(self);
|
||||
IDirect3D9 *real = com_proxy_downcast(self)->real;
|
||||
HRESULT hr;
|
||||
|
||||
log_misc("IDirect3D9::CreateDevice hook hit");
|
||||
@ -117,11 +117,18 @@ static IDirect3D9 *STDCALL my_Direct3DCreate9(UINT sdk_ver)
|
||||
IDirect3D9 *api;
|
||||
IDirect3D9Vtbl *api_vtbl;
|
||||
struct com_proxy *api_proxy;
|
||||
HRESULT hr;
|
||||
|
||||
log_info("Direct3DCreate9 hook hit");
|
||||
|
||||
api = real_Direct3DCreate9(sdk_ver);
|
||||
api_proxy = com_proxy_wrap(api, sizeof(*api->lpVtbl));
|
||||
|
||||
hr = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl));
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Wrapping com proxy failed: %08lx", hr);
|
||||
}
|
||||
|
||||
api_vtbl = api_proxy->vptr;
|
||||
|
||||
api_vtbl->CreateDevice = my_CreateDevice;
|
||||
|
@ -31,7 +31,13 @@ void lcd_init(void)
|
||||
{
|
||||
log_assert(lcd_fd == NULL);
|
||||
|
||||
lcd_fd = iohook_open_dummy_fd();
|
||||
HRESULT hr;
|
||||
|
||||
hr = iohook_open_nul_fd(&lcd_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_fini(void)
|
||||
@ -49,7 +55,7 @@ lcd_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (irp->op != IRP_OP_OPEN && irp->fd != lcd_fd) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
@ -73,7 +79,7 @@ static HRESULT lcd_open(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!wstr_eq(irp->open_filename, L"COM1")) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
irp->fd = lcd_fd;
|
||||
|
@ -51,7 +51,7 @@ HRESULT ac_io_port_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -37,10 +37,6 @@
|
||||
#define SDVXHOOK2_CN_CMD_USAGE \
|
||||
"Usage: launcher.exe -K sdvxhook2.dll <soundvoltex.dll> [options...]"
|
||||
|
||||
static const irp_handler_t sdvxhook_handlers[] = {
|
||||
ac_io_port_dispatch_irp,
|
||||
};
|
||||
|
||||
struct sdvxhook2_cn_config config_cn;
|
||||
struct camhook_config_cam config_cam;
|
||||
struct d3d9exhook_config_gfx config_gfx;
|
||||
@ -90,7 +86,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* iohooks are okay, even if emu is diabled since the fake handlers won't be
|
||||
* used */
|
||||
iohook_init(sdvxhook_handlers, lengthof(sdvxhook_handlers));
|
||||
iohook_push_handler(ac_io_port_dispatch_irp);
|
||||
|
||||
rs232_hook_init();
|
||||
rs232_hook_limit_hooks();
|
||||
|
||||
|
@ -52,7 +52,7 @@ HRESULT ac_io_port_dispatch_irp(struct irp *irp)
|
||||
log_assert(irp != NULL);
|
||||
|
||||
if (!ac_io_emu_match_irp(&ac_io_emu, irp)) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
@ -40,11 +40,6 @@
|
||||
#define SDVXHOOK2_CMD_USAGE \
|
||||
"Usage: launcher.exe -K sdvxhook2.dll <soundvoltex.dll> [options...]"
|
||||
|
||||
static const irp_handler_t sdvxhook_handlers[] = {
|
||||
ac_io_port_dispatch_irp,
|
||||
bio2emu_port_dispatch_irp,
|
||||
};
|
||||
|
||||
struct sdvxhook2_config_io config_io;
|
||||
struct camhook_config_cam config_cam;
|
||||
struct d3d9exhook_config_gfx config_gfx;
|
||||
@ -115,7 +110,9 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
/* iohooks are okay, even if emu is diabled since the fake handlers won't be
|
||||
* used */
|
||||
iohook_init(sdvxhook_handlers, lengthof(sdvxhook_handlers));
|
||||
iohook_push_handler(ac_io_port_dispatch_irp);
|
||||
iohook_push_handler(bio2emu_port_dispatch_irp);
|
||||
|
||||
rs232_hook_init();
|
||||
rs232_hook_limit_hooks();
|
||||
|
||||
|
@ -20,16 +20,13 @@
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
|
||||
static bool my_dll_entry_main(void);
|
||||
|
||||
static const irp_handler_t unicorntail_handlers[] = {
|
||||
p3io_filter_dispatch_irp,
|
||||
usbmem_dispatch_irp,
|
||||
};
|
||||
|
||||
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
{
|
||||
log_info("--- Begin unicorntail dll_entry_init ---");
|
||||
|
||||
iohook_init(unicorntail_handlers, lengthof(unicorntail_handlers));
|
||||
iohook_push_handler(p3io_filter_dispatch_irp);
|
||||
iohook_push_handler(usbmem_dispatch_irp);
|
||||
|
||||
p3io_filter_init();
|
||||
usbmem_init();
|
||||
|
||||
|
@ -55,7 +55,7 @@ p3io_filter_dispatch_irp(struct irp *irp)
|
||||
LeaveCriticalSection(&p3io_handle_lock);
|
||||
|
||||
if (!match) {
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
@ -68,7 +68,7 @@ p3io_filter_dispatch_irp(struct irp *irp)
|
||||
case IRP_OP_READ:
|
||||
return p3io_handle_read(irp);
|
||||
default:
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ static HRESULT p3io_handle_open(struct irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
hr = irp_invoke_next(irp);
|
||||
hr = iohook_invoke_next(irp);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
@ -169,7 +169,7 @@ static HRESULT p3io_handle_write(struct irp *irp)
|
||||
/* Non-UART command, break out here. */
|
||||
irp->write.pos = 0;
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
/* Frame up and queue a response packet */
|
||||
@ -189,7 +189,7 @@ static HRESULT p3io_handle_read(struct irp *irp)
|
||||
if (p3io_resp.pos == 0) {
|
||||
LeaveCriticalSection(&p3io_cmd_lock);
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
} else {
|
||||
iobuf_flip(&tmp, &p3io_resp);
|
||||
iobuf_move(&irp->read, &tmp);
|
||||
|
@ -35,7 +35,7 @@ void usbmem_fini(void)
|
||||
irp.op = IRP_OP_CLOSE;
|
||||
irp.fd = usbmem_fd;
|
||||
|
||||
irp_invoke_next(&irp);
|
||||
iohook_invoke_next(&irp);
|
||||
}
|
||||
|
||||
DeleteCriticalSection(&usbmem_lock);
|
||||
@ -54,7 +54,7 @@ usbmem_dispatch_irp(struct irp *irp)
|
||||
if (!usbmem_match_irp(irp)) {
|
||||
LeaveCriticalSection(&usbmem_lock);
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
} else {
|
||||
hr = usbmem_dispatch_irp_locked(irp);
|
||||
LeaveCriticalSection(&usbmem_lock);
|
||||
@ -94,7 +94,7 @@ static HRESULT usbmem_handle_open(struct irp *irp)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
hr = irp_invoke_next(irp);
|
||||
hr = iohook_invoke_next(irp);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
log_info("Opened a real usbmem port");
|
||||
@ -108,7 +108,11 @@ static HRESULT usbmem_handle_open(struct irp *irp)
|
||||
start emulating a usbmem unit. */
|
||||
|
||||
if (usbmem_fd == NULL || usbmem_fd == INVALID_HANDLE_VALUE) {
|
||||
usbmem_fd = iohook_open_dummy_fd();
|
||||
hr = iohook_open_nul_fd(&usbmem_fd);
|
||||
|
||||
if (hr != S_OK) {
|
||||
log_fatal("Opening nul fd failed: %08lx", hr);
|
||||
}
|
||||
}
|
||||
|
||||
irp->fd = usbmem_fd;
|
||||
@ -120,7 +124,7 @@ static HRESULT usbmem_handle_close(struct irp *irp)
|
||||
{
|
||||
usbmem_fd = NULL;
|
||||
|
||||
return irp_invoke_next(irp);
|
||||
return iohook_invoke_next(irp);
|
||||
}
|
||||
|
||||
static HRESULT usbmem_handle_write(struct irp *irp)
|
||||
|
@ -7,7 +7,6 @@ src_util := \
|
||||
crypto.c \
|
||||
fs.c \
|
||||
hex.c \
|
||||
hr.c \
|
||||
iobuf.c \
|
||||
list.c \
|
||||
log.c \
|
||||
|
@ -1,61 +0,0 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util/hr.h"
|
||||
|
||||
HRESULT
|
||||
hr_from_win32(void)
|
||||
{
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
void hr_propagate_win32_(HRESULT hr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
result = ERROR_SUCCESS;
|
||||
} else if (HRESULT_FACILITY(hr) == FACILITY_WIN32) {
|
||||
result = HRESULT_CODE(hr);
|
||||
} else {
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/seccrypto/common-hresult-values
|
||||
switch (hr) {
|
||||
case E_ABORT:
|
||||
result = ERROR_OPERATION_ABORTED;
|
||||
break;
|
||||
case E_ACCESSDENIED:
|
||||
result = ERROR_ACCESS_DENIED;
|
||||
break;
|
||||
case E_FAIL:
|
||||
result = ERROR_GEN_FAILURE;
|
||||
break;
|
||||
case E_HANDLE:
|
||||
result = ERROR_INVALID_HANDLE;
|
||||
break;
|
||||
case E_INVALIDARG:
|
||||
result = ERROR_INVALID_PARAMETER;
|
||||
break;
|
||||
case E_NOINTERFACE:
|
||||
result = ERROR_NOT_SUPPORTED;
|
||||
break;
|
||||
case E_NOTIMPL:
|
||||
result = ERROR_NOT_SUPPORTED;
|
||||
break;
|
||||
case E_OUTOFMEMORY:
|
||||
result = ERROR_OUTOFMEMORY;
|
||||
break;
|
||||
case E_POINTER:
|
||||
result = ERROR_INVALID_ADDRESS;
|
||||
break;
|
||||
case E_UNEXPECTED:
|
||||
result = ERROR_INTERNAL_ERROR;
|
||||
break;
|
||||
default:
|
||||
result = ERROR_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetLastError(result);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#ifndef UTIL_HR_H
|
||||
#define UTIL_HR_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define hr_propagate_win32(hr, r) (hr_propagate_win32_(hr), r)
|
||||
|
||||
HRESULT hr_from_win32(void);
|
||||
void hr_propagate_win32_(HRESULT hr);
|
||||
|
||||
#endif
|
@ -1,40 +1,10 @@
|
||||
#define LOG_MODULE "iobuf"
|
||||
|
||||
#include <string.h>
|
||||
#define LOG_MODULE "util-iobuf"
|
||||
|
||||
#include "util/hex.h"
|
||||
#include "util/iobuf.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
size_t iobuf_move(struct iobuf *dest, struct const_iobuf *src)
|
||||
{
|
||||
size_t dest_avail;
|
||||
size_t src_avail;
|
||||
size_t chunksz;
|
||||
|
||||
dest_avail = dest->nbytes - dest->pos;
|
||||
src_avail = src->nbytes - src->pos;
|
||||
chunksz = dest_avail < src_avail ? dest_avail : src_avail;
|
||||
|
||||
memcpy(&dest->bytes[dest->pos], &src->bytes[src->pos], chunksz);
|
||||
|
||||
dest->pos += chunksz;
|
||||
src->pos += chunksz;
|
||||
|
||||
return chunksz;
|
||||
}
|
||||
|
||||
void iobuf_flip(struct const_iobuf *dest, const struct iobuf *src)
|
||||
{
|
||||
log_assert(dest != NULL);
|
||||
log_assert(src != NULL);
|
||||
|
||||
dest->bytes = src->bytes;
|
||||
dest->pos = 0;
|
||||
dest->nbytes = src->pos;
|
||||
}
|
||||
|
||||
void iobuf_log(struct iobuf *buffer, const char *tag)
|
||||
{
|
||||
char *str;
|
||||
|
@ -4,21 +4,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct iobuf {
|
||||
uint8_t *bytes;
|
||||
size_t nbytes;
|
||||
size_t pos;
|
||||
};
|
||||
|
||||
struct const_iobuf {
|
||||
const uint8_t *bytes;
|
||||
size_t nbytes;
|
||||
size_t pos;
|
||||
};
|
||||
|
||||
size_t iobuf_move(struct iobuf *dest, struct const_iobuf *src);
|
||||
|
||||
void iobuf_flip(struct const_iobuf *dest, const struct iobuf *src);
|
||||
#include "hook/iobuf.h"
|
||||
|
||||
void iobuf_log(struct iobuf *buffer, const char *tag);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user