[+] Windows 7 support
This commit is contained in:
parent
267c2216b0
commit
cbad382b6a
@ -34,6 +34,7 @@
|
|||||||
#include "CmdLine/CmdLine.hpp"
|
#include "CmdLine/CmdLine.hpp"
|
||||||
#include "Grug/AuGrug.hpp"
|
#include "Grug/AuGrug.hpp"
|
||||||
#include "Threading/AuSleep.hpp"
|
#include "Threading/AuSleep.hpp"
|
||||||
|
#include "Memory/Cache.hpp"
|
||||||
|
|
||||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||||
void LinuxSuperSecretIOTick();
|
void LinuxSuperSecretIOTick();
|
||||||
@ -56,6 +57,8 @@ static void Init()
|
|||||||
Aurora::Extensions::Win32::InitDarkMode();
|
Aurora::Extensions::Win32::InitDarkMode();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Aurora::Memory::Cache::InitCache();
|
||||||
|
|
||||||
Crypto::InitCrypto();
|
Crypto::InitCrypto();
|
||||||
Aurora::RNG::Init();
|
Aurora::RNG::Init();
|
||||||
Aurora::IO::TLS::TLSInit();
|
Aurora::IO::TLS::TLSInit();
|
||||||
|
@ -87,14 +87,11 @@ namespace Aurora::Console
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return fmt::format("{}[{}] {:<8} | {}{}",
|
return fmt::format("[{}] {:<8} | {}",
|
||||||
static_cast<EAnsiColor>(color) <= EAnsiColor::eEnumCount ?
|
|
||||||
kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(color)] :
|
|
||||||
"",
|
|
||||||
StringifyTime(gRuntimeConfig.console.stdOutShortTime),
|
StringifyTime(gRuntimeConfig.console.stdOutShortTime),
|
||||||
GetWrappedTag(),
|
GetWrappedTag(),
|
||||||
line,
|
line);//,
|
||||||
kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(EAnsiColor::eReset)]);
|
//kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(EAnsiColor::eReset)]);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <Source/Console/ConsoleTTY/ConsoleTTY.hpp>
|
#include <Source/Console/ConsoleTTY/ConsoleTTY.hpp>
|
||||||
|
|
||||||
|
#include "../ColorConvert.hpp"
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_POSIX_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_POSIX_DERIVED)
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
@ -805,9 +807,19 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
{
|
{
|
||||||
if (gRuntimeConfig.console.enableStdPassthrough ^ gRuntimeConfig.console.enableStdOut)
|
if (gRuntimeConfig.console.enableStdPassthrough ^ gRuntimeConfig.console.enableStdOut)
|
||||||
{
|
{
|
||||||
|
if (AuSwInfo::IsWindows10OrGreater() && AuSwInfo::GetPlatformInfo().uKernelPatch >= 10586)
|
||||||
|
{
|
||||||
|
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gSupportsColorOutput = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Enable escape processing; enable colored output
|
// Enable escape processing; enable colored output
|
||||||
dwMode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
dwMode |= ENABLE_PROCESSED_OUTPUT;
|
||||||
ok = SetConsoleMode(gOutputStream, dwMode);
|
ok = SetConsoleMode(gOutputStream, dwMode);
|
||||||
|
auto er = GetLastError();
|
||||||
SysAssert(ok, "Couldn't set console mode");
|
SysAssert(ok, "Couldn't set console mode");
|
||||||
|
|
||||||
// Set the output stream to use UTF-8
|
// Set the output stream to use UTF-8
|
||||||
@ -995,13 +1007,37 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
|
|
||||||
void WriteStdOut(AuUInt8 level, const ConsoleMessage &msg)
|
void WriteStdOut(AuUInt8 level, const ConsoleMessage &msg)
|
||||||
{
|
{
|
||||||
|
bool bUseAlt {};
|
||||||
auto writeLine = msg.ToConsole();
|
auto writeLine = msg.ToConsole();
|
||||||
|
|
||||||
|
if (!gSupportsColorOutput)
|
||||||
|
{
|
||||||
|
if (IsStdOutTTY())
|
||||||
|
{
|
||||||
|
bUseAlt = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *pAnsiCode =
|
||||||
|
static_cast<EAnsiColor>(msg.color) <= EAnsiColor::eEnumCount ?
|
||||||
|
kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(msg.color)] :
|
||||||
|
"";
|
||||||
|
|
||||||
|
writeLine = pAnsiCode + writeLine + kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(EAnsiColor::eReset)];
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
writeLine += '\r';
|
writeLine += '\r';
|
||||||
#endif
|
#endif
|
||||||
writeLine += '\n';
|
writeLine += '\n';
|
||||||
|
|
||||||
|
if (bUseAlt)
|
||||||
|
{
|
||||||
|
ConsoleTTY::TTYWrite(writeLine.c_str(), msg.color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(IO_POSIX_STREAMS)
|
#if defined(IO_POSIX_STREAMS)
|
||||||
if (Locale::GetInternalCodePage() == Locale::ECodePage::eUTF8)
|
if (Locale::GetInternalCodePage() == Locale::ECodePage::eUTF8)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,8 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
|
|
||||||
void WriteStdOut(AuUInt8 level, const ConsoleMessage &msg);
|
void WriteStdOut(AuUInt8 level, const ConsoleMessage &msg);
|
||||||
|
|
||||||
|
inline bool gSupportsColorOutput { true };
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
void ProcessCanonical(HANDLE h);
|
void ProcessCanonical(HANDLE h);
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "ConsoleTTY.Unix.hpp"
|
#include "ConsoleTTY.Unix.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../ColorConvert.hpp"
|
||||||
|
|
||||||
namespace Aurora::Console::ConsoleTTY
|
namespace Aurora::Console::ConsoleTTY
|
||||||
{
|
{
|
||||||
static AuThreads::ThreadUnique_t gConsoleTTYThread;
|
static AuThreads::ThreadUnique_t gConsoleTTYThread;
|
||||||
@ -784,7 +786,7 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
{
|
{
|
||||||
if (resChanged)
|
if (resChanged)
|
||||||
{
|
{
|
||||||
for (auto &message : this->screenBuffer)
|
for (auto &[color, message] : this->screenBuffer)
|
||||||
{
|
{
|
||||||
int anyLineRemoveEsc = message.rfind('\x1b', 0) == 0;
|
int anyLineRemoveEsc = message.rfind('\x1b', 0) == 0;
|
||||||
|
|
||||||
@ -833,7 +835,7 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
int idx = AuLocale::Encoding::CountUTF8Length({str.data(), AuMin<AuUInt>(str.size(), maxWidth + (anyLineRemoveEsc * 7))}, true);
|
int idx = AuLocale::Encoding::CountUTF8Length({str.data(), AuMin<AuUInt>(str.size(), maxWidth + (anyLineRemoveEsc * 7))}, true);
|
||||||
|
|
||||||
auto append = str.substr(0, idx);
|
auto append = str.substr(0, idx);
|
||||||
AuTryInsert(this->screenBuffer, append);
|
AuTryInsert(this->screenBuffer, AuMakePair(message.color, append));
|
||||||
|
|
||||||
str = str.substr(idx);
|
str = str.substr(idx);
|
||||||
this->bScreenBufferDoesntMap |= bool(str.size());
|
this->bScreenBufferDoesntMap |= bool(str.size());
|
||||||
@ -935,7 +937,9 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < delta; i++)
|
for (int i = 0; i < delta; i++)
|
||||||
{
|
{
|
||||||
WriteBuffered({GetLeftBorder() + this->leftLogPadding, i + drawPos}, this->screenBuffer[i + oldSize]);
|
auto &[color, message] = this->screenBuffer[i + oldSize];
|
||||||
|
|
||||||
|
WriteBufferedEx({GetLeftBorder() + this->leftLogPadding, i + drawPos}, color, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1129,7 +1133,8 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
DWORD idc;
|
DWORD idc;
|
||||||
WriteConsoleA(GetTTYHandle(), in.data(), AuUInt32(in.size()), &idc, NULL);
|
auto line2 = AuLocale::ConvertFromUTF8(in);
|
||||||
|
WriteConsoleW(GetTTYHandle(), line2.data(), AuUInt32(line2.size()), &idc, NULL);
|
||||||
#else
|
#else
|
||||||
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
|
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
|
||||||
#endif
|
#endif
|
||||||
@ -1174,13 +1179,64 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
DWORD idc;
|
DWORD idc;
|
||||||
WriteConsoleA(GetTTYHandle(), in.data(), AuUInt32(in.size()), &idc, NULL);
|
auto line2 = AuLocale::ConvertFromUTF8(in);
|
||||||
|
WriteConsoleW(GetTTYHandle(), line2.data(), AuUInt32(line2.size()), &idc, NULL);
|
||||||
#else
|
#else
|
||||||
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
|
ConsoleStd::WriteStdOutBlocking2(in.data(), in.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTYConsole::WriteBufferedEx(AuPair<AuUInt32, AuUInt32> pos, EAnsiColor color, const AuString &in)
|
||||||
|
{
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
RecordFunction(std::bind(&TTYConsole::WriteBufferedEx, this, pos, color, std::string(in)));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (in.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TTYSetPos(pos);
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
DWORD idc;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto hConsole = GetTTYHandle();
|
||||||
|
DWORD attrib {};
|
||||||
|
|
||||||
|
if (color != EAnsiColor::eEnumCount)
|
||||||
|
{
|
||||||
|
attrib |= kAnsiColorForegroundToNT[AuStaticCast<AuUInt>(color)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attrib = FOREGROUND_WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto line2 = AuLocale::ConvertFromUTF8(in);
|
||||||
|
SetConsoleTextAttribute(hConsole, attrib);
|
||||||
|
WriteConsoleW(hConsole, line2.data(), AuUInt32(line2.size()), &idc, NULL);
|
||||||
|
SetConsoleTextAttribute(hConsole, FOREGROUND_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//WriteConsoleA(GetTTYHandle(), in.data(), AuUInt32(in.size()), &idc, NULL);
|
||||||
|
#else
|
||||||
|
AuString writeLine;
|
||||||
|
|
||||||
|
const char *pAnsiCode =
|
||||||
|
static_cast<EAnsiColor>(color) <= EAnsiColor::eEnumCount ?
|
||||||
|
kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(color)] :
|
||||||
|
"";
|
||||||
|
|
||||||
|
writeLine = pAnsiCode + in + kAnsiColorForegroundToVirtualEscape[static_cast<AuUInt>(EAnsiColor::eReset)];
|
||||||
|
x
|
||||||
|
ConsoleStd::WriteStdOutBlocking2(writeLine.data(), writeLine.size());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void TTYConsole::RedrawBorders()
|
void TTYConsole::RedrawBorders()
|
||||||
{
|
{
|
||||||
TTYSetPos({});
|
TTYSetPos({});
|
||||||
@ -1620,7 +1676,9 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteBuffered({GetLeftBorder() + this->leftLogPadding, i + startIndex}, this->screenBuffer[strIdx]);
|
auto &[color, message] = this->screenBuffer[strIdx];
|
||||||
|
WriteBufferedEx({ GetLeftBorder() + this->leftLogPadding, i + drawPos }, color, message);
|
||||||
|
//WriteBuffered({GetLeftBorder() + this->leftLogPadding, i + startIndex}, this->screenBuffer[strIdx].second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
virtual AuUInt8 GetPaddingHeadOfLog() override;
|
virtual AuUInt8 GetPaddingHeadOfLog() override;
|
||||||
virtual AuUInt8 GetPaddingTopOfLog() override;
|
virtual AuUInt8 GetPaddingTopOfLog() override;
|
||||||
|
|
||||||
|
void WriteBufferedEx(AuPair<AuUInt32, AuUInt32> pos, EAnsiColor color, const AuString &in);
|
||||||
void WriteBuffered(AuPair<AuUInt32, AuUInt32> pos, const AuString &in);
|
void WriteBuffered(AuPair<AuUInt32, AuUInt32> pos, const AuString &in);
|
||||||
void WriteLine(int Y, const AuString &in);
|
void WriteLine(int Y, const AuString &in);
|
||||||
void BlankLine(int Y, bool borders = true);
|
void BlankLine(int Y, bool borders = true);
|
||||||
@ -189,7 +190,7 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
AuList<AuConsole::ConsoleMessage> messagesPending;
|
AuList<AuConsole::ConsoleMessage> messagesPending;
|
||||||
|
|
||||||
AuList<AuConsole::ConsoleMessage> messages;
|
AuList<AuConsole::ConsoleMessage> messages;
|
||||||
AuList<AuString> screenBuffer;
|
AuList<AuPair<AuConsole::EAnsiColor, AuString>> screenBuffer;
|
||||||
bool bScreenBufferDoesntMap {};
|
bool bScreenBufferDoesntMap {};
|
||||||
|
|
||||||
int iScrollPos { -1 };
|
int iScrollPos { -1 };
|
||||||
|
@ -14,6 +14,14 @@
|
|||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BOOL(__stdcall *GetSystemCpuSetInformation_f)(
|
||||||
|
PSYSTEM_CPU_SET_INFORMATION Information,
|
||||||
|
ULONG BufferLength,
|
||||||
|
PULONG ReturnedLength,
|
||||||
|
HANDLE Process,
|
||||||
|
ULONG Flags
|
||||||
|
);
|
||||||
|
|
||||||
namespace Aurora::HWInfo
|
namespace Aurora::HWInfo
|
||||||
{
|
{
|
||||||
static bool TrySetNtCpuSetInfoSlowExtended()
|
static bool TrySetNtCpuSetInfoSlowExtended()
|
||||||
@ -22,7 +30,14 @@ namespace Aurora::HWInfo
|
|||||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION sysinfo[128];
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION sysinfo[128];
|
||||||
DWORD length = {};
|
DWORD length = {};
|
||||||
|
|
||||||
if (!GetSystemCpuSetInformation(cpuSetInfo, sizeof(cpuSetInfo), &length, 0, 0))
|
GetSystemCpuSetInformation_f = AuReinterpretCast<decltype(GetSystemCpuSetInformation_f)>(GetProcAddress(GetModuleHandleW(L"Kernel32.dll"), "GetSystemCpuSetInformation"));
|
||||||
|
|
||||||
|
if (!GetSystemCpuSetInformation_f)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetSystemCpuSetInformation_f(cpuSetInfo, sizeof(cpuSetInfo), &length, 0, 0))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -181,7 +196,7 @@ namespace Aurora::HWInfo
|
|||||||
|
|
||||||
CpuBitId serverId;
|
CpuBitId serverId;
|
||||||
serverId.lower = mask;
|
serverId.lower = mask;
|
||||||
gCpuInfo.coreTopology.push_back(mask);
|
gCpuInfo.coreTopology.push_back(serverId);
|
||||||
|
|
||||||
int counter {};
|
int counter {};
|
||||||
unsigned long offset {}, tmp;
|
unsigned long offset {}, tmp;
|
||||||
@ -211,17 +226,19 @@ namespace Aurora::HWInfo
|
|||||||
if (hasHTCores && (tmp == 1))
|
if (hasHTCores && (tmp == 1))
|
||||||
{
|
{
|
||||||
AuUInt8 idx {};
|
AuUInt8 idx {};
|
||||||
if (serverId.CpuBitScanForward(idx, 0))
|
while (serverId.CpuBitScanForward(idx, idx))
|
||||||
{
|
{
|
||||||
gCpuInfo.maskECores.Add(idx);
|
gCpuInfo.maskECores.Add(idx);
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AuUInt8 idx {};
|
AuUInt8 idx {};
|
||||||
if (serverId.CpuBitScanForward(idx, 0))
|
while (serverId.CpuBitScanForward(idx, idx))
|
||||||
{
|
{
|
||||||
gCpuInfo.maskPCores.Add(idx);
|
gCpuInfo.maskPCores.Add(idx);
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
gCpuInfo.pCoreTopology.push_back(mask);
|
gCpuInfo.pCoreTopology.push_back(mask);
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,12 @@ namespace Aurora::IO::Net
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iRet {};
|
||||||
HANDLE hHandle = NULL;
|
HANDLE hHandle = NULL;
|
||||||
int iRet = GetAddrInfoExW(AuLocale::ConvertFromUTF8(this->hostname).data(),
|
|
||||||
|
if (GetAddrInfoExCancel_f)
|
||||||
|
{
|
||||||
|
iRet = GetAddrInfoExW(AuLocale::ConvertFromUTF8(this->hostname).data(),
|
||||||
nullptr,
|
nullptr,
|
||||||
NS_DNS,
|
NS_DNS,
|
||||||
nullptr,
|
nullptr,
|
||||||
@ -64,6 +68,21 @@ namespace Aurora::IO::Net
|
|||||||
&this->overlapped,
|
&this->overlapped,
|
||||||
NULL,
|
NULL,
|
||||||
&hHandle);
|
&hHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iRet = GetAddrInfoExW(AuLocale::ConvertFromUTF8(this->hostname).data(),
|
||||||
|
nullptr,
|
||||||
|
NS_DNS,
|
||||||
|
nullptr,
|
||||||
|
&infoEx,
|
||||||
|
&this->resultHandle_,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
this->hName_ = hHandle;
|
this->hName_ = hHandle;
|
||||||
return this->FinishOperationEx(AuSharedFromThis(),
|
return this->FinishOperationEx(AuSharedFromThis(),
|
||||||
this->pWorker_,
|
this->pWorker_,
|
||||||
@ -141,7 +160,10 @@ namespace Aurora::IO::Net
|
|||||||
auto hHandle = AuExchange(this->hName_, (HANDLE)NULL);
|
auto hHandle = AuExchange(this->hName_, (HANDLE)NULL);
|
||||||
if (hHandle != NULL)
|
if (hHandle != NULL)
|
||||||
{
|
{
|
||||||
::GetAddrInfoExCancel(&hHandle);
|
if (GetAddrInfoExCancel_f)
|
||||||
|
{
|
||||||
|
GetAddrInfoExCancel_f(&hHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!this->HasComplete())
|
while (!this->HasComplete())
|
||||||
|
@ -24,6 +24,9 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
wVersionRequested = MAKEWORD(2, 2);
|
wVersionRequested = MAKEWORD(2, 2);
|
||||||
gWin32NetReady = !WSAStartup(wVersionRequested, &wsaData);
|
gWin32NetReady = !WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
|
GetAddrInfoExCancel_f = AuReinterpretCast<decltype(GetAddrInfoExCancel_f)>(GetProcAddress(GetModuleHandleW(L"Ws2_32.dll"), "GetAddrInfoExCancel"));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||||
|
@ -43,5 +43,11 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
static const auto kDefaultStreamSize = 32 * 1024; // ~960 clients for 30MB of 2x 32KiB streams. Seems... reasonable.
|
static const auto kDefaultStreamSize = 32 * 1024; // ~960 clients for 30MB of 2x 32KiB streams. Seems... reasonable.
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
inline INT(__stdcall *GetAddrInfoExCancel_f)(
|
||||||
|
LPHANDLE lpHandle
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool IsNetReady();
|
bool IsNetReady();
|
||||||
}
|
}
|
@ -25,10 +25,27 @@
|
|||||||
|
|
||||||
namespace Aurora::Memory::Cache
|
namespace Aurora::Memory::Cache
|
||||||
{
|
{
|
||||||
|
struct WIN32_MEMORY_RANGE_ENTRY2 {
|
||||||
|
PVOID VirtualAddress;
|
||||||
|
SIZE_T NumberOfBytes;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOL (__stdcall *PrefetchVirtualMemory_f)(
|
||||||
|
HANDLE hProcess,
|
||||||
|
ULONG_PTR NumberOfEntries,
|
||||||
|
WIN32_MEMORY_RANGE_ENTRY2* VirtualAddresses,
|
||||||
|
ULONG Flags
|
||||||
|
);
|
||||||
|
|
||||||
AUKN_SYM void OptimizeAddressRangeOnCore(const AuList<AuPair<AuUInt, AuUInt>> &addressRanges)
|
AUKN_SYM void OptimizeAddressRangeOnCore(const AuList<AuPair<AuUInt, AuUInt>> &addressRanges)
|
||||||
{
|
{
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
AuList<WIN32_MEMORY_RANGE_ENTRY> arry;
|
AuList<WIN32_MEMORY_RANGE_ENTRY2> arry;
|
||||||
|
|
||||||
|
if (!PrefetchVirtualMemory_f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AuTryResize(arry, addressRanges.size()))
|
if (!AuTryResize(arry, addressRanges.size()))
|
||||||
{
|
{
|
||||||
@ -63,7 +80,7 @@ namespace Aurora::Memory::Cache
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
if (!PrefetchVirtualMemory(GetCurrentProcess(), arry.size(), arry.data(), 0))
|
if (!PrefetchVirtualMemory_f(GetCurrentProcess(), arry.size(), arry.data(), 0))
|
||||||
{
|
{
|
||||||
SysPushErrorHAL("Couldn't poke memory physical memory into virtual address space (array)");
|
SysPushErrorHAL("Couldn't poke memory physical memory into virtual address space (array)");
|
||||||
}
|
}
|
||||||
@ -112,4 +129,11 @@ namespace Aurora::Memory::Cache
|
|||||||
__clear_cache(AuReinterpretCast<const char *>(base), AuReinterpretCast<const char *>(base) + length);
|
__clear_cache(AuReinterpretCast<const char *>(base), AuReinterpretCast<const char *>(base) + length);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitCache()
|
||||||
|
{
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
PrefetchVirtualMemory_f = AuReinterpretCast<decltype(PrefetchVirtualMemory_f)>(GetProcAddress(GetModuleHandleW(L"Kernel32.dll"), "PrefetchVirtualMemory"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,5 +9,5 @@
|
|||||||
|
|
||||||
namespace Aurora::Memory::Cache
|
namespace Aurora::Memory::Cache
|
||||||
{
|
{
|
||||||
|
void InitCache();
|
||||||
}
|
}
|
@ -90,7 +90,13 @@ namespace Aurora::RNG
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#if !defined(AURORA_DONT_PREFER_WIN32_USERLAND_AES_RNG)
|
#if !defined(AURORA_DONT_PREFER_WIN32_USERLAND_AES_RNG)
|
||||||
if (::BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, reinterpret_cast<PUCHAR>(pBuf), uLen, 0) == 0)
|
|
||||||
|
#if !defined(BCRYPT_RNG_ALG_HANDLE)
|
||||||
|
#define BCRYPT_RNG_ALG_HANDLE ((BCRYPT_ALG_HANDLE) 0x00000081)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (AuSwInfo::IsWindows10OrGreater() &&
|
||||||
|
::BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, reinterpret_cast<PUCHAR>(pBuf), uLen, 0) == 0)
|
||||||
{
|
{
|
||||||
return uLen;
|
return uLen;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//_WIN32_WINNT=0x0601
|
#define _WIN32_WINNT 0x0601
|
||||||
#include <SDKDDKVer.h>
|
#include <SDKDDKVer.h>
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
@ -25,6 +25,24 @@
|
|||||||
#include <Aux_ulib.h>
|
#include <Aux_ulib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
BOOL (*SetThreadInformation_f)(
|
||||||
|
HANDLE hThread,
|
||||||
|
DWORD ThreadInformationClass,
|
||||||
|
LPVOID ThreadInformation,
|
||||||
|
DWORD ThreadInformationSize
|
||||||
|
);
|
||||||
|
|
||||||
|
static auto const kThreadPowerThrottling = 3;
|
||||||
|
|
||||||
|
struct THREAD_POWER_THROTTLING_STATE2
|
||||||
|
{
|
||||||
|
ULONG Version;
|
||||||
|
ULONG ControlMask;
|
||||||
|
ULONG StateMask;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "AuSpawnThread.hpp"
|
#include "AuSpawnThread.hpp"
|
||||||
|
|
||||||
namespace Aurora
|
namespace Aurora
|
||||||
@ -798,7 +816,7 @@ namespace Aurora::Threading::Threads
|
|||||||
SysPushErrorHAL("Couldn't update thread priority");
|
SysPushErrorHAL("Couldn't update thread priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
THREAD_POWER_THROTTLING_STATE throttlingState {};
|
THREAD_POWER_THROTTLING_STATE2 throttlingState {};
|
||||||
throttlingState.Version = THREAD_POWER_THROTTLING_CURRENT_VERSION;
|
throttlingState.Version = THREAD_POWER_THROTTLING_CURRENT_VERSION;
|
||||||
|
|
||||||
switch (throttle)
|
switch (throttle)
|
||||||
@ -817,10 +835,13 @@ namespace Aurora::Threading::Threads
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetThreadInformation(this->handle_,
|
if (SetThreadInformation_f)
|
||||||
ThreadPowerThrottling,
|
{
|
||||||
|
SetThreadInformation_f(this->handle_,
|
||||||
|
kThreadPowerThrottling,
|
||||||
&throttlingState,
|
&throttlingState,
|
||||||
sizeof(throttlingState));
|
sizeof(throttlingState));
|
||||||
|
}
|
||||||
|
|
||||||
//#elif defined(AURORA_IS_XNU_DERIVED)
|
//#elif defined(AURORA_IS_XNU_DERIVED)
|
||||||
|
|
||||||
@ -1159,6 +1180,11 @@ namespace Aurora::Threading::Threads
|
|||||||
#if defined(AURORA_PLATFORM_WIN32)
|
#if defined(AURORA_PLATFORM_WIN32)
|
||||||
AuxUlibInitialize();
|
AuxUlibInitialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
SetThreadInformation_f = AuReinterpretCast<decltype(SetThreadInformation_f)>(GetProcAddress(GetModuleHandleW(L"Kernel32.dll"), "SetThreadInformation"));
|
||||||
|
#endif
|
||||||
|
|
||||||
AttachSignalKiller();
|
AttachSignalKiller();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user