[*] NT: Further reduce Win32 link-time requirements cont (1948dd0c
)
This commit is contained in:
parent
1948dd0c1a
commit
d45dc977d8
@ -30,6 +30,7 @@ namespace Aurora
|
|||||||
ADD_LOAD_LIB(BCrypt);
|
ADD_LOAD_LIB(BCrypt);
|
||||||
ADD_LOAD_LIB(Theme);
|
ADD_LOAD_LIB(Theme);
|
||||||
ADD_LOAD_LIB(Shell);
|
ADD_LOAD_LIB(Shell);
|
||||||
|
ADD_LOAD_LIB(PSAPILegacy);
|
||||||
|
|
||||||
#define ADD_GET_PROC(name, proc) \
|
#define ADD_GET_PROC(name, proc) \
|
||||||
if (h ## name) \
|
if (h ## name) \
|
||||||
@ -51,6 +52,20 @@ namespace Aurora
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ADD_GET_PROC_BI2(name, name2, proc, proc2) \
|
||||||
|
p ## proc2 = nullptr; \
|
||||||
|
if (h ## name) \
|
||||||
|
{ \
|
||||||
|
p ## proc2 = AuReinterpretCast<decltype(p ## proc2)>(GetProcAddress(h ## name, #proc)); \
|
||||||
|
} \
|
||||||
|
if (!p ## proc2) \
|
||||||
|
{ \
|
||||||
|
if (h ## name2) \
|
||||||
|
{ \
|
||||||
|
p ## proc2 = AuReinterpretCast<decltype(p ## proc2)>(GetProcAddress(h ## name2, #proc2)); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define ADD_GET_PROC_INTERNAL_MAP(name, proc, symbol) \
|
#define ADD_GET_PROC_INTERNAL_MAP(name, proc, symbol) \
|
||||||
if (h ## name) \
|
if (h ## name) \
|
||||||
{ \
|
{ \
|
||||||
@ -86,6 +101,15 @@ namespace Aurora
|
|||||||
ADD_GET_PROC(Kernel32, FindFirstStreamW)
|
ADD_GET_PROC(Kernel32, FindFirstStreamW)
|
||||||
ADD_GET_PROC(Kernel32, FindNextStreamW)
|
ADD_GET_PROC(Kernel32, FindNextStreamW)
|
||||||
ADD_GET_PROC(Kernel32, FindClose)
|
ADD_GET_PROC(Kernel32, FindClose)
|
||||||
|
ADD_GET_PROC(Kernel32, CancelIoEx)
|
||||||
|
ADD_GET_PROC(Kernel32, CancelSynchronousIo)
|
||||||
|
ADD_GET_PROC(Kernel32, SetFileInformationByHandle)
|
||||||
|
ADD_GET_PROC(Kernel32, GetLocaleInfoEx)
|
||||||
|
ADD_GET_PROC(Kernel32, LCIDToLocaleName)
|
||||||
|
ADD_GET_PROC(Kernel32, GetLocaleInfoW)
|
||||||
|
ADD_GET_PROC(Kernel32, GetThreadId)
|
||||||
|
|
||||||
|
ADD_GET_PROC_BI2(Kernel32, PSAPILegacy, K32GetProcessMemoryInfo, GetProcessMemoryInfo)
|
||||||
|
|
||||||
ADD_GET_PROC(Sync, WaitOnAddress)
|
ADD_GET_PROC(Sync, WaitOnAddress)
|
||||||
ADD_GET_PROC(Sync, WakeByAddressSingle)
|
ADD_GET_PROC(Sync, WakeByAddressSingle)
|
||||||
@ -116,6 +140,17 @@ namespace Aurora
|
|||||||
pVirtualAlloc2 = VirtualAlloc2FromApp;
|
pVirtualAlloc2 = VirtualAlloc2FromApp;
|
||||||
pMapViewOfFile3 = MapViewOfFile3FromApp;
|
pMapViewOfFile3 = MapViewOfFile3FromApp;
|
||||||
|
|
||||||
|
pCancelIoEx = CancelIoEx;
|
||||||
|
pCancelSynchronousIo = CancelSynchronousIo;
|
||||||
|
|
||||||
|
pGetLocaleInfoEx = GetLocaleInfoEx;
|
||||||
|
|
||||||
|
pLCIDToLocaleName = LCIDToLocaleName;
|
||||||
|
|
||||||
|
pSetFileInformationByHandle = SetFileInformationByHandle;
|
||||||
|
|
||||||
|
pFindClose = FindClose;
|
||||||
|
|
||||||
pGetSystemCpuSetInformation = GetSystemCpuSetInformation;
|
pGetSystemCpuSetInformation = GetSystemCpuSetInformation;
|
||||||
pGetLogicalProcessorInformation = GetLogicalProcessorInformation;
|
pGetLogicalProcessorInformation = GetLogicalProcessorInformation;
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
***/
|
***/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct _PROCESS_MEMORY_COUNTERS;
|
||||||
|
|
||||||
namespace Aurora
|
namespace Aurora
|
||||||
{
|
{
|
||||||
void InitNTAddresses();
|
void InitNTAddresses();
|
||||||
@ -20,6 +22,7 @@ namespace Aurora
|
|||||||
static const wchar_t *kBCryptDllName { L"bcrypt.dll" };
|
static const wchar_t *kBCryptDllName { L"bcrypt.dll" };
|
||||||
static const wchar_t *kThemeDllName { L"UxTheme.dll" };
|
static const wchar_t *kThemeDllName { L"UxTheme.dll" };
|
||||||
static const wchar_t *kShellDllName { L"Shell32.dll" };
|
static const wchar_t *kShellDllName { L"Shell32.dll" };
|
||||||
|
static const wchar_t *kPSAPILegacyDllName { L"psapi.dll" };
|
||||||
|
|
||||||
struct WIN32_MEMORY_RANGE_ENTRY2
|
struct WIN32_MEMORY_RANGE_ENTRY2
|
||||||
{
|
{
|
||||||
@ -277,6 +280,53 @@ namespace Aurora
|
|||||||
HANDLE hFindFile
|
HANDLE hFindFile
|
||||||
);
|
);
|
||||||
|
|
||||||
|
inline BOOL(__stdcall *pCancelIoEx)(
|
||||||
|
HANDLE hFile,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
);
|
||||||
|
|
||||||
|
inline BOOL(__stdcall *pCancelSynchronousIo)(
|
||||||
|
HANDLE hThread
|
||||||
|
);
|
||||||
|
|
||||||
|
inline BOOL(__stdcall *pGetProcessMemoryInfo)(
|
||||||
|
HANDLE Process,
|
||||||
|
::_PROCESS_MEMORY_COUNTERS *ppsmemCounters,
|
||||||
|
DWORD cb
|
||||||
|
);
|
||||||
|
|
||||||
|
inline BOOL(__stdcall *pSetFileInformationByHandle)(
|
||||||
|
HANDLE hFile,
|
||||||
|
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
|
||||||
|
LPVOID lpFileInformation,
|
||||||
|
DWORD dwBufferSize
|
||||||
|
);
|
||||||
|
|
||||||
|
inline int(__stdcall *pGetLocaleInfoEx)(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
LCTYPE LCType,
|
||||||
|
LPWSTR lpLCData,
|
||||||
|
int cchData
|
||||||
|
);
|
||||||
|
|
||||||
|
inline int(__stdcall *pLCIDToLocaleName)(
|
||||||
|
LCID Locale,
|
||||||
|
LPWSTR lpName,
|
||||||
|
int cchName,
|
||||||
|
DWORD dwFlags
|
||||||
|
);
|
||||||
|
|
||||||
|
inline int(__stdcall *pGetLocaleInfoW)(
|
||||||
|
LCID Locale,
|
||||||
|
LCTYPE LCType,
|
||||||
|
LPWSTR lpLCData,
|
||||||
|
int cchData
|
||||||
|
);
|
||||||
|
|
||||||
|
inline DWORD(__stdcall *pGetThreadId)(
|
||||||
|
HANDLE hThread
|
||||||
|
);
|
||||||
|
|
||||||
inline HRESULT(__stdcall *pSHGetKnownFolderPath)(
|
inline HRESULT(__stdcall *pSHGetKnownFolderPath)(
|
||||||
const GUID & rfid,
|
const GUID & rfid,
|
||||||
DWORD dwFlags,
|
DWORD dwFlags,
|
||||||
|
@ -525,9 +525,10 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
|
|
||||||
void SignalKillNT()
|
void SignalKillNT()
|
||||||
{
|
{
|
||||||
if (IS_STREAM_HANDLE_VALID(gWin32Thread))
|
if (IS_STREAM_HANDLE_VALID(gWin32Thread) &&
|
||||||
|
pCancelSynchronousIo)
|
||||||
{
|
{
|
||||||
CancelSynchronousIo(gWin32Thread);
|
pCancelSynchronousIo(gWin32Thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_STREAM_HANDLE_VALID(gTerminateConsole))
|
if (IS_STREAM_HANDLE_VALID(gTerminateConsole))
|
||||||
|
@ -37,7 +37,9 @@ namespace Aurora::HWInfo
|
|||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
|
||||||
PROCESS_MEMORY_COUNTERS pm;
|
PROCESS_MEMORY_COUNTERS pm;
|
||||||
if (GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm), sizeof(PROCESS_MEMORY_COUNTERS)))
|
if (pGetProcessMemoryInfo(GetCurrentProcess(),
|
||||||
|
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
|
||||||
|
sizeof(PROCESS_MEMORY_COUNTERS)))
|
||||||
{
|
{
|
||||||
return RamStat {pm.WorkingSetSize, max};
|
return RamStat {pm.WorkingSetSize, max};
|
||||||
}
|
}
|
||||||
@ -114,15 +116,22 @@ namespace Aurora::HWInfo
|
|||||||
PROCESS_MEMORY_COUNTERS_EX pmc;
|
PROCESS_MEMORY_COUNTERS_EX pmc;
|
||||||
PROCESS_MEMORY_COUNTERS pm;
|
PROCESS_MEMORY_COUNTERS pm;
|
||||||
|
|
||||||
if (GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc), sizeof(PROCESS_MEMORY_COUNTERS_EX)))
|
if (pGetProcessMemoryInfo)
|
||||||
|
{
|
||||||
|
if (pGetProcessMemoryInfo(GetCurrentProcess(),
|
||||||
|
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc),
|
||||||
|
sizeof(PROCESS_MEMORY_COUNTERS_EX)))
|
||||||
{
|
{
|
||||||
return RamStat { pmc.PrivateUsage, max };
|
return RamStat { pmc.PrivateUsage, max };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm), sizeof(PROCESS_MEMORY_COUNTERS)))
|
if (pGetProcessMemoryInfo(GetCurrentProcess(),
|
||||||
|
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
|
||||||
|
sizeof(PROCESS_MEMORY_COUNTERS)))
|
||||||
{
|
{
|
||||||
return RamStat { pm.WorkingSetSize, max };
|
return RamStat { pm.WorkingSetSize, max };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return RamStat {};
|
return RamStat {};
|
||||||
#else
|
#else
|
||||||
|
@ -491,7 +491,14 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
this->isIrredeemable_ = true;
|
this->isIrredeemable_ = true;
|
||||||
this->bHasFailed = true;
|
this->bHasFailed = true;
|
||||||
::CancelIoEx(this->pHandle_->handle, &this->overlap);
|
if (pCancelIoEx)
|
||||||
|
{
|
||||||
|
pCancelIoEx(this->pHandle_->handle, &this->overlap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::CancelIo(this->pHandle_->handle);
|
||||||
|
}
|
||||||
::SetEvent(this->event);
|
::SetEvent(this->event);
|
||||||
this->dwOsErrorCode = ERROR_ABANDONED_WAIT_0;
|
this->dwOsErrorCode = ERROR_ABANDONED_WAIT_0;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
FILE_DISPOSITION_INFO rm {};
|
FILE_DISPOSITION_INFO rm {};
|
||||||
rm.DeleteFile = true;
|
rm.DeleteFile = true;
|
||||||
if (!SetFileInformationByHandle(this->handle_, _FILE_INFO_BY_HANDLE_CLASS::FileDispositionInfo, &rm, sizeof(rm)))
|
if (!(pSetFileInformationByHandle && pSetFileInformationByHandle(this->handle_, _FILE_INFO_BY_HANDLE_CLASS::FileDispositionInfo, &rm, sizeof(rm))))
|
||||||
{
|
{
|
||||||
SysPushErrorIO("Couldn't delete temporary file {}", this->path_);
|
SysPushErrorIO("Couldn't delete temporary file {}", this->path_);
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,14 @@ namespace Aurora::IO::FS
|
|||||||
|
|
||||||
void NTWatchObject::Cancel()
|
void NTWatchObject::Cancel()
|
||||||
{
|
{
|
||||||
CancelIoEx(this->hFileHandle, &this->ntOverlapped);
|
if (pCancelIoEx)
|
||||||
|
{
|
||||||
|
pCancelIoEx(this->hFileHandle, &this->ntOverlapped);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::CancelIo(this->hFileHandle);
|
||||||
|
}
|
||||||
AuWin32CloseHandle(this->hFileHandle);
|
AuWin32CloseHandle(this->hFileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,14 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
this->bIsIrredeemable = true;
|
this->bIsIrredeemable = true;
|
||||||
this->bHasFailed = true;
|
this->bHasFailed = true;
|
||||||
::CancelIoEx((HANDLE)this->GetSocket(), &this->overlap);
|
if (pCancelIoEx)
|
||||||
|
{
|
||||||
|
pCancelIoEx((HANDLE)this->GetSocket(), &this->overlap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::CancelIo((HANDLE)this->GetSocket());
|
||||||
|
}
|
||||||
this->dwOsErrorCode = ERROR_ABANDONED_WAIT_0;
|
this->dwOsErrorCode = ERROR_ABANDONED_WAIT_0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -94,19 +94,43 @@ namespace Aurora::Locale
|
|||||||
int ret;
|
int ret;
|
||||||
wchar_t name[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
wchar_t name[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
||||||
|
|
||||||
ret = LCIDToLocaleName(LOCALE_USER_DEFAULT, name, LOCALE_NAME_MAX_LENGTH, LOCALE_ALLOW_NEUTRAL_NAMES);
|
if (pLCIDToLocaleName)
|
||||||
|
{
|
||||||
|
ret = pLCIDToLocaleName(LOCALE_USER_DEFAULT, name, LOCALE_NAME_MAX_LENGTH, LOCALE_ALLOW_NEUTRAL_NAMES);
|
||||||
SysAssert(ret, "Couldn't acquire win32 locale information");
|
SysAssert(ret, "Couldn't acquire win32 locale information");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
wchar_t language[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
wchar_t language[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
||||||
ret = GetLocaleInfoEx(name, LOCALE_SISO639LANGNAME, language, LOCALE_NAME_MAX_LENGTH);
|
if (pGetLocaleInfoEx)
|
||||||
|
{
|
||||||
|
ret = pGetLocaleInfoEx(name, LOCALE_SISO639LANGNAME, language, LOCALE_NAME_MAX_LENGTH);
|
||||||
SysAssert(ret, "Couldn't acquire win32 provided ISO 639 map of {}", ConvertFromWChar(name));
|
SysAssert(ret, "Couldn't acquire win32 provided ISO 639 map of {}", ConvertFromWChar(name));
|
||||||
|
}
|
||||||
|
else if (pGetLocaleInfoW)
|
||||||
|
{
|
||||||
|
ret = pGetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, language, LOCALE_NAME_MAX_LENGTH);
|
||||||
|
SysAssert(ret, "Couldn't acquire win32 provided ISO 639 map of {}", ConvertFromWChar(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
gLanguageCode = ConvertFromWChar(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
wchar_t country[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
wchar_t country[LOCALE_NAME_MAX_LENGTH] = { 0 };
|
||||||
ret = GetLocaleInfoEx(name, LOCALE_SISO3166CTRYNAME, country, LOCALE_NAME_MAX_LENGTH);
|
if (pGetLocaleInfoEx)
|
||||||
|
{
|
||||||
|
ret = pGetLocaleInfoEx(name, LOCALE_SISO3166CTRYNAME, country, LOCALE_NAME_MAX_LENGTH);
|
||||||
SysAssert(ret, "Couldn't acquire win32 provided ISO 3166 map of {}", ConvertFromWChar(name));
|
SysAssert(ret, "Couldn't acquire win32 provided ISO 3166 map of {}", ConvertFromWChar(name));
|
||||||
|
}
|
||||||
|
else if (pGetLocaleInfoW)
|
||||||
|
{
|
||||||
|
ret = pGetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, country, LOCALE_NAME_MAX_LENGTH);
|
||||||
|
SysAssert(ret, "Couldn't acquire win32 provided ISO 3166 map of {}", ConvertFromWChar(name));
|
||||||
|
}
|
||||||
|
|
||||||
gCountryCode = ConvertFromWChar(country);
|
gCountryCode = ConvertFromWChar(country);
|
||||||
gLanguageCode = ConvertFromWChar(language);
|
}
|
||||||
|
|
||||||
SetCodesetCommonGuessWin32();
|
SetCodesetCommonGuessWin32();
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,19 @@ namespace Aurora::Threading::Threads
|
|||||||
THREADNAME_INFO info;
|
THREADNAME_INFO info;
|
||||||
info.dwType = 0x1000;
|
info.dwType = 0x1000;
|
||||||
info.szName = this->name_.c_str();
|
info.szName = this->name_.c_str();
|
||||||
info.dwThreadID = ::GetThreadId(this->handle_);
|
if (pGetThreadId)
|
||||||
|
{
|
||||||
|
info.dwThreadID = pGetThreadId(this->handle_);
|
||||||
|
}
|
||||||
|
else if (this->unixThreadId_ == GetCurrentThreadId())
|
||||||
|
{
|
||||||
|
info.dwThreadID = this->unixThreadId_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
info.dwFlags = 0;
|
info.dwFlags = 0;
|
||||||
|
|
||||||
auto raise = AuStaticCast<void(__cdecl *)(THREADNAME_INFO &)>([](THREADNAME_INFO &info)
|
auto raise = AuStaticCast<void(__cdecl *)(THREADNAME_INFO &)>([](THREADNAME_INFO &info)
|
||||||
@ -712,6 +724,10 @@ namespace Aurora::Threading::Threads
|
|||||||
this->unixThreadId_ = 0; // !!!!
|
this->unixThreadId_ = 0; // !!!!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AURORA_PLATFORM_WIN32)
|
||||||
|
this->unixThreadId_ = GetCurrentThreadId();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (this->tls_)
|
if (this->tls_)
|
||||||
{
|
{
|
||||||
SetThreadKey(this->tls_);
|
SetThreadKey(this->tls_);
|
||||||
|
Loading…
Reference in New Issue
Block a user