static HRESULT WINAPI HTMLFormElement_put_dir(IHTMLFormElement *iface, BSTR v) { HTMLFormElement *This = impl_from_IHTMLFormElement(iface); FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); return E_NOTIMPL; }
static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface, BSTR name, DWORD grfdex, DISPID *pid) { HTMLFormElement *This = impl_from_HTMLDOMNode(iface); nsIDOMHTMLCollection *elements; nsAString nsstr, name_str; UINT32 len, i; nsresult nsres; HRESULT hres = DISP_E_UNKNOWNNAME; static const PRUnichar nameW[] = {'n','a','m','e',0}; TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid); nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements); if(NS_FAILED(nsres)) { FIXME("GetElements failed: 0x%08x\n", nsres); return E_FAIL; } nsres = nsIDOMHTMLCollection_GetLength(elements, &len); if(NS_FAILED(nsres)) { FIXME("GetLength failed: 0x%08x\n", nsres); nsIDOMHTMLCollection_Release(elements); return E_FAIL; } if(len > MSHTML_CUSTOM_DISPID_CNT) len = MSHTML_CUSTOM_DISPID_CNT; /* FIXME: Implement in more generic way */ if('0' <= *name && *name <= '9') { WCHAR *end_ptr; i = strtoulW(name, &end_ptr, 10); if(!*end_ptr && i < len) { *pid = MSHTML_DISPID_CUSTOM_MIN + i; return S_OK; } } nsAString_Init(&nsstr, NULL); for(i = 0; i < len; ++i) { nsIDOMNode *nsitem; nsIDOMHTMLElement *nshtml_elem; const PRUnichar *str; nsres = nsIDOMHTMLCollection_Item(elements, i, &nsitem); if(NS_FAILED(nsres)) { FIXME("Item failed: 0x%08x\n", nsres); hres = E_FAIL; break; } nsres = nsIDOMNode_QueryInterface(nsitem, &IID_nsIDOMHTMLElement, (void**)&nshtml_elem); nsIDOMNode_Release(nsitem); if(NS_FAILED(nsres)) { FIXME("Failed to get nsIDOMHTMLNode interface: 0x%08x\n", nsres); hres = E_FAIL; break; } /* compare by id attr */ nsres = nsIDOMHTMLElement_GetId(nshtml_elem, &nsstr); if(NS_FAILED(nsres)) { FIXME("GetId failed: 0x%08x\n", nsres); nsIDOMHTMLElement_Release(nshtml_elem); hres = E_FAIL; break; } nsAString_GetData(&nsstr, &str); if(!strcmpiW(str, name)) { nsIDOMHTMLElement_Release(nshtml_elem); /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; hres = S_OK; break; } /* compare by name attr */ nsres = get_elem_attr_value(nshtml_elem, nameW, &name_str, &str); nsIDOMHTMLElement_Release(nshtml_elem); if(NS_SUCCEEDED(nsres)) { if(!strcmpiW(str, name)) { nsAString_Finish(&name_str); /* FIXME: using index for dispid */ *pid = MSHTML_DISPID_CUSTOM_MIN + i; hres = S_OK; break; } nsAString_Finish(&name_str); } } nsAString_Finish(&nsstr); nsIDOMHTMLCollection_Release(elements); return hres; }
static void test_SetTargetComputer(void) { WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 3]; /* extra space for two '\' and a zero */ DWORD len = MAX_COMPUTERNAME_LENGTH + 1; /* extra space for a zero */ WCHAR *oldname = NULL; WCHAR *name = NULL; HRESULT hres; buffer[0] = '\\'; buffer[1] = '\\'; if (!GetComputerNameW(buffer + 2, &len)) return; /* Create TaskScheduler */ hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskScheduler, (void **) &test_task_scheduler); ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres); if (hres != S_OK) { skip("Failed to create task scheduler. Skipping tests.\n"); return; } hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &oldname); ok(hres == S_OK, "got 0x%x and %s (expected S_OK)\n", hres, wine_dbgstr_w(oldname)); /* NULL is an alias for the local computer */ hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, NULL); ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres); hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &name); ok((hres == S_OK && !lstrcmpiW(name, buffer)), "got 0x%x with %s (expected S_OK and %s)\n", hres, wine_dbgstr_w(name), wine_dbgstr_w(buffer)); CoTaskMemFree(name); /* The name must be valid */ hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, does_not_existW); ok(hres == HRESULT_FROM_WIN32(ERROR_BAD_NETPATH), "got 0x%x (expected 0x80070035)\n", hres); /* the name of the target computer is unchanged */ hres = ITaskScheduler_GetTargetComputer(test_task_scheduler, &name); ok((hres == S_OK && !lstrcmpiW(name, buffer)), "got 0x%x with %s (expected S_OK and %s)\n", hres, wine_dbgstr_w(name), wine_dbgstr_w(buffer)); CoTaskMemFree(name); /* the two backslashes are optional */ hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, oldname + 2); ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres); /* the case is ignored */ CharUpperW(buffer); hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, buffer); ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres); CharLowerW(buffer); hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, buffer); ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres); /* cleanup */ hres = ITaskScheduler_SetTargetComputer(test_task_scheduler, oldname); ok(hres == S_OK, "got 0x%x (expected S_OK)\n", hres); CoTaskMemFree(oldname); ITaskScheduler_Release(test_task_scheduler); return; }
/* * WFP is Windows File Protection, in NT5 and Windows 2000 it maintains a cache * of known good dlls and scans through and replaces corrupted DLLs with these * known good versions. The only programs that should install into this dll * cache are Windows Updates and IE (which is treated like a Windows Update) * * Implementing this allows installing ie in win2k mode to actually install the * system dlls that we expect and need */ static int ProcessWindowsFileProtection(void) { static const WCHAR winlogonW[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s',' ','N','T','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'W','i','n','l','o','g','o','n',0}; static const WCHAR cachedirW[] = {'S','F','C','D','l','l','C','a','c','h','e','D','i','r',0}; static const WCHAR dllcacheW[] = {'\\','d','l','l','c','a','c','h','e','\\','*',0}; static const WCHAR wildcardW[] = {'\\','*',0}; WIN32_FIND_DATAW finddata; HANDLE find_handle; BOOL find_rc; DWORD rc; HKEY hkey; LPWSTR dllcache = NULL; if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, winlogonW, &hkey )) { DWORD sz = 0; if (!RegQueryValueExW( hkey, cachedirW, 0, NULL, NULL, &sz)) { sz += sizeof(WCHAR); dllcache = HeapAlloc(GetProcessHeap(),0,sz + sizeof(wildcardW)); RegQueryValueExW( hkey, cachedirW, 0, NULL, (LPBYTE)dllcache, &sz); strcatW( dllcache, wildcardW ); } } RegCloseKey(hkey); if (!dllcache) { DWORD sz = GetSystemDirectoryW( NULL, 0 ); dllcache = HeapAlloc( GetProcessHeap(), 0, sz * sizeof(WCHAR) + sizeof(dllcacheW)); GetSystemDirectoryW( dllcache, sz ); strcatW( dllcache, dllcacheW ); } find_handle = FindFirstFileW(dllcache,&finddata); dllcache[ strlenW(dllcache) - 2] = 0; /* strip off wildcard */ find_rc = find_handle != INVALID_HANDLE_VALUE; while (find_rc) { static const WCHAR dotW[] = {'.',0}; static const WCHAR dotdotW[] = {'.','.',0}; WCHAR targetpath[MAX_PATH]; WCHAR currentpath[MAX_PATH]; UINT sz; UINT sz2; WCHAR tempfile[MAX_PATH]; if (strcmpW(finddata.cFileName,dotW) == 0 || strcmpW(finddata.cFileName,dotdotW) == 0) { find_rc = FindNextFileW(find_handle,&finddata); continue; } sz = MAX_PATH; sz2 = MAX_PATH; VerFindFileW(VFFF_ISSHAREDFILE, finddata.cFileName, windowsdir, windowsdir, currentpath, &sz, targetpath, &sz2); sz = MAX_PATH; rc = VerInstallFileW(0, finddata.cFileName, finddata.cFileName, dllcache, targetpath, currentpath, tempfile, &sz); if (rc != ERROR_SUCCESS) { WINE_WARN("WFP: %s error 0x%x\n",wine_dbgstr_w(finddata.cFileName),rc); DeleteFileW(tempfile); } /* now delete the source file so that we don't try to install it over and over again */ lstrcpynW( targetpath, dllcache, MAX_PATH - 1 ); sz = strlenW( targetpath ); targetpath[sz++] = '\\'; lstrcpynW( targetpath + sz, finddata.cFileName, MAX_PATH - sz ); if (!DeleteFileW( targetpath )) WINE_WARN( "failed to delete %s: error %u\n", wine_dbgstr_w(targetpath), GetLastError() ); find_rc = FindNextFileW(find_handle,&finddata); } FindClose(find_handle); HeapFree(GetProcessHeap(),0,dllcache); return 1; }
/* * Process a "Run" type registry key. * hkRoot is the HKEY from which "Software\Microsoft\Windows\CurrentVersion" is * opened. * szKeyName is the key holding the actual entries. * bDelete tells whether we should delete each value right before executing it. * bSynchronous tells whether we should wait for the prog to complete before * going on to the next prog. */ static BOOL ProcessRunKeys( HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete, BOOL bSynchronous ) { static const WCHAR WINKEY_NAME[]={'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0}; HKEY hkWin, hkRun; DWORD res, dispos; DWORD i, nMaxCmdLine=0, nMaxValue=0; WCHAR *szCmdLine=NULL; WCHAR *szValue=NULL; if (hkRoot==HKEY_LOCAL_MACHINE) WINE_TRACE("processing %s entries under HKLM\n",wine_dbgstr_w(szKeyName) ); else WINE_TRACE("processing %s entries under HKCU\n",wine_dbgstr_w(szKeyName) ); if (RegCreateKeyExW( hkRoot, WINKEY_NAME, 0, NULL, 0, KEY_READ, NULL, &hkWin, NULL ) != ERROR_SUCCESS) return TRUE; if ((res = RegCreateKeyExW( hkWin, szKeyName, 0, NULL, 0, bDelete ? KEY_ALL_ACCESS : KEY_READ, NULL, &hkRun, &dispos ) != ERROR_SUCCESS)) { RegCloseKey( hkWin ); return TRUE; } RegCloseKey( hkWin ); if (dispos == REG_CREATED_NEW_KEY) goto end; if( (res=RegQueryInfoKeyW( hkRun, NULL, NULL, NULL, NULL, NULL, NULL, &i, &nMaxValue, &nMaxCmdLine, NULL, NULL ))!=ERROR_SUCCESS ) goto end; if( i==0 ) { WINE_TRACE("No commands to execute.\n"); res=ERROR_SUCCESS; goto end; } if( (szCmdLine=HeapAlloc(GetProcessHeap(),0,nMaxCmdLine))==NULL ) { WINE_ERR("Couldn't allocate memory for the commands to be executed\n"); res=ERROR_NOT_ENOUGH_MEMORY; goto end; } if( (szValue=HeapAlloc(GetProcessHeap(),0,(++nMaxValue)*sizeof(*szValue)))==NULL ) { WINE_ERR("Couldn't allocate memory for the value names\n"); res=ERROR_NOT_ENOUGH_MEMORY; goto end; } while( i>0 ) { DWORD nValLength=nMaxValue, nDataLength=nMaxCmdLine; DWORD type; --i; if( (res=RegEnumValueW( hkRun, i, szValue, &nValLength, 0, &type, (LPBYTE)szCmdLine, &nDataLength ))!=ERROR_SUCCESS ) { WINE_ERR("Couldn't read in value %d - %d\n", i, res ); continue; } if( bDelete && (res=RegDeleteValueW( hkRun, szValue ))!=ERROR_SUCCESS ) { WINE_ERR("Couldn't delete value - %d, %d. Running command anyways.\n", i, res ); } if( type!=REG_SZ ) { WINE_ERR("Incorrect type of value #%d (%d)\n", i, type ); continue; } if( (res=runCmd(szCmdLine, NULL, bSynchronous, FALSE ))==INVALID_RUNCMD_RETURN ) { WINE_ERR("Error running cmd %s (%d)\n", wine_dbgstr_w(szCmdLine), GetLastError() ); } WINE_TRACE("Done processing cmd #%d\n", i); } res=ERROR_SUCCESS; end: HeapFree( GetProcessHeap(), 0, szValue ); HeapFree( GetProcessHeap(), 0, szCmdLine ); if( hkRun!=NULL ) RegCloseKey( hkRun ); WINE_TRACE("done\n"); return res==ERROR_SUCCESS; }
/* Process items in the StartUp group of the user's Programs under the Start Menu. Some installers put * shell links here to restart themselves after boot. */ static BOOL ProcessStartupItems(void) { BOOL ret = FALSE; HRESULT hr; IMalloc *ppM = NULL; IShellFolder *psfDesktop = NULL, *psfStartup = NULL; LPITEMIDLIST pidlStartup = NULL, pidlItem; ULONG NumPIDLs; IEnumIDList *iEnumList = NULL; STRRET strret; WCHAR wszCommand[MAX_PATH]; WINE_TRACE("Processing items in the StartUp folder.\n"); hr = SHGetMalloc(&ppM); if (FAILED(hr)) { WINE_ERR("Couldn't get IMalloc object.\n"); goto done; } hr = SHGetDesktopFolder(&psfDesktop); if (FAILED(hr)) { WINE_ERR("Couldn't get desktop folder.\n"); goto done; } hr = SHGetSpecialFolderLocation(NULL, CSIDL_STARTUP, &pidlStartup); if (FAILED(hr)) { WINE_TRACE("Couldn't get StartUp folder location.\n"); goto done; } hr = IShellFolder_BindToObject(psfDesktop, pidlStartup, NULL, &IID_IShellFolder, (LPVOID*)&psfStartup); if (FAILED(hr)) { WINE_TRACE("Couldn't bind IShellFolder to StartUp folder.\n"); goto done; } hr = IShellFolder_EnumObjects(psfStartup, NULL, SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList); if (FAILED(hr)) { WINE_TRACE("Unable to enumerate StartUp objects.\n"); goto done; } while (IEnumIDList_Next(iEnumList, 1, &pidlItem, &NumPIDLs) == S_OK && (NumPIDLs) == 1) { hr = IShellFolder_GetDisplayNameOf(psfStartup, pidlItem, SHGDN_FORPARSING, &strret); if (FAILED(hr)) WINE_TRACE("Unable to get display name of enumeration item.\n"); else { hr = StrRetToBufW(&strret, pidlItem, wszCommand, MAX_PATH); if (FAILED(hr)) WINE_TRACE("Unable to parse display name.\n"); else { HINSTANCE hinst; hinst = ShellExecuteW(NULL, NULL, wszCommand, NULL, NULL, SW_SHOWNORMAL); if (PtrToUlong(hinst) <= 32) WINE_WARN("Error %p executing command %s.\n", hinst, wine_dbgstr_w(wszCommand)); } } IMalloc_Free(ppM, pidlItem); } /* Return success */ ret = TRUE; done: if (iEnumList) IEnumIDList_Release(iEnumList); if (psfStartup) IShellFolder_Release(psfStartup); if (pidlStartup) IMalloc_Free(ppM, pidlStartup); return ret; }
int main( int argc, char *argv[] ) { extern HANDLE CDECL __wine_make_process_system(void); static const WCHAR RunW[] = {'R','u','n',0}; static const WCHAR RunOnceW[] = {'R','u','n','O','n','c','e',0}; static const WCHAR RunServicesW[] = {'R','u','n','S','e','r','v','i','c','e','s',0}; static const WCHAR RunServicesOnceW[] = {'R','u','n','S','e','r','v','i','c','e','s','O','n','c','e',0}; static const WCHAR wineboot_eventW[] = {'_','_','w','i','n','e','b','o','o','t','_','e','v','e','n','t',0}; /* First, set the current directory to SystemRoot */ int optc; BOOL end_session, force, init, kill, restart, shutdown, update; HANDLE event; SECURITY_ATTRIBUTES sa; BOOL is_wow64; end_session = force = init = kill = restart = shutdown = update = FALSE; GetWindowsDirectoryW( windowsdir, MAX_PATH ); if( !SetCurrentDirectoryW( windowsdir ) ) WINE_ERR("Cannot set the dir to %s (%d)\n", wine_dbgstr_w(windowsdir), GetLastError() ); if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64) { STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR filename[MAX_PATH]; void *redir; DWORD exit_code; memset( &si, 0, sizeof(si) ); si.cb = sizeof(si); GetModuleFileNameW( 0, filename, MAX_PATH ); Wow64DisableWow64FsRedirection( &redir ); if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi )) { WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) ); WaitForSingleObject( pi.hProcess, INFINITE ); GetExitCodeProcess( pi.hProcess, &exit_code ); ExitProcess( exit_code ); } else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename), GetLastError() ); Wow64RevertWow64FsRedirection( redir ); } while ((optc = getopt_long(argc, argv, short_options, long_options, NULL )) != -1) { switch(optc) { case 'e': end_session = TRUE; break; case 'f': force = TRUE; break; case 'i': init = TRUE; break; case 'k': kill = TRUE; break; case 'r': restart = TRUE; break; case 's': shutdown = TRUE; break; case 'u': update = TRUE; break; case 'h': usage(); return 0; case '?': usage(); return 1; } } if (end_session) { if (kill) { if (!shutdown_all_desktops( force )) return 1; } else if (!shutdown_close_windows( force )) return 1; } if (kill) kill_processes( shutdown ); if (shutdown) return 0; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* so that services.exe inherits it */ event = CreateEventW( &sa, TRUE, FALSE, wineboot_eventW ); ResetEvent( event ); /* in case this is a restart */ create_hardware_registry_keys(); create_dynamic_registry_keys(); create_environment_registry_keys(); wininit(); pendingRename(); ProcessWindowsFileProtection(); ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesOnceW, TRUE, FALSE ); if (init || (kill && !restart)) { ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesW, FALSE, FALSE ); start_services_process(); } if (init || update) update_wineprefix( update ); create_volatile_environment_registry_key(); ProcessRunKeys( HKEY_LOCAL_MACHINE, RunOnceW, TRUE, TRUE ); if (!init && !restart) { ProcessRunKeys( HKEY_LOCAL_MACHINE, RunW, FALSE, FALSE ); ProcessRunKeys( HKEY_CURRENT_USER, RunW, FALSE, FALSE ); ProcessStartupItems(); } WINE_TRACE("Operation done\n"); SetEvent( event ); return 0; }