mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
WIP patch for networking
This commit is contained in:
parent
8a1ca0f1b8
commit
aff6a7ac6f
@ -139,6 +139,7 @@ set(SRCS Src/ActionReplay.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
|
||||
Src/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp
|
||||
@ -192,7 +193,7 @@ set(SRCS Src/ActionReplay.cpp
|
||||
Src/PowerPC/JitCommon/JitCache.cpp
|
||||
Src/PowerPC/JitCommon/Jit_Util.cpp)
|
||||
|
||||
set(LIBS bdisasm inputcommon videoogl videosoftware sfml-network)
|
||||
set(LIBS bdisasm inputcommon videoogl videosoftware sfml-network ssl)
|
||||
|
||||
if(WIN32)
|
||||
set(SRCS ${SRCS} Src/HW/BBA-TAP/TAP_Win32.cpp Src/stdafx.cpp
|
||||
|
@ -115,7 +115,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -127,7 +127,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -139,7 +139,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -153,7 +153,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -167,7 +167,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -181,7 +181,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\openssl\$(PlatformName);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -327,6 +327,7 @@
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_fs.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_net.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb.cpp" />
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" />
|
||||
@ -518,6 +519,7 @@
|
||||
<ClInclude Include="Src\HW\WII_IOB.h" />
|
||||
<ClInclude Include="Src\HW\WII_IPC.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\hci.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\fakepoll.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\l2cap.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WiiMote_HID_Attr.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE.h" />
|
||||
@ -528,6 +530,7 @@
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_fs.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_net.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_stm.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb.h" />
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" />
|
||||
|
@ -537,6 +537,9 @@
|
||||
<ClCompile Include="Src\FifoPlayer\FifoDataFile.cpp">
|
||||
<Filter>FifoPlayer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\FifoPlayer\FifoPlayer.cpp">
|
||||
<Filter>FifoPlayer</Filter>
|
||||
</ClCompile>
|
||||
@ -1030,8 +1033,11 @@
|
||||
<Filter>FifoPlayer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Movie.h" />
|
||||
<ClInclude Include="Src\HW\GCMemcard.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\GCMemcard</Filter>
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.h">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\IPC_HLE\fakepoll.h">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -46,6 +46,7 @@ They will also generate a true or false return for UpdateInterrupts() in WII_IPC
|
||||
#include "WII_IPC_HLE_Device_stm.h"
|
||||
#include "WII_IPC_HLE_Device_fs.h"
|
||||
#include "WII_IPC_HLE_Device_net.h"
|
||||
#include "WII_IPC_HLE_Device_net_ssl.h"
|
||||
#include "WII_IPC_HLE_Device_es.h"
|
||||
#include "WII_IPC_HLE_Device_usb.h"
|
||||
#include "WII_IPC_HLE_Device_usb_kbd.h"
|
||||
@ -91,6 +92,7 @@ void Init()
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_kd_time(i, std::string("/dev/net/kd/time")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ncd_manage(i, std::string("/dev/net/ncd/manage")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ip_top(i, std::string("/dev/net/ip/top")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ssl(i, std::string("/dev/net/ssl")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_kbd(i, std::string("/dev/usb/kbd")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_sdio_slot0(i, std::string("/dev/sdio/slot0")); i++;
|
||||
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/sdio/slot1")); i++;
|
||||
|
@ -93,11 +93,11 @@ public:
|
||||
|
||||
virtual bool IsHardware() { return m_Hardware; }
|
||||
virtual bool IsOpened() { return m_Active; }
|
||||
|
||||
public:
|
||||
std::string m_Name;
|
||||
protected:
|
||||
|
||||
// STATE_TO_SAVE
|
||||
std::string m_Name;
|
||||
u32 m_DeviceID;
|
||||
bool m_Hardware;
|
||||
bool m_Active;
|
||||
|
@ -348,7 +348,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
|
||||
_BufferOutSize);
|
||||
|
||||
u32 OwnerID = 0;
|
||||
u16 GroupID = 0;
|
||||
u16 GroupID = 0x3031;
|
||||
std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn), 64);
|
||||
u8 OwnerPerm = 0x3; // read/write
|
||||
u8 GroupPerm = 0x3; // read/write
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,22 @@
|
||||
#ifndef _WII_IPC_HLE_DEVICE_NET_H_
|
||||
#define _WII_IPC_HLE_DEVICE_NET_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4748)
|
||||
#pragma optimize("",off)
|
||||
#endif
|
||||
|
||||
#include "WII_IPC_HLE_Device.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
|
||||
// data layout of the network configuration file (/shared2/sys/net/02/config.dat)
|
||||
// needed for /dev/net/ncd/manage
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
struct netcfg_proxy_t
|
||||
{
|
||||
u8 use_proxy; // 0x00 -> no proxy; 0x01 -> proxy
|
||||
u8 use_proxy_userandpass; // 0x00 -> don't use username and password; 0x01 -> use username and password
|
||||
@ -34,9 +44,9 @@ typedef struct
|
||||
u8 proxy_username[32];
|
||||
u8 padding_3;
|
||||
u8 proxy_password[32];
|
||||
} netcfg_proxy_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct netcfg_connection_t
|
||||
{
|
||||
// settings common to both wired and wireless connections
|
||||
u8 flags; // Connection selected
|
||||
@ -87,27 +97,24 @@ typedef struct
|
||||
|
||||
u8 key[64]; // encryption key; for WEP, key is stored 4 times (20 bytes for WEP64 and 52 bytes for WEP128) then padded with 0x00
|
||||
u8 padding_12[236];
|
||||
} netcfg_connection_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct network_config_t
|
||||
{
|
||||
u8 header0; // 0x00
|
||||
u8 header1; // 0x00
|
||||
u8 header2; // 0x00
|
||||
u8 header3; // 0x00
|
||||
u8 header4; // 0x01 if there's at least one valid connection to the Internet.
|
||||
u8 header5; // 0x00
|
||||
u8 header6; // always 0x07?
|
||||
u8 header7; // 0x00
|
||||
u32 version;
|
||||
u8 connType; // 0x01 if there's at least one valid connection to the Internet.
|
||||
u8 nwc24Permission; // 0x00
|
||||
u8 linkTimeout; // always 0x07?
|
||||
u8 padding; // 0x00
|
||||
|
||||
netcfg_connection_t connection[3];
|
||||
} network_config_t;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
|
||||
// **********************************************************************************
|
||||
// KD is the IOS module responsible for implementing WiiConnect24 functionality. It
|
||||
// can perform HTTPS downloads, send and receive mail via SMTP, and execute a
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// KD is the IOS module responsible for implementing WiiConnect24 functionality.
|
||||
// It can perform HTTPS downloads, send and receive mail via SMTP, and execute a
|
||||
// JavaScript-like language while the Wii is in standby mode.
|
||||
class CWII_IPC_HLE_Device_net_kd_request : public IWII_IPC_HLE_Device
|
||||
{
|
||||
@ -125,24 +132,24 @@ private:
|
||||
{
|
||||
IOCTL_NWC24_SUSPEND_SCHEDULAR = 0x01,
|
||||
IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR = 0x02,
|
||||
IOCTL_NWC24_UNK_3 = 0x03,
|
||||
IOCTL_NWC24_UNK_4 = 0x04,
|
||||
IOCTL_NWC24_EXEC_RESUME_SCHEDULAR = 0x03,
|
||||
IOCTL_NWC24_KD_GET_TIME_TRIGGERS = 0x04,
|
||||
IOCTL_NWC24_UNK_5 = 0x05,
|
||||
IOCTL_NWC24_STARTUP_SOCKET = 0x06,
|
||||
IOCTL_NWC24_CLEANUP_SOCKET = 0x07,
|
||||
IOCTL_NWC24_LOCK_SOCKET = 0x08,
|
||||
IOCTL_NWC24_UNLOCK_SOCKET = 0x09,
|
||||
IOCTL_NWC24_UNK_A = 0x0A,
|
||||
IOCTL_NWC24_UNK_B = 0x0B,
|
||||
IOCTL_NWC24_UNK_C = 0x0C,
|
||||
IOCTL_NWC24_CHECK_MAIL_NOW = 0x0A,
|
||||
IOCTL_NWC24_SEND_MAIL_NOW = 0x0B,
|
||||
IOCTL_NWC24_RECEIVE_MAIL_NOW = 0x0C,
|
||||
IOCTL_NWC24_SAVE_MAIL_NOW = 0x0D,
|
||||
IOCTL_NWC24_DOWNLOAD_NOW_EX = 0x0E,
|
||||
IOCTL_NWC24_REQUEST_GENERATED_USER_ID = 0x0F,
|
||||
IOCTL_NWC24_REQUEST_REGISTER_USER_ID = 0x10,
|
||||
IOCTL_NWC24_GET_SCHEDULAR_STAT = 0x1E,
|
||||
IOCTL_NWC24_UNK_1F = 0x1F,
|
||||
IOCTL_NWC24_UNK_20 = 0x20,
|
||||
IOCTL_NWC24_UNK_21 = 0x21,
|
||||
IOCTL_NWC24_SET_FILTER_MODE = 0x1F,
|
||||
IOCTL_NWC24_SET_DEBUG_MODE = 0x20,
|
||||
IOCTL_NWC24_KD_SET_NEXT_WAKEUP = 0x21,
|
||||
IOCTL_NWC24_SET_SCRIPT_MODE = 0x22,
|
||||
IOCTL_NWC24_REQUEST_SHUTDOWN = 0x28,
|
||||
};
|
||||
@ -151,13 +158,16 @@ private:
|
||||
std::string m_UserID;
|
||||
};
|
||||
|
||||
// **********************************************************************************
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CWII_IPC_HLE_Device_net_kd_time : public IWII_IPC_HLE_Device
|
||||
{
|
||||
u64 timediff;
|
||||
public:
|
||||
CWII_IPC_HLE_Device_net_kd_time(u32 _DeviceID, const std::string& _rDeviceName) :
|
||||
IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
{}
|
||||
CWII_IPC_HLE_Device_net_kd_time(u32 _DeviceID, const std::string& _rDeviceName)
|
||||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
{
|
||||
timediff = 1337; // this must be stored somewhere?
|
||||
}
|
||||
|
||||
virtual ~CWII_IPC_HLE_Device_net_kd_time()
|
||||
{}
|
||||
@ -188,26 +198,29 @@ public:
|
||||
switch (Parameter)
|
||||
{
|
||||
case IOCTL_NW24_SET_RTC_COUNTER: // NWC24iSetRtcCounter (but prolly just the first 4 bytes are intresting...)
|
||||
{
|
||||
_dbg_assert_msg_(WII_IPC_NET, BufferInSize==0x20, "NET_KD_TIME: Set RTC Counter BufferIn to small");
|
||||
_dbg_assert_msg_(WII_IPC_NET, BufferOutSize==0x20, "NET_KD_TIME: Set RTC Counter BufferOut to small");
|
||||
|
||||
for (int i=0; i<0x20; i++)
|
||||
{
|
||||
m_RtcCounter[i] = Memory::Read_U8(BufferIn+i);
|
||||
}
|
||||
|
||||
// send back for sync?? at least there is a out buffer...
|
||||
for (int i=0; i<0x20; i++)
|
||||
{
|
||||
Memory::Write_U8(m_RtcCounter[i], BufferOut+i);
|
||||
}
|
||||
|
||||
u64 rtctime = Memory::Read_U64(BufferIn+4);
|
||||
Memory::Write_U32(0, BufferOut);
|
||||
Memory::Write_U64(rtctime + timediff, BufferOut+4);
|
||||
|
||||
INFO_LOG(WII_IPC_NET, "NET_KD_TIME: Set RTC Counter");
|
||||
|
||||
Memory::Write_U32(0, _CommandAddress + 0x4);
|
||||
return true;
|
||||
}
|
||||
|
||||
case IOCTL_NW24_GET_TIME_DIFF:
|
||||
{
|
||||
Memory::Write_U32(0, BufferOut);
|
||||
Memory::Write_U64(timediff, BufferOut+4);
|
||||
INFO_LOG(WII_IPC_NET, "NET_KD_TIME: Get time diff");
|
||||
|
||||
Memory::Write_U32(0, _CommandAddress + 0x4);
|
||||
return true;
|
||||
}
|
||||
|
||||
case IOCTL_NW24_GET_TIME_DIFF: // Input: none, Output: 32
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_NET, "%s - IOCtl:\n"
|
||||
" Parameter: 0x%x (0x17 NWC24iSetRtcCounter) \n"
|
||||
@ -234,7 +247,7 @@ private:
|
||||
u8 m_RtcCounter[0x20];
|
||||
};
|
||||
|
||||
// **********************************************************************************
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CWII_IPC_HLE_Device_net_ip_top : public IWII_IPC_HLE_Device
|
||||
{
|
||||
public:
|
||||
@ -248,7 +261,12 @@ public:
|
||||
virtual bool IOCtlV(u32 _CommandAddress);
|
||||
|
||||
private:
|
||||
enum {
|
||||
#ifdef _WIN32
|
||||
WSADATA InitData;
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
IOCTL_SO_ACCEPT = 1,
|
||||
IOCTL_SO_BIND,
|
||||
IOCTL_SO_CLOSE,
|
||||
@ -287,6 +305,7 @@ private:
|
||||
};
|
||||
|
||||
u32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize);
|
||||
u32 ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer CommandBuffer);
|
||||
};
|
||||
|
||||
// **********************************************************************************
|
||||
@ -303,16 +322,23 @@ public:
|
||||
virtual bool IOCtlV(u32 _CommandAddress);
|
||||
|
||||
private:
|
||||
enum {
|
||||
IOCTLV_NCD_UNK1 = 0x1, // NCDLockWirelessDriver
|
||||
IOCTLV_NCD_UNK2 = 0x2, // NCDUnlockWirelessDriver
|
||||
IOCTLV_NCD_READCONFIG = 0x3, // NCDReadConfig?
|
||||
IOCTLV_NCD_UNK4 = 0x4,
|
||||
IOCTLV_NCD_GETLINKSTATUS = 0x7, // NCDGetLinkStatus
|
||||
IOCTLV_NCD_GETWIRELESSMACADDRESS = 0x8, // NCDGetWirelessMacAddress
|
||||
enum
|
||||
{
|
||||
IOCTLV_NCD_LOCKWIRELESSDRIVER = 0x1, // NCDLockWirelessDriver
|
||||
IOCTLV_NCD_UNLOCKWIRELESSDRIVER = 0x2, // NCDUnlockWirelessDriver
|
||||
IOCTLV_NCD_GETCONFIG = 0x3, // NCDiGetConfig
|
||||
IOCTLV_NCD_SETCONFIG = 0x4, // NCDiSetConfig
|
||||
IOCTLV_NCD_READCONFIG = 0x5,
|
||||
IOCTLV_NCD_WRITECONFIG = 0x6,
|
||||
IOCTLV_NCD_GETLINKSTATUS = 0x7, // NCDGetLinkStatus
|
||||
IOCTLV_NCD_GETWIRELESSMACADDRESS = 0x8, // NCDGetWirelessMacAddress
|
||||
};
|
||||
|
||||
network_config_t m_Ifconfig;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("",on)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
467
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
Normal file
467
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
Normal file
@ -0,0 +1,467 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4748)
|
||||
#pragma optimize("",off)
|
||||
#endif
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include "FileUtil.h"
|
||||
#include "WII_IPC_HLE_Device_net_ssl.h"
|
||||
|
||||
CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName)
|
||||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
{
|
||||
SSL_library_init();
|
||||
sslfds[0] = NULL;
|
||||
sslfds[1] = NULL;
|
||||
sslfds[2] = NULL;
|
||||
sslfds[3] = NULL;
|
||||
}
|
||||
|
||||
CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
|
||||
{
|
||||
}
|
||||
|
||||
int CWII_IPC_HLE_Device_net_ssl::getSSLFreeID()
|
||||
{
|
||||
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++)
|
||||
{
|
||||
if (sslfds[i] == NULL)
|
||||
return i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bool CWII_IPC_HLE_Device_net_ssl::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
|
||||
m_Active = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWII_IPC_HLE_Device_net_ssl::Close(u32 _CommandAddress, bool _bForce)
|
||||
{
|
||||
if (!_bForce)
|
||||
Memory::Write_U32(0, _CommandAddress + 4);
|
||||
m_Active = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWII_IPC_HLE_Device_net_ssl::IOCtl(u32 _CommandAddress)
|
||||
{
|
||||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
|
||||
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
|
||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
||||
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
|
||||
u32 Command = Memory::Read_U32(_CommandAddress + 0x0C);
|
||||
|
||||
u32 ReturnValue = ExecuteCommand(Command, BufferIn, BufferInSize, BufferOut, BufferOutSize);
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||
{
|
||||
u32 ReturnValue = 0;
|
||||
SIOCtlVBuffer CommandBuffer(_CommandAddress);
|
||||
|
||||
ReturnValue = ExecuteCommandV(CommandBuffer.Parameter, CommandBuffer);
|
||||
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer CommandBuffer)
|
||||
{
|
||||
u32 returnValue = 0;
|
||||
|
||||
u32 _BufferIn = 0, _BufferIn2 = 0, _BufferIn3 = 0;
|
||||
u32 BufferInSize = 0, BufferInSize2 = 0, BufferInSize3 = 0;
|
||||
|
||||
u32 _BufferOut = 0, _BufferOut2 = 0, _BufferOut3 = 0;
|
||||
u32 BufferOutSize = 0, BufferOutSize2 = 0, BufferOutSize3 = 0;
|
||||
|
||||
if (CommandBuffer.InBuffer.size() > 0)
|
||||
{
|
||||
_BufferIn = CommandBuffer.InBuffer.at(0).m_Address;
|
||||
BufferInSize = CommandBuffer.InBuffer.at(0).m_Size;
|
||||
}
|
||||
if (CommandBuffer.InBuffer.size() > 1)
|
||||
{
|
||||
_BufferIn2 = CommandBuffer.InBuffer.at(1).m_Address;
|
||||
BufferInSize2 = CommandBuffer.InBuffer.at(1).m_Size;
|
||||
}
|
||||
if (CommandBuffer.InBuffer.size() > 2)
|
||||
{
|
||||
_BufferIn3 = CommandBuffer.InBuffer.at(2).m_Address;
|
||||
BufferInSize3 = CommandBuffer.InBuffer.at(2).m_Size;
|
||||
}
|
||||
|
||||
if (CommandBuffer.PayloadBuffer.size() > 0)
|
||||
{
|
||||
_BufferOut = CommandBuffer.PayloadBuffer.at(0).m_Address;
|
||||
BufferOutSize = CommandBuffer.PayloadBuffer.at(0).m_Size;
|
||||
}
|
||||
if (CommandBuffer.PayloadBuffer.size() > 1)
|
||||
{
|
||||
_BufferOut2 = CommandBuffer.PayloadBuffer.at(1).m_Address;
|
||||
BufferOutSize2 = CommandBuffer.PayloadBuffer.at(1).m_Size;
|
||||
}
|
||||
if (CommandBuffer.PayloadBuffer.size() > 2)
|
||||
{
|
||||
_BufferOut3 = CommandBuffer.PayloadBuffer.at(2).m_Address;
|
||||
BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size;
|
||||
}
|
||||
|
||||
switch (_Parameter)
|
||||
{
|
||||
case IOCTLV_NET_SSL_NEW:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
char out2[256];
|
||||
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
Memory::ReadBigEData((u8*)out2, _BufferOut2, 256);
|
||||
|
||||
int freeSSL = this->getSSLFreeID();
|
||||
if (freeSSL)
|
||||
{
|
||||
Memory::Write_U32(freeSSL, _BufferIn);
|
||||
|
||||
SSL_CTX* ctx = SSL_CTX_new(SSLv23_method());
|
||||
|
||||
//SSL_CTX_set_options(ctx,0);
|
||||
|
||||
SSL* ssl = SSL_new(ctx);
|
||||
sslfds[freeSSL-1] = ssl;
|
||||
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_NEW "
|
||||
"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);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_SHUTDOWN:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
SSL_CTX* ctx = sslfds[sslID]->ctx;
|
||||
SSL_shutdown(sslfds[sslID]);
|
||||
if (ctx)
|
||||
SSL_CTX_free(ctx);
|
||||
sslfds[sslID] = NULL;
|
||||
Memory::Write_U32(0, _BufferIn);
|
||||
}
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_SHUTDOWN "
|
||||
"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);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
||||
{
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
"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);
|
||||
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
char out2[32];
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
Memory::ReadBigEData((u8*)out2, _BufferOut2, 32);
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
SSL* ssl = sslfds[sslID];
|
||||
|
||||
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
|
||||
FILE * clientca = fopen((cert_base_path + "clientca.cer").c_str(), "rb");
|
||||
if (clientca == NULL)
|
||||
break;
|
||||
|
||||
X509 *cert = d2i_X509_fp(clientca, NULL);
|
||||
fclose(clientca);
|
||||
|
||||
FILE * clientcakey = fopen((cert_base_path + "clientcakey.der").c_str(), "rb");
|
||||
if (clientcakey == NULL)
|
||||
break;
|
||||
|
||||
|
||||
EVP_PKEY * key = d2i_PrivateKey_fp(clientcakey, NULL);
|
||||
|
||||
|
||||
if (SSL_use_certificate(ssl,cert) <= 0)
|
||||
break;
|
||||
if (SSL_use_PrivateKey(ssl,key) <= 0)
|
||||
break;
|
||||
|
||||
|
||||
if (!SSL_check_private_key(ssl))
|
||||
break;
|
||||
|
||||
if (cert)
|
||||
X509_free(cert);
|
||||
if (key)
|
||||
EVP_PKEY_free(key);
|
||||
|
||||
/*PKCS12 *p12;
|
||||
|
||||
FILE* f = fopen("c:\\wii_retail.p12", "rb");
|
||||
|
||||
if (!f)
|
||||
break;
|
||||
|
||||
|
||||
p12 = d2i_PKCS12_fp(f, NULL);
|
||||
fclose(f);
|
||||
if (!p12)
|
||||
break;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
X509 *cert = NULL;
|
||||
STACK_OF(X509) *ca = sk_X509_new_null();
|
||||
|
||||
PKCS12_PBE_add();
|
||||
|
||||
if (!PKCS12_parse(p12, "", &pkey, &cert, &ca))
|
||||
break;
|
||||
|
||||
if (cert) {
|
||||
SSL_CTX_use_certificate(ssl->ctx, cert);
|
||||
X509_free(cert);
|
||||
}
|
||||
if (pkey)
|
||||
{
|
||||
SSL_CTX_use_PrivateKey(ssl->ctx, pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < sk_X509_num(ca); i++) {
|
||||
X509 *cert2 = sk_X509_value(ca, i);
|
||||
|
||||
char buf[200];
|
||||
|
||||
X509_NAME_oneline(X509_get_subject_name(cert2), buf, sizeof(buf));
|
||||
SSL_CTX_add_extra_chain_cert(ssl->ctx, cert2);
|
||||
|
||||
}
|
||||
sk_X509_free(ca);
|
||||
|
||||
PKCS12_free(p12);
|
||||
*/
|
||||
|
||||
//SSL_CTX_use_certificate_chain_file(ssl->ctx, (char*)ssl->cert);
|
||||
Memory::Write_U32(0, _BufferIn);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_SETBUILTINROOTCA:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
char out2[32];
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
Memory::ReadBigEData((u8*)out2, _BufferOut2, 32);
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
|
||||
Memory::Write_U32(0, _BufferIn);
|
||||
}
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||
"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);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_CONNECT:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
char out2[32];
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
Memory::ReadBigEData((u8*)out2, _BufferOut2, 32);
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
int sock = Memory::Read_U32(_BufferOut2);
|
||||
SSL* ssl = sslfds[sslID];
|
||||
SSL_set_fd(ssl,sock);
|
||||
returnValue = SSL_connect(ssl);
|
||||
Memory::Write_U32(0, _BufferIn);
|
||||
}
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_CONNECT "
|
||||
"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);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
SSL* ssl = sslfds[sslID];
|
||||
returnValue = SSL_do_handshake(ssl);
|
||||
if (returnValue == 1)
|
||||
Memory::Write_U32(0, _BufferIn);
|
||||
}
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_DOHANDSHAKE "
|
||||
"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);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
{
|
||||
char in1[32];
|
||||
char out1[32];
|
||||
char out2[256];
|
||||
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
Memory::ReadBigEData((u8*)out2, _BufferOut2, 256);
|
||||
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
SSL* ssl = sslfds[sslID];
|
||||
returnValue = SSL_write(ssl, Memory::GetPointer(_BufferOut2), BufferOutSize2);
|
||||
Memory::Write_U32(returnValue, _BufferIn);
|
||||
returnValue = 0;
|
||||
}
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request 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));
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_READ:
|
||||
{
|
||||
char in1[32];
|
||||
char in2[256];
|
||||
char out1[32];
|
||||
memset(in2, 0, 256);
|
||||
Memory::ReadBigEData((u8*)in1, _BufferIn, 32);
|
||||
//Memory::ReadBigEData((u8*)in2, _BufferIn2, BufferInSize2);
|
||||
Memory::ReadBigEData((u8*)out1, _BufferOut, 32);
|
||||
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (sslID >= 0 && sslID < NET_SSL_MAXINSTANCES && sslfds[sslID] != NULL)
|
||||
{
|
||||
SSL* ssl = sslfds[sslID];
|
||||
returnValue = SSL_read(ssl, Memory::GetPointer(_BufferIn2), BufferInSize2);
|
||||
Memory::Write_U32(returnValue, _BufferIn);
|
||||
//returnValue = 0;
|
||||
}
|
||||
strncpy(in2, (char*)Memory::GetPointer(_BufferIn2), BufferInSize2);
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request IOCTLV_NET_SSL_READ(%d) %s "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
returnValue, in2,
|
||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
||||
_BufferIn3, BufferInSize3, _BufferOut, BufferOutSize,
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtlV request %x "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
_Parameter,
|
||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
||||
_BufferIn3, BufferInSize3, _BufferOut, BufferOutSize,
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command,
|
||||
u32 _BufferIn, u32 BufferInSize,
|
||||
u32 _BufferOut, u32 BufferOutSize)
|
||||
{
|
||||
switch (_Command)
|
||||
{
|
||||
default:
|
||||
{
|
||||
INFO_LOG(WII_IPC_NET, "/dev/net/ssl::IOCtl request %x "
|
||||
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
_Command,
|
||||
_BufferIn, BufferInSize, _BufferOut, BufferOutSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("",on)
|
||||
#endif
|
82
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h
Normal file
82
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h
Normal file
@ -0,0 +1,82 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _WII_IPC_HLE_DEVICE_NET_SSL_H_
|
||||
#define _WII_IPC_HLE_DEVICE_NET_SSL_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4748)
|
||||
#pragma optimize("",off)
|
||||
#endif
|
||||
|
||||
#include "WII_IPC_HLE_Device.h"
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#define NET_SSL_MAXINSTANCES 4
|
||||
|
||||
class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device
|
||||
{
|
||||
public:
|
||||
|
||||
CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName);
|
||||
|
||||
virtual ~CWII_IPC_HLE_Device_net_ssl();
|
||||
|
||||
virtual bool Open(u32 _CommandAddress, u32 _Mode);
|
||||
|
||||
virtual bool Close(u32 _CommandAddress, bool _bForce);
|
||||
|
||||
virtual bool IOCtl(u32 _CommandAddress);
|
||||
virtual bool IOCtlV(u32 _CommandAddress);
|
||||
int getSSLFreeID();
|
||||
|
||||
private:
|
||||
SSL * sslfds[NET_SSL_MAXINSTANCES];
|
||||
enum
|
||||
{
|
||||
IOCTLV_NET_SSL_NEW = 0x01,
|
||||
IOCTLV_NET_SSL_CONNECT = 0x02,
|
||||
IOCTLV_NET_SSL_DOHANDSHAKE = 0x03,
|
||||
IOCTLV_NET_SSL_READ = 0x04,
|
||||
IOCTLV_NET_SSL_WRITE = 0x05,
|
||||
IOCTLV_NET_SSL_SHUTDOWN = 0x06,
|
||||
IOCTLV_NET_SSL_SETCLIENTCERT = 0x07,
|
||||
IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT = 0x08,
|
||||
IOCTLV_NET_SSL_REMOVECLIENTCERT = 0x09,
|
||||
IOCTLV_NET_SSL_SETROOTCA = 0x0A,
|
||||
IOCTLV_NET_SSL_SETROOTCADEFAULT = 0x0B,
|
||||
IOCTLV_NET_SSL_DOHANDSHAKEEX = 0x0C,
|
||||
IOCTLV_NET_SSL_SETBUILTINROOTCA = 0x0D,
|
||||
IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = 0x0E,
|
||||
IOCTLV_NET_SSL_DISABLEVERIFYOPTIONFORDEBUG = 0x0F,
|
||||
IOCTLV_NET_SSL_DEBUGGETVERSION = 0x14,
|
||||
IOCTLV_NET_SSL_DEBUGGETTIME = 0x15,
|
||||
};
|
||||
|
||||
|
||||
u32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize);
|
||||
u32 ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer CommandBuffer);
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("",off)
|
||||
#endif
|
||||
|
||||
#endif
|
178
Source/Core/Core/Src/IPC_HLE/fakepoll.h
Normal file
178
Source/Core/Core/Src/IPC_HLE/fakepoll.h
Normal file
@ -0,0 +1,178 @@
|
||||
// fakepoll.h
|
||||
// poll using select
|
||||
//Matthew Parlane sourced this from http://www.sealiesoftware.com/
|
||||
//Was listed as "Public domain." as of 31/07/2010
|
||||
|
||||
// Warning: a call to this poll() takes about 4K of stack space.
|
||||
|
||||
// Greg Parker gparker-web@sealiesoftware.com December 2000
|
||||
// This code is in the public domain and may be copied or modified without
|
||||
// permission.
|
||||
|
||||
// Updated May 2002:
|
||||
// * fix crash when an fd is less than 0
|
||||
// * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
|
||||
// * don't set POLLIN or POLLOUT in revents if it wasn't requested
|
||||
// in events (only happens when an fd is in the poll set twice)
|
||||
|
||||
#if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
|
||||
|
||||
#ifndef _FAKE_POLL_H
|
||||
#define _FAKE_POLL_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4748)
|
||||
#pragma optimize("",off)
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct pollfd {
|
||||
int fd; /* file desc to poll */
|
||||
short events; /* events of interest on fd */
|
||||
short revents; /* events that occurred on fd */
|
||||
} pollfd_t;
|
||||
|
||||
#define EINVAL 22
|
||||
// poll flags
|
||||
#define POLLIN 0x0001
|
||||
#define POLLOUT 0x0008
|
||||
#define POLLERR 0x0040
|
||||
|
||||
// synonyms
|
||||
#define POLLNORM POLLIN
|
||||
#define POLLPRI POLLIN
|
||||
#define POLLRDNORM POLLIN
|
||||
#define POLLRDBAND POLLIN
|
||||
#define POLLWRNORM POLLOUT
|
||||
#define POLLWRBAND POLLOUT
|
||||
|
||||
// ignored
|
||||
#define POLLHUP 0x0010
|
||||
#define POLLNVAL 0x0020
|
||||
|
||||
inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timeval *tvp;
|
||||
fd_set readFDs, writeFDs, exceptFDs;
|
||||
fd_set *readp, *writep, *exceptp;
|
||||
struct pollfd *pollEnd, *p;
|
||||
int selected;
|
||||
int result;
|
||||
int maxFD;
|
||||
|
||||
if (!pollSet) {
|
||||
pollEnd = NULL;
|
||||
readp = NULL;
|
||||
writep = NULL;
|
||||
exceptp = NULL;
|
||||
maxFD = 0;
|
||||
}
|
||||
else {
|
||||
pollEnd = pollSet + pollCount;
|
||||
readp = &readFDs;
|
||||
writep = &writeFDs;
|
||||
exceptp = &exceptFDs;
|
||||
|
||||
FD_ZERO(readp);
|
||||
FD_ZERO(writep);
|
||||
FD_ZERO(exceptp);
|
||||
|
||||
// Find the biggest fd in the poll set
|
||||
maxFD = 0;
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
if (p->fd > maxFD) maxFD = p->fd;
|
||||
}
|
||||
|
||||
// Transcribe flags from the poll set to the fd sets
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
if (p->fd < 0) {
|
||||
// Negative fd checks nothing and always reports zero
|
||||
} else {
|
||||
if (p->events & POLLIN) FD_SET(p->fd, readp);
|
||||
if (p->events & POLLOUT) FD_SET(p->fd, writep);
|
||||
if (p->events != 0) FD_SET(p->fd, exceptp);
|
||||
// POLLERR is never set coming in; poll() always reports errors
|
||||
// But don't report if we're not listening to anything at all.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// poll timeout is in milliseconds. Convert to struct timeval.
|
||||
// poll timeout == -1 : wait forever : select timeout of NULL
|
||||
// poll timeout == 0 : return immediately : select timeout of zero
|
||||
if (pollTimeout >= 0) {
|
||||
tv.tv_sec = pollTimeout / 1000;
|
||||
tv.tv_usec = (pollTimeout % 1000) * 1000;
|
||||
tvp = &tv;
|
||||
} else {
|
||||
tvp = NULL;
|
||||
}
|
||||
|
||||
|
||||
selected = select(maxFD+1, readp, writep, exceptp, tvp);
|
||||
|
||||
|
||||
if (selected < 0) {
|
||||
// Error during select
|
||||
result = -1;
|
||||
}
|
||||
else if (selected > 0) {
|
||||
// Select found something
|
||||
// Transcribe result from fd sets to poll set.
|
||||
// Also count the number of selected fds. poll returns the
|
||||
// number of ready fds; select returns the number of bits set.
|
||||
int polled = 0;
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
p->revents = 0;
|
||||
if (p->fd < 0) {
|
||||
// Negative fd always reports zero
|
||||
} else {
|
||||
int isToRead = FD_ISSET(p->fd, readp);
|
||||
if ((p->events & POLLIN) && isToRead) {
|
||||
p->revents |= POLLIN;
|
||||
}
|
||||
|
||||
int isToWrite = FD_ISSET(p->fd, writep);
|
||||
if ((p->events & POLLOUT) && isToWrite) {
|
||||
p->revents |= POLLOUT;
|
||||
}
|
||||
|
||||
int isToError = FD_ISSET(p->fd, exceptp);
|
||||
if ((p->events != 0) && isToError) {
|
||||
p->revents |= POLLERR;
|
||||
}
|
||||
|
||||
if (p->revents) polled++;
|
||||
}
|
||||
}
|
||||
result = polled;
|
||||
}
|
||||
else {
|
||||
// selected == 0, select timed out before anything happened
|
||||
// Clear all result bits and return zero.
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
p->revents = 0;
|
||||
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma optimize("",on)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#else // (_WIN32_WINNT < _WIN32_WINNT_VISTA)
|
||||
|
||||
typedef pollfd pollfd_t;
|
||||
#define poll WSAPoll
|
||||
|
||||
#endif
|
@ -10,6 +10,9 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32d.lib;ssleay32d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
@ -11,6 +11,9 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
@ -24,6 +24,7 @@
|
||||
<Link>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<AdditionalDependencies>libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>..\..\..\Externals\SDL\$(PlatformName);..\..\..\Externals\GLew;..\..\..\Externals\Cg;..\..\..\Externals\portaudio\$(PlatformName)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\Externals\SDL\$(PlatformName);..\..\..\Externals\GLew;..\..\..\Externals\Cg;..\..\..\Externals\portaudio\$(PlatformName);..\..\..\Externals\openssl\$(PlatformName)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>portaudio.lib;dsound.lib;dxerr.lib;iphlpapi.lib;winmm.lib;setupapi.lib;xinput.lib;vfw32.lib;cg.lib;cgGL.lib;opengl32.lib;glew32s.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>..\..\..\Externals\SDL\$(PlatformName);..\..\..\Externals\GLew;..\..\..\Externals\Cg64;..\..\..\Externals\portaudio\$(PlatformName)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>..\..\..\Externals\SDL\$(PlatformName);..\..\..\Externals\GLew;..\..\..\Externals\Cg64;..\..\..\Externals\portaudio\$(PlatformName);..\..\..\Externals\openssl\$(PlatformName)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>portaudio.lib;dsound.lib;dxerr.lib;iphlpapi.lib;winmm.lib;setupapi.lib;xinput.lib;vfw32.lib;cg.lib;cgGL.lib;opengl32.lib;glew64s.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user