From 3e91ac239332708652c431dc45a202d84bc5f67a Mon Sep 17 00:00:00 2001 From: Tau Date: Tue, 14 May 2019 18:03:25 -0400 Subject: [PATCH] platform/amvideo.c: Add virtual amvideo.dll hook --- platform/amvideo.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ platform/amvideo.h | 5 +++ platform/meson.build | 2 ++ 3 files changed, 82 insertions(+) create mode 100644 platform/amvideo.c create mode 100644 platform/amvideo.h diff --git a/platform/amvideo.c b/platform/amvideo.c new file mode 100644 index 0000000..fa076cf --- /dev/null +++ b/platform/amvideo.c @@ -0,0 +1,75 @@ +#include + +#include +#include + +#include "hook/table.h" + +#include "hooklib/dll.h" + +#include "util/dprintf.h" + +/* Hook functions */ + +static int amDllVideoOpen(void *ctx); +static int amDllVideoClose(void *ctx); +static int amDllVideoSetResolution(void *ctx, void *param); +static int amDllVideoGetVBiosVersion(void *ctx, char *dest, size_t nchars); + +static const struct hook_symbol amvideo_syms[] = { + { + .ordinal = 1, + .name = "amDllVideoOpen", + .patch = amDllVideoOpen, + }, { + .ordinal = 2, + .name = "amDllVideoClose", + .patch = amDllVideoClose, + }, { + .ordinal = 3, + .name = "amDllVideoSetResolution", + .patch = amDllVideoSetResolution, + }, { + .ordinal = 4, + .name = "amDllVideoGetVBiosVersion", + .patch = amDllVideoGetVBiosVersion, + } +}; + +HRESULT amvideo_hook_init(HMODULE redir_mod) +{ + return dll_hook_push( + redir_mod, + L"$amvideo", + amvideo_syms, + _countof(amvideo_syms)); +} + +static int amDllVideoOpen(void *ctx) +{ + dprintf("AmVideo: %s(%p)\n", __func__, ctx); + + return 0; +} + +static int amDllVideoClose(void *ctx) +{ + dprintf("AmVideo: %s(%p)\n", __func__, ctx); + + return 0; +} + +static int amDllVideoSetResolution(void *ctx, void *param) +{ + dprintf("AmVideo: %s(%p, %p)\n", __func__, ctx, param); + + return 0; +} + +static int amDllVideoGetVBiosVersion(void *ctx, char *dest, size_t nchars) +{ + dprintf("AmVideo: %s(%p, %p, %i)\n", __func__, ctx, dest, (int) nchars); + strcpy(dest, "01.02.03.04.05"); + + return 0; +} diff --git a/platform/amvideo.h b/platform/amvideo.h new file mode 100644 index 0000000..d81fc82 --- /dev/null +++ b/platform/amvideo.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +HRESULT amvideo_hook_init(HMODULE redir_mod); diff --git a/platform/meson.build b/platform/meson.build index 91f5b85..e6e55f7 100644 --- a/platform/meson.build +++ b/platform/meson.build @@ -7,6 +7,8 @@ platform_lib = static_library( capnhook.get_variable('hook_dep'), ], sources : [ + 'amvideo.c', + 'amvideo.h', 'hwmon.c', 'hwmon.h', 'pcbid.c',