ReactOS  0.4.12-dev-14-gd0c8636
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.

Referenced by LoadBootIni().

Function Documentation

◆ FreeLdrPageWndProc()

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

Definition at line 134 of file freeldrpage.c.

Referenced by CreatePropSheet(), and OnCreate().

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:
148  pos = SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0);
149  if (pos != LB_ERR)
150  {
152  if (!res) /* line is not a default one */
154  else
156 
157 
158  }
159  break;
160  }
161  }
162  return 0;
163 }
#define LB_SETCURSEL
Definition: winuser.h:2024
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define LB_GETITEMDATA
Definition: winuser.h:2002
#define SWP_NOZORDER
Definition: winuser.h:1232
#define LBN_SELCHANGE
Definition: winuser.h:2036
WPARAM wParam
Definition: combotst.c:138
#define LB_ERR
Definition: winuser.h:2386
LONG_PTR LPARAM
Definition: windef.h:208
static BOOL InitializeFreeLDRDialog(HWND hDlg)
Definition: freeldrpage.c:118
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WM_COMMAND
Definition: winuser.h:1716
#define SWP_NOSIZE
Definition: winuser.h:1230
#define LB_GETCURSEL
Definition: winuser.h:2000
static FREELDR_SETTINGS Settings
Definition: freeldrpage.c:24
#define SendMessage
Definition: winuser.h:5709
GLuint res
Definition: glext.h:9613
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG_PTR LRESULT
Definition: windef.h:209
HWND hFreeLdrDialog
Definition: freeldrpage.c:13
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234

◆ InitializeFreeLDRDialog()

static BOOL InitializeFreeLDRDialog ( HWND  hDlg)
static

Definition at line 118 of file freeldrpage.c.

Referenced by FreeLdrPageWndProc().

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 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define PATH_MAX
Definition: types.h:280
static BOOL LoadBootIni(WCHAR *szDrive, HWND hDlg)
Definition: freeldrpage.c:29
static const WCHAR L[]
Definition: oid.c:1087

◆ LoadBootIni()

static BOOL LoadBootIni ( WCHAR szDrive,
HWND  hDlg 
)
static

Definition at line 29 of file freeldrpage.c.

Referenced by InitializeFreeLDRDialog().

30 {
31  WCHAR szBuffer[BUFFER_SIZE];
32  HWND hDlgCtrl;
33  FILE * file;
34  UINT length;
35  LRESULT pos;
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
93  }
94  }
95  }
96 
97  fclose(file);
99 
100  pos = SendMessageW(hDlgCtrl, LB_FINDSTRING, 3, (LPARAM)Settings.szDefaultOS);
101  if (pos != LB_ERR)
102  {
104  SendMessage(hDlgCtrl, LB_SETCURSEL, pos, 0);
105  }
106 
109  {
113  }
114  return TRUE;
115 }
#define LB_SETCURSEL
Definition: winuser.h:2024
WCHAR szDefaultOS[512]
Definition: freeldrpage.c:18
#define TRUE
Definition: types.h:120
#define IDC_TXT_BOOT_TIMEOUT
Definition: resource.h:41
#define LB_ADDSTRING
Definition: winuser.h:1992
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_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)
#define BUFFER_SIZE
Definition: freeldrpage.c:26
#define IDC_LIST_BOX
Definition: resource.h:30
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define IDC_BTN_MOVE_UP_BOOT_OPTION
Definition: resource.h:33
#define LB_ERR
Definition: winuser.h:2386
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_BTN_MOVE_DOWN_BOOT_OPTION
Definition: resource.h:34
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
const char file[]
Definition: icontest.c:11
unsigned int UINT
Definition: ndis.h:50
#define LB_SETITEMDATA
Definition: winuser.h:2026
ULONG OSConfigurationCount
Definition: freeldrpage.c:20
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
static const WCHAR L[]
Definition: oid.c:1087
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LB_FINDSTRING
Definition: winuser.h:1995
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static FREELDR_SETTINGS Settings
Definition: freeldrpage.c:24
#define SendMessage
Definition: winuser.h:5709
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
LONG_PTR LRESULT
Definition: windef.h:209
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDC_BTN_SET_DEFAULT_BOOT
Definition: resource.h:32

Variable Documentation

◆ hFreeLdrDialog

HWND hFreeLdrDialog

Definition at line 13 of file freeldrpage.c.

◆ hFreeLdrPage

HWND hFreeLdrPage

Definition at line 12 of file freeldrpage.c.

Referenced by MsConfig_OnTabWndSelChange(), MsConfigWndProc(), and OnCreate().

◆ Settings

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

Definition at line 24 of file freeldrpage.c.