Add generate id support.

Add hollywood id to config file.
SSL and WC24 have their own logs now.
This commit is contained in:
Matthew Parlane 2013-01-04 22:35:48 +13:00
parent 5e4e2ef852
commit 67d0e66af4
13 changed files with 438 additions and 65 deletions

View file

@ -89,6 +89,7 @@
#define MAIL_LOGS_DIR LOGS_DIR DIR_SEP "Mail"
#define SHADERS_DIR "Shaders"
#define WII_SYSCONF_DIR "shared2" DIR_SEP "sys"
#define WII_WC24CONF_DIR "shared2" DIR_SEP "wc24"
// Filenames
// Files in the directory returned by GetUserPath(D_CONFIG_IDX)

View file

@ -679,6 +679,7 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP;
paths[D_MAILLOGS_IDX] = paths[D_USER_IDX] + MAIL_LOGS_DIR DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP;
paths[D_WIIWC24_IDX] = paths[D_WIIUSER_IDX] + WII_WC24CONF_DIR DIR_SEP;
paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG;
paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG;
@ -707,6 +708,7 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
}
paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP;
paths[D_WIIWC24_IDX] = paths[D_WIIUSER_IDX] + WII_WC24CONF_DIR DIR_SEP;
paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR + DIR_SEP;
paths[F_WIISYSCONF_IDX] = paths[D_WIISYSCONF_IDX] + WII_SYSCONF;
}

View file

