mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[SETUPAPI]
Partly sync with Wine 1.7.47: - Implement SetupCloseLog(), SetupOpenLog(), SetupLogErrorA(), SetupLogErrorW() CORE-9924 svn path=/trunk/; revision=68705
This commit is contained in:
parent
740d16b122
commit
1f86353d60
4 changed files with 154 additions and 28 deletions
|
@ -28,6 +28,18 @@
|
|||
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(
|
||||
IN PWSTR InstallerName,
|
||||
|
@ -1964,4 +1976,143 @@ BOOL WINAPI SetupTerminateFileLog(HANDLE FileLogHandle)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -675,6 +675,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
UnloadCABINETDll();
|
||||
SetupCloseLog();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,32 +29,6 @@ BOOL WINAPI pSetupRegistryDelnode(DWORD x, DWORD 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;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupPromptReboot(SETUPAPI.@)
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue