#include #include #include #include #include #include #include #include #include #include #include #include "platform/vfs.h" #include "platform/config.h" #include "platform/platform.h" #include "platform/clock.h" #include "platform/dns.h" #include "platform/es3sec.h" 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); } 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", L"", cfg->path, _countof(cfg->path), filename); len = wcslen(cfg->path); if (cfg->path[len - 2] != '\\' && cfg->path[len - 2] != '/') { // -2 for null terminator StringCbCatW(cfg->path, sizeof(cfg->path), L"\\\0"); } 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); 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); GetPrivateProfileStringW( L"misc", L"systemVersion", L"XXX100-1-NA-SYS0-A00", cfg->system_version, _countof(cfg->system_version), filename); } 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); }