Author: pschweitzer Date: Thu Aug 13 09:38:33 2015 New Revision: 68705
URL: http://svn.reactos.org/svn/reactos?rev=68705&view=rev Log: [SETUPAPI] Partly sync with Wine 1.7.47: - Implement SetupCloseLog(), SetupOpenLog(), SetupLogErrorA(), SetupLogErrorW()
CORE-9924
Modified: trunk/reactos/dll/win32/setupapi/misc.c trunk/reactos/dll/win32/setupapi/setupapi.spec trunk/reactos/dll/win32/setupapi/setupcab.c trunk/reactos/dll/win32/setupapi/stubs.c
Modified: trunk/reactos/dll/win32/setupapi/misc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/misc.c?r... ============================================================================== --- trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] Thu Aug 13 09:38:33 2015 @@ -27,6 +27,18 @@ /* Unicode constants */ static const WCHAR BackSlash[] = {'\',0}; static const WCHAR TranslationRegKey[] = {'\','V','e','r','F','i','l','e','I','n','f','o','\','T','r','a','n','s','l','a','t','i','o','n',0}; + +/* Handles and critical sections for the SetupLog API */ +static HANDLE setupact = INVALID_HANDLE_VALUE; +static HANDLE setuperr = INVALID_HANDLE_VALUE; +static CRITICAL_SECTION setupapi_cs; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &setupapi_cs, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": setupapi_cs") } +}; +static CRITICAL_SECTION setupapi_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
DWORD GetFunctionPointer( @@ -1964,4 +1976,143 @@ SetLastError(ERROR_SUCCESS);
return TRUE; -} +} + +/*********************************************************************** + * SetupCloseLog(SETUPAPI.@) + */ +void WINAPI SetupCloseLog(void) +{ + EnterCriticalSection(&setupapi_cs); + + CloseHandle(setupact); + setupact = INVALID_HANDLE_VALUE; + + CloseHandle(setuperr); + setuperr = INVALID_HANDLE_VALUE; + + LeaveCriticalSection(&setupapi_cs); +} + +/*********************************************************************** + * SetupOpenLog(SETUPAPI.@) + */ +BOOL WINAPI SetupOpenLog(BOOL reserved) +{ + WCHAR path[MAX_PATH]; + + static const WCHAR setupactlog[] = {'\','s','e','t','u','p','a','c','t','.','l','o','g',0}; + static const WCHAR setuperrlog[] = {'\','s','e','t','u','p','e','r','r','.','l','o','g',0}; + + EnterCriticalSection(&setupapi_cs); + + if (setupact != INVALID_HANDLE_VALUE && setuperr != INVALID_HANDLE_VALUE) + { + LeaveCriticalSection(&setupapi_cs); + return TRUE; + } + + GetWindowsDirectoryW(path, MAX_PATH); + lstrcatW(path, setupactlog); + + setupact = CreateFileW(path, FILE_GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (setupact == INVALID_HANDLE_VALUE) + { + LeaveCriticalSection(&setupapi_cs); + return FALSE; + } + + SetFilePointer(setupact, 0, NULL, FILE_END); + + GetWindowsDirectoryW(path, MAX_PATH); + lstrcatW(path, setuperrlog); + + setuperr = CreateFileW(path, FILE_GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (setuperr == INVALID_HANDLE_VALUE) + { + CloseHandle(setupact); + setupact = INVALID_HANDLE_VALUE; + LeaveCriticalSection(&setupapi_cs); + return FALSE; + } + + SetFilePointer(setuperr, 0, NULL, FILE_END); + + LeaveCriticalSection(&setupapi_cs); + + 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; +}
Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi... ============================================================================== --- trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] Thu Aug 13 09:38:33 2015 @@ -452,7 +452,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) @ stub SetupLogFileA @ stub SetupLogFileW
Modified: trunk/reactos/dll/win32/setupapi/setupcab.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupcab... ============================================================================== --- trunk/reactos/dll/win32/setupapi/setupcab.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/setupcab.c [iso-8859-1] Thu Aug 13 09:38:33 2015 @@ -675,6 +675,7 @@ break; case DLL_PROCESS_DETACH: UnloadCABINETDll(); + SetupCloseLog(); break; }
Modified: trunk/reactos/dll/win32/setupapi/stubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/stubs.c?... ============================================================================== --- trunk/reactos/dll/win32/setupapi/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/setupapi/stubs.c [iso-8859-1] Thu Aug 13 09:38:33 2015 @@ -27,32 +27,6 @@ { FIXME("%08x %08x: stub\n", x, y); return FALSE; -} - -/*********************************************************************** - * SetupCloseLog(SETUPAPI.@) - */ -void WINAPI SetupCloseLog(void) -{ - FIXME("() stub\n"); -} - -/*********************************************************************** - * SetupLogErrorW(SETUPAPI.@) - */ -BOOL WINAPI SetupLogErrorW(LPCWSTR MessageString, LogSeverity Severity) -{ - FIXME("(%s, %d) stub\n", debugstr_w(MessageString), Severity); - return TRUE; -} - -/*********************************************************************** - * SetupOpenLog(SETUPAPI.@) - */ -BOOL WINAPI SetupOpenLog(BOOL Reserved) -{ - FIXME("(%d) stub\n", Reserved); - return TRUE; }
/***********************************************************************