@ -50,6 +50,7 @@ enum {
D_LOGS_IDX,
D_MAILLOGS_IDX,
D_WIISYSCONF_IDX,
D_WIIWC24_IDX,
F_DOLPHINCONFIG_IDX,
F_DSPCONFIG_IDX,
F_DEBUGGERCONFIG_IDX,

View file

@ -66,6 +66,8 @@ enum LOG_TYPE {
WII_IPC_FILEIO,
WII_IPC_HLE,
WII_IPC_NET,
WII_IPC_WC24,
WII_IPC_SSL,
WII_IPC_SD,
WII_IPC_STM,
WII_IPC_WIIMOTE,
@ -100,7 +102,7 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
#define MAX_LOGLEVEL DEBUG_LEVEL
#else
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL WARNING_LEVEL
#define MAX_LOGLEVEL DEBUG_LEVEL
#endif // loglevel
#endif // logging

View file

@ -78,6 +78,8 @@ LogManager::LogManager()
m_Log[LogTypes::WII_IPC_SD] = new LogContainer("WII_IPC_SD", "WII IPC SD");
m_Log[LogTypes::WII_IPC_STM] = new LogContainer("WII_IPC_STM", "WII IPC STM");
m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET");
m_Log[LogTypes::WII_IPC_WC24] = new LogContainer("WII_IPC_WC24", "WII IPC WC24");
m_Log[LogTypes::WII_IPC_SSL] = new LogContainer("WII_IPC_SSL", "WII IPC SSL");
m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE");
m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay");
m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager");

View file

@ -258,14 +258,14 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
File::CreateFullPath(settings_Filename);
{
File::IOFile settingsFileHandle(settings_Filename, "wb");
if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
{
PanicAlertT("SetupWiiMem: Cant create setting file");
return false;
}
Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
File::IOFile settingsFileHandle(settings_Filename, "wb");
if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
{
PanicAlertT("SetupWiiMem: Cant create setting file");
return false;
}
Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
}
/*
@ -319,7 +319,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
Memory::Write_U32(0x00000000, 0x00003160); // Init semaphore (sysmenu waits for this to clear)
Memory::Write_U32(0x00090204, 0x00003188); // Expected IOS revision
Memory::Write_U8(0x80, 0x0000315c); // OSInit
Memory::Write_U8(0x80, 0x0000315c); // OSInit
Memory::Write_U16(0x0000, 0x000030e0); // PADInit
Memory::Write_U32(0x80000000, 0x00003184); // GameID Address

View file

@ -157,6 +157,7 @@ void SConfig::SaveSettings()
ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
ini.Set("General", "NANDRoot", m_NANDPath);
ini.Set("General", "WirelessMac", m_WirelessMac);
ini.Set("General", "HollywoodID", m_HollywoodID);
// Interface
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
@ -292,7 +293,8 @@ void SConfig::LoadSettings()
m_NANDPath = File::GetUserPath(D_WIIROOT_IDX, m_NANDPath);
DiscIO::cUIDsys::AccessInstance().UpdateLocation();
DiscIO::CSharedContent::AccessInstance().UpdateLocation();
ini.Get("General", "WirelessMac", &m_WirelessMac);
ini.Get("General", "WirelessMac", &m_WirelessMac);
ini.Get("General", "HollywoodID", &m_HollywoodID, "0x21FFFFF");
}
{

View file

@ -79,6 +79,7 @@ struct SConfig : NonCopyable
int m_ListSort2;
std::string m_WirelessMac;
std::string m_HollywoodID;
bool m_PauseMovie;
bool m_ShowLag;
std::string m_strMovieAuthor;

View file

@ -52,6 +52,7 @@
#include "../VolumeHandler.h"
#include "FileUtil.h"
#include "Crypto/aes.h"
#include "ConfigManager.h"
#include "../Boot/Boot_DOL.h"
#include "NandPaths.h"
@ -106,6 +107,15 @@ void CWII_IPC_HLE_Device_es::LoadWAD(const std::string& _rContentFile)
m_ContentFile = _rContentFile;
}
u32 CWII_IPC_HLE_Device_es::GetHollywoodID()
{
unsigned int HollywoodID = 0;
std::stringstream ss;
ss << std::hex << SConfig::GetInstance().m_HollywoodID;
ss >> HollywoodID;
return HollywoodID;
}
bool CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
{
m_pContentLoader = &DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile);
@ -179,9 +189,8 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "IOCTL_ES_GETDEVICEID no out buffer");
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETDEVICEID");
// Return arbitrary device ID - TODO allow user to set value?
Memory::Write_U32(0x21FFFFF, Buffer.PayloadBuffer[0].m_Address);
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETDEVICEID %s", SConfig::GetInstance().m_HollywoodID.c_str());
Memory::Write_U32(GetHollywoodID(), Buffer.PayloadBuffer[0].m_Address);
Memory::Write_U32(0, _CommandAddress + 0x4);
return true;
}

View file

@ -31,6 +31,7 @@ public:
virtual ~CWII_IPC_HLE_Device_es();
void LoadWAD(const std::string& _rContentFile);
static u32 GetHollywoodID();
virtual bool Open(u32 _CommandAddress, u32 _Mode);

View file

@ -47,11 +47,15 @@ it failed)
#endif
#include "WII_IPC_HLE_Device_net.h"
#include "WII_IPC_HLE_Device_es.h"
#include "../ConfigManager.h"
#include "FileUtil.h"
#include <stdio.h>
#include <string>
#include "ICMP.h"
#include "CommonPaths.h"
#include "SettingsHandler.h"
#ifdef _WIN32
#include <ws2tcpip.h>
@ -91,8 +95,6 @@ const u8 default_address[] = { 0x00, 0x17, 0xAB, 0x99, 0x99, 0x99 };
// Handle /dev/net/kd/request requests
CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
, m_UserID("Dolphin-EMU")
// TODO: Dump the true ID from real Wii
{
}
@ -102,7 +104,7 @@ CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request()
bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: Open");
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: Open");
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return true;
@ -110,7 +112,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode)
bool CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: Close");
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
@ -130,65 +132,109 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
{
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
break;
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
break;
case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR : // NWC24iResumeForCloseLib
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
break;
case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket
Memory::Write_U32(0, BufferOut);
Memory::Write_U32(0, BufferOut+4);
ReturnValue = 0;
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
break;
case IOCTL_NWC24_CLEANUP_SOCKET:
Memory::Memset(BufferOut, 0, BufferOutSize);
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI");
break;
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
break;
case IOCTL_NWC24_UNLOCK_SOCKET:
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
break;
case IOCTL_NWC24_REQUEST_REGISTER_USER_ID:
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
Memory::Write_U32(0, BufferOut);
Memory::Write_U32(0, BufferOut+4);
break;
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
//Memory::Write_U32(0xFFFFFFDC, BufferOut);
//Memory::Write_U32(0x00050495, BufferOut + 4);
//Memory::Write_U32(0x90CFBF35, BufferOut + 8);
//Memory::Write_U32(0x00000002, BufferOut + 0xC);
Memory::WriteBigEData((u8*)m_UserID.c_str(), BufferOut, m_UserID.length() + 1);
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_INITIAL)
{
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
SettingsHandler gen;
std::string area, model;
bool _GotSettings = false;
if (File::Exists(settings_Filename))
{
File::IOFile settingsFileHandle(settings_Filename, "rb");
if (settingsFileHandle.ReadBytes((void*)gen.GetData(), SettingsHandler::SETTINGS_SIZE))
{
gen.Decrypt();
area = gen.GetValue("AREA");
model = gen.GetValue("MODEL");
_GotSettings = true;
}
}
if (_GotSettings)
{
u8 area_code = GetAreaCode(area.c_str());
u8 id_ctr = config.IdGen();
u8 hardware_model = GetHardwareModel(model.c_str());
u32 HollywoodID = CWII_IPC_HLE_Device_es::GetHollywoodID();
u64 UserID = 0;
s32 ret = NWC24MakeUserID(&UserID, HollywoodID, id_ctr, hardware_model, area_code);
config.SetId(UserID);
config.IncrementIdGen();
config.SetCreationStage(nwc24_config_t::NWC24_IDCS_GENERATED);
config.WriteConfig();
Memory::Write_U32(ret, BufferOut);
}
else
{
Memory::Write_U32(nwc24_err_t::WC24_ERR_FATAL, BufferOut);
}
}
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED)
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_GENERATED, BufferOut);
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_REGISTERED)
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_REGISTERED, BufferOut);
Memory::Write_U64(config.Id(), BufferOut + 4);
Memory::Write_U32(config.CreationStage(), BufferOut + 0xC);
break;
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
break;
case IOCTL_NWC24_SAVE_MAIL_NOW:
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
break;
case IOCTL_NWC24_REQUEST_SHUTDOWN:
// if ya set the IOS version to a very high value this happens ...
WARN_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI");
WARN_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI");
break;
default:
WARN_LOG(WII_IPC_NET, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
WARN_LOG(WII_IPC_WC24, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize);
break;
}
@ -200,6 +246,107 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
}
u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode( const char * area )
{
u32 i;
u8 regions_[] = {0,1,2,2,1,3,3,4,5,5,1,2,6,7};
const char* regions[] = {"JPN", "USA", "EUR", "AUS", "BRA", "TWN", "ROC", "KOR", "HKG", "ASI", "LTN", "SAF", "CHN", ""};
u8 region_code = 0xff;
for (i=0; i<sizeof(regions)/sizeof(*regions); i++)
{
if (!strncmp(regions[i], area, 4))
{
return regions_[i];
}
}
return 7;
}
u8 CWII_IPC_HLE_Device_net_kd_request::GetHardwareModel(const char * model)
{
u8 mdl;
if (!strncmp(model, "RVL", 4))
{
mdl = MODEL_RVL;
}else if (!strncmp(model, "RVT", 4))
{
mdl = MODEL_RVT;
}else if (!strncmp(model, "RVV", 4))
{
mdl = MODEL_RVV;
}else if (!strncmp(model, "RVD", 4))
{
mdl = MODEL_RVD;
}else
{
mdl = MODEL_ELSE;
}
return mdl;
}
static inline u8 u64_get_byte(u64 value, u8 shift)
{
return (u8)(value >> (shift*8));
}
static inline u64 u64_insert_byte(u64 value, u8 shift, u8 byte)
{
u64 mask = 0x00000000000000FFULL << (shift*8);
u64 inst = (u64)byte << (shift*8);
return (value & ~mask) | inst;
}
s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model, u8 area_code)
{
const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7};
const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, 0xC, 0x2, 0x6, 0xE, 0x8, 0x0, 0xA, 0x5};
u64 mix_id = ((u64)area_code<<50) | ((u64)hardware_model<<47) | ((u64)hollywood_id<<15) | ((u64)id_ctr<<10);
u64 mix_id_copy1 = mix_id;
int ctr = 0;
for (ctr = 0; ctr <= 42; ctr++)
{
u64 value = mix_id >> (52-ctr);
if (value & 1)
{
value = 0x0000000000000635ULL << (42-ctr);
mix_id ^= value;
}
}
mix_id = (mix_id_copy1 | (mix_id & 0xFFFFFFFFUL)) ^ 0x0000B3B3B3B3B3B3ULL;
mix_id = (mix_id >> 10) | ((mix_id & 0x3FF) << (11+32));
for (ctr = 0; ctr <= 5; ctr++)
{
u8 ret = u64_get_byte(mix_id, ctr);
u8 foobar = ((table1[(ret>>4)&0xF])<<4) | (table1[ret&0xF]);
mix_id = u64_insert_byte(mix_id, ctr, foobar & 0xff);
}
u64 mix_id_copy2 = mix_id;
for (ctr = 0; ctr <= 5; ctr++)
{
u8 ret = u64_get_byte(mix_id_copy2, ctr);
mix_id = u64_insert_byte(mix_id, table2[ctr], ret);
}
mix_id &= 0x001FFFFFFFFFFFFFULL;
mix_id = (mix_id << 1) | ((mix_id >> 52) & 1);
mix_id ^= 0x00005E5E5E5E5E5EULL;
mix_id &= 0x001FFFFFFFFFFFFFULL;
*nwc24_id = mix_id;
if (mix_id > 9999999999999999ULL)
return nwc24_err_t::WC24_ERR_FATAL;
return nwc24_err_t::WC24_OK;
}
// **********************************************************************************
// Handle /dev/net/ncd/manage requests
CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName)
@ -522,9 +669,9 @@ struct GC_sockaddr_in
char* DecodeError(int ErrorCode)
{
static char Message[1024];
#ifdef _WIN32
static char Message[1024];
// If this program was multi-threaded, we'd want to use FORMAT_MESSAGE_ALLOCATE_BUFFER
// instead of a static buffer here.
// (And of course, free the buffer when we were done with it)
@ -1448,26 +1595,23 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
{
u32 sock = Memory::Read_U32(_BufferIn);
u32 flags = Memory::Read_U32(_BufferIn + 4);
char *buf = (char *)Memory::GetPointer(_BufferOut);
int len = BufferOutSize;
struct sockaddr_in addr;
memset(&addr, 0, sizeof(sockaddr_in));
socklen_t fromlen = 0;
if (BufferOutSize2 != 0)
{
fromlen = BufferOutSize2 >= sizeof(struct sockaddr) ? BufferOutSize2 : sizeof(struct sockaddr);
}
if (flags != 2)
flags = 0;
else
flags = MSG_PEEK;
static int ret;
#ifdef _WIN32
if(flags & MSG_PEEK){
@ -1496,10 +1640,10 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
addr.sin_family = (addr.sin_family << 8) | (BufferOutSize2&0xFF);
Memory::WriteBigEData((u8*)&addr, _BufferOut2, BufferOutSize2);
}
return err;
}
case IOCTLV_SO_GETADDRINFO:
{
struct addrinfo hints;

View file

@ -134,8 +134,204 @@ struct network_config_t
netcfg_connection_t connection[3];
};
enum nwc24_err_t
{
WC24_OK = 0,
WC24_ERR_FATAL = -1,
WC24_ERR_ID_NONEXISTANCE = -34,
WC24_ERR_ID_GENERATED = -35,
WC24_ERR_ID_REGISTERED = -36,
WC24_ERR_ID_NOT_REGISTERED = -44,
};
struct nwc24_config_t
{
enum
{
NWC24_IDCS_INITIAL = 0,
NWC24_IDCS_GENERATED = 1,
NWC24_IDCS_REGISTERED = 2
};
enum
{
URL_COUNT = 0x05,
MAX_URL_LENGTH = 0x80,
MAX_EMAIL_LENGTH = 0x40,
MAX_PASSWORD_LENGTH = 0x20,
};
u32 magic; /* 'WcCf' 0x57634366 */
u32 _unk_04; /* must be 8 */
u64 nwc24_id;
u32 id_generation;
u32 creation_stage; /* 0==not_generated;1==generated;2==registered; */
char email[MAX_EMAIL_LENGTH];
char paswd[MAX_PASSWORD_LENGTH];
char mlchkid[0x24];
char http_urls[URL_COUNT][MAX_URL_LENGTH];
u8 reserved[0xDC];
u32 enable_booting;
u32 checksum;
};
#pragma pack(pop)
class NWC24Config
{
private:
std::string path;
nwc24_config_t config;
public:
NWC24Config()
{
path = File::GetUserPath(D_WIIWC24_IDX) + "nwc24msg.cfg";
ReadConfig();
}
void ResetConfig()
{
int i;
if (File::Exists(path))
File::Delete(path);
const char* urls[5] = {
"https://amw.wc24.wii.com/cgi-bin/account.cgi",
"http://rcw.wc24.wii.com/cgi-bin/check.cgi",
"http://mtw.wc24.wii.com/cgi-bin/receive.cgi",
"http://mtw.wc24.wii.com/cgi-bin/delete.cgi",
"http://mtw.wc24.wii.com/cgi-bin/send.cgi",
};
memset(&config, 0, sizeof(config));
SetMagic(0x57634366);
SetUnk(8);
SetCreationStage(nwc24_config_t::NWC24_IDCS_INITIAL);
SetEnableBooting(0);
SetEmail("@wii.com");
for(i=0; i<nwc24_config_t::URL_COUNT; i++)
{
strncpy(config.http_urls[i], urls[i], nwc24_config_t::MAX_URL_LENGTH);
}
SetChecksum(CalculateNwc24ConfigChecksum());
WriteConfig();
}
void WriteConfig()
{
if (!File::Exists(path))
{
if (!File::CreateFullPath(File::GetUserPath(D_WIIWC24_IDX)))
{
ERROR_LOG(WII_IPC_WC24, "Failed to create directory for WC24");
}
}
File::IOFile(path, "wb").WriteBytes((void*)&config, sizeof(config));
}
void ReadConfig()
{
if (File::Exists(path))
{
if (!File::IOFile(path, "rb").ReadBytes((void *)&config, sizeof(config)))
ResetConfig();
else
{
s32 config_error = CheckNwc24Config();
if(config_error)
ERROR_LOG(WII_IPC_WC24, "There is an error in the config for for WC24: %d", config_error);
}
}
else
{
ResetConfig();
}
}
u32 CalculateNwc24ConfigChecksum(void)
{
u32* ptr = (u32*)&config;
u32 sum = 0;
int i;
for (i=0; i<0xFF; i++)
{
sum += Common::swap32(*ptr++);
}
return sum;
}
s32 CheckNwc24Config(void)
{
if (Magic() != 0x57634366) /* 'WcCf' magic */
{
ERROR_LOG(WII_IPC_WC24, "Magic mismatch");
return -14;
}
u32 checksum = CalculateNwc24ConfigChecksum();
DEBUG_LOG(WII_IPC_WC24, "Checksum: %X", checksum);
if (Checksum() != checksum)
{
ERROR_LOG(WII_IPC_WC24, "Checksum mismatch expected %X and got %X", checksum, Checksum());
return -14;
}
if (IdGen() > 0x1F)
{
ERROR_LOG(WII_IPC_WC24, "Id gen error");
return -14;
}
if (Unk() != 8)
return -27;
return 0;
}
u32 Magic(){return Common::swap32(config.magic);}
void SetMagic(u32 magic){config.magic = Common::swap32(magic);}
u32 Unk(){return Common::swap32(config._unk_04);}
void SetUnk(u32 _unk_04){config._unk_04 = Common::swap32(_unk_04);}
u32 IdGen(){return Common::swap32(config.id_generation);}
void SetIdGen(u32 id_generation){config.id_generation = Common::swap32(id_generation);}
void IncrementIdGen(){
u32 id_ctr = IdGen();
id_ctr++;
id_ctr &= 0x1F;
SetIdGen(id_ctr);
}
u32 Checksum(){return Common::swap32(config.checksum);}
void SetChecksum(u32 checksum){config.checksum = Common::swap32(checksum);}
u32 CreationStage(){return Common::swap32(config.creation_stage);}
void SetCreationStage(u32 creation_stage){config.creation_stage = Common::swap32(creation_stage);}
u32 EnableBooting(){return Common::swap32(config.enable_booting);}
void SetEnableBooting(u32 enable_booting){config.enable_booting = Common::swap32(enable_booting);}
u64 Id(){return Common::swap64(config.nwc24_id);}
void SetId(u64 nwc24_id){config.nwc24_id = Common::swap64(nwc24_id);}
const char * Email(){return config.email;}
void SetEmail(const char * email)
{
strncpy(config.email, email, nwc24_config_t::MAX_EMAIL_LENGTH);
config.email[nwc24_config_t::MAX_EMAIL_LENGTH-1] = '\0';
}
};
class WiiNetConfig
{
std::string path;
@ -246,9 +442,21 @@ private:
IOCTL_NWC24_SET_SCRIPT_MODE = 0x22,
IOCTL_NWC24_REQUEST_SHUTDOWN = 0x28,
};
// Max size 32 Bytes
std::string m_UserID;
enum {
MODEL_RVT = 0,
MODEL_RVV = 0,
MODEL_RVL = 1,
MODEL_RVD = 2,
MODEL_ELSE = 7
};
u8 GetAreaCode(const char * area);
u8 GetHardwareModel(const char * model);
s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model, u8 area_code);
NWC24Config config;
};
//////////////////////////////////////////////////////////////////////////
@ -438,7 +646,7 @@ private:
enum
{
IOCTLV_NCD_LOCKWIRELESSDRIVER = 0x1, // NCDLockWirelessDriver
IOCTLV_NCD_UNLOCKWIRELESSDRIVER = 0x2, // NCDUnlockWirelessDriver
IOCTLV_NCD_UNLOCKWIRELESSDRIVER = 0x2, // NCDUnlockWirelessDriver
IOCTLV_NCD_GETCONFIG = 0x3, // NCDiGetConfig
IOCTLV_NCD_SETCONFIG = 0x4, // NCDiSetConfig
IOCTLV_NCD_READCONFIG = 0x5,

View file

@ -147,7 +147,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_NEW "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_NEW "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -169,7 +169,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
sslfds[sslID] = NULL;
Memory::Write_U32(0, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SHUTDOWN "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SHUTDOWN "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -180,7 +180,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
}
case IOCTLV_NET_SSL_SETROOTCA:
{
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SETROOTCA "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -236,7 +236,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
{
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -291,7 +291,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
Memory::Write_U32(0, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SETBUILTINROOTCA "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -313,7 +313,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
returnValue = SSL_connect(ssl);
Memory::Write_U32(0, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_CONNECT "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -335,7 +335,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
// if (returnValue == 1)
Memory::Write_U32(0, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_DOHANDSHAKE "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -361,14 +361,14 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
returnValue = -SSL_get_error(ssl, returnValue);
Memory::Write_U32(returnValue, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_WRITE "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_WRITE "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferIn3, BufferInSize3, _BufferOut, BufferOutSize,
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
INFO_LOG(WII_IPC_NET, "%s", Memory::GetPointer(_BufferOut2));
INFO_LOG(WII_IPC_SSL, "%s", Memory::GetPointer(_BufferOut2));
break;
}
@ -382,7 +382,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
if (returnValue == -1)
{
returnValue = -SSL_get_error(ssl, returnValue);
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_READ errorVal= %d", returnValue);
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ errorVal= %d", returnValue);
}else{
File::IOFile("ssl_read.bin", "ab").WriteBytes(Memory::GetPointer(_BufferIn2), returnValue);
}
@ -410,13 +410,13 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
}
else
{
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_READ ERRORCODE= %d", errorCode);
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ ERRORCODE= %d", errorCode);
}
}
Memory::Write_U32(returnValue, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_READ(%d)"
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ(%d)"
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -433,7 +433,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
Memory::Write_U32(0, _BufferIn);
}
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SETROOTCADEFAULT "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -445,7 +445,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
{
INFO_LOG(WII_IPC_NET, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -495,7 +495,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
default:
{
ERROR_LOG(WII_IPC_NET, "%i "
ERROR_LOG(WII_IPC_SSL, "%i "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
@ -517,7 +517,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command,
{
default:
{
INFO_LOG(WII_IPC_NET, "%s unknown %i "
INFO_LOG(WII_IPC_SSL, "%s unknown %i "
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
GetDeviceName().c_str(), _Command,
_BufferIn, BufferInSize, _BufferOut, BufferOutSize);