[XAM/Net] inet_addr: Handle edge cases

This commit is contained in:
Gliniak 2021-05-22 20:56:59 +02:00 committed by Rick Gibbed
parent 29f7987401
commit fbc31652e0
1 changed files with 11 additions and 0 deletions

View File

@ -598,7 +598,18 @@ dword_result_t NetDll_XNetQosListen(dword_t caller, lpvoid_t id, lpvoid_t data,
DECLARE_XAM_EXPORT1(NetDll_XNetQosListen, kNetworking, kStub);
dword_result_t NetDll_inet_addr(lpstring_t addr_ptr) {
if (!addr_ptr) {
return -1;
}
uint32_t addr = inet_addr(addr_ptr);
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-inet_addr#return-value
// Based on console research it seems like x360 uses old version of inet_addr
// In case of empty string it return 0 instead of -1
if (addr == -1 && !addr_ptr.value().length()) {
return 0;
}
return xe::byte_swap(addr);
}
DECLARE_XAM_EXPORT1(NetDll_inet_addr, kNetworking, kImplemented);