add MSVC build, remove precompiled headers

This commit is contained in:
Kevin Trocolli 2024-12-19 14:00:51 -05:00
parent e67bfc2cc0
commit 9f4e82d5cb
65 changed files with 694 additions and 59 deletions

View File

@ -3,7 +3,6 @@ aimeio_lib = static_library(
name_prefix : '',
include_directories: inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
link_with : [
util_lib,
],

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <assert.h>
#include <unknwnbase.h>
#include <combaseapi.h>
#include <rpcproxy.h>

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <combaseapi.h>
#include <stdint.h>
#include <stdio.h>
#include "amcus/iauth.h"
#include "amcus/amcus.h"

View File

@ -2,7 +2,6 @@ amcus_lib = static_library(
'gfxhook',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>

View File

@ -2,7 +2,6 @@ board_lib = static_library(
'board',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],

View File

@ -1,5 +1,6 @@
#include <windows.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <assert.h>
#include "board/qr.h"

View File

@ -354,13 +354,13 @@ static HRESULT sg_nfc_poll_felica(
felica->type = 0x20;
felica->id_len = sizeof(felica->IDm) + sizeof(felica->PMm);
felica->IDm = _byteswap_uint64(IDm);
felica->PMm = _byteswap_uint64(felica_get_generic_PMm());
felica->PMm = _byteswap_uint64(felica_get_amusement_ic_PMm());
/* Initialize FeliCa IC emulator */
nfc->felica.IDm = IDm;
nfc->felica.PMm = felica_get_generic_PMm();
nfc->felica.system_code = 0x0000;
nfc->felica.PMm = felica_get_amusement_ic_PMm();
nfc->felica.system_code = 0x88b4;
return S_OK;
}

View File

@ -10,7 +10,7 @@
*/
#include <windows.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <stdlib.h>
#include <stddef.h>
#include "exvs2hook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'exvs2hook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -3,7 +3,6 @@ exvs2io_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "ferrumhook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'ferrumhook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -1,4 +1,6 @@
#include <windows.h>
#include <assert.h>
#include <stdlib.h>
#include <xinput.h>
#include <stdint.h>

View File

@ -3,7 +3,6 @@ ferrumio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

View File

@ -130,12 +130,29 @@ static HWND WINAPI hook_CreateWindowExA(
LPVOID lpParam
)
{
RECT rect;
dprintf("Gfx: CreateWindowExA hook hit\n");
DWORD windowStyle = 0;
if (gfx_config.windowed) {
if (gfx_config.framed)
dwStyle |= WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
else
dwStyle = WS_POPUP;
rect.left = ((X == CW_USEDEFAULT) ? 0 : X);
rect.top = ((Y == CW_USEDEFAULT) ? 0 : Y);
rect.right = rect.left + nWidth;
rect.bottom = rect.top + nHeight;
windowStyle = WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
return next_CreateWindowExA(dwExStyle, lpClassName, lpWindowName, windowStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
AdjustWindowRect(&rect, dwStyle, !!hMenu);
X = ((X == CW_USEDEFAULT) ? X : rect.left);
Y = ((Y == CW_USEDEFAULT) ? Y : rect.top);
nWidth = rect.right - rect.left;
nHeight = rect.bottom - rect.top;
}
return next_CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
}
static HWND WINAPI hook_CreateWindowExW(
@ -153,10 +170,27 @@ static HWND WINAPI hook_CreateWindowExW(
LPVOID lpParam
)
{
RECT rect;
dprintf("Gfx: CreateWindowExW hook hit\n");
DWORD windowStyle = 0;
if (gfx_config.windowed) {
if (gfx_config.framed)
dwStyle |= WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
else
dwStyle = WS_POPUP;
rect.left = ((X == CW_USEDEFAULT) ? 0 : X);
rect.top = ((Y == CW_USEDEFAULT) ? 0 : Y);
rect.right = rect.left + nWidth;
rect.bottom = rect.top + nHeight;
windowStyle = WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
AdjustWindowRect(&rect, dwStyle, !!hMenu);
X = ((X == CW_USEDEFAULT) ? X : rect.left);
Y = ((Y == CW_USEDEFAULT) ? Y : rect.top);
nWidth = rect.right - rect.left;
nHeight = rect.bottom - rect.top;
}
return next_CreateWindowExW(dwExStyle, lpClassName, lpWindowName, windowStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
return next_CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
}

View File

@ -2,7 +2,6 @@ gfxhook_lib = static_library(
'gfxhook',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
dxguid_lib,

View File

@ -2,7 +2,6 @@ hooklib_lib = static_library(
'hooklib',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],

View File

@ -214,6 +214,7 @@ static bool reg_hook_initted;
static CRITICAL_SECTION reg_hook_lock;
static struct reg_hook_key *reg_hook_keys;
static size_t reg_hook_nkeys;
static FARPROC n_RegOpenKeyExW;
HRESULT reg_hook_push_key(
HKEY root,
@ -229,6 +230,15 @@ HRESULT reg_hook_push_key(
assert(name != NULL);
assert(vals != NULL || nvals == 0);
/*
Some games do a funny thing where they query keys as W but open then as A, and never
import RegOpenKeyExW, meaning next_RegOpenKeyExW is null. This checks for that and, in
those cases, uses GetProcAddress.
*/
HMODULE adv = LoadLibrary("ADVAPI32.DLL");
n_RegOpenKeyExW = GetProcAddress(adv, "RegOpenKeyExW");
reg_hook_init();
/*dprintf("Pushing reg key %ls:\n", name);
@ -382,13 +392,11 @@ static LSTATUS reg_hook_open_locked(
this virtual registry key. We open a read-only handle to an arbitrary
registry key that we can reliably assume exists and isn't one of the
hardcoded root handles. HKLM\SOFTWARE will suffice for this purpose. */
err = next_RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
L"SOFTWARE",
0,
KEY_READ,
out);
if (next_RegOpenKeyExW == NULL) {
err = n_RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE", 0, KEY_READ, out);
} else {
err = next_RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE", 0, KEY_READ, out);
}
if (err == ERROR_SUCCESS) {
key->handle = *out;
@ -482,7 +490,11 @@ static LSTATUS WINAPI hook_RegOpenKeyExW(
if (*out != NULL) {
//dprintf("Registry: Opened virtual key %S\n", name);
} else {
err = next_RegOpenKeyExW(parent, name, flags, access, out);
if (next_RegOpenKeyExW == NULL) {
err = n_RegOpenKeyExW(parent, name, flags, access, out);
} else {
err = next_RegOpenKeyExW(parent, name, flags, access, out);
}
}
}
@ -899,6 +911,11 @@ static LSTATUS WINAPI hook_RegGetValueW(
key = reg_hook_match_key_locked(handle);
} else {
err = hook_RegOpenKeyExW(handle, subkey, flags, 1, &tmp);
if (err != ERROR_SUCCESS && err != ERROR_SHARING_VIOLATION) {
dprintf("Registry: hook_RegOpenKeyExW ERROR %08ld -> %ls\\%ls\n", err, subkey, name);
return err;
}
key = reg_hook_match_key_locked(tmp);
}

View File

@ -1,5 +1,5 @@
#include <windows.h>
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>

View File

@ -1,3 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>

View File

@ -1,5 +1,6 @@
#include <windows.h>
#include <stdlib.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
@ -21,11 +22,21 @@ static HRESULT felica_cmd_get_system_code(
struct const_iobuf *req,
struct iobuf *res);
static HRESULT felica_cmd_nda_a4(
static HRESULT felica_cmd_active(
struct felica *f,
struct const_iobuf *req,
struct iobuf *res);
static HRESULT felica_cmd_read_without_encryption(
struct felica *f,
struct const_iobuf *req,
struct iobuf *res);
static HRESULT felica_cmd_write_without_encryption(
struct felica* f,
struct const_iobuf* req,
struct iobuf* res);
uint64_t felica_get_generic_PMm(void)
{
/* A FeliCa PMm contains low-level protocol timing information for
@ -40,6 +51,16 @@ uint64_t felica_get_generic_PMm(void)
return 0x01168B868FBECBFFULL;
}
uint64_t felica_get_amusement_ic_PMm(void)
{
/*
* AIC Card PMm, if this is returned from the card,
* the aimelib will access the actual blocks for authentication.
*/
return 0x00F1000000014300;
}
HRESULT felica_transact(
struct felica *f,
struct const_iobuf *req,
@ -90,8 +111,8 @@ HRESULT felica_transact(
case FELICA_CMD_GET_SYSTEM_CODE:
return felica_cmd_get_system_code(f, req, res);
case FELICA_CMD_NDA_A4:
return felica_cmd_nda_a4(f, req, res);
case FELICA_CMD_ACTIVE:
return felica_cmd_active(f, req, res);
default:
dprintf("FeliCa: Unimplemented command %02x, payload:\n", code);
@ -184,7 +205,7 @@ static HRESULT felica_cmd_get_system_code(
return S_OK;
}
static HRESULT felica_cmd_nda_a4(
static HRESULT felica_cmd_active(
struct felica *f,
struct const_iobuf *req,
struct iobuf *res)
@ -194,3 +215,127 @@ static HRESULT felica_cmd_nda_a4(
return iobuf_write_8(res, 0);
}
static HRESULT felica_cmd_read_without_encryption(
struct felica *f,
struct const_iobuf *req,
struct iobuf *res)
{
HRESULT hr;
uint8_t system_code_count;
uint16_t* system_codes;
uint8_t read_block_count;
uint8_t* blocks;
size_t i;
hr = iobuf_read_8(req, &system_code_count);
if (FAILED(hr)) {
goto fail;
}
system_codes = malloc(sizeof(uint16_t) * system_code_count);
if (!system_codes) goto fail;
for (i = 0; i < system_code_count; i++) {
hr = iobuf_read_be16(req, system_codes + i);
if (FAILED(hr)) {
goto fail;
}
}
hr = iobuf_read_8(req, &read_block_count);
if (FAILED(hr)) {
goto fail;
}
blocks = malloc(read_block_count);
if (!system_codes) goto fail;
for (i = 0; i < read_block_count; i++) {
// 0x80
hr = iobuf_read_8(req, blocks + i);
if (FAILED(hr)) {
goto fail;
}
// actual block num
hr = iobuf_read_8(req, blocks + i);
if (FAILED(hr)) {
goto fail;
}
}
// status
hr = iobuf_write_be16(res, 0);
if (FAILED(hr)) {
goto fail;
}
// block count
hr = iobuf_write_8(res, read_block_count);
if (FAILED(hr)) {
goto fail;
}
// block data
for (i = 0; i < read_block_count; i++)
{
dprintf("FeliCa: Read block %x\n", blocks[i]);
switch (blocks[i]) {
case 0x82: {
hr = iobuf_write_be64(res, f->IDm);
if (FAILED(hr))
{
goto fail;
}
hr = iobuf_write_be64(res, 0x0078000000000000ull);
if (FAILED(hr))
{
goto fail;
}
}
default: {
hr = iobuf_write_be64(res, 0);
if (FAILED(hr))
{
goto fail;
}
hr = iobuf_write_be64(res, 0);
if (FAILED(hr))
{
goto fail;
}
}
}
}
hr = S_OK;
fail:
if (system_codes) free(system_codes);
if (blocks) free(blocks);
return hr;
}
static HRESULT felica_cmd_write_without_encryption(
struct felica* f,
struct const_iobuf* req,
struct iobuf* res)
{
return iobuf_write_be16(res, 0);
}

View File

@ -8,9 +8,11 @@
#include "hook/iobuf.h"
enum {
FELICA_CMD_POLL = 0x00,
FELICA_CMD_GET_SYSTEM_CODE = 0x0c,
FELICA_CMD_NDA_A4 = 0xa4,
FELICA_CMD_POLL = 0x00,
FELICA_READ_WITHOUT_ENCRYPTION = 0x06,
FELICA_WRITE_WITHOUT_ENCRYPTION = 0x08,
FELICA_CMD_GET_SYSTEM_CODE = 0x0c,
FELICA_CMD_ACTIVE = 0xa4,
};
struct felica {
@ -25,3 +27,4 @@ HRESULT felica_transact(
struct iobuf *res);
uint64_t felica_get_generic_PMm(void);
uint64_t felica_get_amusement_ic_PMm(void);

View File

@ -2,7 +2,6 @@ iccard_lib = static_library(
'iccard',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],

View File

@ -2,7 +2,6 @@ jvs_lib = static_library(
'jvs',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <stdlib.h>
#include <stddef.h>
#include "kizunahook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'kizunahook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -3,7 +3,6 @@ kizunaio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

View File

@ -13,7 +13,7 @@ add_project_arguments(
'-DWIN32_LEAN_AND_MEAN',
'-D_WIN32_WINNT=_WIN32_WINNT_WIN7',
'-DMINGW_HAS_SECURE_API=1',
'-Wno-unused',
'-Db_pch=false',
language: 'c',
)
@ -21,6 +21,7 @@ if meson.get_compiler('c').get_id() != 'msvc'
add_project_arguments(
'-ffunction-sections',
'-fdata-sections',
'-Wno-unused',
language: 'c',
)

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "mkachook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'mkachook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -1,6 +1,8 @@
#include <windows.h>
#include <xinput.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
#ifdef __GNUC__
#include <ntdef.h>

View File

@ -3,7 +3,6 @@ mkacio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

73
msvc-build.bat Normal file
View File

@ -0,0 +1,73 @@
@echo off
set BUILD_DIR=build
set BUILD_DIR_32=%BUILD_DIR%\build32
set BUILD_DIR_64=%BUILD_DIR%\build64
set BUILD_DIR_ZIP=%BUILD_DIR%\zip
set DIST_DIR=dist
set DOC_DIR=doc
REM Set Your Visual Studio install path if this one was wrong
if "%VS_INSTALLATION%"=="" set VS_INSTALLATION=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
if /I "%1"=="build" (
call :build
exit /b
)
if /I "%1"=="zip" (
powershell -NoProfile -ExecutionPolicy Bypass -Command "& './package.ps1'"
exit /b
)
echo %~nx0 [action]
echo build: Build the for both x86 and x64
echo zip: Make zip file
exit /b
:build (
REM Check VC++
set VSVARALL="%VS_INSTALLATION%\VC\Auxiliary\Build\vcvarsall.bat"
if not exist %VSVARALL% (
echo Build tools for Microsoft Visual C++ 2022 is not Installed
echo Edit this file to change the VS_INSTALLATION if you are installed the Visual Studio in other path
goto end
)
REM Check Meson
for /f "tokens=* usebackq" %%i in (`where meson`) do set MESON="%%i"
if not exist %MESON% (
echo Meson is not Installed
goto end
)
:build_x64 (
call %VSVARALL% x64
if exist %BUILD_DIR_64% (
%MESON% setup %BUILD_DIR_64% --backend vs --buildtype release --reconfigure
) else (
%MESON% setup %BUILD_DIR_64% --backend vs --buildtype release
)
pushd %BUILD_DIR_64%
msbuild /m /p:Configuration=release /p:Platform=x64 segatools.sln
popd
)
:build_x86 (
call %VSVARALL% x86
if exist %BUILD_DIR_32% (
%MESON% setup %BUILD_DIR_32% --backend vs --buildtype release --reconfigure
) else (
%MESON% setup %BUILD_DIR_32% --backend vs --buildtype release
)
pushd %BUILD_DIR_32%
msbuild /m /p:Configuration=release /p:Platform=Win32 segatools.sln
popd
)
:end (
endlocal
)
)

96
package.ps1 Normal file
View File

@ -0,0 +1,96 @@
if ($null -eq $env:BUILD_DIR) {
$BUILD_DIR="build"
$BUILD_DIR_32="$BUILD_DIR\build32"
$BUILD_DIR_64="$BUILD_DIR\build64"
$BUILD_DIR_ZIP="$BUILD_DIR\zip"
$DIST_DIR="dist"
$DOC_DIR="doc"
} else {
$BUILD_DIR = $env:BUILD_DIR;
$BUILD_DIR_32 = $env:BUILD_DIR_32;
$BUILD_DIR_64 = $env:BUILD_DIR_64;
$BUILD_DIR_ZIP = $env:BUILD_DIR_ZIP;
$DIST_DIR = $env:DIST_DIR;
$DOC_DIR = $env:DOC_DIR;
}
$target = $null;
$line = '';
[System.Collections.ArrayList]$files = @();
$folder = Get-Location
cat .\Package.mk | % {
$trimmed = $_.TrimEnd('\').
TrimStart("`t ").
Replace('$(V)', '').
Replace('$(BUILD_DIR)', $BUILD_DIR).
Replace('$(BUILD_DIR_32)', $BUILD_DIR_32).
Replace('$(BUILD_DIR_64)', $BUILD_DIR_64).
Replace('$(BUILD_DIR_ZIP)', $BUILD_DIR_ZIP).
Replace('$(DIST_DIR)', $DIST_DIR).
Replace('$(DOC_DIR)', $DOC_DIR).
Replace('$@', $target).
Replace('/', '\');
if ($trimmed.EndsWith(': ') -or $trimmed.EndsWith(':')) {
$target = $trimmed.TrimEnd(': ');
$line = '';
$files.Clear();
cd $folder;
return;
}
if (-not $trimmed.StartsWith('|')) {
$line += $trimmed;
if ($_.EndsWith('\')) {
return;
}
}
$line.Split(';') | % {
$cmd = $_.Trim(' ');
if ($cmd.StartsWith('echo')) {
echo $cmd.TrimStart('echo ')
} elseif ($cmd.StartsWith('mkdir')) {
$cmd = $cmd.Replace('-p', '-Force')
echo " - $cmd"
Invoke-Expression $cmd | Out-Null
} elseif ($cmd.StartsWith('cp')) {
$tokens = $cmd.Replace('cp ', '').Split(' ');
$srcs = $tokens[0..($tokens.Count - 2)];
$dest = $tokens[$tokens.Count - 1];
echo " - cp -Path $srcs -Destination $dest";
cp -Path $srcs -Destination $dest
} elseif ($cmd.StartsWith('cd')) {
echo " - $cmd"
Invoke-Expression $cmd | Out-Null
} elseif ($cmd.StartsWith('zip ')) {
$tokens = $cmd.Substring(4, $cmd.Length - 4).Replace('-r ', '').Replace('-j ', '').Replace('*', '.\*');
$tokens = $tokens.Split(' ');
$target = $tokens[0]
if (-not $tokens.Contains('$^')) {
$files.AddRange($tokens[1..($tokens.Count - 1)]);
}
echo " - Compress-Archive -Path $files -DestinationPath $target -Force"
Compress-Archive -Path $files -DestinationPath $target -Force
} else {
$allExists = $true
$args = $cmd.Split(' ');
$args | ? { -not $_ -eq '' } | % {
if (-not (Test-Path $_)) {
$allExists = $false
}
}
if ($allExists) {
$files.AddRange($args);
}
}
}
$line = '';
}

179
platform/amactivator.c Normal file
View File

@ -0,0 +1,179 @@
#include "platform/amactivator.h"
#include "platform/es3sec.h"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "hook/table.h"
#include "util/dprintf.h"
HANDLE amactivator_handle;
static HANDLE my_AMActivator_Create();
static uint64_t my_AMActivator_SetUSBSerialID(HANDLE amactivator, char* serial);
static uint64_t my_AMActivator_SetUSBProductID(HANDLE amactivator, char* product_id);
static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id);
static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password);
/*static uint64_t my_AMActivator_SetDevelopmentMode();
static uint64_t my_AMActivator_BitLockerUnlock();
static uint64_t my_AMActivator_RequestSignature();
static uint64_t my_AMActivator_Update();
static uint64_t my_AMActivator_IsBusy();
static uint64_t my_AMActivator_RequestOneTimeKey();
static uint64_t my_AMActivator_Restore();
static uint64_t my_AMActivator_GetSignatureGeneration();
static uint64_t my_AMActivator_GetSignatureLastStatus();
static uint64_t my_AMActivator_GetOneTimeKey();
static uint64_t my_AMActivator_GetOneTimeKeyExpiration();
static uint64_t my_AMActivator_GetOneTimeKeyLastStatus();*/
static HANDLE (*next_AMActivator_Create)();
static uint64_t (*next_AMActivator_SetUSBSerialID)(HANDLE amactivator, char* serial);
static uint64_t (*next_AMActivator_SetUSBProductID)(HANDLE amactivator, char* product_id);
static uint64_t (*next_AMActivator_SetUSBVendorID)(HANDLE amactivator, char* vendor_id);
static uint64_t (*next_AMActivator_SetUSBBitLockerPassword)(HANDLE amactivator, char* password);
/*static uint64_t (*next_AMActivator_SetDevelopmentMode)();
static uint64_t (*next_AMActivator_BitLockerUnlock)();
static uint64_t (*next_AMActivator_RequestSignature)();
static uint64_t (*next_AMActivator_Update)();
static uint64_t (*next_AMActivator_IsBusy)();
static uint64_t (*next_AMActivator_RequestOneTimeKey)();
static uint64_t (*next_AMActivator_Restore)();
static uint64_t (*next_AMActivator_GetSignatureGeneration)();
static uint64_t (*next_AMActivator_GetSignatureLastStatus)();
static uint64_t (*next_AMActivator_GetOneTimeKey)();
static uint64_t (*next_AMActivator_GetOneTimeKeyExpiration)();
static uint64_t (*next_AMActivator_GetOneTimeKeyLastStatus)();*/
static const struct hook_symbol activator_syms[] = {
{
.name = "AMActivator_Create",
.patch = my_AMActivator_Create,
.link = (void **) &next_AMActivator_Create,
},
{
.name = "AMActivator_SetUSBSerialID",
.patch = my_AMActivator_SetUSBSerialID,
.link = (void **) &next_AMActivator_SetUSBSerialID,
},
{
.name = "AMActivator_SetUSBProductID",
.patch = my_AMActivator_SetUSBProductID,
.link = (void **) &next_AMActivator_SetUSBProductID,
},
{
.name = "AMActivator_SetUSBVendorID",
.patch = my_AMActivator_SetUSBVendorID,
.link = (void **) &next_AMActivator_SetUSBVendorID,
},
{
.name = "AMActivator_SetUSBBitLockerPassword",
.patch = my_AMActivator_SetUSBBitLockerPassword,
.link = (void **) &next_AMActivator_SetUSBBitLockerPassword,
}/*,
{
.name = "AMActivator_SetDevelopmentMode",
.patch = my_AMActivator_SetDevelopmentMode,
.link = (void **) &next_AMActivator_SetDevelopmentMode,
},
{
.name = "AMActivator_BitLockerUnlock",
.patch = my_AMActivator_BitLockerUnlock,
.link = (void **) &next_AMActivator_BitLockerUnlock,
},
{
.name = "AMActivator_RequestSignature",
.patch = my_AMActivator_RequestSignature,
.link = (void **) &next_AMActivator_RequestSignature,
},
{
.name = "AMActivator_Update",
.patch = my_AMActivator_Update,
.link = (void **) &next_AMActivator_Update,
},
{
.name = "AMActivator_IsBusy",
.patch = my_AMActivator_IsBusy,
.link = (void **) &next_AMActivator_IsBusy,
},
{
.name = "AMActivator_RequestOneTimeKey",
.patch = my_AMActivator_RequestOneTimeKey,
.link = (void **) &next_AMActivator_RequestOneTimeKey,
},
{
.name = "AMActivator_Restore",
.patch = my_AMActivator_Restore,
.link = (void **) &next_AMActivator_Restore,
},
{
.name = "AMActivator_GetSignatureGeneration",
.patch = my_AMActivator_GetSignatureGeneration,
.link = (void **) &next_AMActivator_GetSignatureGeneration,
},
{
.name = "AMActivator_GetSignatureLastStatus",
.patch = my_AMActivator_GetSignatureLastStatus,
.link = (void **) &next_AMActivator_GetSignatureLastStatus,
},
{
.name = "AMActivator_GetOneTimeKey",
.patch = my_AMActivator_GetOneTimeKey,
.link = (void **) &next_AMActivator_GetOneTimeKey,
},
{
.name = "AMActivator_GetOneTimeKeyExpiration",
.patch = my_AMActivator_GetOneTimeKeyExpiration,
.link = (void **) &next_AMActivator_GetOneTimeKeyExpiration,
},
{
.name = "AMActivator_GetOneTimeKeyLastStatus",
.patch = my_AMActivator_GetOneTimeKeyLastStatus,
.link = (void **) &next_AMActivator_GetOneTimeKeyLastStatus,
}*/
};
HRESULT amactivator_hook_init(const struct amactivator_config* cfg, const struct es3sec_config* dong_cfg) {
if (!cfg->enable) {
return S_OK;
}
dprintf("AMActivator: init\n");
hook_table_apply(
NULL,
"amactivator.dll",
activator_syms,
_countof(activator_syms));
return S_OK;
}
static HANDLE my_AMActivator_Create() {
dprintf("AMActivator: Create\n");
amactivator_handle = next_AMActivator_Create();
return amactivator_handle;
}
static uint64_t my_AMActivator_SetUSBSerialID(HANDLE amactivator, char* serial) {
dprintf("AMActivator: SetUSBSerialID %s\n", serial);
//return next_AMActivator_SetUSBSerialID(amactivator, serial);
return 0;
}
static uint64_t my_AMActivator_SetUSBProductID(HANDLE amactivator, char* product_id) {
dprintf("AMActivator: SetUSBProductID %s\n", product_id);
return next_AMActivator_SetUSBProductID(amactivator, product_id);
}
static uint64_t my_AMActivator_SetUSBVendorID(HANDLE amactivator, char* vendor_id) {
dprintf("AMActivator: SetUSBVendorID %s\n", vendor_id);
return next_AMActivator_SetUSBVendorID(amactivator, vendor_id);
}
static uint64_t my_AMActivator_SetUSBBitLockerPassword(HANDLE amactivator, char* password) {
dprintf("AMActivator: SetUSBBitLockerPassword %s\n", password);
return next_AMActivator_SetUSBBitLockerPassword(amactivator, password);
}

12
platform/amactivator.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <windows.h>
#include <stdint.h>
#include <stdbool.h>
#include "platform/es3sec.h"
struct amactivator_config {
bool enable;
};
HRESULT amactivator_hook_init(const struct amactivator_config* cfg, const struct es3sec_config* dong_cfg);

View File

@ -1,5 +1,5 @@
#include <windows.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>

View File

@ -33,6 +33,7 @@ void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
misc_config_load(&cfg->misc, filename);
es3sec_config_load(&cfg->dongle, filename);
epay_config_load(&cfg->epay, filename);
amactivator_config_load(&cfg->amactivator, filename);
}
void vfs_config_load(struct vfs_config *cfg, const wchar_t *filename)
@ -251,3 +252,8 @@ void epay_config_load(struct epay_config *cfg, const wchar_t *filename)
{
cfg->enable = GetPrivateProfileIntW(L"dongle", L"enable", 1, filename);
}
void amactivator_config_load(struct amactivator_config *cfg, const wchar_t *filename)
{
cfg->enable = GetPrivateProfileIntW(L"amactivator", L"enable", 1, filename);
}

View File

@ -1,12 +1,13 @@
#pragma once
#include <windows.h>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "platform/vfs.h"
#include "platform/amactivator.h"
#include "platform/netenv.h"
#include "platform/locale.h"
#include "platform/clock.h"
@ -37,3 +38,5 @@ void misc_config_load(struct misc_config *cfg, const wchar_t *filename);
void es3sec_config_load(struct es3sec_config *cfg, const wchar_t *filename);
void epay_config_load(struct epay_config *cfg, const wchar_t *filename);
void amactivator_config_load(struct amactivator_config *cfg, const wchar_t *filename);

View File

@ -1,6 +1,9 @@
#include <windows.h>
#include <stdlib.h>
#include <assert.h>
#include <cfgmgr32.h>
#include <usbioctl.h>
#include <objbase.h>
#include "hook/table.h"
#include "hook/iohook.h"

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <stdlib.h>
#include "hook/table.h"

View File

@ -2,7 +2,6 @@ platform_lib = static_library(
'platform',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
shlwapi_lib,
@ -35,5 +34,7 @@ platform_lib = static_library(
'vfs.h',
'es3sec.c',
'es3sec.h',
'amactivator.c',
'amactivator.h',
],
)

View File

@ -1,8 +1,9 @@
#include <windows.h>
#include <stdlib.h>
#include <winuser.h>
#include <assert.h>
#include <stdint.h>
#include <winerror.h>
#include "hook/table.h"
#include "hooklib/reg.h"
@ -22,6 +23,9 @@ static int my_snprintf(char *const buffer, const size_t buffer_count, const char
static int (*next_snprintf)(char *const buffer, const size_t buffer_count, const char *const format, ...);
static HRESULT reg_read_sys_ver(void *bytes, uint32_t *nbytes);
static HRESULT reg_read_display_ver(void *bytes, uint32_t *nbytes);
static HRESULT reg_read_product_name(void *bytes, uint32_t *nbytes);
static HRESULT reg_read_release_id(void *bytes, uint32_t *nbytes);
static BOOL (WINAPI *next_BlockInput)(BOOL fBlockIt);
static int (WINAPI *next_ShowCursor)(BOOL bShow);
@ -71,6 +75,24 @@ static const struct reg_hook_val nbgi_reg[] = {
}
};
static const struct reg_hook_val winver_reg[] = {
{
.name = L"DisplayVersion",
.type = REG_SZ,
.read = reg_read_display_ver
},
{
.name = L"ProductName",
.type = REG_SZ,
.read = reg_read_product_name
},
{
.name = L"ReleaseId",
.type = REG_SZ,
.read = reg_read_release_id
}
};
HRESULT misc_hook_init(const struct misc_config *cfg)
{
assert(cfg != NULL);
@ -102,6 +124,12 @@ HRESULT misc_hook_init(const struct misc_config *cfg)
L"SOFTWARE\\NBGI",
nbgi_reg,
_countof(nbgi_reg));
reg_hook_push_key(
HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
winver_reg,
_countof(winver_reg));
return S_OK;
}
@ -159,6 +187,24 @@ static HRESULT reg_read_sys_ver(void *bytes, uint32_t *nbytes)
return reg_hook_read_wstr(bytes, nbytes, config.system_version);
}
static HRESULT reg_read_display_ver(void *bytes, uint32_t *nbytes)
{
dprintf("Misc: Get display version\n");
return reg_hook_read_wstr(bytes, nbytes, L"22H2");
}
static HRESULT reg_read_product_name(void *bytes, uint32_t *nbytes)
{
dprintf("Misc: Get system version\n");
return reg_hook_read_wstr(bytes, nbytes, L"Windows 10 Enterprise 2016 LTSB");
}
static HRESULT reg_read_release_id(void *bytes, uint32_t *nbytes)
{
dprintf("Misc: Get release ID\n");
return reg_hook_read_wstr(bytes, nbytes, L"1607");
}
static UINT WINAPI my_GetDriveTypeA(LPCSTR lpRootPathName)
{
dprintf("Misc: Get Drive Type for %s\n", lpRootPathName);

View File

@ -1,14 +1,17 @@
#include <winsock2.h>
#include <windows.h>
#include <wincrypt.h>
#include <iphlpapi.h>
#include <winsock.h>
#include <winsock2.h>
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <icmpapi.h>
#include "hook/table.h"
@ -68,7 +71,7 @@ static uint32_t WINAPI hook_IcmpSendEcho(
static uint32_t WINAPI hook_IcmpSendEcho2(
HANDLE IcmpHandle,
HANDLE Event,
PIO_APC_ROUTINE ApcRoutine,
FARPROC ApcRoutine,
void *ApcContext,
uint32_t DestinationAddress,
void *RequestData,
@ -106,7 +109,7 @@ static uint32_t (WINAPI *next_GetIfTable)(
static uint32_t (WINAPI *next_IcmpSendEcho2)(
HANDLE IcmpHandle,
HANDLE Event,
PIO_APC_ROUTINE ApcRoutine,
FARPROC ApcRoutine,
void *ApcContext,
uint32_t DestinationAddress,
void *RequestData,
@ -465,7 +468,7 @@ static uint32_t WINAPI hook_GetIfTable(
static uint32_t WINAPI hook_IcmpSendEcho2(
HANDLE IcmpHandle,
HANDLE Event,
PIO_APC_ROUTINE ApcRoutine,
FARPROC ApcRoutine,
void *ApcContext,
uint32_t DestinationAddress,
void *RequestData,

View File

@ -1,3 +1,5 @@
#include <assert.h>
#include "platform/platform.h"
HRESULT platform_hook_init(
@ -69,5 +71,11 @@ HRESULT platform_hook_init(
return hr;
}
hr = amactivator_hook_init(&cfg->amactivator, &cfg->dongle);
if (FAILED(hr)) {
return hr;
}
return S_OK;
}

View File

@ -9,6 +9,7 @@
#include "platform/vfs.h"
#include "platform/es3sec.h"
#include "platform/epay.h"
#include "platform/amactivator.h"
struct dongle_info {
USHORT pid;
@ -27,6 +28,7 @@ struct platform_config {
struct vfs_config vfs;
struct es3sec_config dongle;
struct epay_config epay;
struct amactivator_config amactivator;
};
enum platform_type {

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "saohook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'saohook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <stdlib.h>
#include "hook/table.h"
#include "hooklib/reg.h"

View File

@ -1,4 +1,6 @@
#include <windows.h>
#include <winuser.h>
#include <stdlib.h>
#include "hook/table.h"
#include "hooklib/reg.h"

View File

@ -3,7 +3,6 @@ saoio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

View File

@ -1,4 +1,4 @@
[wrap-git]
directory = capnhook
url = https://github.com/Hay1tsme/capnhook
revision = f060250e1b92dcb06946eb77742f0ab51755e158
revision = b595e4bf8a274ba3bdaf583e13a7ebc7efe0f48f

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "taikohook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'taikohook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <stdlib.h>
#include "taikohook/network.h"

View File

@ -3,7 +3,6 @@ taikoio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
xinput_lib,
],

View File

@ -1,5 +1,6 @@
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include "tekkenhook/config.h"

View File

@ -4,7 +4,6 @@ shared_library(
include_directories : inc,
implicit_include_directories : false,
vs_module_defs : 'tekkenhook.def',
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
capnhook.get_variable('hooklib_dep'),

View File

@ -3,7 +3,6 @@ tekkenio_lib = static_library(
name_prefix : '',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
sources : [
'tekkenio.c',
'tekkenio.h',

View File

@ -1,4 +1,5 @@
#include <windows.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "util/hexstr.h"

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <stdbool.h>
#include <stdlib.h>
wchar_t *module_file_name(HMODULE module)
{

View File

@ -2,7 +2,6 @@ util_lib = static_library(
'util',
include_directories : inc,
implicit_include_directories : false,
c_pch : '../precompiled.h',
dependencies : [
capnhook.get_variable('hook_dep'),
],