diff --git a/ext/winevt/winevt_c.h b/ext/winevt/winevt_c.h index 8dc50d2..2d1892a 100644 --- a/ext/winevt/winevt_c.h +++ b/ext/winevt/winevt_c.h @@ -38,6 +38,9 @@ typedef struct { extern "C" { #endif /* __cplusplus */ +#define WINEVT_UTILS_ERROR_NONE_MAPPED -1 +#define WINEVT_UTILS_ERROR_OTHERS -2 + VALUE wstr_to_rb_str(UINT cp, const WCHAR* wstr, int clen); #if defined(__cplusplus) [[ noreturn ]] diff --git a/ext/winevt/winevt_utils.cpp b/ext/winevt/winevt_utils.cpp index 9ccdb1b..a8870fb 100644 --- a/ext/winevt/winevt_utils.cpp +++ b/ext/winevt/winevt_utils.cpp @@ -635,16 +635,17 @@ static int ExpandSIDWString(PSID sid, CHAR **out_expanded) DWORD result_len = 0; CHAR *formatted = NULL; VALUE vformatted; +#undef MAX_NAME if (!LookupAccountSidW(NULL, sid, wAccount, &len, wDomain, &len, &sid_type)) { err = GetLastError(); if (err == ERROR_NONE_MAPPED) { - goto not_mapped_error; + goto none_mapped_error; } else { - return -2; + return WINEVT_UTILS_ERROR_OTHERS; } goto error; @@ -680,9 +681,9 @@ static int ExpandSIDWString(PSID sid, CHAR **out_expanded) return 0; -not_mapped_error: +none_mapped_error: - return -1; + return WINEVT_UTILS_ERROR_NONE_MAPPED; error: err = GetLastError();