mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-06 01:12:33 +00:00
added socket creation
This commit is contained in:
parent
5d5118f12f
commit
aed5853242
@ -1,17 +1,33 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <common/singleton.h>
|
||||||
#include <core/libraries/libs.h>
|
#include <core/libraries/libs.h>
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
int PS4_SYSV_ABI posix_socket(int domain, int type, int protocol) {}
|
int PS4_SYSV_ABI posix_socket(int domain, int type, int protocol) {
|
||||||
int PS4_SYSV_ABI posix_connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {}
|
auto* socket = Common::Singleton<NetPosixInternal>::Instance();
|
||||||
u32 PS4_SYSV_ABI posix_htonl(u32 hostlong) {}
|
return socket->create_socket(domain, type, protocol);
|
||||||
u16 PS4_SYSV_ABI posix_htons(u16 hostshort) {}
|
}
|
||||||
int PS4_SYSV_ABI posix_bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {}
|
int PS4_SYSV_ABI posix_connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {
|
||||||
int PS4_SYSV_ABI posix_listen(int sockfd, int backlog) {}
|
return 0;
|
||||||
int PS4_SYSV_ABI posix_accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen) {}
|
}
|
||||||
|
u32 PS4_SYSV_ABI posix_htonl(u32 hostlong) {
|
||||||
|
return htonl(hostlong);
|
||||||
|
}
|
||||||
|
u16 PS4_SYSV_ABI posix_htons(u16 hostshort) {
|
||||||
|
return htons(hostshort);
|
||||||
|
}
|
||||||
|
int PS4_SYSV_ABI posix_bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int PS4_SYSV_ABI posix_listen(int sockfd, int backlog) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int PS4_SYSV_ABI posix_accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterNet(Core::Loader::SymbolsResolver* sym) {
|
void RegisterNet(Core::Loader::SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("XVL8So3QJUk", "libkernel", 1, "libkernel", 1, 1, posix_connect);
|
LIB_FUNCTION("XVL8So3QJUk", "libkernel", 1, "libkernel", 1, 1, posix_connect);
|
||||||
@ -22,4 +38,12 @@ void RegisterNet(Core::Loader::SymbolsResolver* sym) {
|
|||||||
LIB_FUNCTION("pxnCmagrtao", "libkernel", 1, "libkernel", 1, 1, posix_listen);
|
LIB_FUNCTION("pxnCmagrtao", "libkernel", 1, "libkernel", 1, 1, posix_listen);
|
||||||
LIB_FUNCTION("3e+4Iv7IJ8U", "libkernel", 1, "libkernel", 1, 1, posix_accept);
|
LIB_FUNCTION("3e+4Iv7IJ8U", "libkernel", 1, "libkernel", 1, 1, posix_accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NetPosixInternal::create_socket(int domain, int type, int protocol) {
|
||||||
|
s_socket sock = socket(domain, type, protocol);
|
||||||
|
auto id = ++next_id;
|
||||||
|
socks.emplace(id, sock);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
@ -8,10 +8,18 @@
|
|||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <WS2tcpip.h>
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||||
|
#include <Ws2tcpip.h>
|
||||||
|
#include <iphlpapi.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
typedef SOCKET s_socket;
|
||||||
#else
|
#else
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
typedef int s_socket;
|
||||||
#endif
|
#endif
|
||||||
|
#include <mutex>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class NativeClock;
|
class NativeClock;
|
||||||
@ -32,4 +40,18 @@ int PS4_SYSV_ABI posix_accept(int sockfd, struct sockaddr* addr, socklen_t* addr
|
|||||||
|
|
||||||
void RegisterNet(Core::Loader::SymbolsResolver* sym);
|
void RegisterNet(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
|
class NetPosixInternal {
|
||||||
|
public:
|
||||||
|
explicit NetPosixInternal() = default;
|
||||||
|
~NetPosixInternal() = default;
|
||||||
|
int create_socket(int domain, int type, int protocol);
|
||||||
|
|
||||||
|
public:
|
||||||
|
s_socket sock;
|
||||||
|
std::mutex m_mutex;
|
||||||
|
typedef std::map<int, s_socket> NetSockets;
|
||||||
|
NetSockets socks;
|
||||||
|
int next_id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
#ifdef ENABLE_DISCORD_RPC
|
#ifdef ENABLE_DISCORD_RPC
|
||||||
#include "common/discord_rpc_handler.h"
|
#include "common/discord_rpc_handler.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#endif
|
||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
#include "common/ntapi.h"
|
#include "common/ntapi.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
@ -49,6 +52,10 @@ Emulator::Emulator() {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Common::NtApi::Initialize();
|
Common::NtApi::Initialize();
|
||||||
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
|
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
|
||||||
|
// need to init this in order for winsock2 to work
|
||||||
|
WORD versionWanted = MAKEWORD(2, 2);
|
||||||
|
WSADATA wsaData;
|
||||||
|
WSAStartup(versionWanted, &wsaData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start logger.
|
// Start logger.
|
||||||
|
Loading…
Reference in New Issue
Block a user