1
0
mirror of synced 2024-11-27 23:10:49 +01:00
bananatools/amcus/iauth.c

450 lines
12 KiB
C
Raw Normal View History

2023-01-03 05:35:53 +01:00
#include <windows.h>
#include <combaseapi.h>
#include <stdint.h>
#include "amcus/iauth.h"
#include "amcus/amcus.h"
#include "amcus/config.h"
#include "util/dprintf.h"
static struct amcus_config config;
void iauth_set_config(struct amcus_config *cfg)
{
memcpy(&config, cfg, sizeof(*cfg));
}
static ULONG REF_COUNT = 0;
static HRESULT STDMETHODCALLTYPE IAuth_QueryInterface(IAuth FAR *This, REFIID riid, void **ppvObj)
{
dprintf("IAuth: QueryInterface\n");
if (ppvObj == NULL) {
return E_POINTER;
}
if (IsEqualGUID(riid, &amcus_rclsid)) {
This->lpVtbl->AddRef(This);
*ppvObj = This;
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE IAuth_AddRef(IAuth FAR *This)
{
// dprintf("IAuth: AddRef\n");
return ++REF_COUNT;
}
static ULONG STDMETHODCALLTYPE IAuth_Release(IAuth FAR *This)
{
// dprintf("IAuth: Release\n");
return --REF_COUNT;
}
2023-01-17 09:17:38 +01:00
static HRESULT STDMETHODCALLTYPE IAuth_Initialize(IAuth FAR *This, int64_t p0)
2023-01-03 05:35:53 +01:00
{
dprintf("IAuth: %s hit! p0 %I64d\n", __func__, p0);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return 0;
}
2023-01-17 09:17:38 +01:00
static HRESULT STDMETHODCALLTYPE IAuth_Finalize(IAuth FAR *This)
2023-01-03 05:35:53 +01:00
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return 0;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func5(IAuth FAR *This, int64_t p0)
{
dprintf("IAuth: %s hit! p0 %I64d\n", __func__, p0);
return S_OK;
}
static LONG STDMETHODCALLTYPE IAuth_Func6(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return 1;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func7(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func8(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// Likely has to do with mucha and the updater
static HRESULT STDMETHODCALLTYPE IAuth_GetUpdaterState(IAuth FAR *This, struct amcus_updater_state *arr)
{
// dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
// these work with taiko, pokken never hits this
char cacfg_ver[6];
wcstombs_s(NULL, cacfg_ver, sizeof(cacfg_ver), config.cacfg_game_ver, sizeof(config.cacfg_game_ver));
double ver_d = atof(cacfg_ver);
int ver_top = (int)ver_d;
int ver_btm = (int)(ver_d * 100);
if (ver_top != 0) {
ver_btm %= (ver_top * 100);
}
memset(arr, 0, sizeof(*arr));
2023-01-17 09:17:38 +01:00
arr->Member0.Member0 = 15;
2023-01-03 05:35:53 +01:00
arr->Member0.Member4 = 0;
arr->Member0.Member8 = 2;
arr->Member0.MemberC = 1;
arr->Member0.Member10 = 0;
2023-01-17 09:17:38 +01:00
arr->Member18.Member0 = 9;
2023-01-03 05:35:53 +01:00
arr->Member18.Member4 = 0;
2023-01-17 09:17:38 +01:00
arr->Member18.Member8 = 2;
arr->Member18.MemberC = 1;
arr->Member18.Member10 = 27;
arr->Member18.Member14 = 32;
arr->Member18.Member18 = 43;
arr->Member18.Member1C = 52;
2023-01-03 05:35:53 +01:00
arr->Member18.Member20 = 59;
arr->Member18.cacfg_ver_whole = ver_top;
arr->Member18.cacfg_ver_decimal = ver_btm;
arr->Member18.app_ver_whole = ver_top;
arr->Member18.app_ver_decimal = ver_btm;
arr->Member18.Member2C = 0;
arr->Member18.Member2E = 0;
arr->Member18.Member30 = 0;
arr->Member18.Member34 = 0;
arr->Member18.Member38 = 0;
arr->Member18.Member40 = 0;
arr->Member18.Member48 = 0;
arr->Member18.Member50 = 0;
arr->Member18.Member58 = 0;
arr->Member18.Member60 = 1;
arr->Member18.Member64 = 0;
arr->Member18.Member68 = 0;
arr->Member18.Member6C = 0;
arr->Member18.Member70 = 0;
arr->Member18.Member74 = 0;
arr->Member18.Member78 = 0;
arr->Member18.Member7C = 0;
arr->Member18.Member80 = 0;
arr->Member18.Member84 = 0;
arr->Member18.Member88 = 0;
arr->MemberA8 = 1;
arr->MemberB0 = 0;
arr->MemberB8 = 1;
arr->MemberBC = 3;
2023-01-17 09:17:38 +01:00
arr->MemberC0 = 9;
2023-01-03 05:35:53 +01:00
arr->MemberC4 = 0;
return S_OK;
}
// Valid valnues for mode are STANDALONE, CLIENT, SERVER
static HRESULT STDMETHODCALLTYPE IAuth_GetCabinetConfig(IAuth FAR *This, struct amcus_cab_config *arr)
{
// dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
memset(arr, 0, sizeof(*arr));
char am_serial[12];
char dongle_serial[13];
wcstombs_s(NULL, am_serial, sizeof(am_serial), config.am_serial, sizeof(config.am_serial));
// TODO: read the serial off a real dongle if enabled is 0
wcstombs_s(NULL, dongle_serial, sizeof(dongle_serial), config.dongle.serial, sizeof(config.dongle.serial));
strcpy_s(arr->mode, sizeof(arr->mode), "STANDALONE");
strcpy_s(arr->pcbid, sizeof(arr->pcbid), am_serial);
strcpy_s(arr->dongle_serial, sizeof(arr->dongle_serial), dongle_serial);
strcpy_s(arr->shop_router_ip, sizeof(arr->shop_router_ip), "192.168.123.254");
strcpy_s(arr->auth_server_ip, sizeof(arr->auth_server_ip), "192.168.1.114");
strcpy_s(arr->local_ip, sizeof(arr->local_ip), "192.168.123.11");
strcpy_s(arr->subnet_mask, sizeof(arr->subnet_mask), "255.255.225.0");
strcpy_s(arr->gateway, sizeof(arr->gateway), "192.168.123.254");
strcpy_s(arr->primary_dns, sizeof(arr->primary_dns), "192.168.1.3");
arr->hop_count = 1;
arr->line_type = 1;
return S_OK;
}
// Gets things like version and game id
static HRESULT STDMETHODCALLTYPE IAuth_GetVersionInfo(IAuth FAR *This, struct amcus_version_info *arr)
{
2023-01-17 09:17:38 +01:00
//dprintf("IAuth: %s hit!\n", __func__);
2023-01-03 05:35:53 +01:00
memset(arr, 0, sizeof(*arr));
char game_id[5];
char am_ver[6];
char cacfg_ver[6];
wcstombs_s(NULL, game_id, sizeof(game_id), config.game_id, sizeof(config.game_id));
wcstombs_s(NULL, am_ver, sizeof(am_ver), config.am_game_ver, sizeof(config.am_game_ver));
wcstombs_s(NULL, cacfg_ver, sizeof(cacfg_ver), config.cacfg_game_ver, sizeof(config.cacfg_game_ver));
strcpy_s(arr->game_rev, sizeof(arr->game_rev), "1");
strcpy_s(arr->auth_type, sizeof(arr->auth_type), "ALL.NET");
strcpy_s(arr->game_id, sizeof(arr->game_id), game_id);
strcpy_s(arr->game_ver, sizeof(arr->game_ver), am_ver); // version sent in allnet request
strcpy_s(arr->game_cd, sizeof(arr->game_cd), "S121"); // S121
strcpy_s(arr->cacfg_game_ver, sizeof(arr->cacfg_game_ver), cacfg_ver); // first 2 are 0 = A - 25 = Z, 2nd two are the two digits
strcpy_s(arr->game_board_type, sizeof(arr->game_board_type), "0");
strcpy_s(arr->game_board_id, sizeof(arr->game_board_id), "PCB");
2023-01-17 09:17:38 +01:00
strcpy_s(arr->auth_url, sizeof(arr->auth_url), "https://mucha.hay1ts.me/");
2023-01-03 05:35:53 +01:00
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func12(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func13(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// Response from All.net, thanks mon!
static HRESULT STDMETHODCALLTYPE IAuth_GetAuthServerResp(IAuth FAR *This, struct amcus_auth_server_resp *arr)
{
// dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
memset(arr, 0, sizeof(*arr));
char uri[257];
char host[257];
wcstombs_s(NULL, uri, sizeof(uri), config.server_uri, sizeof(config.server_uri));
wcstombs_s(NULL, host, sizeof(host), config.server_host, sizeof(config.server_host));
strcpy_s(arr->uri, sizeof(arr->uri), uri);
strcpy_s(arr->host, sizeof(arr->host), host);
strcpy_s(arr->shop_name, sizeof(arr->shop_name), "Test Shop!");
strcpy_s(arr->shop_nickname, sizeof(arr->shop_nickname), "Test Shop");
strcpy_s(arr->region0, sizeof(arr->region0), "1");
strcpy_s(arr->region_name0, sizeof(arr->region_name0), "W");
strcpy_s(arr->region_name1, sizeof(arr->region_name1), "X");
strcpy_s(arr->region_name2, sizeof(arr->region_name2), "Y");
strcpy_s(arr->region_name3, sizeof(arr->region_name3), "Z");
strcpy_s(arr->place_id, sizeof(arr->place_id), "123");
strcpy_s(arr->setting, sizeof(arr->setting), "1");
strcpy_s(arr->country, sizeof(arr->country), "JPN");
strcpy_s(arr->timezone, sizeof(arr->timezone), "+0900");
strcpy_s(arr->res_class, sizeof(arr->res_class), "PowerOnResponseVer2");
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func15(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func16(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
static HRESULT STDMETHODCALLTYPE IAuth_Func17(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// Another struct
2023-01-17 09:17:38 +01:00
static HRESULT STDMETHODCALLTYPE IAuth_GetMuchaAuthResponse(IAuth FAR *This, struct mucha_boardauth_resp *arr)
2023-01-03 05:35:53 +01:00
{
// dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// Another struct
static HRESULT STDMETHODCALLTYPE IAuth_Func19(IAuth FAR *This, struct amcus_arr19 *arr)
{
// dprintf("IAuth: %s hit!\n", __func__);
memset(arr, 0, sizeof(*arr));
2023-01-17 09:17:38 +01:00
arr->Member0 = 0; // if this isn't 1 taiko thinks it isn't auth'd
return 1;
2023-01-03 05:35:53 +01:00
}
// Converts allnet responsed to mucha info
static HRESULT STDMETHODCALLTYPE IAuth_Func20(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// dl_mode_lan and dl_mode_wan enable/disable?
static HRESULT STDMETHODCALLTYPE IAuth_Func21(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// similar to 18 but different...
static HRESULT STDMETHODCALLTYPE IAuth_Func22(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// similar to 18 but different...
static HRESULT STDMETHODCALLTYPE IAuth_Func23(IAuth FAR *This, int64_t p0)
{
dprintf("IAuth: %s hit! %I64d\n", __func__, p0);
2023-01-17 09:17:38 +01:00
return E_ACCESSDENIED;
2023-01-03 05:35:53 +01:00
}
// more dtmode stuff
static HRESULT STDMETHODCALLTYPE IAuth_Func24(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// something to do with fileio and version and the like?
static HRESULT STDMETHODCALLTYPE IAuth_Func25(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return 1;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func26(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// something to do with downloaded patches
static HRESULT STDMETHODCALLTYPE IAuth_Func27(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return 1;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func28(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func29(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func30(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func31(IAuth FAR *This)
{
dprintf("IAuth: %s hit!\n", __func__);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// just seems to allocate stuff
static HRESULT STDMETHODCALLTYPE IAuth_Func32(IAuth FAR *This, int64_t p0, int64_t* p1)
{
dprintf("IAuth: %s hit! p0 %I64d p1 %I64d\n", __func__, p0, *p1);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
// no clue
static HRESULT STDMETHODCALLTYPE IAuth_Func33(IAuth FAR *This, int64_t p0, int64_t* p1, int64_t* p2, int64_t* p3, int64_t* p4)
{
dprintf("IAuth: %s hit! p0 %I64d p1 %I64d p2 %I64d p3 %I64d p4 %I64d\n", __func__, p0, *p1, *p2, *p3, *p4);
2023-01-17 09:17:38 +01:00
2023-01-03 05:35:53 +01:00
return S_OK;
}
IAuthVtbl iauth_vtbl = {
.QueryInterface = IAuth_QueryInterface,
.AddRef = IAuth_AddRef,
.Release = IAuth_Release,
2023-01-17 09:17:38 +01:00
.Initialize = IAuth_Initialize,
.Finalize = IAuth_Finalize,
2023-01-03 05:35:53 +01:00
.Func5 = IAuth_Func5,
.Func6 = IAuth_Func6,
.Func7 = IAuth_Func7,
.Func8 = IAuth_Func8,
.GetUpdaterState = IAuth_GetUpdaterState,
.GetCabinetConfig = IAuth_GetCabinetConfig,
.GetVersionInfo = IAuth_GetVersionInfo,
.Func12 = IAuth_Func12,
.Func13 = IAuth_Func13,
.GetAuthServerResp = IAuth_GetAuthServerResp,
.Func15 = IAuth_Func15,
.Func16 = IAuth_Func16,
.Func17 = IAuth_Func17,
2023-01-17 09:17:38 +01:00
.GetMuchaAuthResponse = IAuth_GetMuchaAuthResponse,
2023-01-03 05:35:53 +01:00
.Func19 = IAuth_Func19,
.Func20 = IAuth_Func20,
.Func21 = IAuth_Func21,
.Func22 = IAuth_Func22,
.Func23 = IAuth_Func23,
.Func24 = IAuth_Func24,
.Func25 = IAuth_Func25,
.Func26 = IAuth_Func26,
.Func27 = IAuth_Func27,
.Func28 = IAuth_Func28,
.Func29 = IAuth_Func29,
.Func30 = IAuth_Func30,
.Func31 = IAuth_Func31,
.Func32 = IAuth_Func32,
.Func33 = IAuth_Func33,
};
IAuth iauth_stub_object = {
.lpVtbl = &iauth_vtbl,
};
IAuth *iauth_stub = &iauth_stub_object;