2018-03-23 22:55:13 +08:00
|
|
|
/*
|
2022-10-06 20:21:52 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2018-03-23 22:55:13 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-03-23 22:55:13 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/windows/sys_calls.h"
|
2018-03-23 22:55:13 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-03-23 22:55:13 +08:00
|
|
|
|
2021-05-27 05:45:38 +08:00
|
|
|
unsigned int getPid() {
|
|
|
|
return GetCurrentProcessId();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isShutdownInProgress() {
|
|
|
|
auto handle = GetModuleHandleA("ntdll.dll");
|
|
|
|
|
|
|
|
if (!handle) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto RtlDllShutdownInProgress = reinterpret_cast<BOOLEAN(WINAPI *)()>(GetProcAddress(handle, "RtlDllShutdownInProgress"));
|
|
|
|
return RtlDllShutdownInProgress();
|
|
|
|
}
|
|
|
|
|
2018-03-23 22:55:13 +08:00
|
|
|
namespace SysCalls {
|
|
|
|
|
2021-07-09 01:19:43 +08:00
|
|
|
unsigned int getProcessId() {
|
|
|
|
return GetCurrentProcessId();
|
|
|
|
}
|
|
|
|
|
2022-10-06 20:21:52 +08:00
|
|
|
unsigned long getNumThreads() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-03-23 22:55:13 +08:00
|
|
|
HANDLE createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) {
|
|
|
|
return CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL closeHandle(HANDLE hObject) {
|
|
|
|
return CloseHandle(hObject);
|
|
|
|
}
|
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
BOOL getSystemPowerStatus(LPSYSTEM_POWER_STATUS systemPowerStatusPtr) {
|
|
|
|
return GetSystemPowerStatus(systemPowerStatusPtr);
|
|
|
|
}
|
2019-10-03 21:33:18 +08:00
|
|
|
BOOL getModuleHandle(DWORD dwFlags, LPCWSTR lpModuleName, HMODULE *phModule) {
|
|
|
|
return GetModuleHandleEx(dwFlags, lpModuleName, phModule);
|
|
|
|
}
|
|
|
|
DWORD getModuleFileName(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) {
|
|
|
|
return GetModuleFileName(hModule, lpFilename, nSize);
|
|
|
|
}
|
2020-08-24 07:55:47 +08:00
|
|
|
char *getenv(const char *variableName) {
|
|
|
|
return ::getenv(variableName);
|
|
|
|
}
|
2021-10-05 19:21:46 +08:00
|
|
|
|
|
|
|
LSTATUS regOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult) {
|
|
|
|
return RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
LSTATUS regQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) {
|
|
|
|
return RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
|
|
|
}
|
2018-03-23 22:55:13 +08:00
|
|
|
} // namespace SysCalls
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|