1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
* WineCfg main entry point
*
* Copyright 2002 Jaco Greeff
* Copyright 2003 Dimitrie O. Paun
* Copyright 2003 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#define WIN32_LEAN_AND_MEAN
#define NONAMELESSUNION
#include <windows.h>
#include <commctrl.h>
#include <objbase.h>
#include <wine/debug.h>
#include "resource.h"
#include "winecfg.h"
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
static INT CALLBACK
PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
{
switch (uMsg)
{
/*
* hWnd = NULL, lParam == dialog resource
*/
case PSCB_PRECREATE:
break;
case PSCB_INITIALIZED:
/* Set the window icon */
SendMessageW( hWnd, WM_SETICON, ICON_BIG,
(LPARAM)LoadIconW( (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE),
MAKEINTRESOURCEW(IDI_WINECFG) ));
break;
default:
break;
}
return 0;
}
#define NUM_PROPERTY_PAGES 7
static INT_PTR
doPropertySheet (HINSTANCE hInstance, HWND hOwner)
{
PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
PROPSHEETHEADERW psh;
int pg = 0; /* start with page 0 */
/*
* Fill out the (Applications) PROPSHEETPAGE data structure
* for the property sheet
*/
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = AppDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
psp[pg].lParam = 0;
pg++;
/*
* Fill out the (Libraries) PROPSHEETPAGE data structure
* for the property sheet
*/
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = LibrariesDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
psp[pg].lParam = 0;
pg++;
/*
* Fill out the (X11Drv) PROPSHEETPAGE data structure
* for the property sheet
*/
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = GraphDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
psp[pg].lParam = 0;
pg++;
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = ThemeDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
psp[pg].lParam = 0;
pg++;
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = DriveDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
psp[pg].lParam = 0;
pg++;
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = AudioDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
psp[pg].lParam = 0;
pg++;
/*
* Fill out the (General) PROPSHEETPAGE data structure
* for the property sheet
*/
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
psp[pg].dwFlags = PSP_USETITLE;
psp[pg].hInstance = hInstance;
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
psp[pg].u2.pszIcon = NULL;
psp[pg].pfnDlgProc = AboutDlgProc;
psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
psp[pg].lParam = 0;
pg++;
/*
* Fill out the PROPSHEETHEADER
*/
psh.dwSize = sizeof (PROPSHEETHEADERW);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
psh.hwndParent = hOwner;
psh.hInstance = hInstance;
psh.u.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
psh.pszCaption = load_string (IDS_WINECFG_TITLE);
psh.nPages = NUM_PROPERTY_PAGES;
psh.u3.ppsp = psp;
psh.pfnCallback = PropSheetCallback;
psh.u2.nStartPage = 0;
/*
* Display the modal property sheet
*/
return PropertySheetW (&psh);
}
/******************************************************************************
* Name : ProcessCmdLine
* Description: Checks command line parameters for 'autodetect drives' option
* Parameters : lpCmdLine - the command line
* Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
* FALSE - no '/D' option found in command line
* Notes : This is a very simple implementation, which only works
* correctly if the one and only cmd line option is '/D' or
* no option at all. Has to be reworked, if more options are to
* be supported.
*/
static BOOL
ProcessCmdLine(LPSTR lpCmdLine)
{
if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
(lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
{
gui_mode = FALSE;
if (autodetect_drives()) {
apply_drive_changes();
}
return TRUE;
}
return FALSE;
}
/*****************************************************************************
* Name : WinMain
* Description: Main windows entry point
* Parameters : hInstance
* hPrev
* szCmdLine
* nShow
* Returns : Program exit code
*/
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
{
BOOL is_wow64;
if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
{
STARTUPINFOW si;
PROCESS_INFORMATION pi;
WCHAR filename[MAX_PATH];
void *redir;
DWORD exit_code;
memset( &si, 0, sizeof(si) );
si.cb = sizeof(si);
GetModuleFileNameW( 0, filename, MAX_PATH );
Wow64DisableWow64FsRedirection( &redir );
if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
{
WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) );
WaitForSingleObject( pi.hProcess, INFINITE );
GetExitCodeProcess( pi.hProcess, &exit_code );
ExitProcess( exit_code );
}
else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename), GetLastError() );
Wow64RevertWow64FsRedirection( redir );
}
if (ProcessCmdLine(szCmdLine)) {
return 0;
}
if (initialize(hInstance)) {
WINE_ERR("initialization failed, aborting\n");
ExitProcess(1);
}
/*
* The next 9 lines should be all that is needed
* for the Wine Configuration property sheet
*/
InitCommonControls ();
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (doPropertySheet (hInstance, NULL) > 0) {
WINE_TRACE("OK\n");
} else {
WINE_TRACE("Cancel\n");
}
CoUninitialize();
ExitProcess (0);
return 0;
}