commit so I can work somewhere else lol
This commit is contained in:
parent
0263157f1a
commit
ffcf6dafc2
139
platform/cert.c
Normal file
139
platform/cert.c
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include <wincrypt.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "hook/table.h"
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
|
#include "hook/procaddr.h"
|
||||||
|
|
||||||
|
#include "util/dprintf.h"
|
||||||
|
#include "util/str.h"
|
||||||
|
|
||||||
|
static CRITICAL_SECTION cert_lock;
|
||||||
|
static wchar_t path[MAX_PATH];
|
||||||
|
|
||||||
|
HCERTSTORE WINAPI hook_CertOpenStore(
|
||||||
|
LPCSTR lpszStoreProvider,
|
||||||
|
DWORD dwEncodingType,
|
||||||
|
HCRYPTPROV_LEGACY hCryptProv,
|
||||||
|
DWORD dwFlags,
|
||||||
|
const void *pvPara
|
||||||
|
);
|
||||||
|
|
||||||
|
PCCERT_CONTEXT WINAPI hook_CertFindCertificateInStore(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType,
|
||||||
|
DWORD dwFindFlags,
|
||||||
|
DWORD dwFindType,
|
||||||
|
const void *pvFindPara,
|
||||||
|
PCCERT_CONTEXT pPrevCertContext
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOL WINAPI hook_CertCloseStore(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwFlags
|
||||||
|
);
|
||||||
|
|
||||||
|
HCERTSTORE (WINAPI *next_CertOpenStore)(
|
||||||
|
LPCSTR lpszStoreProvider,
|
||||||
|
DWORD dwEncodingType,
|
||||||
|
HCRYPTPROV_LEGACY hCryptProv,
|
||||||
|
DWORD dwFlags,
|
||||||
|
const void *pvPara
|
||||||
|
);
|
||||||
|
|
||||||
|
PCCERT_CONTEXT (WINAPI *next_CertFindCertificateInStore)(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType,
|
||||||
|
DWORD dwFindFlags,
|
||||||
|
DWORD dwFindType,
|
||||||
|
const void *pvFindPara,
|
||||||
|
PCCERT_CONTEXT pPrevCertContext
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOL (WINAPI *next_CertCloseStore)(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwFlags
|
||||||
|
);
|
||||||
|
|
||||||
|
static const struct hook_symbol cert_syms[] = {
|
||||||
|
{
|
||||||
|
.name = "CertOpenStore",
|
||||||
|
.patch = hook_CertOpenStore,
|
||||||
|
.link = (void **) &next_CertOpenStore,
|
||||||
|
}, {
|
||||||
|
.name = "CertFindCertificateInStore",
|
||||||
|
.patch = hook_CertFindCertificateInStore,
|
||||||
|
.link = (void **) &next_CertFindCertificateInStore,
|
||||||
|
}, {
|
||||||
|
.name = "CertCloseStore",
|
||||||
|
.patch = hook_CertCloseStore,
|
||||||
|
.link = (void **) &next_CertCloseStore,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT cert_hook_init(const struct cert_config *cfg)
|
||||||
|
{
|
||||||
|
assert(cfg != NULL);
|
||||||
|
|
||||||
|
if (!cfg->enable) {
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dprintf("Cert hook init\n");
|
||||||
|
wcscpy_s(path, MAX_PATH, cfg->path);
|
||||||
|
InitializeCriticalSection(&cert_lock);
|
||||||
|
cert_hook_insert_hooks(NULL);
|
||||||
|
|
||||||
|
proc_addr_table_push(
|
||||||
|
NULL,
|
||||||
|
"crypt32.dll",
|
||||||
|
(struct hook_symbol *) cert_syms,
|
||||||
|
_countof(cert_syms));
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cert_hook_insert_hooks(HMODULE target)
|
||||||
|
{
|
||||||
|
hook_table_apply(
|
||||||
|
target,
|
||||||
|
"crypt32.dll",
|
||||||
|
cert_syms,
|
||||||
|
_countof(cert_syms));
|
||||||
|
}
|
||||||
|
|
||||||
|
HCERTSTORE WINAPI hook_CertOpenStore(
|
||||||
|
LPCSTR lpszStoreProvider,
|
||||||
|
DWORD dwEncodingType,
|
||||||
|
HCRYPTPROV_LEGACY hCryptProv,
|
||||||
|
DWORD dwFlags,
|
||||||
|
const void *pvPara
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PCCERT_CONTEXT WINAPI hook_CertFindCertificateInStore(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType,
|
||||||
|
DWORD dwFindFlags,
|
||||||
|
DWORD dwFindType,
|
||||||
|
const void *pvFindPara,
|
||||||
|
PCCERT_CONTEXT pPrevCertContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI hook_CertCloseStore(
|
||||||
|
HCERTSTORE hCertStore,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
14
platform/cert.h
Normal file
14
platform/cert.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct cert_config {
|
||||||
|
bool enable;
|
||||||
|
wchar_t path[MAX_PATH];
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT cert_hook_init(const struct cert_config *cfg);
|
||||||
|
void cert_hook_insert_hooks(HMODULE target);
|
@ -9,6 +9,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
#include "platform/clock.h"
|
#include "platform/clock.h"
|
||||||
#include "platform/config.h"
|
#include "platform/config.h"
|
||||||
#include "platform/dns.h"
|
#include "platform/dns.h"
|
||||||
@ -24,6 +25,7 @@ void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
|
|||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
assert(filename != NULL);
|
assert(filename != NULL);
|
||||||
|
|
||||||
|
cert_config_load(&cfg->cert, filename);
|
||||||
clock_config_load(&cfg->clock, filename);
|
clock_config_load(&cfg->clock, filename);
|
||||||
dns_config_load(&cfg->dns, filename);
|
dns_config_load(&cfg->dns, filename);
|
||||||
misc_config_load(&cfg->misc, filename);
|
misc_config_load(&cfg->misc, filename);
|
||||||
@ -33,6 +35,21 @@ void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
|
|||||||
syscfg_config_load(&cfg->syscfg, filename);
|
syscfg_config_load(&cfg->syscfg, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cert_config_load(struct cert_config *cfg, const wchar_t *filename)
|
||||||
|
{
|
||||||
|
assert(cfg != NULL);
|
||||||
|
assert(filename != NULL);
|
||||||
|
|
||||||
|
cfg->enable = GetPrivateProfileIntW(L"cert", L"enable", 1, filename);
|
||||||
|
GetPrivateProfileStringW(
|
||||||
|
L"cert",
|
||||||
|
L"path",
|
||||||
|
L"cert",
|
||||||
|
cfg->path,
|
||||||
|
_countof(cfg->path),
|
||||||
|
filename);
|
||||||
|
}
|
||||||
|
|
||||||
void clock_config_load(struct clock_config *cfg, const wchar_t *filename)
|
void clock_config_load(struct clock_config *cfg, const wchar_t *filename)
|
||||||
{
|
{
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
#include "platform/clock.h"
|
#include "platform/clock.h"
|
||||||
#include "platform/dns.h"
|
#include "platform/dns.h"
|
||||||
#include "platform/misc.h"
|
#include "platform/misc.h"
|
||||||
@ -19,6 +20,7 @@ void platform_config_load(
|
|||||||
struct platform_config *cfg,
|
struct platform_config *cfg,
|
||||||
const wchar_t *filename);
|
const wchar_t *filename);
|
||||||
|
|
||||||
|
void cert_config_load(struct cert_config *cfg, const wchar_t *filename);
|
||||||
void clock_config_load(struct clock_config *cfg, const wchar_t *filename);
|
void clock_config_load(struct clock_config *cfg, const wchar_t *filename);
|
||||||
void dns_config_load(struct dns_config *cfg, const wchar_t *filename);
|
void dns_config_load(struct dns_config *cfg, const wchar_t *filename);
|
||||||
void misc_config_load(struct misc_config *cfg, const wchar_t *filename);
|
void misc_config_load(struct misc_config *cfg, const wchar_t *filename);
|
||||||
|
@ -8,6 +8,8 @@ platform_lib = static_library(
|
|||||||
shlwapi_lib,
|
shlwapi_lib,
|
||||||
],
|
],
|
||||||
sources : [
|
sources : [
|
||||||
|
'cert.c',
|
||||||
|
'cert.h',
|
||||||
'clock.c',
|
'clock.c',
|
||||||
'clock.h',
|
'clock.h',
|
||||||
'config.c',
|
'config.c',
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
#include "platform/clock.h"
|
#include "platform/clock.h"
|
||||||
#include "platform/dns.h"
|
#include "platform/dns.h"
|
||||||
#include "platform/misc.h"
|
#include "platform/misc.h"
|
||||||
@ -22,6 +23,12 @@ HRESULT platform_hook_init(
|
|||||||
assert(game_id != 0);
|
assert(game_id != 0);
|
||||||
assert(redir_mod != NULL);
|
assert(redir_mod != NULL);
|
||||||
|
|
||||||
|
hr = cert_hook_init(&cfg->cert);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
hr = clock_hook_init(&cfg->clock);
|
hr = clock_hook_init(&cfg->clock);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
#include "platform/clock.h"
|
#include "platform/clock.h"
|
||||||
#include "platform/dns.h"
|
#include "platform/dns.h"
|
||||||
#include "platform/misc.h"
|
#include "platform/misc.h"
|
||||||
@ -11,6 +12,7 @@
|
|||||||
#include "platform/syscfg.h"
|
#include "platform/syscfg.h"
|
||||||
|
|
||||||
struct platform_config {
|
struct platform_config {
|
||||||
|
struct cert_config cert;
|
||||||
struct clock_config clock;
|
struct clock_config clock;
|
||||||
struct dns_config dns;
|
struct dns_config dns;
|
||||||
struct misc_config misc;
|
struct misc_config misc;
|
||||||
|
@ -76,6 +76,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (cause != DLL_PROCESS_ATTACH) {
|
if (cause != DLL_PROCESS_ATTACH) {
|
||||||
|
dprintf("Connected\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "hooklib/reg.h"
|
#include "hooklib/reg.h"
|
||||||
#include "hook/procaddr.h"
|
#include "hook/procaddr.h"
|
||||||
|
|
||||||
|
#include "platform/cert.h"
|
||||||
|
|
||||||
#include "util/dprintf.h"
|
#include "util/dprintf.h"
|
||||||
|
|
||||||
static void dll_hook_insert_hooks(HMODULE target);
|
static void dll_hook_insert_hooks(HMODULE target);
|
||||||
@ -104,6 +106,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
|
|||||||
path_hook_insert_hooks(result);
|
path_hook_insert_hooks(result);
|
||||||
reg_hook_insert_hooks(result);
|
reg_hook_insert_hooks(result);
|
||||||
proc_addr_insert_hooks(result);
|
proc_addr_insert_hooks(result);
|
||||||
|
cert_hook_insert_hooks(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < dep_hooks_len; i++) {
|
for (size_t i = 0; i < dep_hooks_len; i++) {
|
||||||
@ -115,6 +118,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
|
|||||||
iohook_apply_hooks(dep_mod);
|
iohook_apply_hooks(dep_mod);
|
||||||
serial_hook_apply_hooks(dep_mod);
|
serial_hook_apply_hooks(dep_mod);
|
||||||
reg_hook_insert_hooks(dep_mod);
|
reg_hook_insert_hooks(dep_mod);
|
||||||
|
cert_hook_insert_hooks(dep_mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user