2018-10-17 11:15:50 -06:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-10-09 17:15:07 -06:00
|
|
|
using System;
|
2018-02-28 13:58:04 -07:00
|
|
|
using System.Collections.Generic;
|
2018-10-09 17:15:07 -06:00
|
|
|
using System.Net;
|
|
|
|
using System.Net.Sockets;
|
|
|
|
using System.Text;
|
|
|
|
|
2019-09-18 18:45:11 -06:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
2018-02-28 13:58:04 -07:00
|
|
|
{
|
2019-07-10 09:59:54 -06:00
|
|
|
[Service("sfdnsres")]
|
2018-04-05 22:01:52 -06:00
|
|
|
class IResolver : IpcService
|
2018-02-28 13:58:04 -07:00
|
|
|
{
|
2019-07-11 19:13:43 -06:00
|
|
|
public IResolver(ServiceCtx context) { }
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private long SerializeHostEnt(ServiceCtx context, IPHostEntry hostEntry, List<IPAddress> addresses = null)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
long originalBufferPosition = context.Request.ReceiveBuff[0].Position;
|
|
|
|
long bufferPosition = originalBufferPosition;
|
|
|
|
long bufferSize = context.Request.ReceiveBuff[0].Size;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
string hostName = hostEntry.HostName + '\0';
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// h_name
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, Encoding.ASCII.GetBytes(hostName));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += hostName.Length;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// h_aliases list size
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder(hostEntry.Aliases.Length));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += 4;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// Actual aliases
|
2018-12-06 04:16:24 -07:00
|
|
|
foreach (string alias in hostEntry.Aliases)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, Encoding.ASCII.GetBytes(alias + '\0'));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += alias.Length + 1;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// h_addrtype but it's a short (also only support IPv4)
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder((short)2));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += 2;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// h_length but it's a short
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder((short)4));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += 2;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// Ip address count, we can only support ipv4 (blame Nintendo)
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, addresses != null ? IPAddress.HostToNetworkOrder(addresses.Count) : 0);
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += 4;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (addresses != null)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
foreach (IPAddress ip in addresses)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)bufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(ip.GetAddressBytes(), 0)));
|
2018-12-06 04:16:24 -07:00
|
|
|
bufferPosition += 4;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
return bufferPosition - originalBufferPosition;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private string GetGaiStringErrorFromErrorCode(GaiError errorCode)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
if (errorCode > GaiError.Max)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errorCode = GaiError.Max;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
switch (errorCode)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
|
|
|
case GaiError.AddressFamily:
|
|
|
|
return "Address family for hostname not supported";
|
|
|
|
case GaiError.Again:
|
|
|
|
return "Temporary failure in name resolution";
|
|
|
|
case GaiError.BadFlags:
|
|
|
|
return "Invalid value for ai_flags";
|
|
|
|
case GaiError.Fail:
|
|
|
|
return "Non-recoverable failure in name resolution";
|
|
|
|
case GaiError.Family:
|
|
|
|
return "ai_family not supported";
|
|
|
|
case GaiError.Memory:
|
|
|
|
return "Memory allocation failure";
|
|
|
|
case GaiError.NoData:
|
|
|
|
return "No address associated with hostname";
|
|
|
|
case GaiError.NoName:
|
|
|
|
return "hostname nor servname provided, or not known";
|
|
|
|
case GaiError.Service:
|
|
|
|
return "servname not supported for ai_socktype";
|
|
|
|
case GaiError.SocketType:
|
|
|
|
return "ai_socktype not supported";
|
|
|
|
case GaiError.System:
|
|
|
|
return "System error returned in errno";
|
|
|
|
case GaiError.BadHints:
|
|
|
|
return "Invalid value for hints";
|
|
|
|
case GaiError.Protocol:
|
|
|
|
return "Resolved protocol is unknown";
|
|
|
|
case GaiError.Overflow:
|
|
|
|
return "Argument buffer overflow";
|
|
|
|
case GaiError.Max:
|
|
|
|
return "Unknown error";
|
|
|
|
default:
|
|
|
|
return "Success";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private string GetHostStringErrorFromErrorCode(NetDbError errorCode)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
if (errorCode <= NetDbError.Internal)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
|
|
|
return "Resolver internal error";
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
switch (errorCode)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
case NetDbError.Success:
|
2018-10-09 17:15:07 -06:00
|
|
|
return "Resolver Error 0 (no error)";
|
2018-12-06 04:16:24 -07:00
|
|
|
case NetDbError.HostNotFound:
|
2018-10-09 17:15:07 -06:00
|
|
|
return "Unknown host";
|
2018-12-06 04:16:24 -07:00
|
|
|
case NetDbError.TryAgain:
|
2018-10-09 17:15:07 -06:00
|
|
|
return "Host name lookup failure";
|
2018-12-06 04:16:24 -07:00
|
|
|
case NetDbError.NoRecovery:
|
2018-10-09 17:15:07 -06:00
|
|
|
return "Unknown server error";
|
2018-12-06 04:16:24 -07:00
|
|
|
case NetDbError.NoData:
|
2018-10-09 17:15:07 -06:00
|
|
|
return "No address associated with name";
|
|
|
|
default:
|
|
|
|
return "Unknown resolver error";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
private List<IPAddress> GetIpv4Addresses(IPHostEntry hostEntry)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
List<IPAddress> result = new List<IPAddress>();
|
|
|
|
foreach (IPAddress ip in hostEntry.AddressList)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
|
|
|
result.Add(ip);
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
return result;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(0)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// SetDnsAddressesPrivate(u32, buffer<unknown, 5, 0>)
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode SetDnsAddressesPrivate(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
uint unknown0 = context.RequestData.ReadUInt32();
|
|
|
|
long bufferPosition = context.Request.SendBuff[0].Position;
|
|
|
|
long bufferSize = context.Request.SendBuff[0].Size;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake completeness.
|
2020-08-03 17:32:53 -06:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown0 });
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.NotAllocated;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(1)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// GetDnsAddressPrivate(u32) -> buffer<unknown, 6, 0>
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode GetDnsAddressesPrivate(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
uint unknown0 = context.RequestData.ReadUInt32();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake completeness.
|
2020-08-03 17:32:53 -06:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown0 });
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.NotAllocated;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(2)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// GetHostByName(u8, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>)
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode GetHostByName(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2020-05-03 16:54:50 -06:00
|
|
|
byte[] rawName = new byte[context.Request.SendBuff[0].Size];
|
|
|
|
|
|
|
|
context.Memory.Read((ulong)context.Request.SendBuff[0].Position, rawName);
|
|
|
|
|
|
|
|
string name = Encoding.ASCII.GetString(rawName).TrimEnd('\0');
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// TODO: use params
|
2018-12-06 04:16:24 -07:00
|
|
|
bool enableNsdResolve = context.RequestData.ReadInt32() == 1;
|
|
|
|
int timeOut = context.RequestData.ReadInt32();
|
|
|
|
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
IPHostEntry hostEntry = null;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
NetDbError netDbErrorCode = NetDbError.Success;
|
|
|
|
GaiError errno = GaiError.Overflow;
|
|
|
|
long serializedSize = 0;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (name.Length <= 255)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
hostEntry = Dns.GetHostEntry(name);
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
catch (SocketException exception)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.Internal;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (exception.ErrorCode == 11001)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.HostNotFound;
|
|
|
|
errno = GaiError.NoData;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11002)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.TryAgain;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11003)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.NoRecovery;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11004)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.NoData;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 10060)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errno = GaiError.Again;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.HostNotFound;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (hostEntry != null)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errno = GaiError.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
List<IPAddress> addresses = GetIpv4Addresses(hostEntry);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (addresses.Count == 0)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errno = GaiError.NoData;
|
|
|
|
netDbErrorCode = NetDbError.NoAddress;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
serializedSize = SerializeHostEnt(context, hostEntry, addresses);
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
context.ResponseData.Write((int)netDbErrorCode);
|
|
|
|
context.ResponseData.Write((int)errno);
|
|
|
|
context.ResponseData.Write(serializedSize);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(3)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// GetHostByAddr(u32, u32, u32, u64, pid, buffer<unknown, 5, 0>) -> (u32, u32, u32, buffer<unknown, 6, 0>)
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode GetHostByAddress(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2020-05-03 16:54:50 -06:00
|
|
|
byte[] rawIp = new byte[context.Request.SendBuff[0].Size];
|
|
|
|
|
|
|
|
context.Memory.Read((ulong)context.Request.SendBuff[0].Position, rawIp);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
|
|
|
// TODO: use params
|
2018-12-06 04:16:24 -07:00
|
|
|
uint socketLength = context.RequestData.ReadUInt32();
|
|
|
|
uint type = context.RequestData.ReadUInt32();
|
|
|
|
int timeOut = context.RequestData.ReadInt32();
|
|
|
|
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
IPHostEntry hostEntry = null;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
NetDbError netDbErrorCode = NetDbError.Success;
|
|
|
|
GaiError errno = GaiError.AddressFamily;
|
|
|
|
long serializedSize = 0;
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (rawIp.Length == 4)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
IPAddress address = new IPAddress(rawIp);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
hostEntry = Dns.GetHostEntry(address);
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
catch (SocketException exception)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.Internal;
|
|
|
|
if (exception.ErrorCode == 11001)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.HostNotFound;
|
|
|
|
errno = GaiError.NoData;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11002)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.TryAgain;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11003)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.NoRecovery;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 11004)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.NoData;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-12-06 04:16:24 -07:00
|
|
|
else if (exception.ErrorCode == 10060)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errno = GaiError.Again;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
netDbErrorCode = NetDbError.NoAddress;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (hostEntry != null)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
errno = GaiError.Success;
|
|
|
|
serializedSize = SerializeHostEnt(context, hostEntry, GetIpv4Addresses(hostEntry));
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
context.ResponseData.Write((int)netDbErrorCode);
|
|
|
|
context.ResponseData.Write((int)errno);
|
|
|
|
context.ResponseData.Write(serializedSize);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(4)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// GetHostStringError(u32) -> buffer<unknown, 6, 0>
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode GetHostStringError(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2019-07-14 13:04:38 -06:00
|
|
|
ResultCode resultCode = ResultCode.NotAllocated;
|
2018-12-06 04:16:24 -07:00
|
|
|
NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32();
|
|
|
|
string errorString = GetHostStringErrorFromErrorCode(errorCode);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
resultCode = 0;
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
return resultCode;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(5)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// GetGaiStringError(u32) -> buffer<unknown, 6, 0>
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode GetGaiStringError(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2019-07-14 13:04:38 -06:00
|
|
|
ResultCode resultCode = ResultCode.NotAllocated;
|
|
|
|
GaiError errorCode = (GaiError)context.RequestData.ReadInt32();
|
|
|
|
string errorString = GetGaiStringErrorFromErrorCode(errorCode);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
if (errorString.Length + 1 <= context.Request.ReceiveBuff[0].Size)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
resultCode = 0;
|
2020-05-03 16:54:50 -06:00
|
|
|
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, Encoding.ASCII.GetBytes(errorString + '\0'));
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
return resultCode;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(8)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// RequestCancelHandle(u64, pid) -> u32
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode RequestCancelHandle(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
ulong unknown0 = context.RequestData.ReadUInt64();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
context.ResponseData.Write(0);
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2020-08-03 17:32:53 -06:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown0 });
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(9)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// CancelSocketCall(u32, u64, pid)
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode CancelSocketCall(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
uint unknown0 = context.RequestData.ReadUInt32();
|
|
|
|
ulong unknown1 = context.RequestData.ReadUInt64();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2020-08-03 17:32:53 -06:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown0, unknown1 });
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 19:13:43 -06:00
|
|
|
[Command(11)]
|
2018-10-09 17:15:07 -06:00
|
|
|
// ClearDnsAddresses(u32)
|
2019-07-14 13:04:38 -06:00
|
|
|
public ResultCode ClearDnsAddresses(ServiceCtx context)
|
2018-10-09 17:15:07 -06:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
uint unknown0 = context.RequestData.ReadUInt32();
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2020-08-03 17:32:53 -06:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown0 });
|
2018-10-09 17:15:07 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-10-09 17:15:07 -06:00
|
|
|
}
|
2018-02-28 13:58:04 -07:00
|
|
|
}
|
2019-07-11 19:13:43 -06:00
|
|
|
}
|