1
0
mirror of synced 2024-11-11 22:07:09 +01:00

Dongle emulated for Konami and some more libio apis.

Seems to be missing some libavs stuff now, need to debug futher :(
This commit is contained in:
Reaver 2018-09-13 22:11:35 +03:00
parent fc07d4e623
commit 4c9d55350f
2 changed files with 123 additions and 22 deletions

View File

@ -279,9 +279,8 @@ char __cdecl ac_io_get_node_no(int a1)
DWORD *__cdecl ac_io_get_rs232c_status(DWORD *a1) // JGT
{
// TODO
// UNK RET
return 0;
memset(a1, 0, 0x54);
return a1;
}
DWORD coinDw = 0;
@ -321,9 +320,9 @@ char __cdecl ac_io_hbhi_current_coinstock(signed int a1, DWORD *a2) // JGT
int __cdecl ac_io_hbhi_get_control_status_buffer(int a1) // JGT
{
// TODO
// TODO UNK RET
return 1;
// Apparently a1 is button bits ?
a1 = 0;
return 0;
}
int __cdecl ac_io_hbhi_get_softwareid(DWORD *a1) // JGT
@ -438,10 +437,10 @@ bool __cdecl ac_io_icca_get_keep_alive_error(int a1, DWORD *a2)
return 0;
}
char __cdecl ac_io_icca_get_status(int a1, int a2) // JGT
char __cdecl ac_io_icca_get_status(int a1, DWORD *a2) // JGT
{
// TODO
// TODO UNK RET
// ALSO FE ?
*a2 = 0x0000000A;
return 1;
}
@ -468,6 +467,11 @@ bool __cdecl ac_io_icca_req_uid_isfinished(int a1, DWORD *a2) // JGT
int __cdecl ac_io_icca_workflow(int a1, int a2) // JGT
{
// This requires some smarts, not sure if required for JGT
if(a1 == 0 && a1 == 1)
{
return 0;
}
// TODO
// TODO UNK RET
return 1;
@ -504,12 +508,12 @@ int __cdecl ac_io_set_get_status_device(int a1)
return a1;
}
const char *ac_io_version()
{
// TODO
// TODO UNK RET
return "1337";
}
//const char *ac_io_version()
//{
// // TODO
// // TODO UNK RET
// return "1337";
//}
int init_libacioHooks()
{
@ -602,7 +606,7 @@ int init_libacioHooks()
injector::MakeJMP(GetProcAddress(GetModuleHandleA("libacio.dll"), "ac_io_is_active_device"), ac_io_is_active_device);
injector::MakeJMP(GetProcAddress(GetModuleHandleA("libacio.dll"), "ac_io_reset"), ac_io_reset);
injector::MakeJMP(GetProcAddress(GetModuleHandleA("libacio.dll"), "ac_io_set_get_status_device"), ac_io_set_get_status_device);
injector::MakeJMP(GetProcAddress(GetModuleHandleA("libacio.dll"), "ac_io_version"), ac_io_version);
//injector::MakeJMP(GetProcAddress(GetModuleHandleA("libacio.dll"), "ac_io_version"), ac_io_version);
return 1;
}

View File

@ -1,12 +1,109 @@
#include <Windows.h>
#include "libavs-win32.h"
#include "libacio.h"
#include <MinHook.h>
typedef signed(__stdcall *dll_entry_main)();
typedef signed(__stdcall *dll_entry_init)();
#include <stdio.h>
#include <iostream>
int __cdecl bt_get_ikey_status(unsigned char *a1)
{
memset(a1, 0, 28);
a1[4] = 1;
a1[6] = 1;
a1[12] = -1;
a1[20] = 1;
a1[22] = 1;
a1[28] = -1;
return 0;
}
int bt_fcheck_main()
{
return 0;
}
void bt_fcheck_init()
{
// Do nothing
}
void bt_fcheck_finish()
{
// Do nothing
}
HMODULE (WINAPI *OrigGetModuleHandleA)(
_In_opt_ LPCTSTR lpModuleName
);
HMODULE WINAPI GetModuleHandleAWrap(
_In_opt_ LPCTSTR lpModuleName
)
{
if ((DWORD)lpModuleName == 0x00)
{
return OrigGetModuleHandleA(lpModuleName);
}
if(strlen(lpModuleName) != 7)
{
return OrigGetModuleHandleA(lpModuleName);
}
if(strcmp(lpModuleName, "kbt.dll") == 0)
{
return (HMODULE)0x8001;
}
if(strcmp(lpModuleName, "kld.dll") == 0)
{
return (HMODULE)0x8002;
}
return OrigGetModuleHandleA(lpModuleName);
}
FARPROC(WINAPI *OrigGetProcAddress)(
_In_ HMODULE hModule,
_In_ LPCSTR lpProcName
);
FARPROC WINAPI GetProcAddressWrap(
_In_ HMODULE hModule,
_In_ LPCSTR lpProcName
)
{
if(hModule == (HMODULE)0x8001)
{
// kbt.dll
if(strcmp(lpProcName, "bt_get_ikey_status") == 0)
{
return (FARPROC)bt_get_ikey_status;
}
}
if(hModule == (HMODULE)0x8002)
{
// kld.dll
if(strcmp(lpProcName, "bt_fcheck_init") == 0)
{
return (FARPROC)bt_fcheck_init;
}
if(strcmp(lpProcName, "bt_fcheck_main") == 0)
{
return (FARPROC)bt_fcheck_main;
}
if (strcmp(lpProcName, "bt_fcheck_finish") == 0)
{
return (FARPROC)bt_fcheck_finish;
}
}
return OrigGetProcAddress(hModule, lpProcName);
}
inline bool file_exists(const std::string& name)
{
@ -30,14 +127,14 @@ int main(int argc, char* argv[])
}
init_libavs();
// Add some sleep just in case.
Sleep(1000);
init_libacioHooks();
// Add some sleep just in case.
Sleep(1000);
// Hook dongle stuff without needing any lame dlls
MH_Initialize();
MH_CreateHookApi(L"kernel32.dll", "GetModuleHandleA", GetModuleHandleAWrap, (void **)&OrigGetModuleHandleA);
MH_CreateHookApi(L"kernel32.dll", "GetProcAddress", GetProcAddressWrap, (void **)&OrigGetProcAddress);
MH_EnableHook(MH_ALL_HOOKS);
auto gameBinary = LoadLibraryA(argv[1]);