static void fetch_module_name(void* name_addr, BOOL unicode, void* mod_addr, WCHAR* buffer, size_t bufsz, BOOL is_pcs) { static WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0}; static WCHAR dlladdr[] = {'D','L','L','_','%','0','8','l','x',0}; memory_get_string_indirect(dbg_curr_process, name_addr, unicode, buffer, bufsz); if (!buffer[0] && !GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz)) { if (is_pcs) { HMODULE h; WORD (WINAPI *gpif)(HANDLE, LPWSTR, DWORD); /* On Windows, when we get the process creation debug event for a process * created by winedbg, the modules' list is not initialized yet. Hence, * GetModuleFileNameExA (on the main module) will generate an error. * Psapi (starting on XP) provides GetProcessImageFileName() which should * give us the expected result */ if (!(h = GetModuleHandleA("psapi")) || !(gpif = (void*)GetProcAddress(h, "GetProcessImageFileNameW")) || !(gpif)(dbg_curr_process->handle, buffer, bufsz)) snprintfW(buffer, bufsz, pcspid, dbg_curr_pid); } else snprintfW(buffer, bufsz, dlladdr, (unsigned long)mod_addr); } }
static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p) { HTMLLocation *This = impl_from_IHTMLLocation(iface); URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)}; HRESULT hres; TRACE("(%p)->(%p)\n", This, p); if(!p) return E_POINTER; hres = get_url_components(This, &url); if(FAILED(hres)) return hres; if(url.nPort) { const WCHAR format[] = {'%','u',0}; WCHAR buf[6]; snprintfW(buf, 6, format, url.nPort); *p = SysAllocString(buf); }else { const WCHAR empty[] = {0}; *p = SysAllocString(empty); } if(!*p) return E_OUTOFMEMORY; return S_OK; }
static void set_status_text(BindStatusCallback *This, ULONG statuscode, LPCWSTR str) { VARIANTARG arg; DISPPARAMS dispparams = {&arg, NULL, 1, 0}; WCHAR fmt[IDS_STATUSFMT_MAXLEN]; WCHAR buffer[IDS_STATUSFMT_MAXLEN + INTERNET_MAX_URL_LENGTH]; if(!This->doc_host) return; TRACE("(%p, %d, %s)\n", This, statuscode, debugstr_w(str)); buffer[0] = 0; if (statuscode && str && *str) { fmt[0] = 0; /* the format string must have one "%s" for the str */ LoadStringW(ieframe_instance, IDS_STATUSFMT_FIRST + statuscode, fmt, IDS_STATUSFMT_MAXLEN); snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), fmt, str); } V_VT(&arg) = VT_BSTR; V_BSTR(&arg) = str ? SysAllocString(buffer) : NULL; TRACE("=> %s\n", debugstr_w(V_BSTR(&arg))); call_sink(This->doc_host->cps.wbe2, DISPID_STATUSTEXTCHANGE, &dispparams); if(This->doc_host->frame) IOleInPlaceFrame_SetStatusText(This->doc_host->frame, buffer); VariantClear(&arg); }
/*********************************************************************** * drvSetDefaultCommConfigW (SERIALUI.@) * * Used by Win98 KERNEL to set the default config for a COMM port * FIXME: uses the wrong registry key... should use a digit, not * the comm port name. */ BOOL WINAPI drvSetDefaultCommConfigW( LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize) { HKEY hKeyReg=0, hKeyPort=0; WCHAR szKeyName[100]; DWORD r,dwDCBSize; static const WCHAR fmt[] = {'%','s','\\','%','s',0 }; TRACE("%p %p %lx\n",lpszDevice,lpCommConfig,dwSize); if(!lpCommConfig) return FALSE; if(dwSize < sizeof (COMMCONFIG)) return FALSE; r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg); if(r != ERROR_SUCCESS) return FALSE; snprintfW(szKeyName, sizeof(szKeyName)/sizeof(WCHAR), fmt, lpszCommKey ,lpszDevice); r = RegCreateKeyW(hKeyReg, szKeyName, &hKeyPort); if(r == ERROR_SUCCESS) { dwDCBSize = sizeof (DCB); r = RegSetValueExW( hKeyPort, lpszDCB, 0, REG_BINARY, (LPBYTE)&lpCommConfig->dcb,dwDCBSize); TRACE("write key r=%ld\n",r); RegCloseKey(hKeyPort); } RegCloseKey(hKeyReg); return (r==ERROR_SUCCESS); }
/*********************************************************************** * tapiGetLocationInfoW (TAPI32.@) */ DWORD WINAPI tapiGetLocationInfoW(LPWSTR countrycode, LPWSTR citycode) { HKEY hkey, hsubkey; DWORD currid; DWORD valsize; DWORD type; DWORD bufsize; BYTE buf[200]; WCHAR szlockey[20]; static const WCHAR currentidW[] = {'C','u','r','r','e','n','t','I','D',0}; static const WCHAR locationW[] = {'L','o','c','a','t','i','o','n','%','u',0}; static const WCHAR areacodeW[] = {'A','r','e','a','C','o','d','e',0}; static const WCHAR countryW[] = {'C','o','u','n','t','r','y',0}; static const WCHAR fmtW[] = {'%','u',0}; static const WCHAR locations_keyW[] = {'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','\\', 'T','e','l','e','p','h','o','n','y','\\','L','o','c','a','t','i','o','n','s',0}; if(!RegOpenKeyW(HKEY_LOCAL_MACHINE, locations_keyW, &hkey) != ERROR_SUCCESS) { valsize = sizeof( DWORD); if(!RegQueryValueExW(hkey, currentidW, 0, &type, (LPBYTE) &currid, &valsize) && type == REG_DWORD) { /* find a subkey called Location1, Location2... */ sprintfW( szlockey, locationW, currid); if( !RegOpenKeyW( hkey, szlockey, &hsubkey)) { if( citycode) { bufsize=sizeof(buf); if( !RegQueryValueExW( hsubkey, areacodeW, 0, &type, buf, &bufsize) && type == REG_SZ) { lstrcpynW( citycode, (WCHAR *) buf, 8); } else citycode[0] = '\0'; } if( countrycode) { bufsize=sizeof(buf); if( !RegQueryValueExW( hsubkey, countryW, 0, &type, buf, &bufsize) && type == REG_DWORD) snprintfW( countrycode, 8, fmtW, *(LPDWORD) buf ); else countrycode[0] = '\0'; } TRACE("(%p \"%s\", %p \"%s\"): success.\n", countrycode, debugstr_w(countrycode), citycode, debugstr_w(citycode)); RegCloseKey( hkey); RegCloseKey( hsubkey); return 0; /* SUCCESS */ } } RegCloseKey( hkey); } WARN("(%p, %p): failed (no telephony registry entries?).\n", countrycode, citycode); return TAPIERR_REQUESTFAILED; }
static HRESULT DXDiag_InitDXDiagDirectXFilesContainer(IDxDiagContainer* pSubCont) { HRESULT hr = S_OK; static const WCHAR dlls[][15] = { {'d','3','d','8','.','d','l','l',0}, {'d','3','d','9','.','d','l','l',0}, {'d','d','r','a','w','.','d','l','l',0}, {'d','e','v','e','n','u','m','.','d','l','l',0}, {'d','i','n','p','u','t','8','.','d','l','l',0}, {'d','i','n','p','u','t','.','d','l','l',0}, {'d','m','b','a','n','d','.','d','l','l',0}, {'d','m','c','o','m','p','o','s','.','d','l','l',0}, {'d','m','i','m','e','.','d','l','l',0}, {'d','m','l','o','a','d','e','r','.','d','l','l',0}, {'d','m','s','c','r','i','p','t','.','d','l','l',0}, {'d','m','s','t','y','l','e','.','d','l','l',0}, {'d','m','s','y','n','t','h','.','d','l','l',0}, {'d','m','u','s','i','c','.','d','l','l',0}, {'d','p','l','a','y','x','.','d','l','l',0}, {'d','p','n','e','t','.','d','l','l',0}, {'d','s','o','u','n','d','.','d','l','l',0}, {'d','s','w','a','v','e','.','d','l','l',0}, {'d','x','d','i','a','g','n','.','d','l','l',0}, {'q','u','a','r','t','z','.','d','l','l',0} }; WCHAR szFilePath[MAX_PATH]; INT i; GetSystemDirectoryW(szFilePath, MAX_PATH); for (i = 0; i < sizeof(dlls) / sizeof(dlls[0]); i++) { static const WCHAR szFormat[] = {'%','d',0}; WCHAR szFileID[5]; IDxDiagContainer *pDXFileSubCont; snprintfW(szFileID, sizeof(szFileID)/sizeof(szFileID[0]), szFormat, i); hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDXFileSubCont); if (FAILED(hr)) continue; if (FAILED(DXDiag_AddFileDescContainer(pDXFileSubCont, szFilePath, dlls[i])) || FAILED(IDxDiagContainerImpl_AddChildContainer(pSubCont, szFileID, pDXFileSubCont))) { IUnknown_Release(pDXFileSubCont); continue; } } return hr; }
/***************************************************************************** * WCMD_getfileowner * * Reverse a WCHARacter string in-place (strrev() is not available under unixen :-( ). */ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) { ULONG sizeNeeded = 0; DWORD rc; WCHAR name[MAXSTRING]; WCHAR domain[MAXSTRING]; /* In case of error, return empty string */ *owner = 0x00; /* Find out how much space we need for the owner security descriptor */ GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, 0, 0, &sizeNeeded); rc = GetLastError(); if(rc == ERROR_INSUFFICIENT_BUFFER && sizeNeeded > 0) { LPBYTE secBuffer; PSID pSID = NULL; BOOL defaulted = FALSE; ULONG nameLen = MAXSTRING; ULONG domainLen = MAXSTRING; SID_NAME_USE nameuse; secBuffer = HeapAlloc(GetProcessHeap(),0,sizeNeeded * sizeof(BYTE)); if(!secBuffer) return; /* Get the owners security descriptor */ if(!GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, secBuffer, sizeNeeded, &sizeNeeded)) { HeapFree(GetProcessHeap(),0,secBuffer); return; } /* Get the SID from the SD */ if(!GetSecurityDescriptorOwner(secBuffer, &pSID, &defaulted)) { HeapFree(GetProcessHeap(),0,secBuffer); return; } /* Convert to a username */ if (LookupAccountSidW(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) { static const WCHAR fmt[] = {'%','s','%','c','%','s','\0'}; snprintfW(owner, ownerlen, fmt, domain, '\\', name); } HeapFree(GetProcessHeap(),0,secBuffer); } return; }
/*********************************************************************** * GetMonitorInfo (MACDRV.@) */ BOOL CDECL macdrv_GetMonitorInfo(HMONITOR monitor, LPMONITORINFO info) { static const WCHAR adapter_name[] = { '\\','\\','.','\\','D','I','S','P','L','A','Y','%','d',0 }; struct macdrv_display *displays; int num_displays; CGDirectDisplayID display_id; int i; TRACE("%p, %p\n", monitor, info); if (macdrv_get_displays(&displays, &num_displays)) { ERR("couldn't get display list\n"); SetLastError(ERROR_GEN_FAILURE); return FALSE; } display_id = monitor_to_display_id(monitor); for (i = 0; i < num_displays; i++) { if (displays[i].displayID == display_id) break; } if (i < num_displays) { info->rcMonitor = rect_from_cgrect(displays[i].frame); info->rcWork = rect_from_cgrect(displays[i].work_frame); info->dwFlags = (i == 0) ? MONITORINFOF_PRIMARY : 0; if (info->cbSize >= sizeof(MONITORINFOEXW)) snprintfW(((MONITORINFOEXW*)info)->szDevice, sizeof(((MONITORINFOEXW*)info)->szDevice) / sizeof(WCHAR), adapter_name, i + 1); TRACE(" -> rcMonitor %s rcWork %s dwFlags %08x szDevice %s\n", wine_dbgstr_rect(&info->rcMonitor), wine_dbgstr_rect(&info->rcWork), info->dwFlags, info->cbSize >= sizeof(MONITORINFOEXW) ? debugstr_w(((MONITORINFOEXW*)info)->szDevice) : "n/a"); } else { ERR("invalid monitor handle\n"); SetLastError(ERROR_INVALID_HANDLE); } macdrv_free_displays(displays); return (i < num_displays); }
static int query_screens(void) { int i, count, event_base, error_base; XineramaScreenInfo *screens; RECT rc_work = {0, 0, 0, 0}; if (!monitors) /* first time around */ load_xinerama(); query_work_area( &rc_work ); if (!pXineramaQueryExtension || !pXineramaQueryScreens || !pXineramaQueryExtension( gdi_display, &event_base, &error_base ) || !(screens = pXineramaQueryScreens( gdi_display, &count ))) return 0; if (monitors != &default_monitor) HeapFree( GetProcessHeap(), 0, monitors ); if ((monitors = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*monitors) ))) { int device = 2; /* 1 is reserved for primary */ nb_monitors = count; for (i = 0; i < nb_monitors; i++) { monitors[i].cbSize = sizeof( monitors[i] ); monitors[i].rcMonitor.left = screens[i].x_org; monitors[i].rcMonitor.top = screens[i].y_org; monitors[i].rcMonitor.right = screens[i].x_org + screens[i].width; monitors[i].rcMonitor.bottom = screens[i].y_org + screens[i].height; monitors[i].dwFlags = 0; if (!IntersectRect( &monitors[i].rcWork, &rc_work, &monitors[i].rcMonitor )) monitors[i].rcWork = monitors[i].rcMonitor; } get_primary()->dwFlags |= MONITORINFOF_PRIMARY; for (i = 0; i < nb_monitors; i++) { snprintfW( monitors[i].szDevice, sizeof(monitors[i].szDevice) / sizeof(WCHAR), monitor_deviceW, (monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? 1 : device++ ); } } else count = 0; XFree( screens ); return count; }
/* only one service started at a time, so there is no race on the registry * value here */ static LPWSTR service_get_pipe_name(void) { static const WCHAR format[] = { '\\','\\','.','\\','p','i','p','e','\\', 'n','e','t','\\','N','t','C','o','n','t','r','o','l','P','i','p','e','%','u',0 }; static const WCHAR service_current_key_str[] = { 'S','Y','S','T','E','M','\\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 'C','o','n','t','r','o','l','\\', 'S','e','r','v','i','c','e','C','u','r','r','e','n','t',0 }; LPWSTR name; DWORD len; HKEY service_current_key; DWORD service_current = -1; LONG ret; DWORD type; ret = RegCreateKeyExW(HKEY_LOCAL_MACHINE, service_current_key_str, 0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE | KEY_QUERY_VALUE, NULL, &service_current_key, NULL); if (ret != ERROR_SUCCESS) return NULL; len = sizeof(service_current); ret = RegQueryValueExW(service_current_key, NULL, NULL, &type, (BYTE *)&service_current, &len); if ((ret == ERROR_SUCCESS && type == REG_DWORD) || ret == ERROR_FILE_NOT_FOUND) { service_current++; RegSetValueExW(service_current_key, NULL, 0, REG_DWORD, (BYTE *)&service_current, sizeof(service_current)); } RegCloseKey(service_current_key); if ((ret != ERROR_SUCCESS || type != REG_DWORD) && (ret != ERROR_FILE_NOT_FOUND)) return NULL; len = sizeof(format)/sizeof(WCHAR) + 10 /* strlenW("4294967295") */; name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!name) return NULL; snprintfW(name, len, format, service_current); return name; }
/*********************************************************************** * AtlModuleRegisterWndClassInfoW [ATL.@] * * PARAMS * pm [IO] Information about the module registering the window. * wci [IO] Information about the window being registered. * pProc [O] Window procedure of the registered class. * * RETURNS * Atom representing the registered class. * * NOTES * Can be called multiple times without error, unlike RegisterClassEx(). * * If the class name is NULL, then a class with a name of "ATLxxxxxxxx" is * registered, where the 'x's represent a unique value. * */ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW *wci, WNDPROC *pProc) { ATOM atom; FIXME("%p %p %p semi-stub\n", pm, wci, pProc); atom = wci->m_atom; if (!atom) { WNDCLASSEXW wc; TRACE("wci->m_wc.lpszClassName = %s\n", debugstr_w(wci->m_wc.lpszClassName)); if (wci->m_lpszOrigName) FIXME( "subclassing %s not implemented\n", debugstr_w(wci->m_lpszOrigName)); if (!wci->m_wc.lpszClassName) { static const WCHAR szFormat[] = {'A','T','L','%','0','8','l','x',0}; snprintfW(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), szFormat, (UINT_PTR)wci); TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName)); wci->m_wc.lpszClassName = wci->m_szAutoName; } atom = GetClassInfoExW(pm->m_hInst, wci->m_wc.lpszClassName, &wc); if (!atom) { wci->m_wc.hInstance = pm->m_hInst; wci->m_wc.hCursor = LoadCursorW( wci->m_bSystemCursor ? NULL : pm->m_hInst, wci->m_lpszCursorID ); atom = RegisterClassExW(&wci->m_wc); } wci->pWndProc = wci->m_wc.lpfnWndProc; wci->m_atom = atom; } if (wci->m_lpszOrigName) *pProc = wci->pWndProc; TRACE("returning 0x%04x\n", atom); return atom; }
static void dlg_invalid_portname(HWND hWnd, LPCWSTR portname) { WCHAR res_PortW[IDS_LOCALPORT_MAXLEN]; WCHAR res_InvalidNameW[IDS_INVALIDNAME_MAXLEN]; LPWSTR message; DWORD len; res_PortW[0] = '\0'; res_InvalidNameW[0] = '\0'; LoadStringW(LOCALUI_hInstance, IDS_LOCALPORT, res_PortW, IDS_LOCALPORT_MAXLEN); LoadStringW(LOCALUI_hInstance, IDS_INVALIDNAME, res_InvalidNameW, IDS_INVALIDNAME_MAXLEN); len = lstrlenW(portname) + IDS_INVALIDNAME_MAXLEN; message = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (message) { message[0] = '\0'; snprintfW(message, len, res_InvalidNameW, portname); MessageBoxW(hWnd, message, res_PortW, MB_OK | MB_ICONERROR); HeapFree(GetProcessHeap(), 0, message); } }
static void dlg_port_already_exists(HWND hWnd, LPCWSTR portname) { WCHAR res_PortW[IDS_LOCALPORT_MAXLEN]; WCHAR res_PortExistsW[IDS_PORTEXISTS_MAXLEN]; LPWSTR message; DWORD len; res_PortW[0] = '\0'; res_PortExistsW[0] = '\0'; LoadStringW(LOCALUI_hInstance, IDS_LOCALPORT, res_PortW, IDS_LOCALPORT_MAXLEN); LoadStringW(LOCALUI_hInstance, IDS_PORTEXISTS, res_PortExistsW, IDS_PORTEXISTS_MAXLEN); len = lstrlenW(portname) + IDS_PORTEXISTS_MAXLEN + 1; message = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (message) { message[0] = '\0'; snprintfW(message, len, res_PortExistsW, portname); MessageBoxW(hWnd, message, res_PortW, MB_OK | MB_ICONERROR); HeapFree(GetProcessHeap(), 0, message); } }
static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p) { HTMLLocation *This = impl_from_IHTMLLocation(iface); URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)}; HRESULT hres; TRACE("(%p)->(%p)\n", This, p); if(!p) return E_POINTER; url.dwHostNameLength = 1; hres = get_url_components(This, &url); if(FAILED(hres)) return hres; if(!url.dwHostNameLength){ *p = NULL; return S_OK; } if(url.nPort) { /* <hostname>:<port> */ const WCHAR format[] = {'%','u',0}; DWORD len = url.dwHostNameLength + 1 + 5; WCHAR *buf; buf = *p = SysAllocStringLen(NULL, len); memcpy(buf, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR)); buf[url.dwHostNameLength] = ':'; snprintfW(buf + url.dwHostNameLength + 1, 6, format, url.nPort); }else *p = SysAllocStringLen(url.lpszHostName, url.dwHostNameLength); if(!*p) return E_OUTOFMEMORY; return S_OK; }
void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg) { int index = id - IDS_STATUS_DONE; LPWSTR p = status_strings[index]; if(!doc->frame) return; if(!p) { DWORD len = 255; p = heap_alloc(len * sizeof(WCHAR)); len = LoadStringW(hInst, id, p, len); len++; p = heap_realloc(p, len * sizeof(WCHAR)); if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) { heap_free(p); p = status_strings[index]; } } if(arg) { DWORD len = lstrlenW(p) + lstrlenW(arg) - 1; LPWSTR buf = heap_alloc(len * sizeof(WCHAR)); snprintfW(buf, len, p, arg); p = buf; } IOleInPlaceFrame_SetStatusText(doc->frame, p); if(arg) heap_free(p); }
static void copy_file(LPCWSTR source, LPCWSTR destination) { WCHAR destfile[MAX_PATH]; /* append source filename if destination is a directory */ if (PathIsDirectoryW(destination)) { PathCombineW(destfile, destination, PathFindFileNameW(source)); destination = destfile; } if (PathFileExistsW(destination) && !force_mode) { static const WCHAR overwriteMsg[] = {'O','v','e','r','w','r','i','t','e',' ','"','%','s','"','?',0}; static const WCHAR titleMsg[] = {'E','x','t','r','a','c','t',0}; WCHAR msg[MAX_PATH+100]; snprintfW(msg, sizeof(msg)/sizeof(msg[0]), overwriteMsg, destination); if (MessageBoxW(NULL, msg, titleMsg, MB_YESNO | MB_ICONWARNING) != IDYES) return; } WINE_TRACE("copying %s to %s\n", wine_dbgstr_w(source), wine_dbgstr_w(destination)); CopyFileW(source, destination, FALSE); }
/*********************************************************************** * SetupPromptForDiskW (SETUPAPI.@) */ UINT WINAPI SetupPromptForDiskW(HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize) { struct promptdisk_params params; UINT ret; TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_w(DialogTitle), debugstr_w(DiskName), debugstr_w(PathToSource), debugstr_w(FileSought), debugstr_w(TagFile), DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize); if(!FileSought) { SetLastError(ERROR_INVALID_PARAMETER); return DPROMPT_CANCEL; } if (PathToSource && (DiskPromptStyle & IDF_CHECKFIRST)) { static const WCHAR format[] = {'%', 's', '\\', '%', 's', '\0'}; WCHAR filepath[MAX_PATH]; if (strlenW(PathToSource) + 1 + strlenW(FileSought) < sizeof(filepath)) { snprintfW(filepath, MAX_PATH, format, PathToSource, FileSought); if (GetFileAttributesW(filepath) != INVALID_FILE_ATTRIBUTES) { if (PathRequiredSize) *PathRequiredSize = strlenW(PathToSource) + 1; if (!PathBuffer) return DPROMPT_SUCCESS; if (PathBufferSize >= strlenW(PathToSource) + 1) { strcpyW(PathBuffer, PathToSource); return DPROMPT_SUCCESS; } else return DPROMPT_BUFFERTOOSMALL; } } } params.DialogTitle = DialogTitle; params.DiskName = DiskName; params.PathToSource = PathToSource; params.FileSought = FileSought; params.TagFile = TagFile; params.DiskPromptStyle = DiskPromptStyle; params.PathBuffer = PathBuffer; params.PathBufferSize = PathBufferSize; params.PathRequiredSize = PathRequiredSize; ret = DialogBoxParamW(SETUPAPI_hInstance, MAKEINTRESOURCEW(IDPROMPTFORDISK), hwndParent, promptdisk_proc, (LPARAM)¶ms); if(ret == DPROMPT_CANCEL) SetLastError(ERROR_CANCELLED); return ret; }
/********************************************************************* * GetCalendarInfoW (KERNEL32.@) * */ int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue) { if (CalType & CAL_NOUSEROVERRIDE) FIXME("flag CAL_NOUSEROVERRIDE used, not fully implemented\n"); if (CalType & CAL_USE_CP_ACP) FIXME("flag CAL_USE_CP_ACP used, not fully implemented\n"); if (CalType & CAL_RETURN_NUMBER) { if (!lpValue) { SetLastError( ERROR_INVALID_PARAMETER ); return 0; } if (lpCalData != NULL) WARN("lpCalData not NULL (%p) when it should!\n", lpCalData); if (cchData != 0) WARN("cchData not 0 (%d) when it should!\n", cchData); } else { if (lpValue != NULL) WARN("lpValue not NULL (%p) when it should!\n", lpValue); } /* FIXME: No verification is made yet wrt Locale * for the CALTYPES not requiring GetLocaleInfoA */ switch (CalType & ~(CAL_NOUSEROVERRIDE|CAL_RETURN_NUMBER|CAL_USE_CP_ACP)) { case CAL_ICALINTVALUE: if (CalType & CAL_RETURN_NUMBER) return GetLocaleInfoW(Locale, LOCALE_RETURN_NUMBER | LOCALE_ICALENDARTYPE, (LPWSTR)lpValue, 2); return GetLocaleInfoW(Locale, LOCALE_ICALENDARTYPE, lpCalData, cchData); case CAL_SCALNAME: FIXME("Unimplemented caltype %d\n", CalType & 0xffff); if (lpCalData) *lpCalData = 0; return 1; case CAL_IYEAROFFSETRANGE: FIXME("Unimplemented caltype %d\n", CalType & 0xffff); return 0; case CAL_SERASTRING: FIXME("Unimplemented caltype %d\n", CalType & 0xffff); return 0; case CAL_SSHORTDATE: return GetLocaleInfoW(Locale, LOCALE_SSHORTDATE, lpCalData, cchData); case CAL_SLONGDATE: return GetLocaleInfoW(Locale, LOCALE_SLONGDATE, lpCalData, cchData); case CAL_SDAYNAME1: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME1, lpCalData, cchData); case CAL_SDAYNAME2: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME2, lpCalData, cchData); case CAL_SDAYNAME3: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME3, lpCalData, cchData); case CAL_SDAYNAME4: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME4, lpCalData, cchData); case CAL_SDAYNAME5: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME5, lpCalData, cchData); case CAL_SDAYNAME6: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME6, lpCalData, cchData); case CAL_SDAYNAME7: return GetLocaleInfoW(Locale, LOCALE_SDAYNAME7, lpCalData, cchData); case CAL_SABBREVDAYNAME1: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME1, lpCalData, cchData); case CAL_SABBREVDAYNAME2: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME2, lpCalData, cchData); case CAL_SABBREVDAYNAME3: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME3, lpCalData, cchData); case CAL_SABBREVDAYNAME4: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME4, lpCalData, cchData); case CAL_SABBREVDAYNAME5: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME5, lpCalData, cchData); case CAL_SABBREVDAYNAME6: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME6, lpCalData, cchData); case CAL_SABBREVDAYNAME7: return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME7, lpCalData, cchData); case CAL_SMONTHNAME1: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME1, lpCalData, cchData); case CAL_SMONTHNAME2: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME2, lpCalData, cchData); case CAL_SMONTHNAME3: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME3, lpCalData, cchData); case CAL_SMONTHNAME4: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME4, lpCalData, cchData); case CAL_SMONTHNAME5: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME5, lpCalData, cchData); case CAL_SMONTHNAME6: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME6, lpCalData, cchData); case CAL_SMONTHNAME7: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME7, lpCalData, cchData); case CAL_SMONTHNAME8: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME8, lpCalData, cchData); case CAL_SMONTHNAME9: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME9, lpCalData, cchData); case CAL_SMONTHNAME10: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME10, lpCalData, cchData); case CAL_SMONTHNAME11: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME11, lpCalData, cchData); case CAL_SMONTHNAME12: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME12, lpCalData, cchData); case CAL_SMONTHNAME13: return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME13, lpCalData, cchData); case CAL_SABBREVMONTHNAME1: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME1, lpCalData, cchData); case CAL_SABBREVMONTHNAME2: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME2, lpCalData, cchData); case CAL_SABBREVMONTHNAME3: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME3, lpCalData, cchData); case CAL_SABBREVMONTHNAME4: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME4, lpCalData, cchData); case CAL_SABBREVMONTHNAME5: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME5, lpCalData, cchData); case CAL_SABBREVMONTHNAME6: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME6, lpCalData, cchData); case CAL_SABBREVMONTHNAME7: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME7, lpCalData, cchData); case CAL_SABBREVMONTHNAME8: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME8, lpCalData, cchData); case CAL_SABBREVMONTHNAME9: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME9, lpCalData, cchData); case CAL_SABBREVMONTHNAME10: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME10, lpCalData, cchData); case CAL_SABBREVMONTHNAME11: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME11, lpCalData, cchData); case CAL_SABBREVMONTHNAME12: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME12, lpCalData, cchData); case CAL_SABBREVMONTHNAME13: return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME13, lpCalData, cchData); case CAL_SYEARMONTH: return GetLocaleInfoW(Locale, LOCALE_SYEARMONTH, lpCalData, cchData); case CAL_ITWODIGITYEARMAX: if (CalType & CAL_RETURN_NUMBER) { *lpValue = CALINFO_MAX_YEAR; return sizeof(DWORD) / sizeof(WCHAR); } else { static const WCHAR fmtW[] = {'%','u',0}; WCHAR buffer[10]; int ret = snprintfW( buffer, 10, fmtW, CALINFO_MAX_YEAR ) + 1; if (!lpCalData) return ret; if (ret <= cchData) { strcpyW( lpCalData, buffer ); return ret; } SetLastError( ERROR_INSUFFICIENT_BUFFER ); return 0; } break; default: FIXME("Unknown caltype %d\n",CalType & 0xffff); SetLastError(ERROR_INVALID_FLAGS); return 0; } return 0; }
/*********************************************************************** * MSACM_WriteCurrentPriorities() * Writes out current order of driver priorities to registry key: * HKCU\\Software\\Microsoft\\Multimedia\\Audio Compression Manager\\Priority v4.00 */ void MSACM_WriteCurrentPriorities(void) { LONG lError; HKEY hPriorityKey; static const WCHAR basePriorityKey[] = { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'M','u','l','t','i','m','e','d','i','a','\\', 'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', 'P','r','i','o','r','i','t','y',' ','v','4','.','0','0','\0' }; PWINE_ACMDRIVERID padid; DWORD dwPriorityCounter; static const WCHAR priorityTmpl[] = {'P','r','i','o','r','i','t','y','%','l','d','\0'}; static const WCHAR valueTmpl[] = {'%','c',',',' ','%','s','\0'}; static const WCHAR converterAlias[] = {'I','n','t','e','r','n','a','l',' ','P','C','M',' ','C','o','n','v','e','r','t','e','r','\0'}; WCHAR szSubKey[17]; WCHAR szBuffer[256]; /* Delete ACM priority key and create it anew */ lError = RegDeleteKeyW(HKEY_CURRENT_USER, basePriorityKey); if (lError != ERROR_SUCCESS && lError != ERROR_FILE_NOT_FOUND) { ERR("unable to remove current key %s (0x%08x) - priority changes won't persist past application end.\n", debugstr_w(basePriorityKey), lError); return; } lError = RegCreateKeyW(HKEY_CURRENT_USER, basePriorityKey, &hPriorityKey); if (lError != ERROR_SUCCESS) { ERR("unable to create key %s (0x%08x) - priority changes won't persist past application end.\n", debugstr_w(basePriorityKey), lError); return; } /* Write current list of priorities */ for (dwPriorityCounter = 0, padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) { if (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL) continue; if (padid->pszDriverAlias == NULL) continue; /* internal PCM converter is last */ /* Build required value name */ dwPriorityCounter++; snprintfW(szSubKey, 17, priorityTmpl, dwPriorityCounter); /* Value has a 1 in front for enabled drivers and 0 for disabled drivers */ snprintfW(szBuffer, 256, valueTmpl, (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ? '0' : '1', padid->pszDriverAlias); strlwrW(szBuffer); lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (strlenW(szBuffer) + 1) * sizeof(WCHAR)); if (lError != ERROR_SUCCESS) { ERR("unable to write value for %s under key %s (0x%08x)\n", debugstr_w(padid->pszDriverAlias), debugstr_w(basePriorityKey), lError); } } /* Build required value name */ dwPriorityCounter++; snprintfW(szSubKey, 17, priorityTmpl, dwPriorityCounter); /* Value has a 1 in front for enabled drivers and 0 for disabled drivers */ snprintfW(szBuffer, 256, valueTmpl, '1', converterAlias); lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (strlenW(szBuffer) + 1) * sizeof(WCHAR)); if (lError != ERROR_SUCCESS) { ERR("unable to write value for %s under key %s (0x%08x)\n", debugstr_w(converterAlias), debugstr_w(basePriorityKey), lError); } RegCloseKey(hPriorityKey); }
/*********************************************************************** * MSACM_ReorderDriversByPriority() * Reorders all drivers based on the priority list indicated by the registry key: * HKCU\\Software\\Microsoft\\Multimedia\\Audio Compression Manager\\Priority v4.00 */ static void MSACM_ReorderDriversByPriority(void) { PWINE_ACMDRIVERID padid; unsigned int iNumDrivers; PWINE_ACMDRIVERID * driverList = NULL; HKEY hPriorityKey = NULL; TRACE("\n"); /* Count drivers && alloc corresponding memory for list */ iNumDrivers = 0; for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) iNumDrivers++; if (iNumDrivers > 1) { LONG lError; static const WCHAR basePriorityKey[] = { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'M','u','l','t','i','m','e','d','i','a','\\', 'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\', 'P','r','i','o','r','i','t','y',' ','v','4','.','0','0','\0' }; unsigned int i; LONG lBufferLength; WCHAR szBuffer[256]; driverList = HeapAlloc(MSACM_hHeap, 0, iNumDrivers * sizeof(PWINE_ACMDRIVERID)); if (!driverList) { ERR("out of memory\n"); goto errCleanUp; } lError = RegOpenKeyW(HKEY_CURRENT_USER, basePriorityKey, &hPriorityKey); if (lError != ERROR_SUCCESS) { TRACE("RegOpenKeyW failed, possibly key does not exist yet\n"); hPriorityKey = NULL; goto errCleanUp; } /* Copy drivers into list to simplify linked list modification */ for (i = 0, padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID, i++) { driverList[i] = padid; } /* Query each of the priorities in turn. Alias key is in lowercase. The general form of the priority record is the following: "PriorityN" --> "1, msacm.driveralias" where N is an integer, and the value is a string of the driver alias, prefixed by "1, " for an enabled driver, or "0, " for a disabled driver. */ for (i = 0; i < iNumDrivers; i++) { static const WCHAR priorityTmpl[] = {'P','r','i','o','r','i','t','y','%','l','d','\0'}; WCHAR szSubKey[17]; unsigned int iTargetPosition; unsigned int iCurrentPosition; WCHAR * pAlias; static const WCHAR sPrefix[] = {'m','s','a','c','m','.','\0'}; /* Build expected entry name */ snprintfW(szSubKey, 17, priorityTmpl, i + 1); lBufferLength = sizeof(szBuffer); lError = RegQueryValueExW(hPriorityKey, szSubKey, NULL, NULL, (LPBYTE)szBuffer, (LPDWORD)&lBufferLength); if (lError != ERROR_SUCCESS) continue; /* Recovered driver alias should be at this position */ iTargetPosition = i; /* Locate driver alias in driver list */ pAlias = strstrW(szBuffer, sPrefix); if (pAlias == NULL) continue; for (iCurrentPosition = 0; iCurrentPosition < iNumDrivers; iCurrentPosition++) { if (strcmpiW(driverList[iCurrentPosition]->pszDriverAlias, pAlias) == 0) break; } if (iCurrentPosition < iNumDrivers && iTargetPosition != iCurrentPosition) { padid = driverList[iTargetPosition]; driverList[iTargetPosition] = driverList[iCurrentPosition]; driverList[iCurrentPosition] = padid; /* Locate enabled status */ if (szBuffer[0] == '1') { driverList[iTargetPosition]->fdwSupport &= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED; } else if (szBuffer[0] == '0') { driverList[iTargetPosition]->fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED; } } } /* Re-assign pointers so that linked list traverses the ordered array */ for (i = 0; i < iNumDrivers; i++) { driverList[i]->pPrevACMDriverID = (i > 0) ? driverList[i - 1] : NULL; driverList[i]->pNextACMDriverID = (i < iNumDrivers - 1) ? driverList[i + 1] : NULL; } MSACM_pFirstACMDriverID = driverList[0]; MSACM_pLastACMDriverID = driverList[iNumDrivers - 1]; } errCleanUp: if (hPriorityKey != NULL) RegCloseKey(hPriorityKey); HeapFree(MSACM_hHeap, 0, driverList); }
static int MenuCommand(WPARAM wParam, HWND hWnd) { BOOL vis; HTREEITEM hSelect; WCHAR wszAbout[MAX_LOAD_STRING]; WCHAR wszAboutVer[MAX_LOAD_STRING]; switch(wParam) { case IDM_ABOUT: LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout, sizeof(wszAbout)/sizeof(wszAbout[0])); LoadStringW(globals.hMainInst, IDS_ABOUTVER, wszAboutVer, sizeof(wszAboutVer)/sizeof(wszAboutVer[0])); ShellAboutW(hWnd, wszAbout, wszAboutVer, NULL); break; case IDM_COPYCLSID: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CopyClsid(hSelect); break; case IDM_HTMLTAG: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CopyHTMLTag(hSelect); break; case IDM_CREATEINST: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CreateInst(hSelect, NULL); SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_CREATEINSTON: if(DialogBoxW(0, MAKEINTRESOURCEW(DLG_CREATEINSTON), hWnd, CreateInstOnProc) == IDCANCEL) break; hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CreateInst(hSelect, globals.wszMachineName); SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_RELEASEINST: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); ReleaseInst(hSelect); RefreshMenu(hSelect); RefreshDetails(hSelect); break; case IDM_EXPERT: globals.bExpert = !globals.bExpert; CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), globals.bExpert ? MF_CHECKED : MF_UNCHECKED); EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT); SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_FLAG_INSERV: vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_INHANDL: vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_LOCSERV: vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_REMSERV: vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_REFRESH: EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT); SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_REGEDIT: { STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR app[MAX_PATH]; GetWindowsDirectoryW( app, MAX_PATH - sizeof(wszRegEdit)/sizeof(WCHAR) ); lstrcatW( app, wszRegEdit ); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); if (CreateProcessW(app, app, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } break; } case IDM_STATUSBAR: vis = IsWindowVisible(globals.hStatusBar); ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_SYSCONF: DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF), hWnd, SysConfProc); break; case IDM_TOOLBAR: vis = IsWindowVisible(globals.hToolBar); ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_TYPELIB: { static const WCHAR filterW[] = {'%','s','%','c','*','.','t','l','b',';','*','.','o','l','b',';','*','.','d','l','l',';','*','.','o','c','x',';','*','.','e','x','e','%','c','%','s','%','c','*','.','*','%','c',0}; OPENFILENAMEW ofn; static WCHAR wszTitle[MAX_LOAD_STRING]; static WCHAR wszName[MAX_LOAD_STRING]; WCHAR filter_typelib[MAX_LOAD_STRING], filter_all[MAX_LOAD_STRING], filter[MAX_PATH]; LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0])); LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, sizeof(filter_typelib)/sizeof(WCHAR)); LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, sizeof(filter_all)/sizeof(WCHAR)); snprintfW( filter, MAX_PATH, filterW, filter_typelib, 0, 0, filter_all, 0, 0 ); InitOpenFileName(hWnd, &ofn, filter, wszTitle, wszName); if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName); break; } case IDM_VIEW: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); if(IsInterface(hSelect)) InterfaceViewer(hSelect); else CreateTypeLibWindow(globals.hMainInst, NULL); break; case IDM_EXIT: DestroyWindow(hWnd); break; } return 0; }
/*********************************************************************** * register_decoders */ static HRESULT register_decoders(struct regsvr_decoder const *list) { LONG res = ERROR_SUCCESS; HKEY coclass_key; WCHAR buf[39]; HKEY decoders_key; HKEY instance_key; res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL); if (res == ERROR_SUCCESS) { StringFromGUID2(&CATID_WICBitmapDecoders, buf, 39); res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &decoders_key, NULL); if (res == ERROR_SUCCESS) { res = RegCreateKeyExW(decoders_key, instance_keyname, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &instance_key, NULL); if (res != ERROR_SUCCESS) goto error_close_coclass_key; } if (res != ERROR_SUCCESS) RegCloseKey(coclass_key); } if (res != ERROR_SUCCESS) goto error_return; for (; res == ERROR_SUCCESS && list->clsid; ++list) { HKEY clsid_key; HKEY instance_clsid_key; StringFromGUID2(list->clsid, buf, 39); res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL); if (res != ERROR_SUCCESS) goto error_close_coclass_key; StringFromGUID2(list->clsid, buf, 39); res = RegCreateKeyExW(instance_key, buf, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &instance_clsid_key, NULL); if (res == ERROR_SUCCESS) { res = RegSetValueExW(instance_clsid_key, clsid_valuename, 0, REG_SZ, (CONST BYTE*)(buf), 78); RegCloseKey(instance_clsid_key); } if (res != ERROR_SUCCESS) goto error_close_clsid_key; if (list->author) { res = RegSetValueExA(clsid_key, author_valuename, 0, REG_SZ, (CONST BYTE*)(list->author), strlen(list->author) + 1); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->friendlyname) { res = RegSetValueExA(clsid_key, friendlyname_valuename, 0, REG_SZ, (CONST BYTE*)(list->friendlyname), strlen(list->friendlyname) + 1); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->vendor) { StringFromGUID2(list->vendor, buf, 39); res = RegSetValueExW(clsid_key, vendor_valuename, 0, REG_SZ, (CONST BYTE*)(buf), 78); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->version) { res = RegSetValueExA(clsid_key, version_valuename, 0, REG_SZ, (CONST BYTE*)(list->version), strlen(list->version) + 1); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->mimetypes) { res = RegSetValueExA(clsid_key, mimetypes_valuename, 0, REG_SZ, (CONST BYTE*)(list->mimetypes), strlen(list->mimetypes) + 1); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->extensions) { res = RegSetValueExA(clsid_key, extensions_valuename, 0, REG_SZ, (CONST BYTE*)(list->extensions), strlen(list->extensions) + 1); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->formats) { HKEY formats_key; GUID const * const *format; res = RegCreateKeyExW(clsid_key, formats_keyname, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &formats_key, NULL); if (res != ERROR_SUCCESS) goto error_close_clsid_key; for (format=list->formats; *format; ++format) { HKEY format_key; StringFromGUID2(*format, buf, 39); res = RegCreateKeyExW(formats_key, buf, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &format_key, NULL); if (res != ERROR_SUCCESS) break; RegCloseKey(format_key); } RegCloseKey(formats_key); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } if (list->patterns) { HKEY patterns_key; int i; res = RegCreateKeyExW(clsid_key, patterns_keyname, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &patterns_key, NULL); if (res != ERROR_SUCCESS) goto error_close_clsid_key; for (i=0; list->patterns[i].length; i++) { HKEY pattern_key; static const WCHAR int_format[] = {'%','i',0}; snprintfW(buf, 39, int_format, i); res = RegCreateKeyExW(patterns_key, buf, 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &pattern_key, NULL); if (res != ERROR_SUCCESS) break; res = RegSetValueExA(pattern_key, length_valuename, 0, REG_DWORD, (CONST BYTE*)(&list->patterns[i].length), 4); if (res == ERROR_SUCCESS) res = RegSetValueExA(pattern_key, position_valuename, 0, REG_DWORD, (CONST BYTE*)(&list->patterns[i].position), 4); if (res == ERROR_SUCCESS) res = RegSetValueExA(pattern_key, pattern_valuename, 0, REG_BINARY, list->patterns[i].pattern, list->patterns[i].length); if (res == ERROR_SUCCESS) res = RegSetValueExA(pattern_key, mask_valuename, 0, REG_BINARY, list->patterns[i].mask, list->patterns[i].length); if (res == ERROR_SUCCESS) res = RegSetValueExA(pattern_key, endofstream_valuename, 0, REG_DWORD, (CONST BYTE*)&(list->patterns[i].endofstream), 4); RegCloseKey(pattern_key); } RegCloseKey(patterns_key); if (res != ERROR_SUCCESS) goto error_close_clsid_key; } error_close_clsid_key: RegCloseKey(clsid_key); } error_close_coclass_key: RegCloseKey(instance_key); RegCloseKey(decoders_key); RegCloseKey(coclass_key); error_return: return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; }
static HRESULT DXDiag_InitDXDiagDisplayContainer(IDxDiagContainer* pSubCont) { static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0}; static const WCHAR szDeviceName[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0}; static const WCHAR szKeyDeviceID[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0}; static const WCHAR szKeyDeviceKey[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0}; static const WCHAR szVendorId[] = {'s','z','V','e','n','d','o','r','I','d',0}; static const WCHAR szDeviceId[] = {'s','z','D','e','v','i','c','e','I','d',0}; static const WCHAR szDeviceIdentifier[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0}; static const WCHAR dwWidth[] = {'d','w','W','i','d','t','h',0}; static const WCHAR dwHeight[] = {'d','w','H','e','i','g','h','t',0}; static const WCHAR dwBpp[] = {'d','w','B','p','p',0}; static const WCHAR szDisplayMemoryLocalized[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','L','o','c','a','l','i','z','e','d',0}; static const WCHAR szDisplayMemoryEnglish[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','E','n','g','l','i','s','h',0}; static const WCHAR szAdapterID[] = {'0',0}; static const WCHAR szEmpty[] = {0}; HRESULT hr; IDxDiagContainer *pDisplayAdapterSubCont = NULL; IDirectDraw7 *pDirectDraw; DDSCAPS2 dd_caps; DISPLAY_DEVICEW disp_dev; DDSURFACEDESC2 surface_descr; DWORD tmp; WCHAR buffer[256]; hr = DXDiag_CreateDXDiagContainer( &IID_IDxDiagContainer, (void**) &pDisplayAdapterSubCont ); if (FAILED( hr )) return hr; hr = IDxDiagContainerImpl_AddChildContainer( pSubCont, szAdapterID, pDisplayAdapterSubCont ); if (FAILED( hr )) return hr; if (EnumDisplayDevicesW( NULL, 0, &disp_dev, 0 )) { add_prop_str( pDisplayAdapterSubCont, szDeviceName, disp_dev.DeviceName ); add_prop_str( pDisplayAdapterSubCont, szDescription, disp_dev.DeviceString ); } hr = DirectDrawCreateEx( NULL, (LPVOID *)&pDirectDraw, &IID_IDirectDraw7, NULL); if (FAILED( hr )) return hr; dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY; dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.dwCaps4 = 0; hr = IDirectDraw7_GetAvailableVidMem( pDirectDraw, &dd_caps, &tmp, NULL ); if (SUCCEEDED(hr)) { static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0}; snprintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, ((float)tmp) / 1000000.0 ); add_prop_str( pDisplayAdapterSubCont, szDisplayMemoryLocalized, buffer ); add_prop_str( pDisplayAdapterSubCont, szDisplayMemoryEnglish, buffer ); } surface_descr.dwSize = sizeof(surface_descr); hr = IDirectDraw7_GetDisplayMode( pDirectDraw, &surface_descr ); if (SUCCEEDED(hr)) { if (surface_descr.dwFlags & DDSD_WIDTH) add_prop_ui4( pDisplayAdapterSubCont, dwWidth, surface_descr.dwWidth ); if (surface_descr.dwFlags & DDSD_HEIGHT) add_prop_ui4( pDisplayAdapterSubCont, dwHeight, surface_descr.dwHeight ); if (surface_descr.dwFlags & DDSD_PIXELFORMAT) add_prop_ui4( pDisplayAdapterSubCont, dwBpp, surface_descr.u4.ddpfPixelFormat.u1.dwRGBBitCount ); } get_display_device_id( buffer ); add_prop_str( pDisplayAdapterSubCont, szDeviceIdentifier, buffer ); add_prop_str( pDisplayAdapterSubCont, szVendorId, szEmpty ); add_prop_str( pDisplayAdapterSubCont, szDeviceId, szEmpty ); add_prop_str( pDisplayAdapterSubCont, szKeyDeviceKey, szEmpty ); add_prop_str( pDisplayAdapterSubCont, szKeyDeviceID, szEmpty ); IUnknown_Release( pDirectDraw ); return hr; }
static HMODULE load_graphics_driver( const WCHAR *driver, const GUID *guid ) { static const WCHAR device_keyW[] = { 'S','y','s','t','e','m','\\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 'C','o','n','t','r','o','l','\\', 'V','i','d','e','o','\\', '{','%','0','8','x','-','%','0','4','x','-','%','0','4','x','-', '%','0','2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2','x', '%','0','2','x','%','0','2','x','%','0','2','x','}','\\','0','0','0','0',0}; static const WCHAR graphics_driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0}; static const WCHAR driversW[] = {'S','o','f','t','w','a','r','e','\\', 'W','i','n','e','\\','D','r','i','v','e','r','s',0}; static const WCHAR graphicsW[] = {'G','r','a','p','h','i','c','s',0}; static const WCHAR drv_formatW[] = {'w','i','n','e','%','s','.','d','r','v',0}; WCHAR buffer[MAX_PATH], libname[32], *name, *next; WCHAR key[sizeof(device_keyW)/sizeof(WCHAR) + 39]; HMODULE module = 0; HKEY hkey; char error[80]; if (!driver) { strcpyW( buffer, default_driver ); /* @@ Wine registry key: HKCU\Software\Wine\Drivers */ if (!RegOpenKeyW( HKEY_CURRENT_USER, driversW, &hkey )) { DWORD count = sizeof(buffer); RegQueryValueExW( hkey, graphicsW, 0, NULL, (LPBYTE)buffer, &count ); RegCloseKey( hkey ); } } else lstrcpynW( buffer, driver, sizeof(buffer)/sizeof(WCHAR) ); name = buffer; while (name) { next = strchrW( name, ',' ); if (next) *next++ = 0; snprintfW( libname, sizeof(libname)/sizeof(WCHAR), drv_formatW, name ); if ((module = LoadLibraryW( libname )) != 0) break; switch (GetLastError()) { case ERROR_MOD_NOT_FOUND: strcpy( error, "The graphics driver is missing. Check your build!" ); break; case ERROR_DLL_INIT_FAILED: strcpy( error, "Make sure that your X server is running and that $DISPLAY is set correctly." ); break; default: sprintf( error, "Unknown error (%u).", GetLastError() ); break; } name = next; } if (module) { GetModuleFileNameW( module, buffer, MAX_PATH ); TRACE( "display %s driver %s\n", debugstr_guid(guid), debugstr_w(buffer) ); } sprintfW( key, device_keyW, guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] ); if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, key, 0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hkey, NULL )) { if (module) RegSetValueExW( hkey, graphics_driverW, 0, REG_SZ, (BYTE *)buffer, (strlenW(buffer) + 1) * sizeof(WCHAR) ); else RegSetValueExA( hkey, "DriverError", 0, REG_SZ, (BYTE *)error, strlen(error) + 1 ); RegCloseKey( hkey ); } return module; }
/** * @param szFilePath: usually GetSystemDirectoryW * @param szFileName: name of the dll without path */ static HRESULT DXDiag_AddFileDescContainer(IDxDiagContainer* pSubCont, const WCHAR* szFilePath, const WCHAR* szFileName) { HRESULT hr = S_OK; /**/ static const WCHAR szSlashSep[] = {'\\',0}; static const WCHAR szPath[] = {'s','z','P','a','t','h',0}; static const WCHAR szName[] = {'s','z','N','a','m','e',0}; static const WCHAR szVersion[] = {'s','z','V','e','r','s','i','o','n',0}; static const WCHAR szAttributes[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0}; static const WCHAR szLanguageEnglish[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0}; static const WCHAR dwFileTimeHigh[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0}; static const WCHAR dwFileTimeLow[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0}; static const WCHAR bBeta[] = {'b','B','e','t','a',0}; static const WCHAR bDebug[] = {'b','D','e','b','u','g',0}; static const WCHAR bExists[] = {'b','E','x','i','s','t','s',0}; /** values */ static const WCHAR szFinal_Retail_v[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0}; static const WCHAR szEnglish_v[] = {'E','n','g','l','i','s','h',0}; static const WCHAR szVersionFormat[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0}; VARIANT v; WCHAR szFile[512]; WCHAR szVersion_v[1024]; DWORD retval, hdl; LPVOID pVersionInfo; BOOL boolret; UINT uiLength; VS_FIXEDFILEINFO* pFileInfo; FIXME("(%p,%s)\n", pSubCont, debugstr_w(szFileName)); lstrcpyW(szFile, szFilePath); lstrcatW(szFile, szSlashSep); lstrcatW(szFile, szFileName); retval = GetFileVersionInfoSizeW(szFile, &hdl); pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval); hr = GetFileVersionInfoW(szFile, 0, retval, pVersionInfo); boolret = VerQueryValueW(pVersionInfo, (LPWSTR) szSlashSep, (LPVOID) &pFileInfo, &uiLength); V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFile); hr = IDxDiagContainerImpl_AddProp(pSubCont, szPath, &v); VariantClear(&v); V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFileName); hr = IDxDiagContainerImpl_AddProp(pSubCont, szName, &v); VariantClear(&v); V_VT(&v) = VT_BOOL; V_BOOL(&v) = boolret; hr = IDxDiagContainerImpl_AddProp(pSubCont, bExists, &v); VariantClear(&v); if (boolret) { snprintfW(szVersion_v, sizeof(szVersion_v), szVersionFormat, HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS), LOWORD(pFileInfo->dwFileVersionLS)); TRACE("Found version as (%s)\n", debugstr_w(szVersion_v)); V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szVersion_v); hr = IDxDiagContainerImpl_AddProp(pSubCont, szVersion, &v); VariantClear(&v); V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFinal_Retail_v); hr = IDxDiagContainerImpl_AddProp(pSubCont, szAttributes, &v); VariantClear(&v); V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szEnglish_v); hr = IDxDiagContainerImpl_AddProp(pSubCont, szLanguageEnglish, &v); VariantClear(&v); V_VT(&v) = VT_UI4; V_UI4(&v) = pFileInfo->dwFileDateMS; hr = IDxDiagContainerImpl_AddProp(pSubCont, dwFileTimeHigh, &v); VariantClear(&v); V_VT(&v) = VT_UI4; V_UI4(&v) = pFileInfo->dwFileDateLS; hr = IDxDiagContainerImpl_AddProp(pSubCont, dwFileTimeLow, &v); VariantClear(&v); V_VT(&v) = VT_BOOL; V_BOOL(&v) = (0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE)); hr = IDxDiagContainerImpl_AddProp(pSubCont, bBeta, &v); VariantClear(&v); V_VT(&v) = VT_BOOL; V_BOOL(&v) = (0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG)); hr = IDxDiagContainerImpl_AddProp(pSubCont, bDebug, &v); VariantClear(&v); } HeapFree(GetProcessHeap(), 0, pVersionInfo); return hr; }
/********************************************************************** * format_insert (internal) */ static LPCWSTR format_insert( BOOL unicode_caller, int insert, LPCWSTR format, DWORD flags, struct format_args *args, LPWSTR *result ) { static const WCHAR fmt_lu[] = {'%','l','u',0}; WCHAR *wstring = NULL, *p, fmt[256]; ULONG_PTR arg; int size; if (*format != '!') /* simple string */ { arg = get_arg( insert, flags, args ); if (unicode_caller || !arg) { static const WCHAR nullW[] = {'(','n','u','l','l',')',0}; const WCHAR *str = (const WCHAR *)arg; if (!str) str = nullW; *result = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) ); strcpyW( *result, str ); } else { const char *str = (const char *)arg; DWORD length = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); *result = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, str, -1, *result, length ); } return format; } format++; p = fmt; *p++ = '%'; while (*format == '0' || *format == '+' || *format == '-' || *format == ' ' || *format == '*' || *format == '#') { if (*format == '*') { p += sprintfW( p, fmt_lu, get_arg( insert, flags, args )); insert = -1; format++; } else *p++ = *format++; } while (isdigitW(*format)) *p++ = *format++; if (*format == '.') { *p++ = *format++; if (*format == '*') { p += sprintfW( p, fmt_lu, get_arg( insert, flags, args )); insert = -1; format++; } else while (isdigitW(*format)) *p++ = *format++; } /* replicate MS bug: drop an argument when using va_list with width/precision */ if (insert == -1 && args->list) args->last--; arg = get_arg( insert, flags, args ); /* check for ascii string format */ if ((format[0] == 'h' && format[1] == 's') || (format[0] == 'h' && format[1] == 'S') || (unicode_caller && format[0] == 'S') || (!unicode_caller && format[0] == 's')) { DWORD len = MultiByteToWideChar( CP_ACP, 0, (char *)arg, -1, NULL, 0 ); wstring = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, (char *)arg, -1, wstring, len ); arg = (ULONG_PTR)wstring; *p++ = 's'; } /* check for ascii character format */ else if ((format[0] == 'h' && format[1] == 'c') || (format[0] == 'h' && format[1] == 'C') || (unicode_caller && format[0] == 'C') || (!unicode_caller && format[0] == 'c')) { char ch = (char)arg; wstring = HeapAlloc( GetProcessHeap(), 0, 2 * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, &ch, 1, wstring, 1 ); wstring[1] = 0; arg = (ULONG_PTR)wstring; *p++ = 's'; } /* check for wide string format */ else if ((format[0] == 'l' && format[1] == 's') || (format[0] == 'l' && format[1] == 'S') || (format[0] == 'w' && format[1] == 's') || (!unicode_caller && format[0] == 'S')) { *p++ = 's'; } /* check for wide character format */ else if ((format[0] == 'l' && format[1] == 'c') || (format[0] == 'l' && format[1] == 'C') || (format[0] == 'w' && format[1] == 'c') || (!unicode_caller && format[0] == 'C')) { *p++ = 'c'; } /* FIXME: handle I64 etc. */ else while (*format && *format != '!') *p++ = *format++; *p = 0; size = 256; for (;;) { WCHAR *ret = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ); int needed = snprintfW( ret, size, fmt, arg ); if (needed == -1 || needed >= size) { HeapFree( GetProcessHeap(), 0, ret ); size = max( needed + 1, size * 2 ); } else { *result = ret; break; } } while (*format && *format != '!') format++; if (*format == '!') format++; HeapFree( GetProcessHeap(), 0, wstring ); return format; }
/*********************************************************************** * drvGetDefaultCommConfigW (SERIALUI.@) * * Used by Win9x KERNEL to get the default config for a COMM port * FIXME: uses the wrong registry key... should use a digit, not * the comm port name. */ BOOL WINAPI drvGetDefaultCommConfigW( LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize) { HKEY hKeyReg, hKeyPort; WCHAR szKeyName[100]; DWORD r,dwSize,dwType; static const WCHAR fmt[] = {'%','s','\\','%','s',0 }; TRACE("%p %p %p\n",lpszDevice,lpCommConfig,lpdwSize); if(!lpCommConfig) return FALSE; if(!lpdwSize) return FALSE; if(*lpdwSize < sizeof (COMMCONFIG)) return FALSE; *lpdwSize = sizeof (COMMCONFIG); memset(lpCommConfig, 0 , sizeof (COMMCONFIG)); lpCommConfig->dwSize = sizeof (COMMCONFIG); lpCommConfig->wVersion = 1; r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg); if(r != ERROR_SUCCESS) return FALSE; snprintfW(szKeyName, sizeof(szKeyName)/sizeof(WCHAR), fmt, lpszCommKey ,lpszDevice); r = RegOpenKeyW(hKeyReg, szKeyName, &hKeyPort); if(r == ERROR_SUCCESS) { dwSize = sizeof (DCB); dwType = 0; r = RegQueryValueExW( hKeyPort, lpszDCB, NULL, &dwType, (LPBYTE)&lpCommConfig->dcb, &dwSize); if ((r==ERROR_SUCCESS) && (dwType != REG_BINARY)) r = 1; if ((r==ERROR_SUCCESS) && (dwSize != sizeof(DCB))) r = 1; RegCloseKey(hKeyPort); } else { /* FIXME: default to a hardcoded commconfig */ lpCommConfig->dcb.DCBlength = sizeof(DCB); lpCommConfig->dcb.BaudRate = 9600; lpCommConfig->dcb.fBinary = TRUE; lpCommConfig->dcb.fParity = FALSE; lpCommConfig->dcb.ByteSize = 8; lpCommConfig->dcb.Parity = NOPARITY; lpCommConfig->dcb.StopBits = ONESTOPBIT; return TRUE; } RegCloseKey(hKeyReg); return (r==ERROR_SUCCESS); }
/********************************************************************** * DEVENUM_CreateSpecialCategories (INTERNAL) * * Creates the keys in the registry for the dynamic categories */ static HRESULT DEVENUM_CreateSpecialCategories(void) { HRESULT res; WCHAR szDSoundNameFormat[MAX_PATH + 1]; WCHAR szDSoundName[MAX_PATH + 1]; DWORD iDefaultDevice = -1; UINT numDevs; IFilterMapper2 * pMapper = NULL; REGFILTER2 rf2; REGFILTERPINS2 rfp2; WCHAR path[MAX_PATH]; HKEY basekey; if (DEVENUM_populate_handle) return S_OK; DEVENUM_populate_handle = CreateEventW(NULL, TRUE, FALSE, DEVENUM_populate_handle_nameW); if (GetLastError() == ERROR_ALREADY_EXISTS) { /* Webcams can take some time to scan if the driver is badly written and it enables them, * so have a 10 s timeout here */ if (WaitForSingleObject(DEVENUM_populate_handle, 10000) == WAIT_TIMEOUT) WARN("Waiting for object timed out\n"); TRACE("No need to rescan\n"); return S_OK; } TRACE("Scanning for devices\n"); /* Since devices can change between session, for example because you just plugged in a webcam * or switched from pulseaudio to alsa, delete all old devices first */ if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioRendererCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioInputDeviceCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_VideoInputDeviceCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_MidiRendererCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); rf2.dwVersion = 2; rf2.dwMerit = MERIT_PREFERRED; rf2.u.s1.cPins2 = 1; rf2.u.s1.rgPins2 = &rfp2; rfp2.cInstances = 1; rfp2.nMediums = 0; rfp2.lpMedium = NULL; rfp2.clsPinCategory = &IID_NULL; if (!LoadStringW(DEVENUM_hInstance, IDS_DEVENUM_DS, szDSoundNameFormat, sizeof(szDSoundNameFormat)/sizeof(szDSoundNameFormat[0])-1)) { ERR("Couldn't get string resource (GetLastError() is %d)\n", GetLastError()); return HRESULT_FROM_WIN32(GetLastError()); } res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2, (void **) &pMapper); /* * Fill in info for devices */ if (SUCCEEDED(res)) { UINT i; WAVEOUTCAPSW wocaps; WAVEINCAPSW wicaps; MIDIOUTCAPSW mocaps; REGPINTYPES * pTypes; numDevs = waveOutGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_AudioRendererCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_RENDERER; for (i = 0; i < numDevs; i++) { if (waveOutGetDevCapsW(i, &wocaps, sizeof(WAVEOUTCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Native devenum seems to register a lot more types for * DSound than we do. Not sure what purpose they serve */ pTypes[0].clsMajorType = &MEDIATYPE_Audio; pTypes[0].clsMinorType = &MEDIASUBTYPE_PCM; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AudioRender, wocaps.szPname, &pMoniker, &CLSID_AudioRendererCategory, wocaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) { IMoniker_Release(pMoniker); pMoniker = NULL; } wsprintfW(szDSoundName, szDSoundNameFormat, wocaps.szPname); res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_DSoundRender, szDSoundName, &pMoniker, &CLSID_AudioRendererCategory, szDSoundName, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) IMoniker_Release(pMoniker); if (i == iDefaultDevice) { FIXME("Default device\n"); } CoTaskMemFree(pTypes); } } numDevs = waveInGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_AudioInputDeviceCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_OUTPUT; for (i = 0; i < numDevs; i++) { if (waveInGetDevCapsW(i, &wicaps, sizeof(WAVEINCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Not sure if these are correct */ pTypes[0].clsMajorType = &MEDIATYPE_Audio; pTypes[0].clsMinorType = &MEDIASUBTYPE_PCM; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AudioRecord, wicaps.szPname, &pMoniker, &CLSID_AudioInputDeviceCategory, wicaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) IMoniker_Release(pMoniker); CoTaskMemFree(pTypes); } } numDevs = midiOutGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_MidiRendererCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_RENDERER; for (i = 0; i < numDevs; i++) { if (midiOutGetDevCapsW(i, &mocaps, sizeof(MIDIOUTCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Not sure if these are correct */ pTypes[0].clsMajorType = &MEDIATYPE_Midi; pTypes[0].clsMinorType = &MEDIASUBTYPE_None; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AVIMIDIRender, mocaps.szPname, &pMoniker, &CLSID_MidiRendererCategory, mocaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ /* Native version sets MidiOutId */ if (pMoniker) IMoniker_Release(pMoniker); if (i == iDefaultDevice) { FIXME("Default device\n"); } CoTaskMemFree(pTypes); } } res = DEVENUM_CreateAMCategoryKey(&CLSID_VideoInputDeviceCategory); if (SUCCEEDED(res)) for (i = 0; i < 10; i++) { WCHAR szDeviceName[32], szDeviceVersion[32], szDevicePath[10]; if (capGetDriverDescriptionW ((WORD) i, szDeviceName, sizeof(szDeviceName)/sizeof(WCHAR), szDeviceVersion, sizeof(szDeviceVersion)/sizeof(WCHAR))) { IMoniker * pMoniker = NULL; IPropertyBag * pPropBag = NULL; WCHAR dprintf[] = { 'v','i','d','e','o','%','d',0 }; snprintfW(szDevicePath, sizeof(szDevicePath)/sizeof(WCHAR), dprintf, i); /* The above code prevents 1 device with a different ID overwriting another */ rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } pTypes[0].clsMajorType = &MEDIATYPE_Video; pTypes[0].clsMinorType = &MEDIASUBTYPE_None; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_VfwCapture, szDeviceName, &pMoniker, &CLSID_VideoInputDeviceCategory, szDevicePath, &rf2); if (pMoniker) { OLECHAR wszVfwIndex[] = { 'V','F','W','I','n','d','e','x',0 }; VARIANT var; V_VT(&var) = VT_I4; V_UNION(&var, ulVal) = i; res = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag); if (SUCCEEDED(res)) res = IPropertyBag_Write(pPropBag, wszVfwIndex, &var); IMoniker_Release(pMoniker); } if (i == iDefaultDevice) FIXME("Default device\n"); CoTaskMemFree(pTypes); } } } if (pMapper) IFilterMapper2_Release(pMapper); SetEvent(DEVENUM_populate_handle); return res; }
/*********************************************************************** * drvGetDefaultCommConfigW (SERIALUI.@) * * Used by Win9x KERNEL to get the default config for a COMM port * FIXME: uses the wrong registry key... should use a digit, not * the comm port name. */ DWORD WINAPI drvGetDefaultCommConfigW( LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize) { HKEY hKeyReg, hKeyPort; WCHAR szKeyName[100]; DWORD r,dwSize,dwType; static const WCHAR fmt[] = {'%','s','\\','%','s',0 }; TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_w(lpszDevice), lpCommConfig, lpdwSize, lpdwSize ? *lpdwSize : 0); if ((!lpszDevice) || (!lpCommConfig) || (!lpdwSize)) { return ERROR_INVALID_PARAMETER; } if (*lpdwSize < sizeof (COMMCONFIG)) { *lpdwSize = sizeof (COMMCONFIG); return ERROR_INSUFFICIENT_BUFFER; } /* only "com1" - "com9" is allowed */ r = sizeof(comW) / sizeof(WCHAR); /* len of "com\0" */ lstrcpynW(szKeyName, lpszDevice, r); /* simulate a lstrcmpnW */ r--; if( lstrcmpiW(szKeyName, comW) || (lpszDevice[r] < '1') || (lpszDevice[r] > '9') || lpszDevice[r+1]) { return ERROR_BADKEY; } *lpdwSize = sizeof (COMMCONFIG); memset(lpCommConfig, 0 , sizeof (COMMCONFIG)); lpCommConfig->dwSize = sizeof (COMMCONFIG); lpCommConfig->wVersion = 1; lpCommConfig->dwProviderSubType = PST_RS232; r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg); if(r != ERROR_SUCCESS) return r; snprintfW(szKeyName, sizeof(szKeyName)/sizeof(WCHAR), fmt, lpszCommKey ,lpszDevice); r = RegOpenKeyW(hKeyReg, szKeyName, &hKeyPort); if(r == ERROR_SUCCESS) { dwSize = sizeof (DCB); dwType = 0; r = RegQueryValueExW( hKeyPort, lpszDCB, NULL, &dwType, (LPBYTE)&lpCommConfig->dcb, &dwSize); RegCloseKey(hKeyPort); if ((r!=ERROR_SUCCESS) || (dwType != REG_BINARY) || (dwSize != sizeof(DCB))) { RegCloseKey(hKeyReg); return ERROR_INVALID_PARAMETER; } } else { /* FIXME: default to a hardcoded commconfig */ lpCommConfig->dcb.DCBlength = sizeof(DCB); lpCommConfig->dcb.BaudRate = 9600; lpCommConfig->dcb.fBinary = TRUE; lpCommConfig->dcb.fParity = FALSE; lpCommConfig->dcb.ByteSize = 8; lpCommConfig->dcb.Parity = NOPARITY; lpCommConfig->dcb.StopBits = ONESTOPBIT; return ERROR_SUCCESS; } RegCloseKey(hKeyReg); return r; }