Debug (Windows): adds ffDebugHResult

This commit is contained in:
李通洲
2026-03-27 20:14:47 +08:00
parent 63f7e15554
commit 90ca39b464
2 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -29,6 +29,7 @@ static inline const char* ffFindFileName(const char* file)
#define FF_DEBUG(format, ...) FF_DEBUG_PRINT(__FILE__, __LINE__, format, ##__VA_ARGS__)
#if _WIN32
const char* ffDebugWin32Error(unsigned long errorCode);
const char* ffDebugWin32Error(DWORD errorCode);
const char* ffDebugNtStatus(NTSTATUS status);
const char* ffDebugHResult(HRESULT hr);
#endif
+16
View File
@@ -32,3 +32,19 @@ const char* ffDebugNtStatus(NTSTATUS status)
{
return ffDebugWin32Error(RtlNtStatusToDosError(status));
}
static inline DWORD HRESULTToWin32Error(HRESULT hr)
{
if (SUCCEEDED(hr))
return ERROR_SUCCESS;
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
return HRESULT_CODE(hr);
return ERROR_INTERNAL_ERROR;
}
const char* ffDebugHResult(HRESULT hr)
{
return ffDebugWin32Error(HRESULTToWin32Error(hr));
}