From 6537741841ca6d9394dd3f7ff2541915bd354ed5 Mon Sep 17 00:00:00 2001 From: izzy Date: Tue, 3 Mar 2026 21:19:08 -0500 Subject: [PATCH] feat: `GetSystemTime` and `GetLocalTime` stubs --- .../Cross64/Cross64Extras/Cross64Stubs.h | 88 ++++++++++++++++++- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Cross64/Cross64Extras/Cross64Stubs.h b/Minecraft.Client/Cross64/Cross64Extras/Cross64Stubs.h index ed1eaa708..d6f6741d9 100644 --- a/Minecraft.Client/Cross64/Cross64Extras/Cross64Stubs.h +++ b/Minecraft.Client/Cross64/Cross64Extras/Cross64Stubs.h @@ -1,14 +1,94 @@ #pragma once #include "TLSStorage.h" +#include +using namespace std::chrono; + +// thread local storage + +inline DWORD TlsAlloc(VOID) { return TLSStorageCross64::Instance()->Alloc(); } + +typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; +} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; + +inline VOID GetSystemTime(LPSYSTEMTIME lpSystemTime) { + const auto dateTime = system_clock::now(); + const auto dp = floor(dateTime); + + const year_month_day ymd{dp}; + const hh_mm_ss hms{dateTime - dp}; + const weekday wd{dp}; + + lpSystemTime->wYear = ymd.year(); + lpSystemTime->wMonth = ymd.month(); + lpSystemTime->wDayOfWeek = wd.c_encoding(); // 0 = sunday, etc + lpSystemTime->wHour = hms.hours(); + lpSystemTime->wMinute = hms.minutes(); + lpSystemTime->wSecond = hms.seconds(); + + auto ms = duration_cast(hms.subseconds()); + lpSystemTime->wMilliseconds = ms.count(); +}; + +inline VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) { + const auto dateTime = system_clock::now(); + + const auto tz = current_zone(); + const auto tpl = tz->to_local(dateTime); + const auto dp = floor(tpl); + + const year_month_day ymd{dp}; + const hh_mm_ss hms{tpl - dp}; + const weekday wd{dp}; + + lpSystemTime->wYear = ymd.year(); + lpSystemTime->wMonth = ymd.month(); + lpSystemTime->wDayOfWeek = wd.c_encoding(); // 0 = sunday, etc + lpSystemTime->wHour = hms.hours(); + lpSystemTime->wMinute = hms.minutes(); + lpSystemTime->wSecond = hms.seconds(); + + auto ms = duration_cast(hms.subseconds()); + lpSystemTime->wMilliseconds = ms.count(); +}; + +// d3d11 stub work, i sure hope it does typedef struct _RECT { - LONG left; - LONG top; - LONG right; - LONG bottom; + LONG left; + LONG top; + LONG right; + LONG bottom; } RECT, *PRECT; +typedef enum D3D11_BLEND { + D3D11_BLEND_ZERO = 1, + D3D11_BLEND_ONE = 2, + D3D11_BLEND_SRC_COLOR = 3, + D3D11_BLEND_INV_SRC_COLOR = 4, + D3D11_BLEND_SRC_ALPHA = 5, + D3D11_BLEND_INV_SRC_ALPHA = 6, + D3D11_BLEND_DEST_ALPHA = 7, + D3D11_BLEND_INV_DEST_ALPHA = 8, + D3D11_BLEND_DEST_COLOR = 9, + D3D11_BLEND_INV_DEST_COLOR = 10, + D3D11_BLEND_SRC_ALPHA_SAT = 11, + D3D11_BLEND_BLEND_FACTOR = 14, + D3D11_BLEND_INV_BLEND_FACTOR = 15, + D3D11_BLEND_SRC1_COLOR = 16, + D3D11_BLEND_INV_SRC1_COLOR = 17, + D3D11_BLEND_SRC1_ALPHA = 18, + D3D11_BLEND_INV_SRC1_ALPHA = 19 +} D3D11_BLEND; + typedef void ID3D11Device; typedef void ID3D11DeviceContext; typedef void IDXGISwapChain;