diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c index f294821e073..de73966fb9d 100644 --- a/dlls/setupapi/misc.c +++ b/dlls/setupapi/misc.c @@ -1679,3 +1679,75 @@ BOOL WINAPI SetupOpenLog(BOOL reserved) return TRUE; } + +/*********************************************************************** + * SetupLogErrorA(SETUPAPI.@) + */ +BOOL WINAPI SetupLogErrorA(LPCSTR message, LogSeverity severity) +{ + static const char null[] = "(null)"; + BOOL ret; + DWORD written; + DWORD len; + + EnterCriticalSection(&setupapi_cs); + + if (setupact == INVALID_HANDLE_VALUE || setuperr == INVALID_HANDLE_VALUE) + { + SetLastError(ERROR_FILE_INVALID); + ret = FALSE; + goto done; + } + + if (message == NULL) + message = null; + + len = lstrlenA(message); + + ret = WriteFile(setupact, message, len, &written, NULL); + if (!ret) + goto done; + + if (severity >= LogSevMaximum) + { + ret = FALSE; + goto done; + } + + if (severity > LogSevInformation) + ret = WriteFile(setuperr, message, len, &written, NULL); + +done: + LeaveCriticalSection(&setupapi_cs); + return ret; +} + +/*********************************************************************** + * SetupLogErrorW(SETUPAPI.@) + */ +BOOL WINAPI SetupLogErrorW(LPCWSTR message, LogSeverity severity) +{ + LPSTR msg = NULL; + DWORD len; + BOOL ret; + + if (message) + { + len = WideCharToMultiByte(CP_ACP, 0, message, -1, NULL, 0, NULL, NULL); + msg = HeapAlloc(GetProcessHeap(), 0, len); + if (msg == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + WideCharToMultiByte(CP_ACP, 0, message, -1, msg, len, NULL, NULL); + } + + /* This is the normal way to proceed. The log files are ASCII files + * and W is to be converted. + */ + ret = SetupLogErrorA(msg, severity); + + HeapFree(GetProcessHeap(), 0, msg); + return ret; +} diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 4fcf2981d08..c1dbed5b027 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -459,7 +459,7 @@ @ stdcall SetupInstallServicesFromInfSectionW(long wstr long) @ stdcall SetupIterateCabinetA(str long ptr ptr) @ stdcall SetupIterateCabinetW(wstr long ptr ptr) -@ stub SetupLogErrorA +@ stdcall SetupLogErrorA(str long) @ stdcall SetupLogErrorW(wstr long) @ stdcall SetupLogFileA(ptr str str str long str str str long) @ stdcall SetupLogFileW(ptr wstr wstr wstr long wstr wstr wstr long) diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index 66bd5d4cb46..a57f5fe52ca 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -188,15 +188,6 @@ BOOL WINAPI RegistryDelnode(DWORD x, DWORD y) return FALSE; } -/*********************************************************************** - * SetupLogErrorW(SETUPAPI.@) - */ -BOOL WINAPI SetupLogErrorW(LPCWSTR MessageString, LogSeverity Severity) -{ - FIXME("(%s, %d) stub\n", debugstr_w(MessageString), Severity); - return TRUE; -} - /*********************************************************************** * SetupPromptReboot(SETUPAPI.@) */