From c0507448cf3290221297992507c0beebd283f4d9 Mon Sep 17 00:00:00 2001 From: The Wine Synchronizer Date: Thu, 29 Nov 2007 09:44:39 +0000 Subject: [PATCH] Autosyncing with Wine HEAD svn path=/trunk/; revision=30856 --- reactos/dll/win32/advpack/advpack.c | 36 +++++-- reactos/dll/win32/advpack/advpack.rbuild | 9 +- reactos/dll/win32/advpack/files.c | 126 ++++++++++------------- reactos/dll/win32/advpack/install.c | 12 +-- reactos/dll/win32/advpack/reg.c | 20 ++-- 5 files changed, 106 insertions(+), 97 deletions(-) diff --git a/reactos/dll/win32/advpack/advpack.c b/reactos/dll/win32/advpack/advpack.c index 2a8fecb19f0..8ef1c9ae397 100644 --- a/reactos/dll/win32/advpack/advpack.c +++ b/reactos/dll/win32/advpack/advpack.c @@ -49,6 +49,17 @@ static const WCHAR setup_key[] = { 'C','o','m','p','o','n','e','n','t','s',0 }; +/* Strip single quotes from a token - note size includes NULL */ +static void strip_quotes(WCHAR *buffer, DWORD *size) +{ + if (buffer[0] == '\'' && (*size > 1) && buffer[*size-2]=='\'') + { + *size -= 2; + buffer[*size] = 0x00; + memmove(buffer, buffer + 1, *size * sizeof(WCHAR)); + } +} + /* parses the destination directory parameters from pszSection * the parameters are of the form: root,key,value,unknown,fallback * we first read the reg value root\\key\\value and if that fails, @@ -68,8 +79,11 @@ static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dw /* load the destination parameters */ SetupFindFirstLineW(hInf, pszSection, NULL, &context); SetupGetStringFieldW(&context, 1, prefix, PREFIX_LEN, &size); + strip_quotes(prefix, &size); SetupGetStringFieldW(&context, 2, key, MAX_PATH, &size); + strip_quotes(key, &size); SetupGetStringFieldW(&context, 3, value, MAX_PATH, &size); + strip_quotes(value, &size); if (!lstrcmpW(prefix, hklm)) root = HKEY_LOCAL_MACHINE; @@ -84,7 +98,8 @@ static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dw if (RegOpenKeyW(root, key, &subkey) || RegQueryValueExW(subkey, value, NULL, NULL, (LPBYTE)pszBuffer, &size)) { - SetupGetStringFieldW(&context, 5, pszBuffer, dwSize, NULL); + SetupGetStringFieldW(&context, 5, pszBuffer, dwSize, &size); + strip_quotes(pszBuffer, &size); } RegCloseKey(subkey); @@ -116,6 +131,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) do { LPWSTR value, ptr, key, key_copy = NULL; + DWORD flags = 0; SetupGetLineTextW(&context, NULL, NULL, NULL, line, MAX_FIELD_LENGTH, &size); @@ -141,10 +157,12 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) while (*value == ' ') value++; - /* FIXME: need to check the query option */ + /* Extract the flags */ ptr = strchrW(value, ','); - if (ptr) + if (ptr) { *ptr = '\0'; + flags = atolW(ptr+1); + } /* set dest to pszWorkingDir if key is SourceDir */ if (pszWorkingDir && !lstrcmpiW(value, source_dir)) @@ -152,6 +170,10 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) else get_dest_dir(hInf, value, dest, MAX_PATH); + /* If prompting required, provide dialog to request path */ + if (flags & 0x04) + FIXME("Need to support changing paths - default will be used\n"); + /* set all ldids to dest */ while ((ptr = get_parameter(&key, ','))) { @@ -365,7 +387,7 @@ HRESULT WINAPI OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); set_ldids(*phInf, pszInstallSection, NULL); - + return S_OK; } @@ -672,7 +694,7 @@ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSecti else res = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } - + HeapFree(GetProcessHeap(), 0, bufferW); } @@ -789,7 +811,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename, else res = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } - + HeapFree(GetProcessHeap(), 0, bufferW); } @@ -850,7 +872,7 @@ HRESULT WINAPI TranslateInfStringExW(HINF hInf, LPCWSTR pszInfFilename, return SPAPI_E_LINE_NOT_FOUND; } - return S_OK; + return S_OK; } /*********************************************************************** diff --git a/reactos/dll/win32/advpack/advpack.rbuild b/reactos/dll/win32/advpack/advpack.rbuild index e1d9cf10b5e..2163f1f6988 100644 --- a/reactos/dll/win32/advpack/advpack.rbuild +++ b/reactos/dll/win32/advpack/advpack.rbuild @@ -1,13 +1,12 @@ + + . include/reactos/wine - - - 0x600 - 0x501 - 0x501 + 0x600 + 0x600 wine ole32 setupapi diff --git a/reactos/dll/win32/advpack/files.c b/reactos/dll/win32/advpack/files.c index fbe85cbaa40..7dc816f46bc 100644 --- a/reactos/dll/win32/advpack/files.c +++ b/reactos/dll/win32/advpack/files.c @@ -29,6 +29,7 @@ #include "winternl.h" #include "setupapi.h" #include "advpub.h" +#include "fdi.h" #include "wine/debug.h" #include "wine/unicode.h" #include "advpack_private.h" @@ -109,7 +110,7 @@ HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, * NOTES * If the INI file does not exist before adding entries to it, the file * will be created. - * + * * If lpcszBackupDir is NULL, the INI file is assumed to exist in * c:\windows or created there if it does not exist. */ @@ -122,7 +123,7 @@ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir, static const WCHAR szBackupEntry[] = { '-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0 }; - + static const WCHAR backslash[] = {'\\',0}; static const WCHAR ini[] = {'.','i','n','i',0}; static const WCHAR backup[] = {'b','a','c','k','u','p',0}; @@ -263,7 +264,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou if (!lpszSourceDir || !lpszSourceFile || !lpszDestDir) return E_INVALIDARG; - + fileQueue = SetupOpenFileQueue(); if (fileQueue == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError()); @@ -320,9 +321,9 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou done: SetupTermDefaultQueueCallback(pContext); SetupCloseFileQueue(fileQueue); - + HeapFree(GetProcessHeap(), 0, szDestFilename); - + return HRESULT_FROM_WIN32(dwLastError); } @@ -385,7 +386,7 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags) ret = S_OK; } } - + return ret; } @@ -419,7 +420,7 @@ HRESULT WINAPI DelNodeA(LPCSTR pszFileOrDirName, DWORD dwFlags) * pszFileOrDirName [I] Name of file or directory to delete * dwFlags [I] Flags; see include/advpub.h * - * RETURNS + * RETURNS * Success: S_OK * Failure: E_FAIL * @@ -432,9 +433,9 @@ HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags) { WCHAR fname[MAX_PATH]; HRESULT ret = E_FAIL; - + TRACE("(%s, %d)\n", debugstr_w(pszFileOrDirName), dwFlags); - + if (dwFlags) FIXME("Flags ignored!\n"); @@ -515,28 +516,29 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT /* The following defintions were copied from dlls/cabinet/cabinet.h */ -/* EXTRACTdest flags */ +/* SESSION Operation */ #define EXTRACT_FILLFILELIST 0x00000001 #define EXTRACT_EXTRACTFILES 0x00000002 -struct ExtractFileList { - LPSTR filename; - struct ExtractFileList *next; - BOOL unknown; /* always 1L */ -} ; +struct FILELIST{ + LPSTR FileName; + struct FILELIST *next; + BOOL DoExtract; +}; -/* the first parameter of the function Extract */ typedef struct { - long result1; /* 0x000 */ - long unknown1[3]; /* 0x004 */ - struct ExtractFileList *filelist; /* 0x010 */ - long filecount; /* 0x014 */ - DWORD flags; /* 0x018 */ - char directory[0x104]; /* 0x01c */ - char lastfile[0x20c]; /* 0x120 */ -} EXTRACTdest; + INT FileSize; + ERF Error; + struct FILELIST *FileList; + INT FileCount; + INT Operation; + CHAR Destination[MAX_PATH]; + CHAR CurrentFile[MAX_PATH]; + CHAR Reserved[MAX_PATH]; + struct FILELIST *FilterList; +} SESSION; -static HRESULT (WINAPI *pExtract)(EXTRACTdest*, LPCSTR); +static HRESULT (WINAPI *pExtract)(SESSION*, LPCSTR); /* removes legal characters before and after file list, and * converts the file list to a NULL-separated list @@ -547,7 +549,7 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) const char *first = FileList; const char *last = FileList + strlen(FileList) - 1; LPSTR szConvertedList, temp; - + /* any number of these chars before the list is OK */ while (first < last && (*first == ' ' || *first == '\t' || *first == ':')) first++; @@ -572,7 +574,7 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) HeapFree(GetProcessHeap(), 0, szConvertedList); return NULL; } - + *dwNumFiles = 1; /* convert the colons to double-null termination */ @@ -591,9 +593,9 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) return szConvertedList; } -static void free_file_node(struct ExtractFileList *pNode) +static void free_file_node(struct FILELIST *pNode) { - HeapFree(GetProcessHeap(), 0, pNode->filename); + HeapFree(GetProcessHeap(), 0, pNode->FileName); HeapFree(GetProcessHeap(), 0, pNode); } @@ -619,46 +621,32 @@ static BOOL file_in_list(LPCSTR szFile, LPCSTR szFileList) return FALSE; } -/* removes nodes from the linked list that aren't specified in szFileList - * returns the number of files that are in both the linked list and szFileList - */ -static DWORD fill_file_list(EXTRACTdest *extractDest, LPCSTR szCabName, LPCSTR szFileList) + +/* returns the number of files that are in both the linked list and szFileList */ +static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileList) { DWORD dwNumFound = 0; - struct ExtractFileList *pNode; - struct ExtractFileList *prev = NULL; + struct FILELIST *pNode; - extractDest->flags |= EXTRACT_FILLFILELIST; - if (pExtract(extractDest, szCabName)) + session->Operation |= EXTRACT_FILLFILELIST; + if (pExtract(session, szCabName)) { - extractDest->flags &= ~EXTRACT_FILLFILELIST; + session->Operation &= ~EXTRACT_FILLFILELIST; return -1; } - pNode = extractDest->filelist; + pNode = session->FileList; while (pNode) { - if (file_in_list(pNode->filename, szFileList)) - { - prev = pNode; - pNode = pNode->next; - dwNumFound++; - } - else if (prev) - { - prev->next = pNode->next; - free_file_node(pNode); - pNode = prev->next; - } + if (!file_in_list(pNode->FileName, szFileList)) + pNode->DoExtract = FALSE; else - { - extractDest->filelist = pNode->next; - free_file_node(pNode); - pNode = extractDest->filelist; - } + dwNumFound++; + + pNode = pNode->next; } - extractDest->flags &= ~EXTRACT_FILLFILELIST; + session->Operation &= ~EXTRACT_FILLFILELIST; return dwNumFound; } @@ -689,8 +677,8 @@ static DWORD fill_file_list(EXTRACTdest *extractDest, LPCSTR szCabName, LPCSTR s */ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, LPCSTR FileList, LPVOID LReserved, DWORD Reserved) -{ - EXTRACTdest extractDest; +{ + SESSION session; HMODULE hCabinet; HRESULT res = S_OK; DWORD dwFileCount = 0; @@ -717,8 +705,8 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, goto done; } - ZeroMemory(&extractDest, sizeof(EXTRACTdest)); - lstrcpyA(extractDest.directory, ExpandDir); + ZeroMemory(&session, sizeof(SESSION)); + lstrcpyA(session.Destination, ExpandDir); if (FileList) { @@ -729,7 +717,7 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, goto done; } - dwFilesFound = fill_file_list(&extractDest, CabName, szConvertedList); + dwFilesFound = fill_file_list(&session, CabName, szConvertedList); if (dwFilesFound != dwFileCount) { res = E_FAIL; @@ -737,15 +725,15 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, } } else - extractDest.flags |= EXTRACT_FILLFILELIST; + session.Operation |= EXTRACT_FILLFILELIST; - extractDest.flags |= EXTRACT_EXTRACTFILES; - res = pExtract(&extractDest, CabName); + session.Operation |= EXTRACT_EXTRACTFILES; + res = pExtract(&session, CabName); - if (extractDest.filelist) + if (session.FileList) { - struct ExtractFileList* curr = extractDest.filelist; - struct ExtractFileList* next; + struct FILELIST *curr = session.FileList; + struct FILELIST *next; while (curr) { @@ -824,7 +812,7 @@ HRESULT WINAPI FileSaveRestoreA(HWND hDlg, LPSTR pszFileList, LPSTR pszDir, RtlFreeUnicodeString(&basename); return hr; -} +} /*********************************************************************** * FileSaveRestoreW (ADVPACK.@) diff --git a/reactos/dll/win32/advpack/install.c b/reactos/dll/win32/advpack/install.c index 75f1ebf1d95..c5a5df00cda 100644 --- a/reactos/dll/win32/advpack/install.c +++ b/reactos/dll/win32/advpack/install.c @@ -82,7 +82,7 @@ static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, const void *arg) DWORD size; BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context); - + for (; ok; ok = SetupFindNextLine(&context, &context)) { WCHAR directory[MAX_INF_STRING_LENGTH]; @@ -148,7 +148,7 @@ static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg) HRESULT hr = S_OK; BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context); - + for (; ok; ok = SetupFindNextLine(&context, &context)) { WCHAR buffer[MAX_INF_STRING_LENGTH]; @@ -633,7 +633,7 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved) RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf); RtlCreateUnicodeStringFromAsciiz(§ion, pCab->pszSection); - + MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, sizeof(cabinfo.szSrcPath) / sizeof(WCHAR)); @@ -654,14 +654,14 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved) /*********************************************************************** * ExecuteCabW (ADVPACK.@) - * + * * Installs the INF file extracted from a specified cabinet file. - * + * * PARAMS * hwnd [I] Handle to the window used for the display. * pCab [I] Information about the cabinet file. * pReserved [I] Reserved. Must be NULL. - * + * * RETURNS * Success: S_OK. * Failure: E_FAIL. diff --git a/reactos/dll/win32/advpack/reg.c b/reactos/dll/win32/advpack/reg.c index be4eade5a2c..2b1418ad5d4 100644 --- a/reactos/dll/win32/advpack/reg.c +++ b/reactos/dll/win32/advpack/reg.c @@ -77,7 +77,7 @@ static BOOL create_tmp_ini_file(HMODULE hm, WCHAR *ini_file) if(!rsrc_data || !rsrc_size) { ERR("Can't load REGINST resource\n"); goto error; - } + } if((hf = CreateFileW(ini_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { @@ -213,7 +213,7 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path) * hm [I] Module that contains the REGINST resouce. * pszSection [I] The INF section to execute. * pstTable [I] Table of string substitutions. - * + * * RETURNS * Success: S_OK. * Failure: E_FAIL. @@ -239,11 +239,11 @@ HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstT for(i = 0; i < pstTable->cEntries; i++) { WCHAR tmp_value[MAX_PATH + 2]; - + tmp_value[0] = '\"'; lstrcpyW(tmp_value + 1, pstTable->pse[i].pszValue); lstrcatW(tmp_value, quote); - + WritePrivateProfileStringW(Strings, pstTable->pse[i].pszName, tmp_value, tmp_ini_path); } } @@ -307,8 +307,8 @@ HRESULT WINAPI RegRestoreAllA(HWND hWnd, LPSTR pszTitleString, HKEY hkBackupKey) HRESULT WINAPI RegRestoreAllW(HWND hWnd, LPWSTR pszTitleString, HKEY hkBackupKey) { FIXME("(%p, %s, %p) stub\n", hWnd, debugstr_w(pszTitleString), hkBackupKey); - - return E_FAIL; + + return E_FAIL; } /*********************************************************************** @@ -354,9 +354,9 @@ HRESULT WINAPI RegSaveRestoreA(HWND hWnd, LPCSTR pszTitleString, HKEY hkBackupKe * hkBackupKey [I] Key used to store the backup data. * pcszRootKey [I] Root key of the registry value * pcszSubKey [I] Sub key of the registry value. - * pcszValueName [I] Value to save or restore. + * pcszValueName [I] Value to save or restore. * dwFlags [I] See advpub.h. - * + * * RETURNS * Success: S_OK. * Failure: E_FAIL. @@ -372,7 +372,7 @@ HRESULT WINAPI RegSaveRestoreW(HWND hWnd, LPCWSTR pszTitleString, HKEY hkBackupK hkBackupKey, debugstr_w(pcszRootKey), debugstr_w(pcszSubKey), debugstr_w(pcszValueName), dwFlags); - return E_FAIL; + return E_FAIL; } /*********************************************************************** @@ -434,5 +434,5 @@ HRESULT WINAPI RegSaveRestoreOnINFW(HWND hWnd, LPCWSTR pszTitle, LPCWSTR pszINF, debugstr_w(pszINF), debugstr_w(pszSection), hHKLMBackKey, hHKCUBackKey, dwFlags); - return E_FAIL; + return E_FAIL; }