2023-01-03 05:35:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#include "platform/vfs.h"
|
|
|
|
#include "platform/config.h"
|
|
|
|
#include "platform/platform.h"
|
|
|
|
#include "platform/clock.h"
|
|
|
|
#include "platform/dns.h"
|
|
|
|
#include "platform/es3sec.h"
|
2024-01-10 02:48:19 +01:00
|
|
|
#include "util/dprintf.h"
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
void platform_config_load(struct platform_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
vfs_config_load(&cfg->vfs, filename);
|
|
|
|
clock_config_load(&cfg->clock, filename);
|
|
|
|
netenv_config_load(&cfg->netenv, filename);
|
|
|
|
locale_config_load(&cfg->locale, filename);
|
|
|
|
dns_config_load(&cfg->dns, filename);
|
|
|
|
jvs_config_load(&cfg->jvs, filename);
|
|
|
|
misc_config_load(&cfg->misc, filename);
|
|
|
|
es3sec_config_load(&cfg->dongle, filename);
|
2023-12-08 19:29:37 +01:00
|
|
|
epay_config_load(&cfg->epay, filename);
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_config_load(struct vfs_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
wchar_t keychip_sn[18];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"vfs", L"enable", 1, filename);
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"vfs",
|
|
|
|
L"path",
|
2024-01-10 02:48:19 +01:00
|
|
|
L"\0",
|
2023-01-03 05:35:53 +01:00
|
|
|
cfg->path,
|
|
|
|
_countof(cfg->path),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
len = wcslen(cfg->path);
|
2024-01-10 02:48:19 +01:00
|
|
|
|
|
|
|
if (cfg->path[0] == L'\0') {
|
|
|
|
dprintf("No vfs folder specified, using default 'vfs' at CWD\n");
|
|
|
|
GetCurrentDirectoryW(_countof(cfg->path), cfg->path);
|
2024-01-11 09:17:33 +01:00
|
|
|
wcscat_s(cfg->path, _countof(cfg->path), L"\\vfs");
|
2024-01-10 02:48:19 +01:00
|
|
|
}
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
if (cfg->path[len - 2] != '\\' && cfg->path[len - 2] != '/') { // -2 for null terminator
|
|
|
|
StringCbCatW(cfg->path, sizeof(cfg->path), L"\\\0");
|
|
|
|
}
|
2024-01-10 02:48:19 +01:00
|
|
|
|
2023-01-03 05:35:53 +01:00
|
|
|
wcscpy_s(cfg->d, sizeof(cfg->d), cfg->path);
|
|
|
|
wcscpy_s(cfg->e, sizeof(cfg->d), cfg->path);
|
|
|
|
wcscpy_s(cfg->f, sizeof(cfg->d), cfg->path);
|
|
|
|
wcscpy_s(cfg->g, sizeof(cfg->d), cfg->path);
|
|
|
|
wcscpy_s(cfg->h, sizeof(cfg->d), cfg->path);
|
|
|
|
wcscpy_s(cfg->j, sizeof(cfg->d), cfg->path);
|
|
|
|
|
|
|
|
StringCbCatW(cfg->d, sizeof(cfg->d), L"d\0");
|
|
|
|
StringCbCatW(cfg->e, sizeof(cfg->e), L"e\0");
|
|
|
|
StringCbCatW(cfg->f, sizeof(cfg->f), L"f\0");
|
|
|
|
StringCbCatW(cfg->g, sizeof(cfg->g), L"g\0");
|
|
|
|
StringCbCatW(cfg->h, sizeof(cfg->h), L"h\0");
|
|
|
|
StringCbCatW(cfg->j, sizeof(cfg->j), L"j\0");
|
|
|
|
}
|
|
|
|
|
|
|
|
void clock_config_load(struct clock_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
2024-04-23 03:11:03 +02:00
|
|
|
cfg->enable = GetPrivateProfileIntW(L"clock", L"enable", 1, filename);
|
2023-01-03 05:35:53 +01:00
|
|
|
cfg->timezone = GetPrivateProfileIntW(L"clock", L"timezone", 1, filename);
|
|
|
|
cfg->timewarp = GetPrivateProfileIntW(L"clock", L"timewarp", 0, filename);
|
|
|
|
cfg->writeable = GetPrivateProfileIntW(
|
|
|
|
L"clock",
|
|
|
|
L"writeable",
|
|
|
|
0,
|
|
|
|
filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void netenv_config_load(struct netenv_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
wchar_t mac_addr[18];
|
|
|
|
wchar_t subnet[16];
|
|
|
|
unsigned int ip[4];
|
|
|
|
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"netenv", L"enable", 0, filename);
|
|
|
|
|
|
|
|
cfg->addr_suffix = GetPrivateProfileIntW(
|
|
|
|
L"netenv",
|
|
|
|
L"addrSuffix",
|
|
|
|
11,
|
|
|
|
filename);
|
|
|
|
|
|
|
|
cfg->router_suffix = GetPrivateProfileIntW(
|
|
|
|
L"netenv",
|
|
|
|
L"routerSuffix",
|
|
|
|
254,
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"netenv",
|
|
|
|
L"macAddr",
|
|
|
|
L"01:02:03:04:05:06",
|
|
|
|
mac_addr,
|
|
|
|
_countof(mac_addr),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"netenv",
|
|
|
|
L"subnet",
|
|
|
|
L"192.168.123.0",
|
|
|
|
subnet,
|
|
|
|
_countof(subnet),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
|
|
|
|
swscanf(mac_addr,
|
|
|
|
L"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
|
|
|
&cfg->mac_addr[0],
|
|
|
|
&cfg->mac_addr[1],
|
|
|
|
&cfg->mac_addr[2],
|
|
|
|
&cfg->mac_addr[3],
|
|
|
|
&cfg->mac_addr[4],
|
|
|
|
&cfg->mac_addr[5],
|
|
|
|
&cfg->mac_addr[6]);
|
|
|
|
|
|
|
|
swscanf(subnet, L"%u.%u.%u.%u", &ip[0], &ip[1], &ip[2], &ip[3]);
|
|
|
|
cfg->subnet = (ip[0] << 24) | (ip[1] << 16) | (ip[2] << 8) | ip[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
void locale_config_load(struct locale_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"locale", L"enable", 1, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dns_config_load(struct dns_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
wchar_t default_[128];
|
|
|
|
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"dns", L"enable", 1, filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dns",
|
|
|
|
L"default",
|
|
|
|
L"localhost",
|
|
|
|
default_,
|
|
|
|
_countof(default_),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dns",
|
|
|
|
L"router",
|
|
|
|
default_,
|
|
|
|
cfg->router,
|
|
|
|
_countof(cfg->router),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dns",
|
|
|
|
L"startup",
|
|
|
|
default_,
|
|
|
|
cfg->startup,
|
|
|
|
_countof(cfg->startup),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dns",
|
|
|
|
L"billing",
|
|
|
|
default_,
|
|
|
|
cfg->billing,
|
|
|
|
_countof(cfg->billing),
|
|
|
|
filename);
|
|
|
|
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dns",
|
|
|
|
L"aimedb",
|
|
|
|
default_,
|
|
|
|
cfg->aimedb,
|
|
|
|
_countof(cfg->aimedb),
|
|
|
|
filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void jvs_config_load(
|
|
|
|
struct jvs_config *cfg,
|
|
|
|
const wchar_t *filename)
|
|
|
|
{
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"jvs", L"enable", 1, filename);
|
|
|
|
cfg->port = GetPrivateProfileIntW(L"jvs", L"port", 3, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void misc_config_load(
|
|
|
|
struct misc_config *cfg,
|
|
|
|
const wchar_t *filename)
|
|
|
|
{
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->block_input_hook = GetPrivateProfileIntW(L"misc", L"blockInputHook", 1, filename);
|
|
|
|
cfg->show_cursor_hook = GetPrivateProfileIntW(L"misc", L"showCursorHook", 1, filename);
|
2023-09-18 09:56:15 +02:00
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"misc",
|
|
|
|
L"systemVersion",
|
|
|
|
L"XXX100-1-NA-SYS0-A00",
|
|
|
|
cfg->system_version,
|
|
|
|
_countof(cfg->system_version),
|
|
|
|
filename);
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void es3sec_config_load(struct es3sec_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"dongle", L"enable", 1, filename);
|
|
|
|
GetPrivateProfileStringW(
|
|
|
|
L"dongle",
|
|
|
|
L"serial",
|
|
|
|
L"123456789012",
|
|
|
|
cfg->serial,
|
|
|
|
_countof(cfg->serial),
|
|
|
|
filename);
|
2023-12-08 19:29:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void epay_config_load(struct epay_config *cfg, const wchar_t *filename)
|
|
|
|
{
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"dongle", L"enable", 1, filename);
|
|
|
|
}
|