forked from Hay1tsme/segatools
Compare commits
1 Commits
2024-02-27
...
2024-02-22
Author | SHA1 | Date | |
---|---|---|---|
d118ef614c
|
@ -1,6 +1,6 @@
|
||||
# Segatools
|
||||
|
||||
Version: `2024-02-27`
|
||||
Version: `2024-02-22`
|
||||
|
||||
Loaders and hardware emulators for SEGA games that run on the Nu and ALLS platforms.
|
||||
|
||||
|
16
dist/fgo/segatools.ini
vendored
16
dist/fgo/segatools.ini
vendored
@ -129,12 +129,12 @@ path=
|
||||
|
||||
[io4]
|
||||
; Input API selection for JVS input emulator.
|
||||
; Test button virtual-key code. Default is the F1 key.
|
||||
test=0x70
|
||||
; Service button virtual-key code. Default is the F2 key.
|
||||
service=0x71
|
||||
; Keyboard button to increment coin counter. Default is the F3 key.
|
||||
coin=0x72
|
||||
; Test button virtual-key code. Default is the 1 key.
|
||||
test=0x31
|
||||
; Service button virtual-key code. Default is the 2 key.
|
||||
service=0x32
|
||||
; Keyboard button to increment coin counter. Default is the 3 key.
|
||||
coin=0x33
|
||||
|
||||
; .·:'''''''''''''''''''''''''''''''''''''''''''''':·.
|
||||
; : : ______ / \ [] : :
|
||||
@ -151,8 +151,8 @@ coin=0x72
|
||||
;
|
||||
; Only XInput is currently supported.
|
||||
|
||||
; XInput bindings
|
||||
;
|
||||
; Controller Button
|
||||
; -------------------------------------------------------
|
||||
; Left Stick Joystick
|
||||
; Left Stick Click Reset Camera
|
||||
; Left Trigger Dash
|
||||
|
2
dist/swdc/segatools.ini
vendored
2
dist/swdc/segatools.ini
vendored
@ -63,7 +63,7 @@ enable=1
|
||||
; Enable freeplay mode. This will disable the coin slot and set the game to
|
||||
; freeplay. Keep in mind that some game modes (e.g. Freedom/Time Modes) will not
|
||||
; allow you to start a game in freeplay mode.
|
||||
freeplay=0
|
||||
freeplay=0´
|
||||
|
||||
; -----------------------------------------------------------------------------
|
||||
; Custom IO settings
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <windows.h>
|
||||
#include <windns.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <winhttp.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
@ -66,12 +65,6 @@ static int WSAAPI hook_getaddrinfo(
|
||||
const char *pServiceName,
|
||||
const ADDRINFOA *pHints,
|
||||
ADDRINFOA **ppResult);
|
||||
|
||||
static HINTERNET WINAPI hook_WinHttpConnect(
|
||||
HINTERNET hSession,
|
||||
const wchar_t *pwszServerName,
|
||||
INTERNET_PORT nServerPort,
|
||||
DWORD dwReserved);
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
@ -102,12 +95,6 @@ static int (WSAAPI *next_getaddrinfo)(
|
||||
const ADDRINFOA *pHints,
|
||||
ADDRINFOA **ppResult);
|
||||
|
||||
static HINTERNET (WINAPI *next_WinHttpConnect)(
|
||||
HINTERNET hSession,
|
||||
const wchar_t *pwszServerName,
|
||||
INTERNET_PORT nServerPort,
|
||||
DWORD dwReserved);
|
||||
|
||||
static const struct hook_symbol dns_hook_syms_dnsapi[] = {
|
||||
{
|
||||
.name = "DnsQuery_A",
|
||||
@ -133,14 +120,6 @@ static const struct hook_symbol dns_hook_syms_ws2[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static const struct hook_symbol dns_hook_syms_winhttp[] = {
|
||||
{
|
||||
.name = "WinHttpConnect",
|
||||
.patch = hook_WinHttpConnect,
|
||||
.link = (void **) &next_WinHttpConnect,
|
||||
}
|
||||
};
|
||||
|
||||
static bool dns_hook_initted;
|
||||
static CRITICAL_SECTION dns_hook_lock;
|
||||
static struct dns_hook_entry *dns_hook_entries;
|
||||
@ -166,12 +145,6 @@ static void dns_hook_init(void)
|
||||
"ws2_32.dll",
|
||||
dns_hook_syms_ws2,
|
||||
_countof(dns_hook_syms_ws2));
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"winhttp.dll",
|
||||
dns_hook_syms_winhttp,
|
||||
_countof(dns_hook_syms_winhttp));
|
||||
}
|
||||
|
||||
HRESULT dns_hook_push(const wchar_t *from_src, const wchar_t *to_src)
|
||||
@ -487,38 +460,3 @@ end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static HINTERNET WINAPI hook_WinHttpConnect(
|
||||
HINTERNET hSession,
|
||||
const wchar_t *pwszServerName,
|
||||
INTERNET_PORT nServerPort,
|
||||
DWORD dwReserved)
|
||||
{
|
||||
const struct dns_hook_entry *pos;
|
||||
size_t i;
|
||||
|
||||
if (pwszServerName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&dns_hook_lock);
|
||||
|
||||
for (i = 0 ; i < dns_hook_nentries ; i++) {
|
||||
pos = &dns_hook_entries[i];
|
||||
|
||||
if (_wcsicmp(pwszServerName, pos->from) == 0) {
|
||||
if(pos->to == NULL) {
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pwszServerName = pos->to;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dns_hook_lock);
|
||||
|
||||
return next_WinHttpConnect(hSession, pwszServerName, nServerPort, dwReserved);
|
||||
}
|
||||
|
305
hooklib/path.c
305
hooklib/path.c
@ -101,40 +101,6 @@ static BOOL WINAPI hook_PathFileExistsA(LPCSTR pszPath);
|
||||
|
||||
static BOOL WINAPI hook_PathFileExistsW(LPCWSTR pszPath);
|
||||
|
||||
static BOOL WINAPI hook_MoveFileA(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName);
|
||||
|
||||
static BOOL WINAPI hook_MoveFileW(
|
||||
const wchar_t *lpExistingFileName,
|
||||
const wchar_t *lpNewFileName);
|
||||
|
||||
static BOOL WINAPI hook_MoveFileExA(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName,
|
||||
uint32_t dwFlags);
|
||||
|
||||
|
||||
static BOOL WINAPI hook_ReplaceFileA(
|
||||
const char *lpReplacedFileName,
|
||||
const char *lpReplacementFileName,
|
||||
const char *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved);
|
||||
|
||||
static BOOL WINAPI hook_ReplaceFileW(
|
||||
const wchar_t *lpReplacedFileName,
|
||||
const wchar_t *lpReplacementFileName,
|
||||
const wchar_t *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved);
|
||||
|
||||
static BOOL WINAPI hook_DeleteFileA(const char *lpFileName);
|
||||
|
||||
static BOOL WINAPI hook_DeleteFileW(const wchar_t *lpFileName);
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static BOOL (WINAPI *next_CreateDirectoryA)(
|
||||
@ -219,39 +185,6 @@ static BOOL (WINAPI *next_PathFileExistsA)(LPCSTR pszPath);
|
||||
|
||||
static BOOL (WINAPI *next_PathFileExistsW)(LPCWSTR pszPath);
|
||||
|
||||
static BOOL (WINAPI *next_MoveFileA)(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName);
|
||||
|
||||
static BOOL (WINAPI *next_MoveFileW)(
|
||||
const wchar_t *lpExistingFileName,
|
||||
const wchar_t *lpNewFileName);
|
||||
|
||||
static BOOL (WINAPI *next_MoveFileExA)(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName,
|
||||
uint32_t dwFlags);
|
||||
|
||||
static BOOL (WINAPI *next_ReplaceFileA)(
|
||||
const char *lpReplacedFileName,
|
||||
const char *lpReplacementFileName,
|
||||
const char *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved);
|
||||
|
||||
static BOOL (WINAPI *next_ReplaceFileW)(
|
||||
const wchar_t *lpReplacedFileName,
|
||||
const wchar_t *lpReplacementFileName,
|
||||
const wchar_t *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved);
|
||||
|
||||
static BOOL (WINAPI *next_DeleteFileA)(const char *lpFileName);
|
||||
|
||||
static BOOL (WINAPI *next_DeleteFileW)(const wchar_t *lpFileName);
|
||||
|
||||
/* Hook table */
|
||||
|
||||
static const struct hook_symbol path_hook_syms[] = {
|
||||
@ -327,34 +260,6 @@ static const struct hook_symbol path_hook_syms[] = {
|
||||
.name = "PathFileExistsW",
|
||||
.patch = hook_PathFileExistsW,
|
||||
.link = (void **) &next_PathFileExistsW,
|
||||
}, {
|
||||
.name = "MoveFileA",
|
||||
.patch = hook_MoveFileA,
|
||||
.link = (void **) &next_MoveFileA,
|
||||
}, {
|
||||
.name = "MoveFileW",
|
||||
.patch = hook_MoveFileW,
|
||||
.link = (void **) &next_MoveFileW,
|
||||
}, {
|
||||
.name = "MoveFileExA",
|
||||
.patch = hook_MoveFileExA,
|
||||
.link = (void **) &next_MoveFileExA,
|
||||
}, {
|
||||
.name = "ReplaceFileA",
|
||||
.patch = hook_ReplaceFileA,
|
||||
.link = (void **) &next_ReplaceFileA,
|
||||
}, {
|
||||
.name = "ReplaceFileW",
|
||||
.patch = hook_ReplaceFileW,
|
||||
.link = (void **) &next_ReplaceFileW,
|
||||
}, {
|
||||
.name = "DeleteFileA",
|
||||
.patch = hook_DeleteFileA,
|
||||
.link = (void **) &next_DeleteFileA,
|
||||
}, {
|
||||
.name = "DeleteFileW",
|
||||
.patch = hook_DeleteFileW,
|
||||
.link = (void **) &next_DeleteFileW,
|
||||
}
|
||||
};
|
||||
|
||||
@ -1001,213 +906,3 @@ static BOOL WINAPI hook_PathFileExistsW(LPCWSTR pszPath)
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_MoveFileA(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName)
|
||||
{
|
||||
char *oldTrans;
|
||||
char *newTrans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&oldTrans, lpExistingFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = path_transform_a(&newTrans, lpNewFileName);
|
||||
|
||||
if (!ok) {
|
||||
free(oldTrans);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_MoveFileA(
|
||||
oldTrans ? oldTrans : lpExistingFileName,
|
||||
newTrans ? newTrans : lpNewFileName);
|
||||
|
||||
free(oldTrans);
|
||||
free(newTrans);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_MoveFileW(
|
||||
const wchar_t *lpExistingFileName,
|
||||
const wchar_t *lpNewFileName)
|
||||
{
|
||||
wchar_t *oldTrans;
|
||||
wchar_t *newTrans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_w(&oldTrans, lpExistingFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = path_transform_w(&newTrans, lpNewFileName);
|
||||
|
||||
if (!ok) {
|
||||
free(oldTrans);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_MoveFileW(
|
||||
oldTrans ? oldTrans : lpExistingFileName,
|
||||
newTrans ? newTrans : lpNewFileName);
|
||||
|
||||
free(oldTrans);
|
||||
free(newTrans);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_MoveFileExA(
|
||||
const char *lpExistingFileName,
|
||||
const char *lpNewFileName,
|
||||
uint32_t dwFlags)
|
||||
{
|
||||
char *oldTrans;
|
||||
char *newTrans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&oldTrans, lpExistingFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = path_transform_a(&newTrans, lpNewFileName);
|
||||
|
||||
if (!ok) {
|
||||
free(oldTrans);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_MoveFileExA(
|
||||
oldTrans ? oldTrans : lpExistingFileName,
|
||||
newTrans ? newTrans : lpNewFileName,
|
||||
dwFlags);
|
||||
|
||||
free(oldTrans);
|
||||
free(newTrans);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_ReplaceFileA(
|
||||
const char *lpReplacedFileName,
|
||||
const char *lpReplacementFileName,
|
||||
const char *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved)
|
||||
{
|
||||
char *oldTrans;
|
||||
char *newTrans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&oldTrans, lpReplacedFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = path_transform_a(&newTrans, lpReplacementFileName);
|
||||
|
||||
if (!ok) {
|
||||
free(oldTrans);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_ReplaceFileA(
|
||||
oldTrans ? oldTrans : lpReplacedFileName,
|
||||
newTrans ? newTrans : lpReplacementFileName,
|
||||
lpBackupFileName,
|
||||
dwReplaceFlags,
|
||||
lpExclude,
|
||||
lpReserved);
|
||||
|
||||
free(oldTrans);
|
||||
free(newTrans);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_ReplaceFileW(
|
||||
const wchar_t *lpReplacedFileName,
|
||||
const wchar_t *lpReplacementFileName,
|
||||
const wchar_t *lpBackupFileName,
|
||||
uint32_t dwReplaceFlags,
|
||||
void *lpExclude,
|
||||
void *lpReserved)
|
||||
{
|
||||
wchar_t *oldTrans;
|
||||
wchar_t *newTrans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_w(&oldTrans, lpReplacedFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = path_transform_w(&newTrans, lpReplacementFileName);
|
||||
|
||||
if (!ok) {
|
||||
free(oldTrans);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_ReplaceFileW(
|
||||
oldTrans ? oldTrans : lpReplacedFileName,
|
||||
newTrans ? newTrans : lpReplacementFileName,
|
||||
lpBackupFileName,
|
||||
dwReplaceFlags,
|
||||
lpExclude,
|
||||
lpReserved);
|
||||
|
||||
free(oldTrans);
|
||||
free(newTrans);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_DeleteFileA(const char *lpFileName)
|
||||
{
|
||||
char *trans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_a(&trans, lpFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_DeleteFileA(trans ? trans: lpFileName);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static BOOL WINAPI hook_DeleteFileW(const wchar_t *lpFileName)
|
||||
{
|
||||
wchar_t *trans;
|
||||
BOOL ok;
|
||||
|
||||
ok = path_transform_w(&trans, lpFileName);
|
||||
|
||||
if (!ok) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ok = next_DeleteFileW(trans ? trans: lpFileName);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -82,26 +82,6 @@ HRESULT dns_platform_hook_init(const struct dns_config *cfg)
|
||||
return hr;
|
||||
}
|
||||
|
||||
// AimePay
|
||||
hr = dns_hook_push(L"api-aime.am-all.net", cfg->startup);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
// E-MONEY
|
||||
hr = dns_hook_push(L"tasms-api-basis.thincacloud.com", cfg->startup);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = dns_hook_push(L"shop.tfps.thincacloud.com", cfg->startup);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
// if your ISP resolves bad domains, it will kill the network. These 2
|
||||
// *cannot* resolve
|
||||
|
||||
|
@ -277,12 +277,11 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
||||
const wchar_t *redir;
|
||||
size_t required;
|
||||
size_t redir_len;
|
||||
size_t src_len;
|
||||
|
||||
assert(src != NULL);
|
||||
assert(count != NULL);
|
||||
|
||||
if (src[0] == L'\0' || src[1] != L':') {
|
||||
if (src[0] == L'\0' || src[1] != L':' || !path_is_separator_w(src[2])) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@ -305,15 +304,10 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
/* GetFileAttributesW would request the src "E:", so fix the src_len in
|
||||
in order to redirect the drive letter successfully */
|
||||
|
||||
src_len = path_is_separator_w(src[2]) ? 3 : 2;
|
||||
|
||||
/* Cut off <prefix>\, replace with redir path, count NUL terminator */
|
||||
|
||||
redir_len = wcslen(redir);
|
||||
required = wcslen(src) - src_len + redir_len + 1;
|
||||
required = wcslen(src) - 3 + redir_len + 1;
|
||||
|
||||
if (dest != NULL) {
|
||||
if (required > *count) {
|
||||
@ -321,7 +315,7 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
||||
}
|
||||
|
||||
wcscpy_s(dest, *count, redir);
|
||||
wcscpy_s(dest + redir_len, *count - redir_len, src + src_len);
|
||||
wcscpy_s(dest + redir_len, *count - redir_len, src + 3);
|
||||
}
|
||||
|
||||
*count = required;
|
||||
|
Reference in New Issue
Block a user