From fab72e48ec3d029541e15668073fc3f2dc34708d Mon Sep 17 00:00:00 2001 From: The Wine Synchronizer Date: Mon, 18 Sep 2006 16:28:29 +0000 Subject: [PATCH] Autosyncing with Wine HEAD svn path=/trunk/; revision=24192 --- reactos/dll/win32/advpack/files.c | 13 ++-- reactos/dll/win32/advpack/install.c | 98 +++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 26 deletions(-) diff --git a/reactos/dll/win32/advpack/files.c b/reactos/dll/win32/advpack/files.c index 86cf70f6809..1d024438591 100644 --- a/reactos/dll/win32/advpack/files.c +++ b/reactos/dll/win32/advpack/files.c @@ -116,7 +116,7 @@ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, LPCWSTR lpcszBaseName, DWORD dwFlags) { WCHAR szIniPath[MAX_PATH]; - LPWSTR szString = NULL; + LPCWSTR szString = NULL; static const WCHAR szBackupEntry[] = { '-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0 @@ -144,7 +144,7 @@ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_NORMAL); if (dwFlags & AADBE_ADD_ENTRY) - szString = (LPWSTR)szBackupEntry; + szString = szBackupEntry; else if (dwFlags & AADBE_DEL_ENTRY) szString = NULL; @@ -249,7 +249,8 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou DWORD dwFlags, DWORD dwReserved) { PSP_FILE_CALLBACK_W pFileCallback; - LPWSTR szPath, szDestFilename; + LPWSTR szDestFilename; + LPCWSTR szPath; WCHAR szRootPath[ROOT_LENGTH]; DWORD dwLen, dwLastError; HSPFILEQ fileQueue; @@ -270,7 +271,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou dwLastError = ERROR_SUCCESS; lstrcpynW(szRootPath, lpszSourceDir, ROOT_LENGTH); - szPath = (LPWSTR)lpszSourceDir + ROOT_LENGTH; + szPath = lpszSourceDir + ROOT_LENGTH; /* use lpszSourceFile as destination filename if lpszDestFile is NULL */ if (lpszDestFile) @@ -547,8 +548,8 @@ static HRESULT (WINAPI *pExtract)(EXTRACTdest*, LPCSTR); static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) { DWORD dwLen; - char *first = (char *)FileList; - char *last = (char *)FileList + strlen(FileList) - 1; + const char *first = FileList; + const char *last = FileList + strlen(FileList) - 1; LPSTR szConvertedList, temp; /* any number of these chars before the list is OK */ diff --git a/reactos/dll/win32/advpack/install.c b/reactos/dll/win32/advpack/install.c index 2398b7587cb..8f356bac08a 100644 --- a/reactos/dll/win32/advpack/install.c +++ b/reactos/dll/win32/advpack/install.c @@ -50,6 +50,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(advpack); typedef struct _ADVInfo { HINF hinf; + LPWSTR inf_path; LPWSTR inf_filename; LPWSTR install_sec; LPWSTR working_dir; @@ -326,7 +327,7 @@ static HRESULT spapi_install(ADVInfo *info) SetupTermDefaultQueueCallback(context); ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec, - SPINST_INIFILES | SPINST_REGISTRY, + SPINST_INIFILES | SPINST_REGISTRY | SPINST_REGSVR, HKEY_LOCAL_MACHINE, NULL, 0, NULL, NULL, NULL, NULL); if (!ret) @@ -372,24 +373,80 @@ static HRESULT adv_install(ADVInfo *info) return hr; } +/* determines the proper working directory for the INF file */ +static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR working_dir) +{ + WCHAR path[MAX_PATH]; + LPCWSTR ptr; + DWORD len; + + static const WCHAR backslash[] = {'\\',0}; + static const WCHAR inf_dir[] = {'\\','I','N','F',0}; + + if ((ptr = strrchrW(inf_filename, '\\'))) + { + len = ptr - inf_filename + 1; + ptr = inf_filename; + } + else if (working_dir && *working_dir) + { + len = lstrlenW(working_dir) + 1; + ptr = working_dir; + } + else + { + GetCurrentDirectoryW(MAX_PATH, path); + lstrcatW(path, backslash); + lstrcatW(path, inf_filename); + + /* check if the INF file is in the current directory */ + if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES) + { + GetCurrentDirectoryW(MAX_PATH, path); + } + else + { + /* default to the windows\inf directory if all else fails */ + GetWindowsDirectoryW(path, MAX_PATH); + lstrcatW(path, inf_dir); + } + + len = lstrlenW(path) + 1; + ptr = path; + } + + info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!info->working_dir) + return E_OUTOFMEMORY; + + lstrcpynW(info->working_dir, ptr, len); + + return S_OK; +} + /* loads the INF file and performs checks on it */ HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info) { DWORD len; - LPCWSTR ptr; + HRESULT hr; + LPCWSTR ptr, path; + static const WCHAR backslash[] = {'\\',0}; static const WCHAR default_install[] = { 'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0 }; - len = lstrlenW(inf_filename); + if (!(ptr = strrchrW(inf_filename, '\\'))) + ptr = inf_filename; + + len = lstrlenW(ptr); info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); if (!info->inf_filename) return E_OUTOFMEMORY; - lstrcpyW(info->inf_filename, inf_filename); + lstrcpyW(info->inf_filename, ptr); /* FIXME: determine the proper platform to install (NTx86, etc) */ if (!install_sec || !*install_sec) @@ -409,26 +466,26 @@ HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, lstrcpyW(info->install_sec, ptr); - /* FIXME: need to get the real working directory */ - if (!working_dir || !*working_dir) - { - ptr = strrchrW(info->inf_filename, '\\'); - len = ptr - info->inf_filename + 1; - ptr = info->inf_filename; - } - else - { - len = lstrlenW(working_dir) + 1; - ptr = working_dir; - } + hr = get_working_dir(info, inf_filename, working_dir); + if (FAILED(hr)) + return hr; - info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!info->working_dir) + len = lstrlenW(info->working_dir) + lstrlenW(info->inf_filename) + 2; + info->inf_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!info->inf_path) return E_OUTOFMEMORY; - lstrcpynW(info->working_dir, ptr, len); + lstrcpyW(info->inf_path, info->working_dir); + lstrcatW(info->inf_path, backslash); + lstrcatW(info->inf_path, info->inf_filename); - info->hinf = SetupOpenInfFileW(info->inf_filename, NULL, INF_STYLE_WIN4, NULL); + /* RunSetupCommand opens unmodifed filename parameter */ + if (flags & RSC_FLAG_INF) + path = inf_filename; + else + path = info->inf_path; + + info->hinf = SetupOpenInfFileW(path, NULL, INF_STYLE_WIN4, NULL); if (info->hinf == INVALID_HANDLE_VALUE) return ADV_HRESULT(GetLastError()); @@ -448,6 +505,7 @@ void install_release(ADVInfo *info) if (info->hinf && info->hinf != INVALID_HANDLE_VALUE) SetupCloseInfFile(info->hinf); + HeapFree(GetProcessHeap(), 0, info->inf_path); HeapFree(GetProcessHeap(), 0, info->inf_filename); HeapFree(GetProcessHeap(), 0, info->install_sec); HeapFree(GetProcessHeap(), 0, info->working_dir);