/*********************************************************************** * TranslateInfStringW (ADVPACK.@) * * Translates the value of a specified key in an inf file into the * current locale by expanding string macros. * * PARAMS * pszInfFilename [I] Filename of the inf file. * pszInstallSection [I] * pszTranslateSection [I] Inf section where the key exists. * pszTranslateKey [I] Key to translate. * pszBuffer [O] Contains the translated string on exit. * dwBufferSize [I] Size on input of pszBuffer. * pdwRequiredSize [O] Length of the translated key. * pvReserved [I] Reserved, must be NULL. * * RETURNS * Success: S_OK. * Failure: An hresult error code. */ HRESULT WINAPI TranslateInfStringW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, LPCWSTR pszTranslateSection, LPCWSTR pszTranslateKey, LPWSTR pszBuffer, DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved) { HINF hInf; HRESULT hret = S_OK; TRACE("(%s, %s, %s, %s, %p, %d, %p, %p)\n", debugstr_w(pszInfFilename), debugstr_w(pszInstallSection), debugstr_w(pszTranslateSection), debugstr_w(pszTranslateKey), pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved); if (!pszInfFilename || !pszTranslateSection || !pszTranslateKey || !pdwRequiredSize) return E_INVALIDARG; hInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL); if (hInf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); set_ldids(hInf, pszInstallSection, NULL); if (!SetupGetLineTextW(NULL, hInf, pszTranslateSection, pszTranslateKey, pszBuffer, dwBufferSize, pdwRequiredSize)) { if (dwBufferSize < *pdwRequiredSize) hret = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); else hret = SPAPI_E_LINE_NOT_FOUND; } SetupCloseInfFile(hInf); return hret; }
/*********************************************************************** * OpenINFEngineW (ADVPACK.@) * * Opens and returns a handle to an INF file to be used by * TranslateInfStringEx to continuously translate the INF file. * * PARAMS * pszInfFilename [I] Filename of the INF to open. * pszInstallSection [I] Name of the Install section in the INF. * dwFlags [I] See advpub.h. * phInf [O] Handle to the loaded INF file. * pvReserved [I] Reserved. Must be NULL. * * RETURNS * Success: S_OK. * Failure: E_FAIL. */ HRESULT WINAPI OpenINFEngineW(LPCWSTR pszInfFilename, LPCWSTR pszInstallSection, DWORD dwFlags, HINF *phInf, PVOID pvReserved) { TRACE("(%s, %s, %d, %p, %p)\n", debugstr_w(pszInfFilename), debugstr_w(pszInstallSection), dwFlags, phInf, pvReserved); if (!pszInfFilename || !phInf) return E_INVALIDARG; *phInf = SetupOpenInfFileW(pszInfFilename, NULL, INF_STYLE_WIN4, NULL); if (*phInf == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); set_ldids(*phInf, pszInstallSection, NULL); return S_OK; }
/* loads the INF file and performs checks on it */ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, LPCWSTR working_dir, DWORD flags, ADVInfo *info) { DWORD len; HRESULT hr; LPCWSTR ptr, path; static const WCHAR backslash[] = {'\\',0}; static const WCHAR default_install[] = { 'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0 }; if (!(ptr = strrchrW(inf_filename, '\\'))) ptr = inf_filename; len = lstrlenW(ptr); info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); if (!info->inf_filename) return E_OUTOFMEMORY; lstrcpyW(info->inf_filename, ptr); /* FIXME: determine the proper platform to install (NTx86, etc) */ if (!install_sec || !*install_sec) { len = sizeof(default_install) - 1; ptr = default_install; } else { len = lstrlenW(install_sec); ptr = install_sec; } info->install_sec = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); if (!info->install_sec) return E_OUTOFMEMORY; lstrcpyW(info->install_sec, ptr); hr = get_working_dir(info, inf_filename, working_dir); if (FAILED(hr)) return hr; len = lstrlenW(info->working_dir) + lstrlenW(info->inf_filename) + 2; info->inf_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!info->inf_path) return E_OUTOFMEMORY; lstrcpyW(info->inf_path, info->working_dir); lstrcatW(info->inf_path, backslash); lstrcatW(info->inf_path, info->inf_filename); /* RunSetupCommand opens unmodifed filename parameter */ if (flags & RSC_FLAG_INF) path = inf_filename; else path = info->inf_path; info->hinf = SetupOpenInfFileW(path, NULL, INF_STYLE_WIN4, NULL); if (info->hinf == INVALID_HANDLE_VALUE) return ADV_HRESULT(GetLastError()); set_ldids(info->hinf, info->install_sec, info->working_dir); /* FIXME: check that the INF is advanced */ info->flags = flags; info->need_reboot = FALSE; return S_OK; }