[*] Minor tweaks + more not-so-lazy loads in case of uwp

This commit is contained in:
Reece Wilson 2024-04-09 23:39:00 +01:00
parent 7f0dc81ec3
commit a087595009
12 changed files with 524 additions and 192 deletions

View File

@ -40,6 +40,23 @@ namespace Aurora
FARPROC UWPProcAddress(HMODULE hModule,
LPCSTR lpProcName);
HANDLE __stdcall UWPCreateFileMappingA(HANDLE hFile,
LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
DWORD flProtect,
DWORD dwMaximumSizeHigh,
DWORD dwMaximumSizeLow,
LPCSTR lpName);
HANDLE __stdcall UWPOpenFileMappingA(DWORD dwDesiredAccess,
BOOL bInheritHandle,
LPCSTR lpName);
LPVOID __stdcall UWPMapViewOfFile(HANDLE hFileMappingObject,
DWORD dwDesiredAccess,
DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow,
SIZE_T dwNumberOfBytesToMap);
#endif
#if !defined(AURORA_DLL_BLACKLIST)
@ -250,11 +267,14 @@ namespace Aurora
ADD_GET_PROC(Nt, NtWaitForMultipleObjects)
ADD_GET_PROC_BI(Kernel32, KernelBase, VirtualAlloc2)
ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile)
ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile3)
ADD_GET_PROC_BI(Kernel32, KernelBase, UnmapViewOfFile2)
ADD_GET_PROC_BI(Kernel32, KernelBase, CreateFileW)
ADD_GET_PROC_BI(Kernel32, KernelBase, CreateFile2W)
ADD_GET_PROC_BI(Kernel32, KernelBase, GetTempPathW)
ADD_GET_PROC_BI(Kernel32, KernelBase, CreateFileMappingA)
ADD_GET_PROC_BI(Kernel32, KernelBase, OpenFileMappingA)
ADD_GET_PROC(Kernel32, GetSystemCpuSetInformation)
ADD_GET_PROC(Kernel32, GetLogicalProcessorInformation)
@ -423,6 +443,12 @@ namespace Aurora
pGetProcAddress = UWPProcAddress;
pCreateFile2W = CreateFile2FromAppW;
pCreateFileMappingFromApp = CreateFileMappingFromApp;
pOpenFileMappingFromApp = OpenFileMappingFromApp;
pMapViewOfFileFromApp = MapViewOfFileFromApp;
pCreateFileMappingA = UWPCreateFileMappingA;
pOpenFileMappingA = UWPOpenFileMappingA;
pMapViewOfFile = UWPMapViewOfFile;
pWaitOnAddress = WaitOnAddress;
pWakeByAddressSingle = WakeByAddressSingle;
@ -578,6 +604,63 @@ namespace Aurora
}
}
}
HANDLE UWPCreateFileMappingA(HANDLE hFile,
LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
DWORD flProtect,
DWORD dwMaximumSizeHigh,
DWORD dwMaximumSizeLow,
LPCSTR lpName)
{
auto uSize = AuUInt64(AuUInt64(dwMaximumSizeHigh) << 32ull) |
AuUInt64(dwMaximumSizeLow);
if (!uSize && SysHandleIsNonZero(AuUInt(hFile)))
{
uSize = SysGetFileLength(AuUInt(hFile));
}
if (!pCreateFileMappingFromApp)
{
return NULL;
}
return pCreateFileMappingFromApp(hFile,
lpFileMappingAttributes,
flProtect,
uSize,
lpName ? AuLocale::ConvertFromUTF8(lpName).c_str() : nullptr);
}
HANDLE UWPOpenFileMappingA(DWORD dwDesiredAccess,
BOOL bInheritHandle,
LPCSTR lpName)
{
if (!pOpenFileMappingFromApp)
{
return NULL;
}
return pOpenFileMappingFromApp(dwDesiredAccess,
bInheritHandle,
lpName ? AuLocale::ConvertFromUTF8(lpName).c_str() : nullptr);
}
LPVOID UWPMapViewOfFile(HANDLE hFileMappingObject,
DWORD dwDesiredAccess,
DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow,
SIZE_T dwNumberOfBytesToMap)
{
if (!pMapViewOfFileFromApp)
{
return NULL;
}
return pMapViewOfFileFromApp(hFileMappingObject,
dwDesiredAccess,
AuUInt64(AuUInt64(dwFileOffsetHigh) << 32ull) | AuUInt64(dwFileOffsetLow),
dwNumberOfBytesToMap);
}
void Win32Terminate()
{
@ -691,6 +774,96 @@ namespace Aurora
return INVALID_HANDLE_VALUE;
}
HANDLE Win32Open2(LPCWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlags,
DWORD dwAttributes)
{
bool bSpecialFlags = (dwFlags & 0x4ffff7);
bool bSpecialAttrs = (dwAttributes & 0xFFB00008);
if (!pCreateFile2W)
{
if (bSpecialFlags)
{
SysPushErrorFeatureMissing("Do not use Windows8+ attributes/flags under Win32Open");
return INVALID_HANDLE_VALUE;
}
if (bSpecialAttrs)
{
SysPushErrorFeatureMissing("Do not use Windows8+ attributes/flags under Win32Open");
return INVALID_HANDLE_VALUE;
}
}
if (!dwAttributes)
{
dwAttributes = FILE_ATTRIBUTE_NORMAL;
}
if (pCreateFileW &&
!bSpecialFlags &&
!bSpecialAttrs)
{
return pCreateFileW(lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlags | dwAttributes,
NULL);
}
if (pCreateFile2W)
{
_CREATEFILE2_EXTENDED_PARAMETERS params {};
bool bRead {};
HANDLE hHandle {};
params.dwSize = sizeof(_CREATEFILE2_EXTENDED_PARAMETERS);
params.dwFileFlags = dwFlags;
params.dwFileAttributes = dwAttributes;
params.lpSecurityAttributes = lpSecurityAttributes;
if ((bRead = (::wcscmp(lpFileName, L"CONIN$") == 0)) ||
(::wcscmp(lpFileName, L"CONOUT$") == 0) ||
(::wcscmp(lpFileName, L"CONERR$") == 0))
{
if (!bRead)
{
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
}
else
{
dwDesiredAccess = GENERIC_READ;
}
if ((hHandle = pCreateFile2W(lpFileName,
dwDesiredAccess,
dwShareMode,
dwCreationDisposition,
&params)) != INVALID_HANDLE_VALUE)
{
return hHandle;
}
lpFileName = L"CON";
}
return pCreateFile2W(lpFileName,
dwDesiredAccess,
dwShareMode,
dwCreationDisposition,
&params);
}
return INVALID_HANDLE_VALUE;
}
#if !defined(AURORA_PLATFORM_WIN32)
HMODULE UWPLibraryW(LPCWSTR lpLibFileName)
{

View File

@ -234,6 +234,50 @@ namespace Aurora
HANDLE hTemplateFile
);
inline HANDLE(__stdcall *pCreateFileMappingA)(
HANDLE hFile,
LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
DWORD flProtect,
DWORD dwMaximumSizeHigh,
DWORD dwMaximumSizeLow,
LPCSTR lpName
);
inline HANDLE(__stdcall *pCreateFileMappingFromApp)(
HANDLE hFile,
PSECURITY_ATTRIBUTES SecurityAttributes,
ULONG PageProtection,
ULONG64 MaximumSize,
PCWSTR Name
);
inline HANDLE(__stdcall *pOpenFileMappingA)(
ULONG DesiredAccess,
BOOL InheritHandle,
LPCSTR Name
);
inline HANDLE(__stdcall *pOpenFileMappingFromApp)(
ULONG DesiredAccess,
BOOL InheritHandle,
PCWSTR Name
);
inline LPVOID(__stdcall *pMapViewOfFile)(
HANDLE hFileMappingObject,
DWORD dwDesiredAccess,
DWORD dwFileOffsetHigh,
DWORD dwFileOffsetLow,
SIZE_T dwNumberOfBytesToMap
);
inline LPVOID(__stdcall *pMapViewOfFileFromApp)(
HANDLE hFileMappingObject,
ULONG DesiredAccess,
ULONG64 FileOffset,
SIZE_T dwNumberOfBytesToMap
);
inline NTSTATUS(__stdcall *pNtNotifyChangeDirectoryFile)(
HANDLE FileHandle,
HANDLE Event,
@ -1208,7 +1252,7 @@ namespace Aurora
void Win32DropSchedulerResolution();
void Win32Terminate();
AUKN_SYM /* I'm going to be kind */
HANDLE Win32Open(LPCWSTR lpFileName,
DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE,
@ -1219,6 +1263,16 @@ namespace Aurora
DWORD dwAttributes = 0
);
AUKN_SYM /* I'm going to be kind */
HANDLE Win32Open2(LPCWSTR lpFileName,
DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE,
DWORD dwShareMode = FILE_SHARE_READ,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL,
DWORD dwCreationDisposition = 0,
DWORD dwFlags = 0,
DWORD dwAttributes = 0
);
inline HMODULE(__stdcall *pLoadLibraryW)(
LPCWSTR lpLibFileName
);

View File

@ -115,13 +115,12 @@ namespace Aurora::IO::FS
return utf8Root;
}
auto hFile = ::CreateFileW(widePath.c_str(),
0,
FILE_SHARE_WRITE | FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
nullptr);
auto hFile = Win32Open(widePath.c_str(),
0,
FILE_SHARE_WRITE | FILE_SHARE_READ,
false,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS);
if (hFile == INVALID_HANDLE_VALUE)
{
@ -188,13 +187,11 @@ namespace Aurora::IO::FS
return kImScaredAndDisorientated;
}
auto hDevice = ::CreateFileW(widePath.c_str(),
0,
0,
nullptr,
OPEN_EXISTING,
0,
nullptr);
auto hDevice = Win32Open(widePath.c_str(),
0,
0,
false,
OPEN_EXISTING);
if (hDevice == INVALID_HANDLE_VALUE)
{
@ -348,13 +345,11 @@ namespace Aurora::IO::FS
return 0;
}
auto hDevice = ::CreateFileW(widePath.c_str(),
0,
0,
nullptr,
OPEN_EXISTING,
0,
nullptr);
auto hDevice = Win32Open(widePath.c_str(),
0,
0,
false,
OPEN_EXISTING);
if (hDevice == INVALID_HANDLE_VALUE)
{
@ -476,14 +471,12 @@ namespace Aurora::IO::FS
continue;
}
hDevice = ::CreateFileW(pInterfaceDetailData->DevicePath,
0,
0x00000007,
nullptr,
OPEN_EXISTING,
0,
nullptr);
hDevice = Win32Open(pInterfaceDetailData->DevicePath,
0,
0x00000007,
false,
OPEN_EXISTING);
if (hDevice != INVALID_HANDLE_VALUE)
{
STORAGE_DEVICE_NUMBER sdn {};
@ -707,13 +700,11 @@ namespace Aurora::IO::FS
strVolumePath[i - 1] = '\x00';
}
auto hVolume = ::CreateFileW(strVolumePath.c_str(),
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
0);
auto hVolume = Win32Open(strVolumePath.c_str(),
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
false,
OPEN_EXISTING);
if (hVolume == INVALID_HANDLE_VALUE)
{

View File

@ -62,18 +62,23 @@ namespace Aurora::IO::IPC
handle.PushId(EIPCHandleType::eIPCMemory, token);
if (!pCreateFileMappingA)
{
return {};
}
auto path = token.ToNTPath();
auto file = CreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
PAGE_READWRITE,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
path.c_str());
auto file = pCreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
PAGE_READWRITE,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
path.c_str());
if ((file == INVALID_HANDLE_VALUE) ||
(!file))
@ -81,11 +86,11 @@ namespace Aurora::IO::IPC
return {};
}
auto map = ::MapViewOfFile(file,
FILE_MAP_ALL_ACCESS,
0,
0,
uLength);
auto map = pMapViewOfFile(file,
FILE_MAP_ALL_ACCESS,
0,
0,
uLength);
if (!map)
{
SysPushErrorIO();
@ -124,9 +129,9 @@ namespace Aurora::IO::IPC
auto uLength = token->token.word;
auto path = token->token.ToNTPath();
auto file = ::OpenFileMappingA(FILE_MAP_ALL_ACCESS,
FALSE,
path.c_str());
auto file = pOpenFileMappingA(FILE_MAP_ALL_ACCESS,
FALSE,
path.c_str());
if ((file == INVALID_HANDLE_VALUE) ||
(!file))
@ -134,11 +139,11 @@ namespace Aurora::IO::IPC
return {};
}
auto map = ::MapViewOfFile(file,
FILE_MAP_ALL_ACCESS,
0,
0,
uLength);
auto map = pMapViewOfFile(file,
FILE_MAP_ALL_ACCESS,
0,
0,
uLength);
if (!map)
{
SysPushErrorIO();

View File

@ -459,13 +459,12 @@ namespace Aurora::IO::IPC
#else
auto name = "\\\\.\\pipe\\LOCAL\\" + token->token.ToNTPath();
#endif
pipe = CreateFileA(name.c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);
pipe = Win32Open(AuLocale::ConvertFromUTF8(name).c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
false,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED);
if ((!pipe) ||
(pipe == INVALID_HANDLE_VALUE))

View File

@ -238,13 +238,13 @@ namespace Aurora::IO::NT
DWORD dwWritten {};
auto name = GetIPCServerNameOfPid(handle.pid);
hPipe = CreateFileA(name.c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
hPipe = Win32Open(AuLocale::ConvertFromUTF8(name).c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
false,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hPipe == INVALID_HANDLE_VALUE)
{

View File

@ -28,6 +28,8 @@ namespace Aurora::Locale
AUKN_SYM AuString ConvertFromWChar(const wchar_t *in)
{
AU_DEBUG_MEMCRUNCH;
try
{
return ConvertFromWChar(in, wcslen(in));
@ -41,6 +43,8 @@ namespace Aurora::Locale
AUKN_SYM AuString ConvertFromWChar(const wchar_t *in, AuMach length)
{
AU_DEBUG_MEMCRUNCH;
try
{
#if defined(AU_HAS_MSFT_NATIONALLANGSUPPORT)
@ -72,6 +76,8 @@ namespace Aurora::Locale
AUKN_SYM std::wstring ConvertFromUTF8(const AuString &in)
{
AU_DEBUG_MEMCRUNCH;
try
{
#if defined(AU_HAS_MSFT_NATIONALLANGSUPPORT)

View File

@ -86,6 +86,7 @@ namespace Aurora::Process
if (processLockLevel != AuFS::EFileAdvisoryLockLevel::eNoSafety)
{
DWORD dwFlags {};
HANDLE hEventHandle { INVALID_HANDLE_VALUE };
OVERLAPPED overlapped {};
if (processLockLevel == AuFS::EFileAdvisoryLockLevel::eBlockReadWrite)
@ -98,15 +99,56 @@ namespace Aurora::Process
overlapped.Offset = AuBitsToLower(uOffset);
overlapped.OffsetHigh = AuBitsToHigher(uOffset);
if (!::LockFileEx((HANDLE)pIOHandle->GetOSHandle(),
#if 0
bool bIsAsync = pIOHandle->IsAsync();
if (bIsAsync)
{
hEventHandle = ::CreateEventA(nullptr, false, false, nullptr);
if (!hEventHandle)
{
SysPushErrorGeneric();
return {};
}
overlapped.hEvent = hEventHandle;
}
#endif
auto hHandle = (HANDLE)pIOHandle->GetOSHandle();
if (!::LockFileEx(hHandle,
dwFlags,
0,
AuBitsToLower(uLength),
AuBitsToHigher(uLength),
&overlapped))
{
SysPushErrorIO("No Lock");
return {};
#if 0
if (GetLastError() == ERROR_IO_PENDING)
{
::WaitForSingleObject(hEventHandle, 0);
DWORD idc {};
if (!::GetOverlappedResult(hHandle,
&overlapped,
&idc,
true))
{
SysPushErrorIO("No Lock");
AuWin32CloseHandle(hEventHandle);
return {};
}
}
else
#endif
{
SysPushErrorIO("No Lock");
AuWin32CloseHandle(hEventHandle);
return {};
}
}
else
{
AuWin32CloseHandle(hEventHandle);
}
}
@ -130,17 +172,22 @@ namespace Aurora::Process
return {};
};
hFileMap = ::CreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
nullptr,
pageAttributes,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
if (!pCreateFileMappingA)
{
return {};
}
hFileMap = pCreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
nullptr,
pageAttributes,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength + uOffset),
AuBitsToLower(uLength + uOffset),
#else
0,
uLength,
#endif
nullptr);
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{
@ -148,11 +195,11 @@ namespace Aurora::Process
return {};
}
auto map = ::MapViewOfFile(hFileMap,
desiredAccess,
AuBitsToHigher(uOffset),
AuBitsToLower(uOffset),
uLength);
auto map = pMapViewOfFile(hFileMap,
desiredAccess,
AuBitsToHigher(uOffset),
AuBitsToLower(uOffset),
uLength);
if (!map)
{
SysPushErrorIO("Couldn't create map of section");
@ -232,9 +279,9 @@ namespace Aurora::Process
return {};
};
hFileMap = ::OpenFileMappingA(desiredAccess,
FALSE,
path.c_str());
hFileMap = pOpenFileMappingA(desiredAccess,
FALSE,
path.c_str());
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{
@ -242,11 +289,11 @@ namespace Aurora::Process
return {};
}
auto map = ::MapViewOfFile(hFileMap,
desiredAccess,
AuBitsToHigher(uOffset),
AuBitsToLower(uOffset),
uLength);
auto map = pMapViewOfFile(hFileMap,
desiredAccess,
AuBitsToHigher(uOffset),
AuBitsToLower(uOffset),
uLength);
if (!map)
{
SysPushErrorIO("Couldn't create map of IPC section (handle: {})", handleString);
@ -312,17 +359,22 @@ namespace Aurora::Process
uPageFlags = PAGE_EXECUTE_READ;
}
hFileMap = ::CreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
uPageFlags,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
if (!pCreateFileMappingA)
{
return {};
}
hFileMap = pCreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
uPageFlags,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{
@ -346,11 +398,11 @@ namespace Aurora::Process
sectionPermission |= SECTION_MAP_EXECUTE;
}
auto map = ::MapViewOfFile(hFileMap,
sectionPermission,
0,
0,
uLength);
auto map = pMapViewOfFile(hFileMap,
sectionPermission,
0,
0,
uLength);
if (!map)
{
SysPushErrorIO("Couldn't create allocation of section");

View File

@ -249,17 +249,22 @@ namespace Aurora::Process
return {};
}
hFileMap = ::CreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
uPageFlags,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
if (!pCreateFileMappingA)
{
return {};
}
hFileMap = pCreateFileMappingA(INVALID_HANDLE_VALUE,
nullptr,
uPageFlags,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{
@ -358,6 +363,7 @@ namespace Aurora::Process
if (processLockLevel != AuFS::EFileAdvisoryLockLevel::eNoSafety)
{
DWORD dwFlags {};
HANDLE hEventHandle { INVALID_HANDLE_VALUE };
OVERLAPPED overlapped {};
if (processLockLevel == AuFS::EFileAdvisoryLockLevel::eBlockReadWrite)
@ -370,15 +376,56 @@ namespace Aurora::Process
overlapped.Offset = AuBitsToLower(uOffset);
overlapped.OffsetHigh = AuBitsToHigher(uOffset);
if (!::LockFileEx((HANDLE)pIOHandle->GetOSHandle(),
#if 0
bool bIsAsync = pIOHandle->IsAsync();
if (bIsAsync)
{
hEventHandle = ::CreateEventA(nullptr, false, false, nullptr);
if (!hEventHandle)
{
SysPushErrorGeneric();
return {};
}
overlapped.hEvent = hEventHandle;
}
#endif
auto hHandle = (HANDLE)pIOHandle->GetOSHandle();
if (!::LockFileEx(hHandle,
dwFlags,
0,
AuBitsToLower(uLength),
AuBitsToHigher(uLength),
&overlapped))
{
SysPushErrorIO("No Lock");
return {};
#if 0
if (GetLastError() == ERROR_IO_PENDING)
{
::WaitForSingleObject(hEventHandle, 0);
DWORD idc {};
if (!::GetOverlappedResult(hHandle,
&overlapped,
&idc,
true))
{
SysPushErrorIO("No Lock");
AuWin32CloseHandle(hEventHandle);
return {};
}
}
else
#endif
{
SysPushErrorIO("No Lock");
AuWin32CloseHandle(hEventHandle);
return {};
}
}
else
{
AuWin32CloseHandle(hEventHandle);
}
}
@ -401,18 +448,23 @@ namespace Aurora::Process
SysPushErrorGeneric();
return {};
};
if (!pCreateFileMappingA)
{
return {};
}
hFileMap = ::CreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
nullptr,
pageAttributes,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength),
AuBitsToLower(uLength),
#else
0,
uLength,
#endif
nullptr);
hFileMap = pCreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
nullptr,
pageAttributes,
#if defined(AURORA_IS_64BIT)
AuBitsToHigher(uLength + uOffset),
AuBitsToLower(uLength + uOffset),
#else
0,
uLength,
#endif
nullptr);
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{
@ -515,9 +567,9 @@ namespace Aurora::Process
return {};
}
hFileMap = ::OpenFileMappingA(desiredAccess,
FALSE,
path.c_str());
hFileMap = pOpenFileMappingA(desiredAccess,
FALSE,
path.c_str());
if ((hFileMap == INVALID_HANDLE_VALUE) ||
(!hFileMap))
{

View File

@ -67,11 +67,11 @@ namespace Aurora::Process
}
auto pRet = ::mmap(this->pBaseAddress + uFoundOffset,
uLength,
prot,
share | MAP_FIXED,
fd,
offset);
uLength,
prot,
share | MAP_FIXED,
fd,
offset);
if (!pRet)
{
@ -98,18 +98,18 @@ namespace Aurora::Process
}
AuSPtr<IProcessSectionMapView> ProcessSectionViewReserved::MapFileByObject(const AuSPtr<IO::IIOHandle> &pIOHandle,
AuUInt64 uOffset,
AuUInt uLength,
AuFS::EFileOpenMode mode,
AuFS::EFileAdvisoryLockLevel processLockLevel)
AuUInt64 uOffset,
AuUInt uLength,
AuFS::EFileOpenMode mode,
AuFS::EFileAdvisoryLockLevel processLockLevel)
{
return this->MapFileByObjectEx(-1, pIOHandle, uOffset, uLength, mode, processLockLevel);
}
AuSPtr<IProcessSectionMapView> ProcessSectionViewReserved::MapIPCMemory(const AuString &handleString,
AuUInt64 uOffset,
AuUInt uLength,
AuFS::EFileOpenMode mode)
AuUInt64 uOffset,
AuUInt uLength,
AuFS::EFileOpenMode mode)
{
return this->MapIPCMemoryEx(-1, handleString, uOffset, uLength, mode);
}
@ -258,9 +258,9 @@ namespace Aurora::Process
}
auto pNewObject = AuMakeShared<ProcessSectionFileMapView>(AuUInt(map),
uLength,
false,
fd);
uLength,
false,
fd);
if (!pNewObject)
{
SysPushErrorMem();
@ -273,10 +273,10 @@ namespace Aurora::Process
}
AuSPtr<IProcessSectionMapView> ProcessSectionViewReserved::MapIPCMemoryEx(AuUInt viewOffset,
const AuString &handleString,
AuUInt64 uOffset,
AuUInt uLength,
Aurora::IO::FS::EFileOpenMode mode)
const AuString &handleString,
AuUInt64 uOffset,
AuUInt uLength,
Aurora::IO::FS::EFileOpenMode mode)
{
AuIPC::IPCHandle handle;
@ -351,9 +351,9 @@ namespace Aurora::Process
}
auto pNewObject = AuMakeShared<ProcessSectionFileMapView>(AuUInt(map),
uLength,
false,
fd);
uLength,
false,
fd);
if (!pNewObject)
{
SysPushErrorMem();

View File

@ -40,7 +40,7 @@ CreatePipeEx(
{
HANDLE ReadPipeHandle, WritePipeHandle;
DWORD dwError;
char PipeNameBuffer[MAX_PATH];
wchar_t sPipeNameBuffer[MAX_PATH];
//
// Only one valid OpenMode flag - FILE_FLAG_OVERLAPPED
@ -76,21 +76,21 @@ CreatePipeEx(
nSize = 16 * AuHwInfo::GetPageSize();
}
sprintf(PipeNameBuffer,
"\\\\.\\Pipe\\AuroraProcessCStandardStream.%08x.%08x",
swprintf(sPipeNameBuffer,
L"\\\\.\\Pipe\\AuroraProcessCStandardStream.%08x.%08x",
GetCurrentProcessId(),
AuAtomicAdd(&gPipeSerialNumber, 1u)
);
ReadPipeHandle = CreateNamedPipeA(
PipeNameBuffer,
PIPE_ACCESS_INBOUND | dwReadMode,
PIPE_TYPE_BYTE | PIPE_WAIT,
1, // Number of pipes
nSize, // Out buffer size
nSize, // In buffer size
120 * 1000, // Timeout in ms
lpPipeAttributes
ReadPipeHandle = CreateNamedPipeW(
sPipeNameBuffer,
PIPE_ACCESS_INBOUND | dwReadMode,
PIPE_TYPE_BYTE | PIPE_WAIT,
1, // Number of pipes
nSize, // Out buffer size
nSize, // In buffer size
120 * 1000, // Timeout in ms
lpPipeAttributes
);
if (!ReadPipeHandle)
@ -98,14 +98,13 @@ CreatePipeEx(
return FALSE;
}
WritePipeHandle = CreateFileA(
PipeNameBuffer,
GENERIC_WRITE,
0, // No sharing
lpPipeAttributes,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | dwWriteMode,
NULL // Template file
WritePipeHandle = Aurora::Win32Open2(sPipeNameBuffer,
GENERIC_WRITE,
0, // No sharing
lpPipeAttributes,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | dwWriteMode,
NULL // Template file
);
if (INVALID_HANDLE_VALUE == WritePipeHandle)

View File

@ -236,6 +236,7 @@
// benchmarking: https://github.com/microsoft/STL/issues/2085
#define GIB__GetSteadyTimeNS
// moved: _GetSteadyTimeNS
// ~3.0741 seconds
@ -326,7 +327,7 @@ namespace Aurora::Time
AUKN_SYM AuUInt64 SteadyClock()
{
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_XNU_DERIVED)
#if defined(GIB__GetSteadyTimeNS)
return _NTLikeQueryCounter();
#else
return SteadyClockNS() / (1000000000ull / SteadyClockFrequency());
@ -335,7 +336,7 @@ namespace Aurora::Time
AUKN_SYM AuUInt64 SteadyClockMS()
{
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_XNU_DERIVED)
#if defined(GIB__GetSteadyTimeNS)
return AuNSToMS<AuUInt64>(_GetSteadyTimeNS());
#elif defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
@ -354,7 +355,7 @@ namespace Aurora::Time
AUKN_SYM AuUInt64 SteadyClockNS()
{
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_XNU_DERIVED)
#if defined(GIB__GetSteadyTimeNS)
return _GetSteadyTimeNS();
#elif defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
@ -379,7 +380,7 @@ namespace Aurora::Time
return gFrequency;
}
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_XNU_DERIVED)
#if defined(GIB__GetSteadyTimeNS)
return gFrequency = _NTLikeQueryFrequency();
#elif defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};