static VOID InitFontSizeList(HWND hWnd) { HINF hInf; HKEY hKey; HWND hFontSize; INFCONTEXT Context; int i, ci = 0; DWORD dwSize, dwValue, dwType; hFontSize = GetDlgItem(hWnd, IDC_FONTSIZE_COMBO); hInf = SetupOpenInfFile(_T("font.inf"), NULL, INF_STYLE_WIN4, NULL); if (hInf != INVALID_HANDLE_VALUE) { if (SetupFindFirstLine(hInf, _T("Font Sizes"), NULL, &Context)) { if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontDPI"), 0, KEY_READ, &hKey) == ERROR_SUCCESS) for (;;) { TCHAR Buffer[LINE_LEN]; TCHAR Desc[LINE_LEN]; if (SetupGetStringField(&Context, 0, Buffer, sizeof(Buffer) / sizeof(TCHAR), NULL) && SetupGetIntField(&Context, 1, &ci)) { _stprintf(Desc, _T("%s (%d DPI)"), Buffer, ci); i = SendMessage(hFontSize, CB_ADDSTRING, 0, (LPARAM)Desc); if (i != CB_ERR) SendMessage(hFontSize, CB_SETITEMDATA, (WPARAM)i, (LPARAM)ci); dwSize = MAX_PATH; dwType = REG_DWORD; if (RegQueryValueEx(hKey, _T("LogPixels"), NULL, &dwType, (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS) { if ((int)dwValue == ci) { SendMessage(hFontSize, CB_SETCURSEL, (WPARAM)i, 0); SetWindowText(GetDlgItem(hWnd, IDC_FONTSIZE_CUSTOM), Desc); } } } if (!SetupFindNextLine(&Context, &Context)) { RegCloseKey(hKey); break; } } } } SetupCloseInfFile(hInf); }
BOOL RegisterTypeLibraries (HINF hinf, LPCWSTR szSection) { INFCONTEXT InfContext; BOOL res; WCHAR szName[MAX_PATH]; WCHAR szPath[MAX_PATH]; INT csidl; LPWSTR p; HMODULE hmod; HRESULT hret; /* Begin iterating the entries in the inf section */ res = SetupFindFirstLine(hinf, szSection, NULL, &InfContext); if (!res) return FALSE; do { /* Get the name of the current type library */ if (!SetupGetStringFieldW(&InfContext, 1, szName, MAX_PATH, NULL)) { FatalError("SetupGetStringFieldW failed\n"); continue; } if (!SetupGetIntField(&InfContext, 2, &csidl)) csidl = CSIDL_SYSTEM; hret = SHGetFolderPathW(NULL, csidl, NULL, 0, szPath); if (FAILED(hret)) { FatalError("SHGetFolderPathW failed hret=0x%d\n", hret); continue; } p = PathAddBackslash(szPath); _tcscpy(p, szName); hmod = LoadLibraryW(szName); if (hmod == NULL) { FatalError("LoadLibraryW failed\n"); continue; } __wine_register_resources(hmod); }while (SetupFindNextLine(&InfContext, &InfContext)); return TRUE; }
static BOOL GetSupportedCP(VOID) { UINT uiCPage, Number; LONG Count; INFCONTEXT infCont; LPCPAGE lpCPage; HANDLE hCPage; CPINFOEX cpInfEx; //TCHAR Section[MAX_PATH]; Count = SetupGetLineCountW(hIntlInf, L"CodePages"); if (Count <= 0) return FALSE; for (Number = 0; Number < (UINT)Count; Number++) { if (SetupGetLineByIndexW(hIntlInf, L"CodePages", Number, &infCont) && SetupGetIntField(&infCont, 0, (PINT)&uiCPage)) { if (!(hCPage = GlobalAlloc(GHND, sizeof(CPAGE)))) return FALSE; lpCPage = GlobalLock(hCPage); lpCPage->CPage = uiCPage; lpCPage->hCPage = hCPage; lpCPage->Status = 0; (lpCPage->Name)[0] = 0; if (GetCPInfoEx(uiCPage, 0, &cpInfEx)) { wcscpy(lpCPage->Name, cpInfEx.CodePageName); } else if (!SetupGetStringFieldW(&infCont, 1, lpCPage->Name, MAX_PATH, NULL)) { GlobalUnlock(hCPage); GlobalFree(hCPage); continue; } lpCPage->NextItem = PCPage; PCPage = lpCPage; } } return TRUE; }
static HRESULT check_admin_rights(const ADVInfo *info) { INT check; INFCONTEXT context; HRESULT hr = S_OK; if (!SetupFindFirstLineW(info->hinf, info->install_sec, CheckAdminRights, &context)) return S_OK; if (!SetupGetIntField(&context, 1, &check)) return S_OK; if (check == 1) hr = IsNTAdmin(0, NULL) ? S_OK : E_FAIL; return hr; }
static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *arg) { PERUSERSECTIONW per_user; INFCONTEXT context; DWORD size; static const WCHAR disp_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0}; static const WCHAR version[] = {'V','e','r','s','i','o','n',0}; static const WCHAR is_installed[] = {'I','s','I','n','s','t','a','l','l','e','d',0}; static const WCHAR comp_id[] = {'C','o','m','p','o','n','e','n','t','I','D',0}; static const WCHAR guid[] = {'G','U','I','D',0}; static const WCHAR locale[] = {'L','o','c','a','l','e',0}; static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0}; per_user.bRollback = FALSE; per_user.dwIsInstalled = 0; SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, sizeof(per_user.szDispName) / sizeof(WCHAR), &size); SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, sizeof(per_user.szVersion) / sizeof(WCHAR), &size); if (SetupFindFirstLineW(hinf, field, is_installed, &context)) { SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled); } SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, sizeof(per_user.szCompID) / sizeof(WCHAR), &size); SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, sizeof(per_user.szGUID) / sizeof(WCHAR), &size); SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, sizeof(per_user.szLocale) / sizeof(WCHAR), &size); SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, sizeof(per_user.szStub) / sizeof(WCHAR), &size); return SetPerUserSecValuesW(&per_user); }
static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection) { INFCONTEXT Context; WCHAR szPath[MAX_PATH]; WCHAR szFolder[MAX_PATH]; WCHAR szFolderSection[MAX_PATH]; INT csidl; CoInitialize(NULL); if (!SetupFindFirstLine(hinf, szSection, NULL, &Context)) return FALSE; do { if (SetupGetFieldCount(&Context) < 2) continue; if (!SetupGetStringFieldW(&Context, 0, szFolderSection, MAX_PATH, NULL)) continue; if (!SetupGetIntField(&Context, 1, &csidl)) continue; if (!SetupGetStringFieldW(&Context, 2, szFolder, MAX_PATH, NULL)) continue; if (FAILED(SHGetFolderPathAndSubDirW(NULL, csidl|CSIDL_FLAG_CREATE, (HANDLE)-1, SHGFP_TYPE_DEFAULT, szFolder, szPath))) continue; CreateShortcutsFromSection(hinf, szFolderSection, szPath); }while (SetupFindNextLine(&Context, &Context)); CoUninitialize(); return TRUE; }
static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder) { INFCONTEXT Context; WCHAR szCommand[MAX_PATH]; WCHAR szName[MAX_PATH]; WCHAR szDescription[MAX_PATH]; INT iIconNr; if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context)) return FALSE; do { if (SetupGetFieldCount(&Context) < 4) continue; if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL)) continue; if (!SetupGetStringFieldW(&Context, 2, szName, MAX_PATH, NULL)) continue; if (!SetupGetStringFieldW(&Context, 3, szDescription, MAX_PATH, NULL)) continue; if (!SetupGetIntField(&Context, 4, &iIconNr)) continue; _tcscat(szName, L".lnk"); CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr); }while (SetupFindNextLine(&Context, &Context)); return TRUE; }
DWORD WINAPI NetClassInstaller( IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL) { SP_DRVINFO_DATA_W DriverInfoData; SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail; WCHAR SectionName[LINE_LEN]; HINF hInf = INVALID_HANDLE_VALUE; INFCONTEXT InfContext; UINT ErrorLine; INT CharacteristicsInt; DWORD Characteristics; LPWSTR BusType = NULL; RPC_STATUS RpcStatus; UUID Uuid; LPWSTR UuidRpcString = NULL; LPWSTR UuidString = NULL; LONG rc; DWORD dwLength; if (InstallFunction != DIF_INSTALLDEVICE) return ERROR_DI_DO_DEFAULT; DPRINT("%lu %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData); /* Get driver info details */ DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W); if (!SetupDiGetSelectedDriverW(DeviceInfoSet, DeviceInfoData, &DriverInfoData)) { rc = GetLastError(); DPRINT("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc); goto cleanup; } DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W); if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { rc = GetLastError(); DPRINT("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc); goto cleanup; } hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine); if (hInf == INVALID_HANDLE_VALUE) { rc = GetLastError(); DPRINT("SetupOpenInfFileW() failed with error 0x%lx\n", rc); goto cleanup; } if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL)) { rc = GetLastError(); DPRINT("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc); goto cleanup; } /* Get Characteristics and BusType (optional) from .inf file */ if (!SetupFindFirstLineW(hInf, SectionName, L"Characteristics", &InfContext)) { rc = GetLastError(); DPRINT("Unable to find key %S in section %S of file %S (error 0x%lx)\n", L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc); goto cleanup; } if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt)) { rc = GetLastError(); DPRINT("SetupGetIntField() failed with error 0x%lx\n", rc); goto cleanup; } Characteristics = (DWORD)CharacteristicsInt; if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) { if (SetupFindFirstLineW(hInf, SectionName, L"BusType", &InfContext)) { if (!SetupGetStringFieldW(&InfContext, 1, NULL, 0, &dwLength)) { rc = GetLastError(); DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc); goto cleanup; } BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR)); if (!BusType) { DPRINT("HeapAlloc() failed\n"); rc = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; } if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL)) { rc = GetLastError(); DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc); goto cleanup; } } } /* Create a new UUID */ RpcStatus = UuidCreate(&Uuid); if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY) { DPRINT("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus); rc = ERROR_GEN_FAILURE; goto cleanup; } RpcStatus = UuidToStringW(&Uuid, &UuidRpcString); if (RpcStatus != RPC_S_OK) { DPRINT("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus); rc = ERROR_GEN_FAILURE; goto cleanup; } /* Add curly braces around Uuid */ UuidString = HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL)); if (!UuidString) { DPRINT("HeapAlloc() failed\n"); rc = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; } wcscpy(UuidString, L"{"); wcscat(UuidString, UuidRpcString); wcscat(UuidString, L"}"); if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) rc = InstallNetDevice(DeviceInfoSet, DeviceInfoData, UuidString, Characteristics, BusType); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETCLIENT)) rc = InstallNetClient(); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETSERVICE)) rc = InstallNetService(); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETTRANS)) rc = InstallNetTransport(); else { DPRINT("Invalid class guid\n"); rc = ERROR_GEN_FAILURE; } cleanup: if (hInf != INVALID_HANDLE_VALUE) SetupCloseInfFile(hInf); if (UuidRpcString != NULL) RpcStringFreeW(&UuidRpcString); HeapFree(GetProcessHeap(), 0, BusType); HeapFree(GetProcessHeap(), 0, UuidString); if (rc == ERROR_SUCCESS) rc = ERROR_DI_DO_DEFAULT; DPRINT("Returning 0x%lx\n", rc); return rc; }
static INT LoadFreeldrSettings(HINF hInf, HWND hwndDlg) { INFCONTEXT InfContext; PBOOTRECORD pRecord; WCHAR szDefaultOs[MAX_PATH]; WCHAR szName[MAX_PATH]; WCHAR szValue[MAX_PATH]; DWORD LineLength; DWORD TimeOut; LRESULT lResult; if (!SetupFindFirstLineW(hInf, L"FREELOADER", L"DefaultOS", &InfContext)) { /* Failed to find default os */ return FALSE; } if (!SetupGetStringFieldW(&InfContext, 1, szDefaultOs, sizeof(szDefaultOs) / sizeof(WCHAR), &LineLength)) { /* No key */ return FALSE; } if (!SetupFindFirstLineW(hInf, L"FREELOADER", L"TimeOut", &InfContext)) { /* Expected to find timeout value */ return FALSE; } if (!SetupGetIntField(&InfContext, 1, (PINT)&TimeOut)) { /* Failed to retrieve timeout */ return FALSE; } if (!SetupFindFirstLineW(hInf, L"Operating Systems", NULL, &InfContext)) { /* Expected list of operating systems */ return FALSE; } do { if (!SetupGetStringFieldW(&InfContext, 0, szName, sizeof(szName) / sizeof(WCHAR), &LineLength)) { /* The ini file is messed up */ return FALSE; } if (!SetupGetStringFieldW(&InfContext, 1, szValue, sizeof(szValue) / sizeof(WCHAR), &LineLength)) { /* The ini file is messed up */ return FALSE; } pRecord = ReadFreeldrSection(hInf, szName); if (pRecord) { lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); if (lResult != CB_ERR) { SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); if (!wcscmp(szDefaultOs, szName)) { /* We store the friendly name as key */ wcscpy(szDefaultOs, szValue); } } else { HeapFree(GetProcessHeap(), 0, pRecord); } } } while (SetupFindNextLine(&InfContext, &InfContext)); /* Find default os in list */ lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs); if (lResult != CB_ERR) { /* Set cur sel */ SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); } if(TimeOut) { SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); } SetTimeout(hwndDlg, TimeOut); return TRUE; }
/*********************************************************************** * registry_callback * * Called once for each AddReg and DelReg entry in a given section. */ static BOOLEAN registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete) { OBJECT_ATTRIBUTES ObjectAttributes; WCHAR Buffer[MAX_INF_STRING_LENGTH]; UNICODE_STRING Name; UNICODE_STRING Value; PUNICODE_STRING ValuePtr; NTSTATUS Status; UINT Flags; ULONG Length; INFCONTEXT Context; HANDLE KeyHandle; BOOLEAN Ok; Ok = SetupFindFirstLineW (hInf, Section, NULL, &Context); if (Ok) { for (;Ok; Ok = SetupFindNextLine (&Context, &Context)) { /* get root */ if (!SetupGetStringFieldW (&Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL)) continue; if (!GetRootKey (Buffer)) continue; /* get key */ Length = wcslen (Buffer); if (!SetupGetStringFieldW (&Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL)) *Buffer = 0; DPRINT("KeyName: <%S>\n", Buffer); /* get flags */ if (!SetupGetIntField (&Context, 4, (PINT)&Flags)) Flags = 0; DPRINT("Flags: %lx\n", Flags); #ifdef __ODYSSEY__ RtlInitUnicodeString (&Name, Buffer); InitializeObjectAttributes (&ObjectAttributes, &Name, OBJ_CASE_INSENSITIVE, NULL, NULL); if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY)) { Status = NtOpenKey (&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes); if (!NT_SUCCESS(Status)) { DPRINT("NtOpenKey(%wZ) failed (Status %lx)\n", &Name, Status); continue; /* ignore if it doesn't exist */ } } else { Status = CreateNestedKey (&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes); if (!NT_SUCCESS(Status)) { DPRINT("CreateNestedKey(%wZ) failed (Status %lx)\n", &Name, Status); continue; } } #else if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY)) { LONG rc = RegOpenKeyW(NULL, Buffer, &KeyHandle); if (rc != ERROR_SUCCESS) { DPRINT("RegOpenKeyW(%S) failed (error %lu)\n", Buffer, rc); continue; /* ignore if it doesn't exist */ } } else { LONG rc = RegCreateKeyW(NULL, Buffer, &KeyHandle); if (rc != ERROR_SUCCESS) { DPRINT("RegCreateKeyW(%S) failed (error %lu)\n", Buffer, rc); continue; } } #endif /* get value name */ if (SetupGetStringFieldW (&Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL)) { RtlInitUnicodeString (&Value, Buffer); ValuePtr = &Value; } else { ValuePtr = NULL; } /* and now do it */ if (!do_reg_operation (KeyHandle, ValuePtr, &Context, Flags)) { NtClose (KeyHandle); return FALSE; } #ifdef __ODYSSEY__ NtClose (KeyHandle); #endif } } return TRUE; }