[*] Minor tweaks + more not-so-lazy loads in case of uwp
This commit is contained in:
parent
7f0dc81ec3
commit
a087595009
@ -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;
|
||||
@ -579,6 +605,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()
|
||||
{
|
||||
if (gUseFastFail)
|
||||
@ -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,
|
||||
¶ms)) != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return hHandle;
|
||||
}
|
||||
|
||||
lpFileName = L"CON";
|
||||
}
|
||||
|
||||
return pCreateFile2W(lpFileName,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
dwCreationDisposition,
|
||||
¶ms);
|
||||
}
|
||||
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
#if !defined(AURORA_PLATFORM_WIN32)
|
||||
HMODULE UWPLibraryW(LPCWSTR lpLibFileName)
|
||||
{
|
||||
|
@ -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,
|
||||
@ -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
|
||||
);
|
||||
|
@ -115,13 +115,12 @@ namespace Aurora::IO::FS
|
||||
return utf8Root;
|
||||
}
|
||||
|
||||
auto hFile = ::CreateFileW(widePath.c_str(),
|
||||
auto hFile = Win32Open(widePath.c_str(),
|
||||
0,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_READ,
|
||||
nullptr,
|
||||
false,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
|
||||
nullptr);
|
||||
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(),
|
||||
auto hDevice = Win32Open(widePath.c_str(),
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
nullptr);
|
||||
false,
|
||||
OPEN_EXISTING);
|
||||
|
||||
if (hDevice == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -348,13 +345,11 @@ namespace Aurora::IO::FS
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto hDevice = ::CreateFileW(widePath.c_str(),
|
||||
auto hDevice = Win32Open(widePath.c_str(),
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
nullptr);
|
||||
false,
|
||||
OPEN_EXISTING);
|
||||
|
||||
if (hDevice == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -476,13 +471,11 @@ namespace Aurora::IO::FS
|
||||
continue;
|
||||
}
|
||||
|
||||
hDevice = ::CreateFileW(pInterfaceDetailData->DevicePath,
|
||||
hDevice = Win32Open(pInterfaceDetailData->DevicePath,
|
||||
0,
|
||||
0x00000007,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
nullptr);
|
||||
false,
|
||||
OPEN_EXISTING);
|
||||
|
||||
if (hDevice != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -707,13 +700,11 @@ namespace Aurora::IO::FS
|
||||
strVolumePath[i - 1] = '\x00';
|
||||
}
|
||||
|
||||
auto hVolume = ::CreateFileW(strVolumePath.c_str(),
|
||||
auto hVolume = Win32Open(strVolumePath.c_str(),
|
||||
0,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
0);
|
||||
false,
|
||||
OPEN_EXISTING);
|
||||
|
||||
if (hVolume == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
@ -62,8 +62,13 @@ namespace Aurora::IO::IPC
|
||||
|
||||
handle.PushId(EIPCHandleType::eIPCMemory, token);
|
||||
|
||||
if (!pCreateFileMappingA)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto path = token.ToNTPath();
|
||||
auto file = CreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
auto file = pCreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
nullptr,
|
||||
PAGE_READWRITE,
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
@ -81,7 +86,7 @@ namespace Aurora::IO::IPC
|
||||
return {};
|
||||
}
|
||||
|
||||
auto map = ::MapViewOfFile(file,
|
||||
auto map = pMapViewOfFile(file,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
@ -124,7 +129,7 @@ namespace Aurora::IO::IPC
|
||||
|
||||
auto uLength = token->token.word;
|
||||
auto path = token->token.ToNTPath();
|
||||
auto file = ::OpenFileMappingA(FILE_MAP_ALL_ACCESS,
|
||||
auto file = pOpenFileMappingA(FILE_MAP_ALL_ACCESS,
|
||||
FALSE,
|
||||
path.c_str());
|
||||
|
||||
@ -134,7 +139,7 @@ namespace Aurora::IO::IPC
|
||||
return {};
|
||||
}
|
||||
|
||||
auto map = ::MapViewOfFile(file,
|
||||
auto map = pMapViewOfFile(file,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
|
@ -459,13 +459,12 @@ namespace Aurora::IO::IPC
|
||||
#else
|
||||
auto name = "\\\\.\\pipe\\LOCAL\\" + token->token.ToNTPath();
|
||||
#endif
|
||||
pipe = CreateFileA(name.c_str(),
|
||||
pipe = Win32Open(AuLocale::ConvertFromUTF8(name).c_str(),
|
||||
GENERIC_WRITE | GENERIC_READ,
|
||||
0,
|
||||
NULL,
|
||||
false,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED);
|
||||
|
||||
if ((!pipe) ||
|
||||
(pipe == INVALID_HANDLE_VALUE))
|
||||
|
@ -238,10 +238,10 @@ namespace Aurora::IO::NT
|
||||
DWORD dwWritten {};
|
||||
auto name = GetIPCServerNameOfPid(handle.pid);
|
||||
|
||||
hPipe = CreateFileA(name.c_str(),
|
||||
hPipe = Win32Open(AuLocale::ConvertFromUTF8(name).c_str(),
|
||||
GENERIC_WRITE | GENERIC_READ,
|
||||
0,
|
||||
NULL,
|
||||
false,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
@ -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)
|
||||
|
@ -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,17 +99,58 @@ 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))
|
||||
{
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -130,12 +172,17 @@ namespace Aurora::Process
|
||||
return {};
|
||||
};
|
||||
|
||||
hFileMap = ::CreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
|
||||
if (!pCreateFileMappingA)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = pCreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
|
||||
nullptr,
|
||||
pageAttributes,
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
AuBitsToHigher(uLength),
|
||||
AuBitsToLower(uLength),
|
||||
AuBitsToHigher(uLength + uOffset),
|
||||
AuBitsToLower(uLength + uOffset),
|
||||
#else
|
||||
0,
|
||||
uLength,
|
||||
@ -148,7 +195,7 @@ namespace Aurora::Process
|
||||
return {};
|
||||
}
|
||||
|
||||
auto map = ::MapViewOfFile(hFileMap,
|
||||
auto map = pMapViewOfFile(hFileMap,
|
||||
desiredAccess,
|
||||
AuBitsToHigher(uOffset),
|
||||
AuBitsToLower(uOffset),
|
||||
@ -232,7 +279,7 @@ namespace Aurora::Process
|
||||
return {};
|
||||
};
|
||||
|
||||
hFileMap = ::OpenFileMappingA(desiredAccess,
|
||||
hFileMap = pOpenFileMappingA(desiredAccess,
|
||||
FALSE,
|
||||
path.c_str());
|
||||
if ((hFileMap == INVALID_HANDLE_VALUE) ||
|
||||
@ -242,7 +289,7 @@ namespace Aurora::Process
|
||||
return {};
|
||||
}
|
||||
|
||||
auto map = ::MapViewOfFile(hFileMap,
|
||||
auto map = pMapViewOfFile(hFileMap,
|
||||
desiredAccess,
|
||||
AuBitsToHigher(uOffset),
|
||||
AuBitsToLower(uOffset),
|
||||
@ -312,7 +359,12 @@ namespace Aurora::Process
|
||||
uPageFlags = PAGE_EXECUTE_READ;
|
||||
}
|
||||
|
||||
hFileMap = ::CreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
if (!pCreateFileMappingA)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = pCreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
nullptr,
|
||||
uPageFlags,
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
@ -346,7 +398,7 @@ namespace Aurora::Process
|
||||
sectionPermission |= SECTION_MAP_EXECUTE;
|
||||
}
|
||||
|
||||
auto map = ::MapViewOfFile(hFileMap,
|
||||
auto map = pMapViewOfFile(hFileMap,
|
||||
sectionPermission,
|
||||
0,
|
||||
0,
|
||||
|
@ -249,7 +249,12 @@ namespace Aurora::Process
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = ::CreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
if (!pCreateFileMappingA)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = pCreateFileMappingA(INVALID_HANDLE_VALUE,
|
||||
nullptr,
|
||||
uPageFlags,
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
@ -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,17 +376,58 @@ 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))
|
||||
{
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -402,12 +449,17 @@ namespace Aurora::Process
|
||||
return {};
|
||||
};
|
||||
|
||||
hFileMap = ::CreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
|
||||
if (!pCreateFileMappingA)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = pCreateFileMappingA((HANDLE)pIOHandle->GetOSHandle(),
|
||||
nullptr,
|
||||
pageAttributes,
|
||||
#if defined(AURORA_IS_64BIT)
|
||||
AuBitsToHigher(uLength),
|
||||
AuBitsToLower(uLength),
|
||||
AuBitsToHigher(uLength + uOffset),
|
||||
AuBitsToLower(uLength + uOffset),
|
||||
#else
|
||||
0,
|
||||
uLength,
|
||||
@ -515,7 +567,7 @@ namespace Aurora::Process
|
||||
return {};
|
||||
}
|
||||
|
||||
hFileMap = ::OpenFileMappingA(desiredAccess,
|
||||
hFileMap = pOpenFileMappingA(desiredAccess,
|
||||
FALSE,
|
||||
path.c_str());
|
||||
if ((hFileMap == INVALID_HANDLE_VALUE) ||
|
||||
|
@ -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,14 +76,14 @@ 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,
|
||||
ReadPipeHandle = CreateNamedPipeW(
|
||||
sPipeNameBuffer,
|
||||
PIPE_ACCESS_INBOUND | dwReadMode,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
1, // Number of pipes
|
||||
@ -98,8 +98,7 @@ CreatePipeEx(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WritePipeHandle = CreateFileA(
|
||||
PipeNameBuffer,
|
||||
WritePipeHandle = Aurora::Win32Open2(sPipeNameBuffer,
|
||||
GENERIC_WRITE,
|
||||
0, // No sharing
|
||||
lpPipeAttributes,
|
||||
|
@ -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 {};
|
||||
|
Loading…
Reference in New Issue
Block a user