#include #include #include #include #include #include static const char SOCKET_ADDRESS[108] = { 0, 'L', 'R', 'S', 'S', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static int REGISTRY_SOCKET = -1; NTSTATUS LrcSocketAddress(char Buffer[108]) { std::memcpy(Buffer, SOCKET_ADDRESS, 108); return STATUS_SUCCESS; } NTSTATUS LrcOpenRegistry() { // This may not work if the thing got closed somehow :> if (REGISTRY_SOCKET == -1) { REGISTRY_SOCKET = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (REGISTRY_SOCKET < 0) { REGISTRY_SOCKET = -1; return STATUS_INTERNAL_ERROR; } int tmp = 1; if (setsockopt(REGISTRY_SOCKET, SOL_SOCKET, SO_PASSCRED, &tmp, sizeof(tmp)) < 0) { close(REGISTRY_SOCKET); REGISTRY_SOCKET = -1; return STATUS_INTERNAL_ERROR; } struct sockaddr_un sockaddr { .sun_family = AF_UNIX, .sun_path = {} }; LrcSocketAddress(sockaddr.sun_path); if (connect(REGISTRY_SOCKET, reinterpret_cast(&sockaddr), sizeof(sockaddr)) < 0) { close(REGISTRY_SOCKET); REGISTRY_SOCKET = -1; return STATUS_INTERNAL_ERROR; } return STATUS_SUCCESS; } else return STATUS_SUCCESS; }