2014-11-10 01:53:40 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "hook-helpers.h"
|
|
|
|
|
2016-11-01 02:34:17 -07:00
|
|
|
#define EVENT_CAPTURE_RESTART L"CaptureHook_Restart"
|
2019-06-22 22:13:45 -07:00
|
|
|
#define EVENT_CAPTURE_STOP L"CaptureHook_Stop"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define EVENT_HOOK_READY L"CaptureHook_HookReady"
|
|
|
|
#define EVENT_HOOK_EXIT L"CaptureHook_Exit"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define EVENT_HOOK_INIT L"CaptureHook_Initialize"
|
2016-11-01 00:21:42 -07:00
|
|
|
|
2016-10-31 22:30:30 -07:00
|
|
|
#define WINDOW_HOOK_KEEPALIVE L"CaptureHook_KeepAlive"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define MUTEX_TEXTURE1 L"CaptureHook_TextureMutex1"
|
|
|
|
#define MUTEX_TEXTURE2 L"CaptureHook_TextureMutex2"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define SHMEM_HOOK_INFO L"CaptureHook_HookInfo"
|
|
|
|
#define SHMEM_TEXTURE L"CaptureHook_Texture"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define PIPE_NAME "CaptureHook_Pipe"
|
2014-11-10 01:53:40 -08:00
|
|
|
|
|
|
|
#pragma pack(push, 8)
|
|
|
|
|
|
|
|
struct d3d8_offsets {
|
|
|
|
uint32_t present;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct d3d9_offsets {
|
|
|
|
uint32_t present;
|
|
|
|
uint32_t present_ex;
|
|
|
|
uint32_t present_swap;
|
2016-08-08 21:54:06 -07:00
|
|
|
uint32_t d3d9_clsoff;
|
|
|
|
uint32_t is_d3d9ex_clsoff;
|
2014-11-10 01:53:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dxgi_offsets {
|
|
|
|
uint32_t present;
|
|
|
|
uint32_t resize;
|
2017-06-19 15:45:00 -07:00
|
|
|
|
|
|
|
uint32_t present1;
|
2014-11-10 01:53:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ddraw_offsets {
|
|
|
|
uint32_t surface_create;
|
|
|
|
uint32_t surface_restore;
|
|
|
|
uint32_t surface_release;
|
|
|
|
uint32_t surface_unlock;
|
|
|
|
uint32_t surface_blt;
|
|
|
|
uint32_t surface_flip;
|
|
|
|
uint32_t surface_set_palette;
|
|
|
|
uint32_t palette_set_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shmem_data {
|
|
|
|
volatile int last_tex;
|
|
|
|
uint32_t tex1_offset;
|
|
|
|
uint32_t tex2_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shtex_data {
|
|
|
|
uint32_t tex_handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum capture_type {
|
|
|
|
CAPTURE_TYPE_MEMORY,
|
2019-06-22 22:13:45 -07:00
|
|
|
CAPTURE_TYPE_TEXTURE,
|
2014-11-10 01:53:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct graphics_offsets {
|
|
|
|
struct d3d8_offsets d3d8;
|
|
|
|
struct d3d9_offsets d3d9;
|
|
|
|
struct dxgi_offsets dxgi;
|
|
|
|
struct ddraw_offsets ddraw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hook_info {
|
2020-02-28 23:24:18 -08:00
|
|
|
/* hook version */
|
|
|
|
uint32_t hook_ver_major;
|
|
|
|
uint32_t hook_ver_minor;
|
|
|
|
|
2014-11-10 01:53:40 -08:00
|
|
|
/* capture info */
|
2019-06-22 22:13:45 -07:00
|
|
|
enum capture_type type;
|
|
|
|
uint32_t window;
|
|
|
|
uint32_t format;
|
|
|
|
uint32_t cx;
|
|
|
|
uint32_t cy;
|
|
|
|
uint32_t base_cx;
|
|
|
|
uint32_t base_cy;
|
|
|
|
uint32_t pitch;
|
|
|
|
uint32_t map_id;
|
|
|
|
uint32_t map_size;
|
|
|
|
bool flip;
|
2014-11-10 01:53:40 -08:00
|
|
|
|
|
|
|
/* additional options */
|
2019-06-22 22:13:45 -07:00
|
|
|
uint64_t frame_interval;
|
|
|
|
bool use_scale;
|
|
|
|
bool force_shmem;
|
|
|
|
bool capture_overlay;
|
2014-11-10 01:53:40 -08:00
|
|
|
|
|
|
|
/* hook addresses */
|
2019-06-22 22:13:45 -07:00
|
|
|
struct graphics_offsets offsets;
|
2020-02-28 23:24:18 -08:00
|
|
|
|
|
|
|
uint32_t reserved[128];
|
2014-11-10 01:53:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2016-10-31 01:41:01 -07:00
|
|
|
#define GC_MAPPING_FLAGS (FILE_MAP_READ | FILE_MAP_WRITE)
|
|
|
|
|
2016-11-01 00:21:42 -07:00
|
|
|
static inline HANDLE create_hook_info(DWORD id)
|
2014-11-10 01:53:40 -08:00
|
|
|
{
|
2020-02-27 05:28:05 -08:00
|
|
|
HANDLE handle = NULL;
|
2014-11-10 01:53:40 -08:00
|
|
|
|
2020-02-27 05:28:05 -08:00
|
|
|
wchar_t new_name[64];
|
|
|
|
const int len = swprintf(new_name, _countof(new_name),
|
|
|
|
SHMEM_HOOK_INFO L"%lu", id);
|
|
|
|
if (len > 0) {
|
|
|
|
handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
|
|
|
|
PAGE_READWRITE, 0,
|
|
|
|
sizeof(struct hook_info), new_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return handle;
|
2016-11-01 00:21:42 -07:00
|
|
|
}
|