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:
icex2
2020-09-02 19:35:15 +00:00
parent b777396efd
commit 5de9fdee43
52 changed files with 265 additions and 333 deletions
+1 -1
View File
@@ -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 (;;) {
+4 -6
View File
@@ -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();
+9 -2
View File
@@ -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;
+9 -3
View File
@@ -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;