[*] Minor UWP progress

This commit is contained in:
Reece Wilson 2024-04-21 11:37:00 +01:00
parent 76b5466e87
commit c26eaf86a7
6 changed files with 91 additions and 25 deletions

View File

@ -270,6 +270,7 @@ namespace Aurora
ADD_GET_PROC(Nt, NtQuerySymbolicLinkObject) ADD_GET_PROC(Nt, NtQuerySymbolicLinkObject)
ADD_GET_PROC(Nt, NtOpenSymbolicLinkObject) ADD_GET_PROC(Nt, NtOpenSymbolicLinkObject)
ADD_GET_PROC(Nt, NtWaitForMultipleObjects) ADD_GET_PROC(Nt, NtWaitForMultipleObjects)
ADD_GET_PROC(Nt, NtQuerySystemInformation)
ADD_GET_PROC_BI(Kernel32, KernelBase, VirtualAlloc2) ADD_GET_PROC_BI(Kernel32, KernelBase, VirtualAlloc2)
ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile) ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile)
@ -305,6 +306,10 @@ namespace Aurora
ADD_GET_PROC(Kernel32, RemoveDllDirectory) ADD_GET_PROC(Kernel32, RemoveDllDirectory)
ADD_GET_PROC(Kernel32, AddDllDirectory) ADD_GET_PROC(Kernel32, AddDllDirectory)
ADD_GET_PROC(Kernel32, SetProcessInformation) ADD_GET_PROC(Kernel32, SetProcessInformation)
ADD_GET_PROC(Kernel32, GetNamedPipeClientProcessId)
ADD_GET_PROC(Kernel32, Module32FirstW)
ADD_GET_PROC(Kernel32, Module32NextW)
ADD_GET_PROC(Kernel32, CreateJobObjectW)
ADD_GET_PROC(Kernel32, GetConsoleScreenBufferInfo) ADD_GET_PROC(Kernel32, GetConsoleScreenBufferInfo)
ADD_GET_PROC(Kernel32, SetConsoleScreenBufferSize) ADD_GET_PROC(Kernel32, SetConsoleScreenBufferSize)
@ -912,6 +917,11 @@ namespace Aurora
HMODULE UWPLibraryW(LPCWSTR lpLibFileName) HMODULE UWPLibraryW(LPCWSTR lpLibFileName)
{ {
auto pos = std::basic_string_view<wchar_t>(lpLibFileName).find_last_of('/'); auto pos = std::basic_string_view<wchar_t>(lpLibFileName).find_last_of('/');
if (pos == std::basic_string_view<wchar_t>::npos)
{
pos = std::basic_string_view<wchar_t>(lpLibFileName).find_last_of('\\');
}
if (pos == std::basic_string_view<wchar_t>::npos) if (pos == std::basic_string_view<wchar_t>::npos)
{ {
#if defined(AURORA_HAS_LOAD_PGKD) #if defined(AURORA_HAS_LOAD_PGKD)

View File

@ -26,12 +26,14 @@ struct _NETRESOURCEW;
struct _CONSOLE_SCREEN_BUFFER_INFO; struct _CONSOLE_SCREEN_BUFFER_INFO;
struct _SMALL_RECT; struct _SMALL_RECT;
struct _CHAR_INFO; struct _CHAR_INFO;
struct tagMODULEENTRY32W;
enum _TOKEN_INFORMATION_CLASS; enum _TOKEN_INFORMATION_CLASS;
enum _SE_OBJECT_TYPE; enum _SE_OBJECT_TYPE;
enum _MINIDUMP_TYPE; enum _MINIDUMP_TYPE;
enum _OBJECT_WAIT_TYPE; enum _OBJECT_WAIT_TYPE;
enum _SE_OBJECT_TYPE; enum _SE_OBJECT_TYPE;
enum _PROCESS_INFORMATION_CLASS; enum _PROCESS_INFORMATION_CLASS;
enum _SYSTEM_INFORMATION_CLASS;
//#if defined(AURORA_COMPILER_MSVC) //#if defined(AURORA_COMPILER_MSVC)
struct _IP_ADAPTER_ADDRESSES_LH; struct _IP_ADAPTER_ADDRESSES_LH;
@ -377,8 +379,8 @@ namespace Aurora
DWORD dwDesiredAccess, DWORD dwDesiredAccess,
DWORD dwShareMode, DWORD dwShareMode,
CONST _SECURITY_ATTRIBUTES *lpSecurityAttributes, CONST _SECURITY_ATTRIBUTES *lpSecurityAttributes,
DWORD dwFlags, DWORD dwFlags,
LPVOID lpScreenBufferData LPVOID lpScreenBufferData
); );
inline BOOL(__stdcall *pSetConsoleCursorPosition)( inline BOOL(__stdcall *pSetConsoleCursorPosition)(
@ -425,25 +427,45 @@ namespace Aurora
); );
inline BOOL(__stdcall *pReadConsoleInputW)( inline BOOL(__stdcall *pReadConsoleInputW)(
HANDLE hConsoleInput, HANDLE hConsoleInput,
_INPUT_RECORD * lpBuffer, _INPUT_RECORD * lpBuffer,
DWORD nLength, DWORD nLength,
LPDWORD lpNumberOfEventsRead LPDWORD lpNumberOfEventsRead
); );
inline BOOL(__stdcall *pWriteConsoleInputW)( inline BOOL(__stdcall *pWriteConsoleInputW)(
HANDLE hConsoleInput, HANDLE hConsoleInput,
CONST _INPUT_RECORD * lpBuffer, CONST _INPUT_RECORD * lpBuffer,
DWORD nLength, DWORD nLength,
LPDWORD lpNumberOfEventsWritten LPDWORD lpNumberOfEventsWritten
); );
inline BOOL(__stdcall *pWriteConsoleW)( inline BOOL(__stdcall *pWriteConsoleW)(
HANDLE hConsoleInput, HANDLE hConsoleInput,
CONST wchar_t * lpBuffer, CONST wchar_t * lpBuffer,
DWORD nLength, DWORD nLength,
LPDWORD lpNumberOfEventsWritten, LPDWORD lpNumberOfEventsWritten,
void * pReserved void * pReserved
);
inline BOOL(__stdcall *pGetNamedPipeClientProcessId)(
HANDLE Pipe,
PULONG ClientProcessId
);
inline BOOL(__stdcall *pModule32FirstW)(
HANDLE Pipe,
tagMODULEENTRY32W * lpme
);
inline BOOL(__stdcall *pModule32NextW)(
HANDLE Pipe,
tagMODULEENTRY32W * lpme
);
inline HANDLE(__stdcall *pCreateJobObjectW)(
LPSECURITY_ATTRIBUTES lpJobAttributes,
LPCWSTR lpName
); );
inline BOOL(__stdcall *pPrefetchVirtualMemory)( inline BOOL(__stdcall *pPrefetchVirtualMemory)(
@ -480,6 +502,13 @@ namespace Aurora
); );
#endif #endif
inline NTSTATUS(__stdcall *pNtQuerySystemInformation)(
_SYSTEM_INFORMATION_CLASS SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength
);
inline ULONGLONG(__stdcall *pVerSetConditionMask)( inline ULONGLONG(__stdcall *pVerSetConditionMask)(
ULONGLONG ConditionMask, ULONGLONG ConditionMask,
DWORD TypeMask, DWORD TypeMask,

View File

@ -252,12 +252,18 @@ namespace Aurora::HWInfo
#else #else
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION processorInfo[128]; SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION processorInfo[128];
#endif #endif
if (!pNtQuerySystemInformation)
{
SysPushErrorFeatureMissing();
return false;
}
ULONG uOutLen {}; ULONG uOutLen {};
if (FAILED(NtQuerySystemInformation(SystemProcessorPerformanceInformation, if (FAILED(pNtQuerySystemInformation(SystemProcessorPerformanceInformation,
&processorInfo, &processorInfo,
sizeof(processorInfo), sizeof(processorInfo),
&uOutLen))) &uOutLen)))
{ {
return false; return false;
} }

View File

@ -78,8 +78,14 @@ namespace Aurora::IO::NT
} }
{ {
if (!pGetNamedPipeClientProcessId)
{
SysPushErrorIO("UWP Platform Error");
break;
}
ULONG pid {}; ULONG pid {};
if (!GetNamedPipeClientProcessId(hPipe, &pid)) if (!pGetNamedPipeClientProcessId(hPipe, &pid))
{ {
SysPushErrorIO("IO HANDLE Server Error"); SysPushErrorIO("IO HANDLE Server Error");
break; break;

View File

@ -14,7 +14,7 @@ namespace Aurora::Process
{ {
void MakeToolHelp32Snapshot() void MakeToolHelp32Snapshot()
{ {
MODULEENTRY32 me32; MODULEENTRY32W me32;
HANDLE hModuleSnap = INVALID_HANDLE_VALUE; HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()); hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
@ -23,9 +23,15 @@ namespace Aurora::Process
SysPushErrorGen("CreateToolhelp32Snapshot"); SysPushErrorGen("CreateToolhelp32Snapshot");
return; return;
} }
me32.dwSize = sizeof(MODULEENTRY32); me32.dwSize = sizeof(MODULEENTRY32W);
if (!Module32First(hModuleSnap, &me32)) if (!pModule32FirstW)
{
SysPushErrorFeatureMissing();
return;
}
if (!pModule32FirstW(hModuleSnap, &me32))
{ {
SysPushErrorGen("Module32First failed"); SysPushErrorGen("Module32First failed");
CloseHandle(hModuleSnap); CloseHandle(hModuleSnap);
@ -38,7 +44,8 @@ namespace Aurora::Process
InvaildateModule(h); InvaildateModule(h);
MakeAware(h); MakeAware(h);
} }
while (Module32Next(hModuleSnap, &me32)); while (pModule32NextW &&
pModule32NextW(hModuleSnap, &me32));
CloseHandle(hModuleSnap); CloseHandle(hModuleSnap);
} }

View File

@ -19,7 +19,15 @@ namespace Aurora::Processes
{ {
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli {}; JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli {};
gLeaderJob = CreateJobObject(NULL, NULL); if (!pCreateJobObjectW)
{
SysPushErrorFeatureMissing("Win32-like platform missing job objects!");
return;
}
// 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)
{ {
SysPushErrorArg("CreateJobObject error"); SysPushErrorArg("CreateJobObject error");