mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-11-30 02:56:42 -08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c864f69b5 | ||
|
|
5bb526c4ba |
No files matched your search
@@ -1,4 +1,7 @@
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
name: Continuous Integration
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "external/rapidjson/document.h"
|
||||
#include "cfg/screen_resize.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std::placeholders;
|
||||
using namespace rapidjson;
|
||||
|
||||
|
||||
+95
-60
@@ -1,8 +1,5 @@
|
||||
#define SECURITY_WIN32
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@@ -94,7 +91,6 @@ namespace avs {
|
||||
};
|
||||
|
||||
static constexpr size_t alignment = 16;
|
||||
using handshake_clock = std::chrono::steady_clock;
|
||||
|
||||
static int io_buf_init(struct io_buf *buf, size_t initial_capacity) {
|
||||
uint8_t *tmp_bytes = nullptr;
|
||||
@@ -265,35 +261,89 @@ arg_fail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tls_recv_handshake(
|
||||
static int impl_socket_recv_all(
|
||||
struct avs_net_sock_desc_work *work,
|
||||
handshake_clock::time_point deadline)
|
||||
struct io_buf *buf,
|
||||
uint32_t recv_timeout)
|
||||
{
|
||||
const auto now = handshake_clock::now();
|
||||
if (now < deadline) {
|
||||
const auto remaining = std::chrono::ceil<std::chrono::milliseconds>(deadline - now);
|
||||
avs_net_poll_fd poll_fd {};
|
||||
poll_fd.socket = work->sock_fd;
|
||||
poll_fd.events = AVS_NET_POLL_POLLIN;
|
||||
uint8_t old_non_blocking_value = 0;
|
||||
uint8_t non_blocking = 0;
|
||||
avs_net_size_t old_non_blocking_value_size = 0;
|
||||
struct avs_net_poll_fd poll_fds[1] {};
|
||||
int ret = 0;
|
||||
|
||||
if (work == nullptr || work->sock_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto err = io_buf_validate(buf);
|
||||
|
||||
if (err != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf->pos == buf->limit) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
poll_fds[0].socket = work->sock_fd;
|
||||
poll_fds[0].events = AVS_NET_POLL_POLLIN;
|
||||
|
||||
non_blocking = 1;
|
||||
old_non_blocking_value_size = sizeof(old_non_blocking_value);
|
||||
|
||||
core::avs_net_getsockopt(work->sock_fd, AVS_SO_NONBLOCK, &old_non_blocking_value, &old_non_blocking_value_size);
|
||||
core::avs_net_setsockopt(work->sock_fd, AVS_SO_NONBLOCK, &non_blocking, sizeof(non_blocking));
|
||||
|
||||
while (true) {
|
||||
auto result = core::avs_net_poll(poll_fds, std::size(poll_fds), recv_timeout);
|
||||
|
||||
const auto result = core::avs_net_poll(&poll_fd, 1,
|
||||
static_cast<int>(remaining.count()));
|
||||
if (result < 0) {
|
||||
log_warning("avs::ssl", "avs_net_poll failed during TLS handshake: 0x{:08x}", result);
|
||||
return result;
|
||||
log_warning("avs::ssl", "avs_net_poll failed: 0x{:08x}", result);
|
||||
|
||||
ret = -1;
|
||||
|
||||
goto out;
|
||||
}
|
||||
if (result > 0) {
|
||||
if (poll_fd.r_events & AVS_NET_POLL_POLLIN) {
|
||||
return impl_socket_recv(work, &work->recv_buf);
|
||||
|
||||
if (!result) {
|
||||
#if 0
|
||||
log_warning("avs::ssl", "socket timeout, no data received after {} milliseconds", recv_timeout);
|
||||
#endif
|
||||
|
||||
goto poll_succeeded_or_empty;
|
||||
}
|
||||
|
||||
if (poll_fds[0].r_events & AVS_NET_POLL_POLLIN) {
|
||||
result = core::avs_net_recv(work->sock_fd, &buf->bytes[buf->pos], buf->limit - buf->pos);
|
||||
|
||||
if (result < 0) {
|
||||
break;
|
||||
}
|
||||
log_warning("avs::ssl", "unexpected TLS handshake poll events: 0x{:04x}",
|
||||
poll_fd.r_events);
|
||||
return core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_SC_BADMSG);
|
||||
|
||||
if (result == 0) {
|
||||
log_misc("avs::ssl", "connection closed");
|
||||
|
||||
ret = -1;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
#if 0
|
||||
log_warning("avs::ssl", "socket({}) got {} bytes during handshake", work->sock_fd, result);
|
||||
#endif
|
||||
|
||||
buf->pos += result;
|
||||
}
|
||||
}
|
||||
|
||||
log_warning("avs::ssl", "timed out waiting for TLS handshake data");
|
||||
return core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_NET_TIMEOUT);
|
||||
poll_succeeded_or_empty:
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
core::avs_net_setsockopt(work->sock_fd, AVS_SO_NONBLOCK, &old_non_blocking_value, sizeof(old_non_blocking_value));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int impl_socket_send(struct avs_net_sock_desc_work *work, struct io_buf *buf) {
|
||||
@@ -847,7 +897,6 @@ arg_fail:
|
||||
uint32_t address,
|
||||
avs_net_port_t port)
|
||||
{
|
||||
constexpr uint32_t default_handshake_timeout_ms = 10000;
|
||||
constexpr uint32_t security_context_flags = ISC_REQ_CONFIDENTIALITY |
|
||||
ISC_REQ_INTEGRITY |
|
||||
ISC_REQ_STREAM |
|
||||
@@ -863,7 +912,6 @@ arg_fail:
|
||||
SECURITY_STATUS status = SEC_E_OK;
|
||||
int result = 0;
|
||||
int err = 0;
|
||||
handshake_clock::time_point handshake_deadline;
|
||||
|
||||
char hostname[256];
|
||||
|
||||
@@ -939,11 +987,6 @@ arg_fail:
|
||||
goto first_isc_fail;
|
||||
}
|
||||
|
||||
// share one receive budget across all TLS flights and partial reads
|
||||
handshake_deadline = handshake_clock::now() + std::chrono::milliseconds(work->recv_timeout
|
||||
? std::min<uint32_t>(work->recv_timeout, INT_MAX)
|
||||
: default_handshake_timeout_ms);
|
||||
|
||||
while (status != SEC_E_OK) {
|
||||
switch (status) {
|
||||
case SEC_I_CONTINUE_NEEDED:
|
||||
@@ -959,26 +1002,33 @@ arg_fail:
|
||||
}
|
||||
}
|
||||
|
||||
if (work->recv_buf.pos == 0) {
|
||||
err = tls_recv_handshake(work, handshake_deadline);
|
||||
if (err != 0) {
|
||||
goto loop_fail;
|
||||
}
|
||||
work->recv_buf.pos = 0;
|
||||
work->recv_buf.limit = work->recv_buf.capacity;
|
||||
|
||||
err = impl_socket_recv_all(work, &work->recv_buf, 100);
|
||||
|
||||
if (err != 0) {
|
||||
goto loop_fail;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SEC_E_INCOMPLETE_MESSAGE:
|
||||
if (work->recv_buf.pos == work->recv_buf.capacity) {
|
||||
err = io_buf_grow(&work->recv_buf);
|
||||
if (err != 0) {
|
||||
log_warning("avs::ssl", "failed to grow TLS handshake receive buffer");
|
||||
goto loop_fail;
|
||||
}
|
||||
work->recv_buf.limit = work->recv_buf.capacity;
|
||||
case SEC_E_INCOMPLETE_MESSAGE:
|
||||
if (recv_bufs[1].BufferType != SECBUFFER_MISSING) {
|
||||
err = core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_SC_BADMSG);
|
||||
|
||||
goto loop_fail;
|
||||
}
|
||||
|
||||
err = tls_recv_handshake(work, handshake_deadline);
|
||||
err = io_buf_grow_to(&work->recv_buf, work->recv_buf.pos + recv_bufs[1].cbBuffer);
|
||||
|
||||
if (err != 0) {
|
||||
goto loop_fail;
|
||||
}
|
||||
|
||||
work->recv_buf.limit = work->recv_buf.capacity;
|
||||
|
||||
err = impl_socket_recv(work, &work->recv_buf);
|
||||
|
||||
if (err != 0) {
|
||||
goto loop_fail;
|
||||
@@ -1043,21 +1093,6 @@ arg_fail:
|
||||
&send_vec,
|
||||
&attributes,
|
||||
nullptr);
|
||||
|
||||
if (status == SEC_I_CONTINUE_NEEDED || status == SEC_E_OK) {
|
||||
const auto extra = recv_bufs[1].BufferType == SECBUFFER_EXTRA
|
||||
? recv_bufs[1].cbBuffer : 0;
|
||||
if (extra > 0) {
|
||||
const auto tail = work->recv_buf.bytes + (work->recv_buf.pos - extra);
|
||||
if (status == SEC_E_OK) {
|
||||
work->recv_ciphertext_tail = tail;
|
||||
work->recv_ciphertext_count = extra;
|
||||
} else {
|
||||
memmove(work->recv_buf.bytes, tail, extra);
|
||||
}
|
||||
}
|
||||
work->recv_buf.pos = extra;
|
||||
}
|
||||
}
|
||||
|
||||
log_misc("avs::ssl", "TLS handshake complete");
|
||||
|
||||
@@ -48,8 +48,6 @@ struct OptionDefinition {
|
||||
std::string file_extension = "";
|
||||
|
||||
std::string quick_setting_category = "";
|
||||
|
||||
bool trim_whitespace = false;
|
||||
};
|
||||
|
||||
class Option {
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ RUN useradd user -m && echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
RUN su user -c "cd /tmp/ && git clone https://aur.archlinux.org/yay-bin.git --depth=1 && cd yay-bin && makepkg --noconfirm -si && yay --noconfirm -S mingw-w64-cmake"
|
||||
|
||||
RUN mkdir -p /opt/llvm-mingw-xp \
|
||||
&& curl -fsSL "https://github.com/mon/llvm-mingw-xp/releases/download/llvm-mingw-xp-23.1.5/llvm-mingw-xp-23.1.5-msvcrt-ubuntu-22.04-x86_64.tar.xz" \
|
||||
&& curl -fsSL "https://github.com/mon/llvm-mingw-xp/releases/download/llvm-mingw-xp-22.1.0/llvm-mingw-llvm-mingw-xp-22.1.0-msvcrt-ubuntu-22.04-x86_64.tar.xz" \
|
||||
| tar -xJ --strip-components=1 -C /opt/llvm-mingw-xp
|
||||
ENV PATH="$PATH:/opt/llvm-mingw-xp/bin"
|
||||
|
||||
RUN curl -fsSL "https://github.com/mon/windows-dll-compat-checker/releases/download/v1.6/windows_dll_compat_checker-linux-x86_64.tar.xz" \
|
||||
RUN curl -fsSL "https://github.com/mon/windows-dll-compat-checker/releases/download/v1.3/windows_dll_compat_checker-linux-x86_64.tar.xz" \
|
||||
| tar -xJ -C /usr/local/bin
|
||||
|
||||
# Stock makepkg.conf builds serially; this makes the AUR compiles below parallel.
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/libraryhook.h"
|
||||
#ifdef SPICE64
|
||||
#include <mutex>
|
||||
#include <psapi.h>
|
||||
#include "hooks/graphics/nvapi_impl.h"
|
||||
#endif
|
||||
@@ -217,16 +216,10 @@ namespace games::sdvx {
|
||||
}
|
||||
|
||||
// store a cached copy of the first successful call to K32GetPerformanceInfo
|
||||
static std::mutex cache_mutex;
|
||||
static PERFORMANCE_INFORMATION cached {};
|
||||
static bool cached_valid = false;
|
||||
std::lock_guard<std::mutex> lock(cache_mutex);
|
||||
static const BOOL cached_valid = K32GetPerformanceInfo_orig(&cached, sizeof(cached));
|
||||
if (!cached_valid) {
|
||||
if (!K32GetPerformanceInfo_orig(info, cb)) {
|
||||
return FALSE;
|
||||
}
|
||||
cached = *info;
|
||||
cached_valid = true;
|
||||
return K32GetPerformanceInfo_orig(info, cb);
|
||||
}
|
||||
|
||||
// return the cached copy to avoid performance issues with the game calling this every frame
|
||||
|
||||
@@ -138,7 +138,6 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.setting_name = "example.com:8083",
|
||||
.category = "Network",
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::PCBID] = {
|
||||
.title = "PCBID",
|
||||
@@ -149,7 +148,6 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.category = "Network",
|
||||
.sensitive = true,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1Card] = {
|
||||
.title = "Player 1 Card",
|
||||
@@ -161,7 +159,6 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player2Card] = {
|
||||
.title = "Player 2 Card",
|
||||
@@ -173,7 +170,6 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1PinMacro] = {
|
||||
.title = "Player 1 PIN Macro",
|
||||
|
||||
@@ -5282,16 +5282,9 @@ namespace overlay::windows {
|
||||
ImGui::InputTextWithHint("", hint, buffer, sizeof(buffer) - 1);
|
||||
// would like to use IsItemDeactivatedAfterEdit but can't handle the case when window is closed while editing
|
||||
if (ImGui::IsItemEdited()) {
|
||||
// trim whitespace to prevent copy/paste errors
|
||||
auto value = definition.trim_whitespace ?
|
||||
strtrim(buffer) : std::string(buffer);
|
||||
|
||||
if (option.value != value) {
|
||||
this->options_dirty = true;
|
||||
option.value = std::move(value);
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
}
|
||||
|
||||
this->options_dirty = true;
|
||||
option.value = buffer;
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
ImGui::HelpTooltip(definition.desc.c_str());
|
||||
|
||||
Reference in new issue
Block a user