Skip to content

Commit

Permalink
remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtum committed Oct 9, 2024
1 parent 546f15a commit b464746
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Source/core/Sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,23 +802,19 @@ namespace Core {
WindowsAPI& operator=(WindowsAPI&&) = delete;
WindowsAPI& operator=(const WindowsAPI&) = delete;

~WindowsAPI() = default;
WindowsAPI() {
HMODULE ntdll = GetModuleHandle(_T("ntdll.dll"));
_ntQuerySemaphore = reinterpret_cast<_NTQuerySemaphore>(GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "NtQuerySemaphore"));
ASSERT (_ntQuerySemaphore != nullptr);
}

uint32_t GetSemaphoreCount(HANDLE parameter) {
ASSERT (_ntQuerySemaphore != nullptr);
uint32_t GetSemaphoreCount(HANDLE parameter) const {
SEMAPHORE_BASIC_INFORMATION basicInfo;
NTSTATUS status;
status = _ntQuerySemaphore(parameter, 0, &basicInfo, sizeof(SEMAPHORE_BASIC_INFORMATION), nullptr);
if (status == ERROR_SUCCESS) {
return (basicInfo.CurrentCount);
}
return(0);
return (status == ERROR_SUCCESS) ? basicInfo.CurrentCount : 0;
}

private:
_NTQuerySemaphore _ntQuerySemaphore;
};

Expand Down

0 comments on commit b464746

Please sign in to comment.