[*] Further reduction of static iat imports with an emphasis on NT5[.1] symbols for NT4,5,Win98 compat
This commit is contained in:
parent
0bc958d5b7
commit
c0a7133554
@ -43,6 +43,7 @@ namespace Aurora
|
||||
static ULONG gLastActualResolution {};
|
||||
|
||||
#if !defined(AURORA_PLATFORM_WIN32)
|
||||
|
||||
HMODULE UWPLibraryW(LPCWSTR lpLibFileName);
|
||||
|
||||
FARPROC UWPProcAddress(HMODULE hModule,
|
||||
@ -64,6 +65,16 @@ namespace Aurora
|
||||
DWORD dwFileOffsetHigh,
|
||||
DWORD dwFileOffsetLow,
|
||||
SIZE_T dwNumberOfBytesToMap);
|
||||
|
||||
#else
|
||||
|
||||
BOOL __stdcall Win9XGetFileSizeEx(HANDLE hFile,
|
||||
PLARGE_INTEGER lpFileSize);
|
||||
|
||||
BOOL __stdcall Win9XSetFilePointerEx(HANDLE hFile,
|
||||
LARGE_INTEGER liDistanceToMove,
|
||||
PLARGE_INTEGER lpNewFilePointer,
|
||||
DWORD dwMoveMethod);
|
||||
#endif
|
||||
|
||||
#if !defined(AURORA_DLL_BLACKLIST)
|
||||
@ -329,7 +340,27 @@ namespace Aurora
|
||||
ADD_GET_PROC(Kernel32, WriteConsoleW)
|
||||
ADD_GET_PROC(Kernel32, ReadConsoleInputW)
|
||||
ADD_GET_PROC(Kernel32, GetNumberOfConsoleInputEvents)
|
||||
|
||||
ADD_GET_PROC(Kernel32, GetModuleHandleExW)
|
||||
ADD_GET_PROC(Kernel32, AddVectoredExceptionHandler)
|
||||
ADD_GET_PROC(Kernel32, AttachConsole)
|
||||
ADD_GET_PROC(Kernel32, GetVolumePathNamesForVolumeNameW)
|
||||
ADD_GET_PROC(Kernel32, GetVolumeInformationW)
|
||||
ADD_GET_PROC(Kernel32, FindVolumeClose)
|
||||
ADD_GET_PROC(Kernel32, FindFirstVolumeW)
|
||||
ADD_GET_PROC(Kernel32, FindNextVolumeW)
|
||||
ADD_GET_PROC(Kernel32, GetVolumePathNameW)
|
||||
ADD_GET_PROC(Kernel32, PathStripToRootW)
|
||||
ADD_GET_PROC(Kernel32, SetInformationJobObject)
|
||||
ADD_GET_PROC(Kernel32, AssignProcessToJobObject)
|
||||
ADD_GET_PROC(Kernel32, GlobalMemoryStatusEx)
|
||||
ADD_GET_PROC(Kernel32, GlobalMemoryStatus)
|
||||
ADD_GET_PROC(Kernel32, GetFileSizeEx)
|
||||
ADD_GET_PROC(Kernel32, GetFileSize)
|
||||
ADD_GET_PROC(Kernel32, SetFilePointerEx)
|
||||
ADD_GET_PROC(Kernel32, SetFilePointer)
|
||||
ADD_GET_PROC(Kernel32, GetComputerNameExW)
|
||||
ADD_GET_PROC(Kernel32, GetComputerNameW)
|
||||
|
||||
ADD_GET_PROC_BI2(Kernel32, PSAPILegacy, K32GetProcessMemoryInfo, GetProcessMemoryInfo)
|
||||
|
||||
ADD_GET_PROC(Sync, WaitOnAddress)
|
||||
@ -460,6 +491,16 @@ namespace Aurora
|
||||
ADD_GET_PROC(CredUI, CredUIPromptForWindowsCredentialsW);
|
||||
ADD_GET_PROC(CredUI, CredUnPackAuthenticationBufferW);
|
||||
|
||||
if (!pGetFileSizeEx)
|
||||
{
|
||||
pGetFileSizeEx = Win9XGetFileSizeEx;
|
||||
}
|
||||
|
||||
if (!pSetFilePointerEx)
|
||||
{
|
||||
pSetFilePointerEx = Win9XSetFilePointerEx;
|
||||
}
|
||||
|
||||
if (pNtCreateKeyedEvent &&
|
||||
Threading::Primitives::gKeyedEventHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -497,6 +538,9 @@ namespace Aurora
|
||||
|
||||
pSetFileInformationByHandle = SetFileInformationByHandle;
|
||||
|
||||
pGetFileSizeEx = GetFileSizeEx;
|
||||
pSetFilePointerEx = SetFilePointerEx;
|
||||
|
||||
pFindClose = FindClose;
|
||||
|
||||
pGetTempPathW = GetTempPath2W;
|
||||
@ -570,6 +614,60 @@ namespace Aurora
|
||||
return bool(GetEnvironmentVariableW(L"AURORA_IS_NETBOOK", nullptr, 0));
|
||||
}
|
||||
|
||||
|
||||
BOOL __stdcall Win9XGetFileSizeEx(HANDLE hFile,
|
||||
PLARGE_INTEGER lpFileSize)
|
||||
{
|
||||
if (!lpFileSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pGetFileSize)
|
||||
{
|
||||
DWORD dwSize {};
|
||||
|
||||
if (!pGetFileSize(hFile, &dwSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lpFileSize->QuadPart = dwSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL __stdcall Win9XSetFilePointerEx(HANDLE hFile,
|
||||
LARGE_INTEGER liDistanceToMove,
|
||||
PLARGE_INTEGER lpNewFilePointer,
|
||||
DWORD dwMoveMethod)
|
||||
{
|
||||
if (!lpNewFilePointer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pSetFilePointer)
|
||||
{
|
||||
DWORD dwSize {};
|
||||
DWORD in {};
|
||||
|
||||
in = liDistanceToMove.QuadPart;
|
||||
|
||||
if (!pSetFilePointer(hFile, in, &dwSize, dwMoveMethod))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lpNewFilePointer->QuadPart = dwSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Win32DropSchedulerResolutionNow();
|
||||
|
||||
void Win32DropInit()
|
||||
@ -996,7 +1094,7 @@ namespace Aurora
|
||||
{
|
||||
LARGE_INTEGER length;
|
||||
|
||||
if (!::GetFileSizeEx((HANDLE)uOSHandle, &length))
|
||||
if (!pGetFileSizeEx((HANDLE)uOSHandle, &length))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return 0;
|
||||
|
@ -27,6 +27,8 @@ struct _CONSOLE_SCREEN_BUFFER_INFO;
|
||||
struct _SMALL_RECT;
|
||||
struct _CHAR_INFO;
|
||||
struct tagMODULEENTRY32W;
|
||||
struct _MEMORYSTATUSEX;
|
||||
struct _MEMORYSTATUS;
|
||||
enum _TOKEN_INFORMATION_CLASS;
|
||||
enum _SE_OBJECT_TYPE;
|
||||
enum _MINIDUMP_TYPE;
|
||||
@ -34,6 +36,8 @@ enum _OBJECT_WAIT_TYPE;
|
||||
enum _SE_OBJECT_TYPE;
|
||||
enum _PROCESS_INFORMATION_CLASS;
|
||||
enum _SYSTEM_INFORMATION_CLASS;
|
||||
enum _JOBOBJECTINFOCLASS;
|
||||
enum _COMPUTER_NAME_FORMAT;
|
||||
|
||||
//#if defined(AURORA_COMPILER_MSVC)
|
||||
struct _IP_ADAPTER_ADDRESSES_LH;
|
||||
@ -459,6 +463,119 @@ namespace Aurora
|
||||
HANDLE Pipe,
|
||||
PULONG ClientProcessId
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetModuleHandleExW)(
|
||||
DWORD dwFlags,
|
||||
LPCWSTR lpModuleName,
|
||||
HMODULE* phModule
|
||||
);
|
||||
|
||||
inline PVOID(__stdcall *pAddVectoredExceptionHandler)(
|
||||
ULONG First,
|
||||
void * Handler
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pAttachConsole)(
|
||||
DWORD dwProcessId
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetVolumePathNamesForVolumeNameW)(
|
||||
LPCWSTR lpszVolumeName,
|
||||
LPWCH lpszVolumePathNames,
|
||||
DWORD cchBufferLength,
|
||||
PDWORD lpcchReturnLength
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetVolumeInformationW)(
|
||||
LPCWSTR lpRootPathName,
|
||||
LPWSTR lpVolumeNameBuffer,
|
||||
DWORD nVolumeNameSize,
|
||||
LPDWORD lpVolumeSerialNumber,
|
||||
LPDWORD lpMaximumComponentLength,
|
||||
LPDWORD lpFileSystemFlags,
|
||||
LPWSTR lpFileSystemNameBuffer,
|
||||
DWORD nFileSystemNameSize
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pFindVolumeClose)(
|
||||
HANDLE hFindVolume
|
||||
);
|
||||
|
||||
inline HANDLE(__stdcall *pFindFirstVolumeW)(
|
||||
LPWSTR lpszVolumeName,
|
||||
DWORD cchBufferLength
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pFindNextVolumeW)(
|
||||
HANDLE hFindVolume,
|
||||
LPWSTR lpszVolumeName,
|
||||
DWORD cchBufferLength
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetVolumePathNameW)(
|
||||
LPCWSTR lpszFileName,
|
||||
LPWSTR lpszVolumePathName,
|
||||
DWORD cchBufferLength
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pPathStripToRootW)(
|
||||
LPWSTR pszPath
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pSetInformationJobObject)(
|
||||
HANDLE hJob,
|
||||
_JOBOBJECTINFOCLASS JobObjectInformationClass,
|
||||
LPVOID lpJobObjectInformation,
|
||||
DWORD cbJobObjectInformationLength
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pAssignProcessToJobObject)(
|
||||
HANDLE hJob,
|
||||
HANDLE hProcess
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGlobalMemoryStatusEx)(
|
||||
_MEMORYSTATUSEX * lpBuffer
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGlobalMemoryStatus)(
|
||||
_MEMORYSTATUS * lpBuffer
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetFileSizeEx)(
|
||||
HANDLE hFile,
|
||||
PLARGE_INTEGER lpFileSize
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetFileSize)(
|
||||
HANDLE hFile,
|
||||
LPDWORD lpFileSize
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pSetFilePointerEx)(
|
||||
HANDLE hFile,
|
||||
LARGE_INTEGER liDistanceToMove,
|
||||
PLARGE_INTEGER lpNewFilePointer,
|
||||
DWORD dwMoveMethod
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pSetFilePointer)(
|
||||
HANDLE hFile,
|
||||
DWORD liDistanceToMove,
|
||||
PDWORD lpNewFilePointer,
|
||||
DWORD dwMoveMethod
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetComputerNameExW)(
|
||||
_COMPUTER_NAME_FORMAT NameType,
|
||||
LPWSTR lpBuffer,
|
||||
LPDWORD nSize
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pGetComputerNameW)(
|
||||
LPWSTR lpBuffer,
|
||||
LPDWORD nSize
|
||||
);
|
||||
|
||||
inline BOOL(__stdcall *pModule32FirstW)(
|
||||
HANDLE Pipe,
|
||||
|
@ -9,23 +9,29 @@
|
||||
|
||||
#include "bzlib.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * handle;
|
||||
char buf[BZ_MAX_UNUSED];
|
||||
AuInt32 bufN;
|
||||
char writing;
|
||||
bz_stream strm;
|
||||
AuInt32 lastErr;
|
||||
char initialisedOk;
|
||||
} bz2_file;
|
||||
static const char *bzerrorstrings[] = {
|
||||
"OK"
|
||||
,"SEQUENCE_ERROR"
|
||||
,"PARAM_ERROR"
|
||||
,"MEM_ERROR"
|
||||
,"DATA_ERROR"
|
||||
,"DATA_ERROR_MAGIC"
|
||||
,"IO_ERROR"
|
||||
,"UNEXPECTED_EOF"
|
||||
,"OUTBUFF_FULL"
|
||||
,"CONFIG_ERROR"
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
};
|
||||
|
||||
static const char *BShitToString(int error)
|
||||
{
|
||||
int n {};
|
||||
bz2_file B;
|
||||
B.lastErr = error;
|
||||
return BZ2_bzerror((BZFILE *)&B, &n);
|
||||
if (error > 0) error = 0;
|
||||
return bzerrorstrings[error * -1];
|
||||
}
|
||||
|
||||
namespace Aurora::Compression
|
||||
|
@ -9,23 +9,29 @@
|
||||
|
||||
#include "bzlib.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * handle;
|
||||
char buf[BZ_MAX_UNUSED];
|
||||
AuInt32 bufN;
|
||||
char writing;
|
||||
bz_stream strm;
|
||||
AuInt32 lastErr;
|
||||
char initialisedOk;
|
||||
} bz2_file;
|
||||
static const char *bzerrorstrings[] = {
|
||||
"OK"
|
||||
,"SEQUENCE_ERROR"
|
||||
,"PARAM_ERROR"
|
||||
,"MEM_ERROR"
|
||||
,"DATA_ERROR"
|
||||
,"DATA_ERROR_MAGIC"
|
||||
,"IO_ERROR"
|
||||
,"UNEXPECTED_EOF"
|
||||
,"OUTBUFF_FULL"
|
||||
,"CONFIG_ERROR"
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
,"???" /* for future */
|
||||
};
|
||||
|
||||
static const char *BShitToString(int error)
|
||||
{
|
||||
int n {};
|
||||
bz2_file B;
|
||||
B.lastErr = error;
|
||||
return BZ2_bzerror((BZFILE *)&B, &n);
|
||||
if (error > 0) error = 0;
|
||||
return bzerrorstrings[error * -1];
|
||||
}
|
||||
|
||||
namespace Aurora::Compression
|
||||
|
@ -288,7 +288,12 @@ extern "C" AUKN_SYM void __stdcall _ReportMSVCSEH(void *exception, const void *t
|
||||
|
||||
if (_EH_RELATIVE_TYPEINFO)
|
||||
{
|
||||
if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast<LPCSTR>(caller), reinterpret_cast<HMODULE *>(&handle)))
|
||||
if (!Aurora::pGetModuleHandleExW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Aurora::pGetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast<LPCWSTR>(caller), reinterpret_cast<HMODULE *>(&handle)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -594,9 +594,10 @@ namespace Aurora::Debug
|
||||
DisableWindowsErrorReporting();
|
||||
|
||||
// ..
|
||||
if (gRuntimeConfig.debug.bEnableWin32RootExceptionHandler)
|
||||
if (gRuntimeConfig.debug.bEnableWin32RootExceptionHandler &&
|
||||
pAddVectoredExceptionHandler)
|
||||
{
|
||||
AddVectoredExceptionHandler(1, HandleVectorException);
|
||||
pAddVectoredExceptionHandler(1, HandleVectorException);
|
||||
}
|
||||
}
|
||||
}
|
9
Source/Extensions/BZip2/BZipPanic.cpp
Normal file
9
Source/Extensions/BZip2/BZipPanic.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <RuntimeInternal.hpp>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void bz_internal_error(int error)
|
||||
{
|
||||
SysPanic("bzip error: {}", error);
|
||||
}
|
||||
}
|
@ -177,15 +177,33 @@ namespace Aurora::HWInfo
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
|
||||
MEMORYSTATUSEX statex;
|
||||
MEMORYSTATUS state;
|
||||
statex.dwLength = sizeof(statex);
|
||||
state.dwLength = sizeof(state);
|
||||
|
||||
if (!GlobalMemoryStatusEx(&statex))
|
||||
if (pGlobalMemoryStatusEx)
|
||||
{
|
||||
if (!pGlobalMemoryStatusEx(&statex))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat { statex.ullTotalPageFile - statex.ullAvailPageFile, statex.ullTotalPageFile };
|
||||
}
|
||||
else if (pGlobalMemoryStatus)
|
||||
{
|
||||
if (!pGlobalMemoryStatus(&state))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat { state.dwTotalPageFile - state.dwAvailPageFile, state.dwTotalPageFile };
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat {statex.ullTotalPageFile - statex.ullAvailPageFile, statex.ullTotalPageFile};
|
||||
|
||||
#elif defined(AURORA_IS_BSD_DERIVED)
|
||||
|
||||
auto vmInfo = GetVMInfo();
|
||||
@ -218,15 +236,33 @@ namespace Aurora::HWInfo
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
|
||||
MEMORYSTATUSEX statex;
|
||||
MEMORYSTATUS state;
|
||||
statex.dwLength = sizeof(statex);
|
||||
state.dwLength = sizeof(state);
|
||||
|
||||
if (!GlobalMemoryStatusEx(&statex))
|
||||
if (pGlobalMemoryStatusEx)
|
||||
{
|
||||
if (!pGlobalMemoryStatusEx(&statex))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat {statex.ullTotalPhys - statex.ullAvailPhys, statex.ullTotalPhys};
|
||||
}
|
||||
else if (pGlobalMemoryStatus)
|
||||
{
|
||||
if (!pGlobalMemoryStatus(&state))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat { state.dwTotalPhys - state.dwAvailPhys, state.dwTotalPhys };
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return RamStat {statex.ullTotalPhys - statex.ullAvailPhys, statex.ullTotalPhys};
|
||||
|
||||
#elif defined(AURORA_IS_BSD_DERIVED)
|
||||
|
||||
#if defined(HW_PHYSMEM64)
|
||||
|
@ -117,7 +117,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
auto hHandle = (HANDLE)this->pHandle_->GetOSHandle();
|
||||
|
||||
if (!SetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
if (!pSetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
@ -141,7 +141,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
auto hHandle = (HANDLE)hOptSafe.Value();
|
||||
|
||||
if (!SetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
if (!pSetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
@ -186,7 +186,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
auto hHandle = (HANDLE)hOptSafe.Value();
|
||||
|
||||
if (!SetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
if (!pSetFilePointerEx(hHandle, i, nullptr, FILE_BEGIN))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return false;
|
||||
|
@ -254,7 +254,7 @@ namespace Aurora::IO::FS
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!::GetFileSizeEx(fileHandle, &length))
|
||||
if (!pGetFileSizeEx(fileHandle, &length))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
goto out;
|
||||
|
@ -39,25 +39,35 @@ namespace Aurora::IO::FS
|
||||
AUKN_SYM AuString GetRootFromPath(const AuROString &path)
|
||||
{
|
||||
auto widePath = Locale::ConvertFromUTF8(NormalizePathRet(path));
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
|
||||
// PathStripToRoot is utterly worthless garbage that cannot parse network addresses
|
||||
#if 0
|
||||
// do not switch to PathCchStripToRoot!
|
||||
// (wont remove support for Windows Vista/7!)
|
||||
widePath.reserve(4096 * 3);
|
||||
return PathStripToRootW(widePath.data()) ? Locale::ConvertFromWChar(widePath.c_str()) : "";
|
||||
#else
|
||||
std::wstring str2(32u * 1024u + 10, L'\x00');
|
||||
// i perfer this Kernel32 api (desktop-class only)
|
||||
// update: i was right. you need the Win8 shell api thats in UWP for network paths to work properly
|
||||
auto almostBestPath = ::GetVolumePathNameW(widePath.c_str(), str2.data(), str2.size()) ?
|
||||
Locale::ConvertFromWChar(str2.c_str()) :
|
||||
"";
|
||||
return PathToMount(almostBestPath); /* expand root mountpoints to a network address, if possible*/
|
||||
#endif
|
||||
if (pGetVolumePathNameW)
|
||||
{
|
||||
std::wstring str2(32u * 1024u + 10, L'\x00');
|
||||
auto almostBestPath = pGetVolumePathNameW(widePath.c_str(), str2.data(), str2.size()) ?
|
||||
Locale::ConvertFromWChar(str2.c_str()) :
|
||||
"";
|
||||
return PathToMount(almostBestPath); /* expand root mountpoints to a network address, if possible*/
|
||||
}
|
||||
else if (pPathStripToRootW)
|
||||
{
|
||||
// PathStripToRoot is utterly worthless garbage that cannot parse network addresses
|
||||
widePath.reserve(4096 * 3);
|
||||
return pPathStripToRootW(widePath.data()) ? Locale::ConvertFromWChar(widePath.c_str()) : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// ...the UWP class API in question
|
||||
return PathCchStripToRoot(widePath.data(), widePath.size()) ? Locale::ConvertFromWChar(widePath.c_str()) : "";
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -406,7 +416,11 @@ namespace Aurora::IO::FS
|
||||
HANDLE hDevice = INVALID_HANDLE_VALUE;
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA_W pInterfaceDetailData {};
|
||||
|
||||
if (!pSetupDiGetClassDevsW)
|
||||
if (!pSetupDiGetClassDevsW ||
|
||||
!pSetupDiEnumDeviceInterfaces ||
|
||||
!pSetupDiGetDeviceInterfaceDetailW ||
|
||||
!pSetupDiGetDeviceRegistryPropertyA ||
|
||||
!pSetupDiDestroyDeviceInfoList)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@ -636,7 +650,8 @@ namespace Aurora::IO::FS
|
||||
NTSTATUS uStatus;
|
||||
HANDLE hHandle;
|
||||
|
||||
if (!pNtOpenSymbolicLinkObject)
|
||||
if (!pNtOpenSymbolicLinkObject ||
|
||||
!pNtQuerySymbolicLinkObject)
|
||||
{
|
||||
return reeceWasHere;
|
||||
}
|
||||
@ -692,8 +707,15 @@ namespace Aurora::IO::FS
|
||||
{
|
||||
std::wstring strVolumePath;
|
||||
|
||||
if (!pFindVolumeClose ||
|
||||
!pFindFirstVolumeW ||
|
||||
!pFindNextVolumeW)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
strVolumePath.resize(16 * 1024);
|
||||
auto hVolume = ::FindFirstVolumeW(strVolumePath.data(), strVolumePath.size());
|
||||
auto hVolume = pFindFirstVolumeW(strVolumePath.data(), strVolumePath.size());
|
||||
|
||||
if (hVolume == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -763,9 +785,9 @@ namespace Aurora::IO::FS
|
||||
|
||||
AuWin32CloseHandle(hVolume);
|
||||
}
|
||||
while (::FindNextVolumeW(hVolume, strVolumePath.data(), strVolumePath.size()) != 0);
|
||||
while (pFindNextVolumeW(hVolume, strVolumePath.data(), strVolumePath.size()) != 0);
|
||||
|
||||
::FindVolumeClose(hVolume);
|
||||
pFindVolumeClose(hVolume);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -802,7 +824,12 @@ namespace Aurora::IO::FS
|
||||
wchar_t buffer[4096] {};
|
||||
DWORD dwBufferSize { AuArraySize(buffer) };
|
||||
|
||||
if (!GetVolumeInformationW(widePath.c_str(), buffer, dwBufferSize, {}, {}, {}, {}, {}))
|
||||
if (!pGetVolumeInformationW)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!pGetVolumeInformationW(widePath.c_str(), buffer, dwBufferSize, {}, {}, {}, {}, {}))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@ -818,6 +845,11 @@ namespace Aurora::IO::FS
|
||||
AuList<wchar_t> names;
|
||||
AuList<AuString> ret;
|
||||
|
||||
if (!pGetVolumePathNamesForVolumeNameW)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto widePath = Locale::ConvertFromUTF8(volumeName);
|
||||
|
||||
while (true)
|
||||
@ -825,7 +857,7 @@ namespace Aurora::IO::FS
|
||||
names.clear();
|
||||
names.resize(dwCharCount);
|
||||
|
||||
if ((bSuccess = GetVolumePathNamesForVolumeNameW(widePath.c_str(), names.data(), dwCharCount, &dwCharCount)))
|
||||
if ((bSuccess = pGetVolumePathNamesForVolumeNameW(widePath.c_str(), names.data(), dwCharCount, &dwCharCount)))
|
||||
{
|
||||
pNameIterator = names.data();
|
||||
break;
|
||||
@ -900,7 +932,9 @@ namespace Aurora::IO::FS
|
||||
DWORD dwResult {};
|
||||
DWORD dwEntries { (DWORD) -1 };
|
||||
|
||||
if (!pWNetOpenEnumW)
|
||||
if (!pWNetOpenEnumW ||
|
||||
!pWNetCloseEnum ||
|
||||
!pWNetEnumResourceW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ namespace Aurora::IO::FS
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (::SetFilePointerEx(hHandle,
|
||||
distance,
|
||||
&pos,
|
||||
FILE_CURRENT) == INVALID_SET_FILE_POINTER)
|
||||
if (pSetFilePointerEx(hHandle,
|
||||
distance,
|
||||
&pos,
|
||||
FILE_CURRENT) == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
SysPushErrorIO("SetFilePointerEx IO Error: 0x{:x}, {}", GetLastError(), this->pHandle_ ? this->pHandle_->GetPath() : "");
|
||||
return 0;
|
||||
@ -110,7 +110,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
distance.QuadPart = offset;
|
||||
|
||||
if (::SetFilePointerEx(hHandle, distance, &pos, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
if (pSetFilePointerEx(hHandle, distance, &pos, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
SysPushErrorIO("SetFilePointerEx IO Error: 0x{:x}, {}", GetLastError(), this->pHandle_ ? this->pHandle_->GetPath() : "");
|
||||
return false;
|
||||
@ -148,7 +148,7 @@ namespace Aurora::IO::FS
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!::GetFileSizeEx(hHandle, &length))
|
||||
if (!pGetFileSizeEx(hHandle, &length))
|
||||
{
|
||||
SysPushErrorIO();
|
||||
return 0;
|
||||
|
@ -23,11 +23,27 @@ namespace Aurora::IO::Net
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
DWORD dwLength { AuArraySize(buffer) };
|
||||
|
||||
if (!::GetComputerNameExW(ComputerNameDnsHostname, buffer, &dwLength))
|
||||
if (!pGetComputerNameExW &&
|
||||
!pGetComputerNameW)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (pGetComputerNameExW)
|
||||
{
|
||||
if (!pGetComputerNameExW(ComputerNameDnsHostname, buffer, &dwLength))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!pGetComputerNameW(buffer, &dwLength))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return AuLocale::ConvertFromWChar(buffer, dwLength);
|
||||
#else
|
||||
int iLength { AuArraySize(buffer) };
|
||||
|
@ -250,27 +250,39 @@ namespace Aurora::Locale
|
||||
#define AURORA_HAS_UNIXLOCALE
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32) || defined(AURORA_PLATFORM_LINUX) || defined(AURORA_PLATFORM_BSD)
|
||||
#if defined(AURORA_PLATFORM_WIN32) || defined(AURORA_PLATFORM_LINUX) || defined(AURORA_PLATFORM_BSD)
|
||||
|
||||
static void SetLanguageByEnvVar(const char *pCharName, AuString &str)
|
||||
{
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
|
||||
str.resize(128);
|
||||
auto uChars = GetEnvironmentVariableA(pCharName, str.data(), 128);
|
||||
if (uChars &&
|
||||
uChars < 128)
|
||||
{
|
||||
str.resize(uChars);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = {};
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if ((language = getenv(pCharName)))
|
||||
{
|
||||
str = language;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetLanguageEnvBlock()
|
||||
{
|
||||
const char *language;
|
||||
if ((language = getenv("AURORA_ENV_LANGUAGE")))
|
||||
{
|
||||
gLanguageCode = language;
|
||||
}
|
||||
|
||||
const char *countryCode;
|
||||
if ((countryCode = getenv("AURORA_ENV_COUNTRY")))
|
||||
{
|
||||
gCountryCode = countryCode;
|
||||
}
|
||||
|
||||
// You may not overload codeset on win32 targets
|
||||
const char *codeSet;
|
||||
if ((codeSet = getenv("AURORA_ENV_CODESET")))
|
||||
{
|
||||
gCodeset = codeSet;
|
||||
}
|
||||
SetLanguageByEnvVar("AURORA_ENV_LANGUAGE", gLanguageCode);
|
||||
SetLanguageByEnvVar("AURORA_ENV_COUNTRY", gCountryCode);
|
||||
SetLanguageByEnvVar("AURORA_ENV_CODESET", gCodeset);
|
||||
}
|
||||
|
||||
#define AURORA_HAS_ENVBLOCK
|
||||
|
@ -725,11 +725,11 @@ namespace Aurora::Process
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
ret = reinterpret_cast<AuMach>(pGetProcAddress(::GetModuleHandleW(nullptr), symbol.c_str()));
|
||||
|
||||
if (!ret)
|
||||
if (!ret && pGetModuleHandleExW)
|
||||
{
|
||||
HMODULE hHandle;
|
||||
if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
reinterpret_cast<LPCWSTR>(&GetProcAddressEx), &hHandle))
|
||||
if (pGetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
reinterpret_cast<LPCWSTR>(&GetProcAddressEx), &hHandle))
|
||||
{
|
||||
ret = reinterpret_cast<AuMach>(pGetProcAddress(hHandle, symbol.c_str()));
|
||||
}
|
||||
|
@ -521,8 +521,7 @@ namespace Aurora::Process
|
||||
SysPushErrorUnimplemented("Win7_ReserveAddressSpace_RS4_REQ");
|
||||
|
||||
AuUInt uEnvSize {};
|
||||
::getenv_s(&uEnvSize, nullptr, 0, "AURORA_FORCE_RANDOM_ADDRESS_WITHOUT_VIRTALLOC2");
|
||||
if (uEnvSize)
|
||||
if (GetEnvironmentVariableA("AURORA_FORCE_RANDOM_ADDRESS_WITHOUT_VIRTALLOC2", nullptr, 0))
|
||||
{
|
||||
// bah
|
||||
// enjoy return not respecting what was provided as the expected offset.
|
||||
|
@ -28,14 +28,15 @@ namespace Aurora::Processes
|
||||
// problematic symbol: (others seem to be more ok???)
|
||||
// this file shouldn't be linked against most UWP apps anyway
|
||||
gLeaderJob = pCreateJobObjectW(NULL, NULL);
|
||||
if (!gLeaderJob)
|
||||
if (!gLeaderJob ||
|
||||
!pSetInformationJobObject)
|
||||
{
|
||||
SysPushErrorArg("CreateJobObject error");
|
||||
return;
|
||||
}
|
||||
|
||||
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
||||
if (!SetInformationJobObject(gLeaderJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
|
||||
if (!pSetInformationJobObject(gLeaderJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
|
||||
{
|
||||
SysPushErrorGen("SetInformationJobObject error");
|
||||
}
|
||||
@ -48,12 +49,19 @@ namespace Aurora::Processes
|
||||
|
||||
void AssignJobWorker(HANDLE handle)
|
||||
{
|
||||
if (gLeaderJob)
|
||||
if (!gLeaderJob)
|
||||
{
|
||||
if (!AssignProcessToJobObject(gLeaderJob, handle))
|
||||
{
|
||||
SysPushErrorGen("Could not AssignProcessToObject");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pAssignProcessToJobObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pAssignProcessToJobObject(gLeaderJob, handle))
|
||||
{
|
||||
SysPushErrorGen("Could not AssignProcessToObject");
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +159,12 @@ namespace Aurora::Processes
|
||||
{
|
||||
auto cwnd = GetConsoleWindow();
|
||||
|
||||
if (!(AttachConsole(GetProcessId(handle))))
|
||||
if (!pAttachConsole)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(pAttachConsole(GetProcessId(handle))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user