ReactOS 0.4.15-dev-7705-g2320c37
freeldrpage.c File Reference
#include "precomp.h"
Include dependency graph for freeldrpage.c:

Go to the source code of this file.

Classes

struct  FREELDR_SETTINGS
 

Macros

#define BUFFER_SIZE   512
 

Functions

static BOOL LoadBootIni (WCHAR *szDrive, HWND hDlg)
 
static BOOL InitializeFreeLDRDialog (HWND hDlg)
 
INT_PTR CALLBACK FreeLdrPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

HWND hFreeLdrPage
 
HWND hFreeLdrDialog
 
static FREELDR_SETTINGS Settings = { 0, { 0, }, 0, 0, FALSE }
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   512

Definition at line 26 of file freeldrpage.c.

Function Documentation

◆ FreeLdrPageWndProc()

INT_PTR CALLBACK FreeLdrPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 134 of file freeldrpage.c.

135{
136 LRESULT pos;
137
138 switch (message) {
139 case WM_INITDIALOG:
140 hFreeLdrDialog = hDlg;
143 return TRUE;
144 case WM_COMMAND:
145 switch(HIWORD(wParam))
146 {
147 case LBN_SELCHANGE:
149 if (pos != LB_ERR)
150 {
152 if (!res) /* line is not a default one */
153 SendMessage((HWND)lParam, LB_SETCURSEL, Settings.szDefaultPos, 0);
154 else
155 Settings.szDefaultPos = pos;
156
157
158 }
159 break;
160 }
161 }
162 return 0;
163}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
GLuint res
Definition: glext.h:9613
static BOOL InitializeFreeLDRDialog(HWND hDlg)
Definition: freeldrpage.c:118
HWND hFreeLdrDialog
Definition: freeldrpage.c:13
Definition: tftpd.h:60
#define HIWORD(l)
Definition: typedefs.h:247
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
#define LB_ERR
Definition: winuser.h:2431
#define SWP_NOACTIVATE
Definition: winuser.h:1241
#define LB_GETITEMDATA
Definition: winuser.h:2040
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_COMMAND
Definition: winuser.h:1739
#define SWP_NOSIZE
Definition: winuser.h:1244
#define WM_INITDIALOG
Definition: winuser.h:1738
#define SendMessage
Definition: winuser.h:5842
#define LBN_SELCHANGE
Definition: winuser.h:2074
#define SWP_NOOWNERZORDER
Definition: winuser.h:1248
#define LB_SETCURSEL
Definition: winuser.h:2062
#define SWP_NOZORDER
Definition: winuser.h:1246
#define LB_GETCURSEL
Definition: winuser.h:2038

Referenced by CreatePropSheet(), and OnCreate().

◆ InitializeFreeLDRDialog()

static BOOL InitializeFreeLDRDialog ( HWND  hDlg)
static

Definition at line 118 of file freeldrpage.c.

119{
120 WCHAR winDir[PATH_MAX];
121 WCHAR* ptr = NULL;
122
124 ptr = wcschr(winDir, L'\\');
125 if (ptr == NULL)
126 {
127 return FALSE;
128 }
129 ptr[1] = L'\0';
130 return LoadBootIni(winDir, hDlg);
131}
#define PATH_MAX
Definition: types.h:280
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
static PVOID ptr
Definition: dispmode.c:27
static BOOL LoadBootIni(WCHAR *szDrive, HWND hDlg)
Definition: freeldrpage.c:29
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FreeLdrPageWndProc().

◆ LoadBootIni()

static BOOL LoadBootIni ( WCHAR szDrive,
HWND  hDlg 
)
static

Definition at line 29 of file freeldrpage.c.

30{
31 WCHAR szBuffer[BUFFER_SIZE];
32 HWND hDlgCtrl;
33 FILE * file;
36 HRESULT hr;
37
38 hr = StringCbCopyW(szBuffer, sizeof(szBuffer), szDrive);
39 if (FAILED(hr))
40 return FALSE;
41
42 hr = StringCbCatW(szBuffer, sizeof(szBuffer), L"freeldr.ini");
43 if (FAILED(hr))
44 return FALSE;
45
46 file = _wfopen(szBuffer, L"rt");
47 if (!file)
48 {
49 hr = StringCbCopyW(szBuffer, sizeof(szBuffer), szDrive);
50 if (FAILED(hr))
51 return FALSE;
52
53 hr = StringCbCatW(szBuffer, sizeof(szBuffer), L"boot.ini");
54 if (FAILED(hr))
55 return FALSE;
56
57 file = _wfopen(szBuffer, L"rt");
58 if (!file)
59 return FALSE;
60 }
61
62 hDlgCtrl = GetDlgItem(hDlg, IDC_LIST_BOX);
63
64 while(!feof(file))
65 {
66 if (fgetws(szBuffer, BUFFER_SIZE, file))
67 {
68 length = wcslen(szBuffer);
69 if (length > 1)
70 {
71 szBuffer[length] = L'\0';
72 szBuffer[length - 1] = L'\0';
73
74 pos = SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szBuffer);
75
76 if (szBuffer[0] == L'[')
77 continue;
78
79 if (!_wcsnicmp(szBuffer, L"timeout=", 8))
80 {
81 Settings.TimeOut = _wtoi(&szBuffer[8]);
82 continue;
83 }
84
85 if (!_wcsnicmp(szBuffer, L"default=", 8))
86 {
87 wcscpy(Settings.szDefaultOS, &szBuffer[8]);
88 continue;
89 }
90 if (pos != LB_ERR)
91 SendMessage(hDlgCtrl, LB_SETITEMDATA, pos, 1); // indicate that this item is an boot entry
92 Settings.OSConfigurationCount++;
93 }
94 }
95 }
96
97 fclose(file);
98 Settings.UseBootIni = TRUE;
99
100 pos = SendMessageW(hDlgCtrl, LB_FINDSTRING, 3, (LPARAM)Settings.szDefaultOS);
101 if (pos != LB_ERR)
102 {
103 Settings.szDefaultPos = pos;
104 SendMessage(hDlgCtrl, LB_SETCURSEL, pos, 0);
105 }
106
108 if (Settings.OSConfigurationCount < 2)
109 {
113 }
114 return TRUE;
115}
#define IDC_LIST_BOX
Definition: resource.h:30
#define IDC_BTN_SET_DEFAULT_BOOT
Definition: resource.h:32
#define IDC_BTN_MOVE_DOWN_BOOT_OPTION
Definition: resource.h:34
#define IDC_BTN_MOVE_UP_BOOT_OPTION
Definition: resource.h:33
#define IDC_TXT_BOOT_TIMEOUT
Definition: resource.h:41
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define FAILED(hr)
Definition: intsafe.h:51
#define BUFFER_SIZE
Definition: freeldrpage.c:26
unsigned int UINT
Definition: ndis.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
HRESULT hr
Definition: shlfolder.c:183
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
Definition: fci.c:127
#define LB_ADDSTRING
Definition: winuser.h:2030
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define LB_FINDSTRING
Definition: winuser.h:2033
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LB_SETITEMDATA
Definition: winuser.h:2064
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22

Referenced by InitializeFreeLDRDialog().

Variable Documentation

◆ hFreeLdrDialog

HWND hFreeLdrDialog

Definition at line 13 of file freeldrpage.c.

Referenced by FreeLdrPageWndProc().

◆ hFreeLdrPage

HWND hFreeLdrPage

◆ Settings

FREELDR_SETTINGS Settings = { 0, { 0, }, 0, 0, FALSE }
static

Definition at line 24 of file freeldrpage.c.