1 | /* $Id: Win32kCC.c,v 1.10 2001-01-08 18:05:26 bird Exp $
|
---|
2 | *
|
---|
3 | * Win32CC - Win32k Control Center.
|
---|
4 | *
|
---|
5 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 |
|
---|
12 | /*******************************************************************************
|
---|
13 | * Defined Constants And Macros *
|
---|
14 | *******************************************************************************/
|
---|
15 |
|
---|
16 | /*
|
---|
17 | * Private Window Messages
|
---|
18 | */
|
---|
19 | #define WM_SETCONTROLS (WM_USER + 10)
|
---|
20 | #define WM_QUERYCONTROLS (WM_USER + 11)
|
---|
21 |
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * Include defines
|
---|
25 | */
|
---|
26 | #define INCL_DOSERRORS
|
---|
27 | #define INCL_DOSFILEMGR
|
---|
28 | #define INCL_DOSRESOURCES
|
---|
29 | #define INCL_WINERRORS
|
---|
30 | #define INCL_WINDIALOGS
|
---|
31 | #define INCL_WINMESSAGEMGR
|
---|
32 | #define INCL_WINSTDSPIN
|
---|
33 | #define INCL_WINBUTTONS
|
---|
34 | #define INCL_WINWINDOWMGR
|
---|
35 | #define INCL_DOSMISC
|
---|
36 |
|
---|
37 | /*******************************************************************************
|
---|
38 | * Header Files *
|
---|
39 | *******************************************************************************/
|
---|
40 | #include <os2.h>
|
---|
41 |
|
---|
42 | #include <string.h>
|
---|
43 | #include <stdio.h>
|
---|
44 | #include <stdarg.h>
|
---|
45 | #include <stdlib.h>
|
---|
46 | #include <errno.h>
|
---|
47 |
|
---|
48 | #include <Win32k.h>
|
---|
49 | #include <devSegDf.h> /* Win32k segment definitions. */
|
---|
50 | #include <Options.h>
|
---|
51 |
|
---|
52 | #include "Win32kCC.h"
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 | /*******************************************************************************
|
---|
57 | * Structures and Typedefs *
|
---|
58 | *******************************************************************************/
|
---|
59 | typedef struct _WIN32KCC
|
---|
60 | {
|
---|
61 | HWND hwnd;
|
---|
62 | HAB hab;
|
---|
63 | BOOL fDirty;
|
---|
64 |
|
---|
65 | K32OPTIONS Options;
|
---|
66 | K32OPTIONS NewOptions;
|
---|
67 | K32STATUS Status;
|
---|
68 |
|
---|
69 | } WIN32KCC, *PWIN32KCC;
|
---|
70 |
|
---|
71 |
|
---|
72 | /*******************************************************************************
|
---|
73 | * Global Variables *
|
---|
74 | *******************************************************************************/
|
---|
75 | BOOL fNotExit; /* Global variable used to stop WM_QUITS.
|
---|
76 | * As long as this is true the message
|
---|
77 | * loop will never exit, but ignore all
|
---|
78 | * WM_QUITs.
|
---|
79 | */
|
---|
80 |
|
---|
81 |
|
---|
82 | /*******************************************************************************
|
---|
83 | * Internal Functions *
|
---|
84 | *******************************************************************************/
|
---|
85 | MRESULT EXPENTRY Win32kCCDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
86 | ULONG ShowMessage(HWND hwndOwner, int id, ULONG flStyle);
|
---|
87 | BOOL Complain(HWND hwndOwner, int id, ...);
|
---|
88 | PCSZ getLastErrorMsg(HAB hab);
|
---|
89 | PSZ getMessage(ULONG id);
|
---|
90 | int GetFixpackDesc(ULONG ulBuild, ULONG flKernel, PSZ pszBuffer);
|
---|
91 | char * stristr(const char *pszStr, const char *pszSubStr);
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Main function.
|
---|
97 | * (No parameters)
|
---|
98 | * @returns -1 WinInitialize failed.
|
---|
99 | * -2 Failed to create message queue.
|
---|
100 | * -3 Failed to load dialog.
|
---|
101 | * 0 Dialog was closed using cancel.
|
---|
102 | * 1 Dialog was close using ok.
|
---|
103 | */
|
---|
104 | int main(void)
|
---|
105 | {
|
---|
106 | HAB hab;
|
---|
107 | HMQ hmq;
|
---|
108 | ULONG rc = 0;
|
---|
109 | HWND hwnd;
|
---|
110 |
|
---|
111 | /*
|
---|
112 | * Initialize PM.
|
---|
113 | */
|
---|
114 | hab = WinInitialize(0);
|
---|
115 | if (hab == NULLHANDLE)
|
---|
116 | {
|
---|
117 | return -1;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /*
|
---|
121 | * Create Message Queue.
|
---|
122 | */
|
---|
123 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
124 | if (hmq == NULLHANDLE)
|
---|
125 | {
|
---|
126 | WinTerminate(hab);
|
---|
127 | return -2;
|
---|
128 | }
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * Init Win32k library.
|
---|
132 | */
|
---|
133 | rc = libWin32kInit();
|
---|
134 | if (rc != NO_ERROR)
|
---|
135 | {
|
---|
136 | switch (rc)
|
---|
137 | {
|
---|
138 | case ERROR_FILE_NOT_FOUND:
|
---|
139 | Complain(HWND_DESKTOP, IDS_ERR_WIN32K_NOT_LOADED);
|
---|
140 | break;
|
---|
141 |
|
---|
142 | default:
|
---|
143 | Complain(HWND_DESKTOP, IDS_ERR_WIN32K_OPEN_FAILED, rc);
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * Load the dialog.
|
---|
149 | */
|
---|
150 | hwnd = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP,
|
---|
151 | Win32kCCDlgProc,
|
---|
152 | NULLHANDLE,
|
---|
153 | DL_WIN32KCC,
|
---|
154 | NULL);
|
---|
155 |
|
---|
156 | /*
|
---|
157 | * Process the dialog.
|
---|
158 | */
|
---|
159 | if (hwnd != NULLHANDLE)
|
---|
160 | {
|
---|
161 | QMSG qmsg;
|
---|
162 | do
|
---|
163 | {
|
---|
164 | fNotExit = FALSE;
|
---|
165 | while(WinGetMsg(hab, &qmsg, NULLHANDLE, NULLHANDLE, NULLHANDLE))
|
---|
166 | WinDispatchMsg(hab, &qmsg);
|
---|
167 | } while (fNotExit);
|
---|
168 |
|
---|
169 |
|
---|
170 | }
|
---|
171 | else
|
---|
172 | {
|
---|
173 | Complain(HWND_DESKTOP,
|
---|
174 | IDS_ERR_DIALOGLOAD,
|
---|
175 | DL_WIN32KCC,
|
---|
176 | WinGetLastError(hab),
|
---|
177 | getLastErrorMsg(hab)
|
---|
178 | );
|
---|
179 | rc = -3;
|
---|
180 | }
|
---|
181 |
|
---|
182 | /*
|
---|
183 | * Cleanup.
|
---|
184 | */
|
---|
185 | WinDestroyMsgQueue(hmq);
|
---|
186 | WinTerminate(hab);
|
---|
187 | libWin32kTerm();
|
---|
188 |
|
---|
189 | return rc;
|
---|
190 | }
|
---|
191 |
|
---|
192 | #pragma info(noord) /*remove annoying (and possible incorrect) messages on the MP* macros */
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * Dialog procedure for the DL_WIN32KCC dialog.
|
---|
196 | * (See PMREF for the general specifications of this function.)
|
---|
197 | */
|
---|
198 | MRESULT EXPENTRY Win32kCCDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
199 | {
|
---|
200 | PWIN32KCC pThis;
|
---|
201 |
|
---|
202 |
|
---|
203 | /*
|
---|
204 | * Get instance data pointer (pThis).
|
---|
205 | */
|
---|
206 | if (msg != WM_INITDLG)
|
---|
207 | {
|
---|
208 | pThis = (PWIN32KCC)WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
209 | if (pThis == NULL)
|
---|
210 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | /*
|
---|
215 | * Message switch.
|
---|
216 | */
|
---|
217 | switch (msg)
|
---|
218 | {
|
---|
219 | /*
|
---|
220 | * Sets the controls according to the data from win32k.
|
---|
221 | *
|
---|
222 | * mr: Focus changed or not.
|
---|
223 | * mp1: hwnd of dialog
|
---|
224 | * mp2: (user data) (NULL)
|
---|
225 | */
|
---|
226 | case WM_INITDLG:
|
---|
227 | {
|
---|
228 |
|
---|
229 | /*
|
---|
230 | * Initiate controls (ie. behaviour not data).
|
---|
231 | * - Ranges of the info level spinbuttons.
|
---|
232 | * - Max length of the max heap size entry fields.
|
---|
233 | */
|
---|
234 | WinSendDlgItemMsg(hwnd, SB_LDR_PE_INFOLEVEL, SPBM_SETLIMITS, (MPARAM)4, (MPARAM)0);
|
---|
235 | WinSendDlgItemMsg(hwnd, SB_LDR_ELF_INFOLEVEL, SPBM_SETLIMITS, (MPARAM)4, (MPARAM)0);
|
---|
236 |
|
---|
237 | WinSendDlgItemMsg(hwnd, SB_HEAP_RES_MAX, SPBM_SETLIMITS, (MPARAM)32678, (MPARAM)128);
|
---|
238 | WinSendDlgItemMsg(hwnd, SB_HEAP_SWP_MAX, SPBM_SETLIMITS, (MPARAM)32678, (MPARAM)128);
|
---|
239 |
|
---|
240 |
|
---|
241 | /*
|
---|
242 | * Init and set instance data.
|
---|
243 | */
|
---|
244 | pThis = malloc(sizeof(*pThis));
|
---|
245 | if (pThis == NULL)
|
---|
246 | {
|
---|
247 | /* complain, dismiss and return. */
|
---|
248 | Complain(hwnd, IDS_ERR_MALLOC_FAILED, __FILE__, __LINE__, __FUNCTION__);
|
---|
249 | WinPostMsg(hwnd, WM_QUIT, NULL, NULL);
|
---|
250 | return FALSE;
|
---|
251 | }
|
---|
252 | pThis->hwnd = hwnd;
|
---|
253 | pThis->hab = WinQueryAnchorBlock(hwnd);
|
---|
254 | if (!WinSetWindowPtr(hwnd, QWL_USER, pThis))
|
---|
255 | {
|
---|
256 | /* complain, dismiss and return. */
|
---|
257 | Complain(hwnd, IDS_ERR_SET_INSTACEDATA,
|
---|
258 | WinGetLastError(pThis->hab),
|
---|
259 | getLastErrorMsg(pThis->hab));
|
---|
260 | WinDismissDlg(hwnd, 0);
|
---|
261 | WinPostMsg(hwnd, WM_QUIT, NULL, NULL);
|
---|
262 | free(pThis);
|
---|
263 | return FALSE;
|
---|
264 | }
|
---|
265 |
|
---|
266 | /*
|
---|
267 | * Send a set controls message which gets data from
|
---|
268 | * win32k and puts it into the controls.
|
---|
269 | */
|
---|
270 | WinSendMsg(hwnd, WM_SETCONTROLS, NULL, NULL);
|
---|
271 | break;
|
---|
272 | }
|
---|
273 |
|
---|
274 |
|
---|
275 | /*
|
---|
276 | * The user wants me to do something...
|
---|
277 | */
|
---|
278 | case WM_COMMAND:
|
---|
279 | switch (SHORT1FROMMP(mp1))
|
---|
280 | {
|
---|
281 | /*
|
---|
282 | * The user pushed the "Apply" button.
|
---|
283 | */
|
---|
284 | case PB_APPLY:
|
---|
285 | {
|
---|
286 | /* Check and get data from the dialog. */
|
---|
287 | if (WinSendMsg(hwnd, WM_QUERYCONTROLS, (MPARAM)TRUE, NULL)
|
---|
288 | && pThis->fDirty
|
---|
289 | )
|
---|
290 | {
|
---|
291 | APIRET rc;
|
---|
292 | rc = libWin32kSetOptions(&pThis->NewOptions);
|
---|
293 | if (rc != NO_ERROR)
|
---|
294 | Complain(hwnd, IDS_ERR_SETPOPTIONS, rc);
|
---|
295 | WinSendMsg(hwnd, WM_SETCONTROLS, NULL, NULL);
|
---|
296 | }
|
---|
297 | }
|
---|
298 | break;
|
---|
299 |
|
---|
300 |
|
---|
301 | /*
|
---|
302 | * User pushed the "Refresh" button.
|
---|
303 | */
|
---|
304 | case PB_REFRESH:
|
---|
305 | WinSendMsg(hwnd, WM_SETCONTROLS, NULL, NULL);
|
---|
306 | break;
|
---|
307 |
|
---|
308 |
|
---|
309 | /*
|
---|
310 | * The user pushed the "Close" button.
|
---|
311 | */
|
---|
312 | case DID_OK:
|
---|
313 | /* Check if data is dirty */
|
---|
314 | if (!WinSendMsg(hwnd, WM_QUERYCONTROLS, (MPARAM)FALSE, NULL) || pThis->fDirty)
|
---|
315 | {
|
---|
316 | if (ShowMessage(hwnd, IDM_INFO_DIRTY, MB_YESNO | MB_WARNING) != MBID_YES)
|
---|
317 | {
|
---|
318 | fNotExit = TRUE;
|
---|
319 | return NULL;
|
---|
320 | }
|
---|
321 | }
|
---|
322 | /* Close the dialog */
|
---|
323 | fNotExit = FALSE;
|
---|
324 | WinDismissDlg(hwnd, 0);
|
---|
325 | WinPostMsg(hwnd, WM_QUIT, NULL, NULL);
|
---|
326 | break;
|
---|
327 |
|
---|
328 | /*
|
---|
329 | * The use requested update of config.sys.
|
---|
330 | */
|
---|
331 | case PB_UPD_CONFIGSYS:
|
---|
332 | {
|
---|
333 | ULONG ulBootDrv;
|
---|
334 | FILE * phConfigSys;
|
---|
335 | char * pszConfigSys = "A:\\Config.sys";
|
---|
336 | char szArgs[120];
|
---|
337 | int cchArgs;
|
---|
338 |
|
---|
339 | if (!WinSendMsg(hwnd, WM_QUERYCONTROLS, (MPARAM)TRUE, NULL))
|
---|
340 | break;
|
---|
341 | if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrv, sizeof(ulBootDrv)))
|
---|
342 | break;
|
---|
343 |
|
---|
344 | /*
|
---|
345 | * Make argument list.
|
---|
346 | */
|
---|
347 | szArgs[0] = '\0';
|
---|
348 | if (pThis->NewOptions.fLogging) strcat(szArgs, " -L:Y");
|
---|
349 | if (pThis->NewOptions.usCom == 0x3f8) strcat(szArgs, " -C1");
|
---|
350 | /*if (pThis->NewOptions.usCom != 0x2f8) strcat(szArgs, " -C2"); - default */
|
---|
351 | if (pThis->NewOptions.usCom == 0x3e8) strcat(szArgs, " -C3");
|
---|
352 | if (pThis->NewOptions.usCom == 0x2e8) strcat(szArgs, " -C4");
|
---|
353 | if (pThis->NewOptions.fPE == FLAGS_PE_PE2LX)strcat(szArgs, " -P:pe2lx");
|
---|
354 | /*if (pThis->NewOptions.fPE == FLAGS_PE_MIXED)strcat(szArgs, " -P:mixed"); - old default */
|
---|
355 | if (pThis->NewOptions.fPE == FLAGS_PE_MIXED)strcat(szArgs, " -P:mixed");
|
---|
356 | /* if (pThis->NewOptions.fPE == FLAGS_PE_PE) strcat(szArgs, " -P:pe"); - default */
|
---|
357 | if (pThis->NewOptions.fPE == FLAGS_PE_NOT) strcat(szArgs, " -P:not");
|
---|
358 | if (pThis->NewOptions.ulInfoLevel != 0) /* -W0 is default */
|
---|
359 | sprintf(szArgs + strlen(szArgs), " -W%d", pThis->NewOptions.ulInfoLevel); /* FIXME - to be changed */
|
---|
360 | if (pThis->NewOptions.fElf) strcat(szArgs, " -E:Y"); /* default is disabled */
|
---|
361 | if (!pThis->NewOptions.fUNIXScript) strcat(szArgs, " -Script:N");
|
---|
362 | if (!pThis->NewOptions.fREXXScript) strcat(szArgs, " -Rexx:N");
|
---|
363 | if (!pThis->NewOptions.fJava) strcat(szArgs, " -Java:N");
|
---|
364 | if (pThis->NewOptions.fNoLoader) strcat(szArgs, " -Noloader");
|
---|
365 | if (!pThis->NewOptions.fDllFixes) strcat(szArgs, " -DllFixes:D"); /* default is enabled */
|
---|
366 | if (pThis->NewOptions.cbSwpHeapMax != CB_SWP_MAX)
|
---|
367 | sprintf(szArgs + strlen(szArgs), " -HeapMax:%d", pThis->NewOptions.cbSwpHeapMax); /* FIXME - to be changed */
|
---|
368 | if (pThis->NewOptions.cbResHeapMax != CB_RES_MAX)
|
---|
369 | sprintf(szArgs + strlen(szArgs), " -ResHeapMax:%d", pThis->NewOptions.cbResHeapMax); /* FIXME - to be changed */
|
---|
370 | strcat(szArgs, "\n");
|
---|
371 | cchArgs = strlen(szArgs);
|
---|
372 |
|
---|
373 | /*
|
---|
374 | * Update Config.sys.
|
---|
375 | */
|
---|
376 | *pszConfigSys = ulBootDrv - 1 + 'A';
|
---|
377 | phConfigSys = fopen(pszConfigSys, "r+");
|
---|
378 | if (phConfigSys)
|
---|
379 | {
|
---|
380 | ULONG cbConfigSys;
|
---|
381 | if ( fseek(phConfigSys, 0, SEEK_END) == 0
|
---|
382 | && (cbConfigSys = ftell(phConfigSys)) > 0
|
---|
383 | && fseek(phConfigSys, 0, SEEK_SET) == 0
|
---|
384 | )
|
---|
385 | {
|
---|
386 | char * pszConfigSys;
|
---|
387 |
|
---|
388 | pszConfigSys = (char*)calloc(1, 2 * (cbConfigSys + 256)); /* Paranoia... */
|
---|
389 | if (pszConfigSys)
|
---|
390 | {
|
---|
391 | char *pszCurrent = pszConfigSys;
|
---|
392 |
|
---|
393 | /* Read and modify config.sys */
|
---|
394 | while (fgets(pszCurrent, cbConfigSys + pszCurrent - pszConfigSys, phConfigSys))
|
---|
395 | {
|
---|
396 | char *pszWin32k;
|
---|
397 | /* NB! This statment will not only update the "device=" statements!
|
---|
398 | * We'll call this a feature...
|
---|
399 | */
|
---|
400 | pszWin32k = stristr(pszCurrent, "win32k.sys");
|
---|
401 | if (pszWin32k)
|
---|
402 | {
|
---|
403 | int cch;
|
---|
404 | pszWin32k += 10; /* skip "win32k.sys" */
|
---|
405 | cch = strlen(pszWin32k);
|
---|
406 | strcpy(pszWin32k, szArgs);
|
---|
407 | if (cchArgs < cch)
|
---|
408 | { /* fix which stops us from shrinking the file.. */
|
---|
409 | memset(pszWin32k + cchArgs - 1, ' ', cch - cchArgs);
|
---|
410 | pszWin32k[cch - 1] = '\n';
|
---|
411 | pszWin32k[cch] = '\0';
|
---|
412 | }
|
---|
413 | }
|
---|
414 |
|
---|
415 | /* next */
|
---|
416 | pszCurrent += strlen(pszCurrent);
|
---|
417 | }
|
---|
418 | if (pszCurrent[-1] != '\n')
|
---|
419 | *pszCurrent++ = '\n';
|
---|
420 |
|
---|
421 | /* Write it back
|
---|
422 | * One big question, how do we shrink a file?
|
---|
423 | */
|
---|
424 | if ( fseek(phConfigSys, 0, SEEK_SET) == 0
|
---|
425 | && fwrite(pszConfigSys, 1, pszCurrent - pszConfigSys, phConfigSys))
|
---|
426 | {
|
---|
427 | ShowMessage(hwnd, IDM_CONFIGSYS_UPDATED, MB_OK);
|
---|
428 | }
|
---|
429 | else
|
---|
430 | Complain(hwnd, IDS_FWRITE_FAILED, pszConfigSys);
|
---|
431 | free(pszConfigSys);
|
---|
432 | }
|
---|
433 | else
|
---|
434 | Complain(hwnd, IDS_MALLOC_FAILED, cbConfigSys + 256);
|
---|
435 | }
|
---|
436 | else
|
---|
437 | Complain(hwnd, IDS_FSIZE_FAILED, pszConfigSys);
|
---|
438 | fclose(phConfigSys);
|
---|
439 | }
|
---|
440 | else
|
---|
441 | Complain(hwnd, IDS_ERR_FOPEN_FAILED, pszConfigSys);
|
---|
442 | break;
|
---|
443 | }
|
---|
444 | }
|
---|
445 | return NULL;
|
---|
446 |
|
---|
447 |
|
---|
448 | /*
|
---|
449 | * Close window. Typically sent when Alt-F4 pressed or system-menu-Close is selected.
|
---|
450 | */
|
---|
451 | case WM_CLOSE:
|
---|
452 | fNotExit = TRUE;
|
---|
453 | WinSendMsg(hwnd, WM_COMMAND,
|
---|
454 | MPFROMSHORT(DID_OK), MPFROM2SHORT(CMDSRC_MENU, FALSE));
|
---|
455 | break;
|
---|
456 |
|
---|
457 |
|
---|
458 | /*
|
---|
459 | * Window is destroyed (last message which ever should reach us!)
|
---|
460 | * -Free instance data
|
---|
461 | * -Set the instance data pointer to NULL (just in case).
|
---|
462 | */
|
---|
463 | case WM_DESTROY:
|
---|
464 | {
|
---|
465 | free(pThis);
|
---|
466 | WinSetWindowPtr(hwnd, QWL_USER, NULL);
|
---|
467 | break;
|
---|
468 | }
|
---|
469 |
|
---|
470 |
|
---|
471 | /*
|
---|
472 | * Gets data from win32k.
|
---|
473 | * Sets the controls according to the data from win32k.
|
---|
474 | *
|
---|
475 | * mr: reserved
|
---|
476 | * mp1: reserved
|
---|
477 | * mp2: reserved
|
---|
478 | */
|
---|
479 | case WM_SETCONTROLS:
|
---|
480 | {
|
---|
481 | APIRET rc;
|
---|
482 | CHAR szNumber[32];
|
---|
483 | CHAR szBuffer[100];
|
---|
484 |
|
---|
485 |
|
---|
486 | /*
|
---|
487 | * Call Win32k.sys to get options and statuses.
|
---|
488 | */
|
---|
489 | memset(&pThis->Options, 0, sizeof(K32OPTIONS));
|
---|
490 | pThis->Options.cb = sizeof(K32OPTIONS);
|
---|
491 | memset(&pThis->Status, 0, sizeof(K32STATUS));
|
---|
492 | pThis->Status.cb = sizeof(K32STATUS);
|
---|
493 | rc = libWin32kQueryOptionsStatus(&pThis->Options, &pThis->Status);
|
---|
494 | if (rc != NO_ERROR)
|
---|
495 | {
|
---|
496 | Complain(hwnd, IDS_ERR_QUERYOPTIONSTATUS, rc);
|
---|
497 | fNotExit = FALSE;
|
---|
498 | WinDismissDlg(hwnd, 0);
|
---|
499 | WinPostMsg(hwnd, WM_QUIT, NULL, NULL);
|
---|
500 | return NULL;
|
---|
501 | }
|
---|
502 |
|
---|
503 | /*
|
---|
504 | * Set the controls.
|
---|
505 | */
|
---|
506 | /* win32k */
|
---|
507 | sprintf(szBuffer, "%d.%d", 0, pThis->Status.ulVersion);
|
---|
508 | WinSetDlgItemText(hwnd, TX_W32K_VERSION_VAL, szBuffer);
|
---|
509 | sprintf(szBuffer, "%s %s", pThis->Status.szBuildTime, pThis->Status.szBuildDate);
|
---|
510 | WinSetDlgItemText(hwnd, TX_W32K_BUILD_DATETIME_VAL, szBuffer);
|
---|
511 | WinSetDlgItemText(hwnd, TX_W32K_SYMBOLFILE_VAL, pThis->Status.szSymFile);
|
---|
512 | sprintf(szBuffer, "%d - ", pThis->Status.ulBuild);
|
---|
513 | if (GetFixpackDesc(pThis->Status.ulBuild, pThis->Status.fKernel, szBuffer + strlen(szBuffer)))
|
---|
514 | sprintf(szBuffer, "%d", pThis->Status.ulBuild);
|
---|
515 | WinSetDlgItemText(hwnd, TX_W32K_KERNELBUILD_VAL, szBuffer);
|
---|
516 |
|
---|
517 | /* logging */
|
---|
518 | WinSendDlgItemMsg(hwnd, CB_LOGGING_ENABLED, BM_SETCHECK, (MPARAM)(pThis->Options.fLogging), NULL);
|
---|
519 | WinSendDlgItemMsg(hwnd, RB_LOGGING_COM1, BM_SETCHECK, (MPARAM)(pThis->Options.usCom == 0x3f8), NULL);
|
---|
520 | WinSendDlgItemMsg(hwnd, RB_LOGGING_COM2, BM_SETCHECK, (MPARAM)(pThis->Options.usCom == 0x2f8), NULL);
|
---|
521 | WinSendDlgItemMsg(hwnd, RB_LOGGING_COM3, BM_SETCHECK, (MPARAM)(pThis->Options.usCom == 0x3e8), NULL);
|
---|
522 | WinSendDlgItemMsg(hwnd, RB_LOGGING_COM4, BM_SETCHECK, (MPARAM)(pThis->Options.usCom == 0x2e8), NULL);
|
---|
523 |
|
---|
524 | /* loaders */
|
---|
525 | WinSendDlgItemMsg(hwnd, CB_LDR_DISABLE_ALL, BM_SETCHECK, (MPARAM)(pThis->Options.fNoLoader), NULL);
|
---|
526 | /* PE */
|
---|
527 | WinSendDlgItemMsg(hwnd, RB_LDR_PE_PURE, BM_SETCHECK, (MPARAM)(pThis->Options.fPE == FLAGS_PE_PE2LX), NULL);
|
---|
528 | WinSendDlgItemMsg(hwnd, RB_LDR_PE_MIXED, BM_SETCHECK, (MPARAM)(pThis->Options.fPE == FLAGS_PE_MIXED), NULL);
|
---|
529 | WinSendDlgItemMsg(hwnd, RB_LDR_PE_PE, BM_SETCHECK, (MPARAM)(pThis->Options.fPE == FLAGS_PE_PE), NULL);
|
---|
530 | WinSendDlgItemMsg(hwnd, RB_LDR_PE_NOT, BM_SETCHECK, (MPARAM)(pThis->Options.fPE == FLAGS_PE_NOT), NULL);
|
---|
531 | WinSendDlgItemMsg(hwnd, SB_LDR_PE_INFOLEVEL, SPBM_SETCURRENTVALUE, (MPARAM)(pThis->Options.ulInfoLevel), NULL); /* FIXME to be changed */
|
---|
532 | sprintf(szNumber, "%d", pThis->Status.cPe2LxModules);
|
---|
533 | WinSetDlgItemText(hwnd, TX_LDR_PE_MODULES_VAL, szNumber);
|
---|
534 | /* Elf */
|
---|
535 | WinSendDlgItemMsg(hwnd, CB_LDR_ELF_ENABLED, BM_SETCHECK, (MPARAM)(pThis->Options.fElf), NULL);
|
---|
536 | WinSendDlgItemMsg(hwnd, SB_LDR_ELF_INFOLEVEL, SPBM_SETCURRENTVALUE, (MPARAM)(pThis->Options.ulInfoLevel), NULL); /* FIXME to be changed */
|
---|
537 | sprintf(szNumber, "%d", pThis->Status.cElf2LxModules);
|
---|
538 | WinSetDlgItemText(hwnd, TX_LDR_ELF_MODULES_VAL, szNumber);
|
---|
539 | /* UNIX Shell Scripts */
|
---|
540 | WinSendDlgItemMsg(hwnd, CB_LDR_SHELL_SCRIPTS, BM_SETCHECK, (MPARAM)(pThis->Options.fUNIXScript), NULL);
|
---|
541 | /* JAVA */
|
---|
542 | WinSendDlgItemMsg(hwnd, CB_LDR_JAVA, BM_SETCHECK, (MPARAM)(pThis->Options.fJava), NULL);
|
---|
543 | /* REXX Scripts */
|
---|
544 | WinSendDlgItemMsg(hwnd, CB_LDR_REXX, BM_SETCHECK, (MPARAM)(pThis->Options.fREXXScript), NULL);
|
---|
545 |
|
---|
546 | /* OS/2 Loader Fixes */
|
---|
547 | WinSendDlgItemMsg(hwnd, CB_LDRFIX_DLLFIXES, BM_SETCHECK, (MPARAM)(pThis->Options.fDllFixes), NULL);
|
---|
548 |
|
---|
549 | /* heaps */
|
---|
550 | /* Resident */
|
---|
551 | WinSendDlgItemMsg(hwnd, SB_HEAP_RES_MAX, SPBM_SETCURRENTVALUE, (MPARAM)(pThis->Options.cbResHeapMax / 1024), NULL);
|
---|
552 | sprintf(szNumber, "%d", pThis->Status.cbResHeapInit / 1024);
|
---|
553 | WinSetDlgItemText(hwnd, TX_HEAP_RES_INIT_VAL, szNumber);
|
---|
554 | sprintf(szNumber, "%d", pThis->Status.cbResHeapSize / 1024);
|
---|
555 | WinSetDlgItemText(hwnd, TX_HEAP_RES_SIZE_VAL, szNumber);
|
---|
556 | sprintf(szNumber, "%d", pThis->Status.cbResHeapUsed / 1024);
|
---|
557 | WinSetDlgItemText(hwnd, TX_HEAP_RES_USED_VAL, szNumber);
|
---|
558 | sprintf(szNumber, "%d", pThis->Status.cbResHeapFree / 1024);
|
---|
559 | WinSetDlgItemText(hwnd, TX_HEAP_RES_FREE_VAL, szNumber);
|
---|
560 | sprintf(szNumber, "%d", pThis->Status.cResBlocksUsed);
|
---|
561 | WinSetDlgItemText(hwnd, TX_HEAP_RES_USED_BLOCKS_VAL, szNumber);
|
---|
562 | sprintf(szNumber, "%d", pThis->Status.cResBlocksFree);
|
---|
563 | WinSetDlgItemText(hwnd, TX_HEAP_RES_FREE_BLOCKS_VAL, szNumber);
|
---|
564 | /* Swappable */
|
---|
565 | WinSendDlgItemMsg(hwnd, SB_HEAP_SWP_MAX, SPBM_SETCURRENTVALUE, (MPARAM)(pThis->Options.cbSwpHeapMax / 1024), NULL);
|
---|
566 | sprintf(szNumber, "%d", pThis->Status.cbSwpHeapInit / 1024);
|
---|
567 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_INIT_VAL, szNumber);
|
---|
568 | sprintf(szNumber, "%d", pThis->Status.cbSwpHeapSize / 1024);
|
---|
569 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_SIZE_VAL, szNumber);
|
---|
570 | sprintf(szNumber, "%d", pThis->Status.cbSwpHeapUsed / 1024);
|
---|
571 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_USED_VAL, szNumber);
|
---|
572 | sprintf(szNumber, "%d", pThis->Status.cbSwpHeapFree / 1024);
|
---|
573 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_FREE_VAL, szNumber);
|
---|
574 | sprintf(szNumber, "%d", pThis->Status.cSwpBlocksUsed);
|
---|
575 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_USED_BLOCKS_VAL, szNumber);
|
---|
576 | sprintf(szNumber, "%d", pThis->Status.cSwpBlocksFree);
|
---|
577 | WinSetDlgItemText(hwnd, TX_HEAP_SWP_FREE_BLOCKS_VAL, szNumber);
|
---|
578 |
|
---|
579 | pThis->fDirty = FALSE;
|
---|
580 | return NULL;
|
---|
581 | }
|
---|
582 |
|
---|
583 |
|
---|
584 | /*
|
---|
585 | * Validate data in the controls. Complains accoring to mp1.
|
---|
586 | * Put the data into the win32k option struct.
|
---|
587 | *
|
---|
588 | * mr: Valid indicator.
|
---|
589 | * TRUE: Valid data.
|
---|
590 | * FALSE: Not valid data.
|
---|
591 | * mp1: BOOL fComplain.
|
---|
592 | * TRUE: Do complain about errors. The pThis->Options struct
|
---|
593 | * is updated on successful return.
|
---|
594 | * FALSE: Do not complain about errors, and don't update the
|
---|
595 | * pThis->Options struct.
|
---|
596 | * mp2: reserved.
|
---|
597 | */
|
---|
598 | case WM_QUERYCONTROLS:
|
---|
599 | {
|
---|
600 | BOOL fComplain = (BOOL)mp1;
|
---|
601 | ULONG ul;
|
---|
602 |
|
---|
603 | /*
|
---|
604 | * Init temporary option struct.
|
---|
605 | */
|
---|
606 | memset(&pThis->NewOptions, 0, sizeof(K32OPTIONS));
|
---|
607 | pThis->NewOptions.cb = sizeof(K32OPTIONS);
|
---|
608 |
|
---|
609 | /*
|
---|
610 | * Logging.
|
---|
611 | */
|
---|
612 | pThis->NewOptions.fLogging = WinSendDlgItemMsg(hwnd, CB_LOGGING_ENABLED, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
613 | if (WinSendDlgItemMsg(hwnd, RB_LOGGING_COM1, BM_QUERYCHECK, NULL, NULL))
|
---|
614 | pThis->NewOptions.usCom = 0x3f8;
|
---|
615 | else if (WinSendDlgItemMsg(hwnd, RB_LOGGING_COM2, BM_QUERYCHECK, NULL, NULL))
|
---|
616 | pThis->NewOptions.usCom = 0x2f8;
|
---|
617 | else if (WinSendDlgItemMsg(hwnd, RB_LOGGING_COM3, BM_QUERYCHECK, NULL, NULL))
|
---|
618 | pThis->NewOptions.usCom = 0x3e8;
|
---|
619 | else if (WinSendDlgItemMsg(hwnd, RB_LOGGING_COM4, BM_QUERYCHECK, NULL, NULL))
|
---|
620 | pThis->NewOptions.usCom = 0x2e8;
|
---|
621 | else
|
---|
622 | {
|
---|
623 | if (fComplain)
|
---|
624 | Complain(hwnd, IDS_ERR_NO_COM_RADIOBUTTON);
|
---|
625 | return (MPARAM)FALSE;
|
---|
626 | }
|
---|
627 |
|
---|
628 | /*
|
---|
629 | * Loaders
|
---|
630 | */
|
---|
631 | pThis->NewOptions.fNoLoader = WinSendDlgItemMsg(hwnd, CB_LDR_DISABLE_ALL, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
632 | /* PE */
|
---|
633 | if (WinSendDlgItemMsg(hwnd, RB_LDR_PE_PURE, BM_QUERYCHECK, NULL, NULL))
|
---|
634 | pThis->NewOptions.fPE = FLAGS_PE_PE2LX;
|
---|
635 | else if (WinSendDlgItemMsg(hwnd, RB_LDR_PE_MIXED, BM_QUERYCHECK, NULL, NULL))
|
---|
636 | pThis->NewOptions.fPE = FLAGS_PE_MIXED;
|
---|
637 | else if (WinSendDlgItemMsg(hwnd, RB_LDR_PE_PE, BM_QUERYCHECK, NULL, NULL))
|
---|
638 | pThis->NewOptions.fPE = FLAGS_PE_PE;
|
---|
639 | else if (WinSendDlgItemMsg(hwnd, RB_LDR_PE_NOT, BM_QUERYCHECK, NULL, NULL))
|
---|
640 | pThis->NewOptions.fPE = FLAGS_PE_NOT;
|
---|
641 | else
|
---|
642 | {
|
---|
643 | if (fComplain)
|
---|
644 | Complain(hwnd, IDS_ERR_NO_PE_RADIOBUTTON);
|
---|
645 | return (MPARAM)FALSE;
|
---|
646 | }
|
---|
647 | if (!WinSendDlgItemMsg(hwnd, SB_LDR_PE_INFOLEVEL, SPBM_QUERYVALUE, (MPARAM)&ul, MPFROM2SHORT(0, SPBQ_UPDATEIFVALID)))
|
---|
648 | {
|
---|
649 | if (fComplain)
|
---|
650 | {
|
---|
651 | Complain(hwnd, IDS_ERR_INVALID_INFOLEVEL);
|
---|
652 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, SB_LDR_PE_INFOLEVEL));
|
---|
653 | }
|
---|
654 | return (MPARAM)FALSE;
|
---|
655 | }
|
---|
656 | pThis->NewOptions.ulInfoLevel = ul; /* FIXME to be changed */
|
---|
657 |
|
---|
658 | /* Elf */
|
---|
659 | pThis->NewOptions.fElf = WinSendDlgItemMsg(hwnd, CB_LDR_ELF_ENABLED, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
660 | if (!WinSendDlgItemMsg(hwnd, SB_LDR_ELF_INFOLEVEL, SPBM_QUERYVALUE, (MPARAM)&ul, MPFROM2SHORT(0, SPBQ_UPDATEIFVALID)))
|
---|
661 | {
|
---|
662 | if (fComplain)
|
---|
663 | {
|
---|
664 | Complain(hwnd, IDS_ERR_INVALID_INFOLEVEL);
|
---|
665 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, SB_LDR_ELF_INFOLEVEL));
|
---|
666 | }
|
---|
667 | return (MPARAM)FALSE;
|
---|
668 | }
|
---|
669 | //pThis->NewOptions.ulInfoLevel = ul; /* FIXME to be changed */
|
---|
670 | /* UNIX Shell Scripts */
|
---|
671 | pThis->NewOptions.fUNIXScript = WinSendDlgItemMsg(hwnd, CB_LDR_SHELL_SCRIPTS, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
672 | /* JAVA */
|
---|
673 | pThis->NewOptions.fJava = WinSendDlgItemMsg(hwnd, CB_LDR_JAVA, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
674 | /* REXX Scripts */
|
---|
675 | pThis->NewOptions.fREXXScript = WinSendDlgItemMsg(hwnd, CB_LDR_REXX, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
676 |
|
---|
677 | /*
|
---|
678 | * OS/2 Loader Fixes.
|
---|
679 | */
|
---|
680 | pThis->NewOptions.fDllFixes = WinSendDlgItemMsg(hwnd, CB_LDRFIX_DLLFIXES, BM_QUERYCHECK, NULL, NULL) != 0;
|
---|
681 |
|
---|
682 | /*
|
---|
683 | * Heaps
|
---|
684 | */
|
---|
685 | /* Resident */
|
---|
686 | if (!WinSendDlgItemMsg(hwnd, SB_HEAP_RES_MAX, SPBM_QUERYVALUE, (MPARAM)&ul, MPFROM2SHORT(0, SPBQ_UPDATEIFVALID)))
|
---|
687 | {
|
---|
688 | if (fComplain)
|
---|
689 | {
|
---|
690 | Complain(hwnd, IDS_ERR_INVALID_MAXHEAPSIZE);
|
---|
691 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, SB_HEAP_RES_MAX));
|
---|
692 | }
|
---|
693 | return (MPARAM)FALSE;
|
---|
694 | }
|
---|
695 | pThis->NewOptions.cbResHeapMax = ul*1024;
|
---|
696 | /* Swappable */
|
---|
697 | if (!WinSendDlgItemMsg(hwnd, SB_HEAP_SWP_MAX, SPBM_QUERYVALUE, (MPARAM)&ul, MPFROM2SHORT(0, SPBQ_UPDATEIFVALID)))
|
---|
698 | {
|
---|
699 | if (fComplain)
|
---|
700 | {
|
---|
701 | Complain(hwnd, IDS_ERR_INVALID_MAXHEAPSIZE);
|
---|
702 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, SB_HEAP_SWP_MAX));
|
---|
703 | }
|
---|
704 | return (MPARAM)FALSE;
|
---|
705 | }
|
---|
706 | pThis->NewOptions.cbSwpHeapMax = ul*1024;
|
---|
707 |
|
---|
708 | /*
|
---|
709 | * Check if there is any change and set the fDirty flag accordingly.
|
---|
710 | */
|
---|
711 | pThis->fDirty = memcmp(&pThis->NewOptions, &pThis->Options, sizeof(K32OPTIONS)) != 0;
|
---|
712 | return (MPARAM)TRUE;
|
---|
713 | }
|
---|
714 |
|
---|
715 |
|
---|
716 | }
|
---|
717 |
|
---|
718 | /*
|
---|
719 | * Return thru the default dialog procedure.
|
---|
720 | */
|
---|
721 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
722 | }
|
---|
723 |
|
---|
724 |
|
---|
725 | /**
|
---|
726 | * Pops up a message box displaying a message from the message table.
|
---|
727 | * @returns Return from WinMessageBox
|
---|
728 | * @param hwndOwner Handle to owner window.
|
---|
729 | * @param id Message table id of the message.
|
---|
730 | * @param flStyle Messagebox style.
|
---|
731 | * If 0 the apply default style.
|
---|
732 | */
|
---|
733 | ULONG ShowMessage(HWND hwndOwner, int id, ULONG flStyle)
|
---|
734 | {
|
---|
735 | return WinMessageBox(HWND_DESKTOP,
|
---|
736 | hwndOwner,
|
---|
737 | getMessage(id),
|
---|
738 | "Win32k Control Center", 0,
|
---|
739 | (flStyle == 0
|
---|
740 | ? MB_OK | MB_INFORMATION
|
---|
741 | : flStyle)
|
---|
742 | | MB_MOVEABLE
|
---|
743 | );
|
---|
744 | }
|
---|
745 |
|
---|
746 |
|
---|
747 |
|
---|
748 | /**
|
---|
749 | * Pops up a message box displaying some complaint or error.
|
---|
750 | * @returns Success indicator.
|
---|
751 | * @param hwndOwner Handle of owner window.
|
---|
752 | * @param id String table id of the message.
|
---|
753 | * @param ... Arguments passed on to vsprintf to format the message.
|
---|
754 | */
|
---|
755 | BOOL Complain(HWND hwndOwner, int id, ...)
|
---|
756 | {
|
---|
757 | ULONG rc;
|
---|
758 | char szMsg[1024];
|
---|
759 | char szMsgOutput[4096];
|
---|
760 |
|
---|
761 |
|
---|
762 | /*
|
---|
763 | * Load the string and format it.
|
---|
764 | */
|
---|
765 | if (WinLoadString(WinQueryAnchorBlock(hwndOwner), 0, id, sizeof(szMsg), szMsg))
|
---|
766 | {
|
---|
767 | va_list args;
|
---|
768 | va_start(args, id);
|
---|
769 | vsprintf(szMsgOutput, szMsg, args);
|
---|
770 | va_end(args);
|
---|
771 | }
|
---|
772 | else
|
---|
773 | sprintf(szMsgOutput, "Failed to load the message id %id.\n", id);
|
---|
774 |
|
---|
775 |
|
---|
776 | /*
|
---|
777 | * Show message.
|
---|
778 | */
|
---|
779 | rc = WinMessageBox(HWND_DESKTOP, hwndOwner,
|
---|
780 | szMsgOutput,
|
---|
781 | "Win32k Control Center - error",
|
---|
782 | 0,
|
---|
783 | MB_APPLMODAL | MB_ICONHAND | MB_OK | MB_MOVEABLE);
|
---|
784 | if (rc == (ULONG)MBID_ERROR)
|
---|
785 | {
|
---|
786 | rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
787 | szMsgOutput,
|
---|
788 | "Win32k Control Center - error",
|
---|
789 | 0,
|
---|
790 | MB_ICONHAND | MB_OK | MB_MOVEABLE);
|
---|
791 | }
|
---|
792 |
|
---|
793 |
|
---|
794 | /*
|
---|
795 | * Return according to rc.
|
---|
796 | */
|
---|
797 | return rc != MBID_ERROR;
|
---|
798 | }
|
---|
799 |
|
---|
800 |
|
---|
801 | /**
|
---|
802 | * Gets the message string for the last error message.
|
---|
803 | * @returns Pointer to message string.
|
---|
804 | * @param hab Handle of application anchor block.
|
---|
805 | */
|
---|
806 | PCSZ getLastErrorMsg(HAB hab)
|
---|
807 | {
|
---|
808 | char *pszErrInfo;
|
---|
809 | PERRINFO pErrInfo = WinGetErrorInfo(hab);
|
---|
810 |
|
---|
811 | if (pErrInfo != NULL && pErrInfo->cDetailLevel > 0)
|
---|
812 | {
|
---|
813 | pszErrInfo = (char*)(void*)pErrInfo;
|
---|
814 | pszErrInfo += ((PUSHORT)(void*)(pszErrInfo + pErrInfo->offaoffszMsg))[pErrInfo->cDetailLevel-1];
|
---|
815 | }
|
---|
816 | else
|
---|
817 | pszErrInfo = "<none>";
|
---|
818 |
|
---|
819 | return pszErrInfo;
|
---|
820 | }
|
---|
821 |
|
---|
822 |
|
---|
823 | /**
|
---|
824 | * Gets a message from the executable resources.
|
---|
825 | * @returns Pointer to read-only string.
|
---|
826 | * NULL if not found/error.
|
---|
827 | * @param id String Id.
|
---|
828 | */
|
---|
829 | PSZ getMessage(ULONG id)
|
---|
830 | {
|
---|
831 | PSZ psz;
|
---|
832 |
|
---|
833 | if (DosGetResource(NULLHANDLE, RT_MESSAGE, id / 16 + 1, (PPVOID)(void*)&psz) == NO_ERROR)
|
---|
834 | {
|
---|
835 | psz +=2;
|
---|
836 | id %= 16;
|
---|
837 | while (id-- > 0)
|
---|
838 | psz += 1 + *psz;
|
---|
839 | return psz+1;
|
---|
840 | }
|
---|
841 | else
|
---|
842 | psz = NULL;
|
---|
843 |
|
---|
844 | return psz;
|
---|
845 | }
|
---|
846 |
|
---|
847 |
|
---|
848 | /**
|
---|
849 | * Determin the fixpack+kernel description from build no. and kernel flags.
|
---|
850 | * @returns 0 on success. Description i szBuffer.
|
---|
851 | * -1 on error.
|
---|
852 | * @param ulBuild Kernel build no.
|
---|
853 | * @param flKernel Win32k kernel flags.
|
---|
854 | * @param szBuffer Pointer to buffer
|
---|
855 | */
|
---|
856 | int GetFixpackDesc(ULONG ulBuild, ULONG flKernel, PSZ pszBuffer)
|
---|
857 | {
|
---|
858 |
|
---|
859 | pszBuffer[0] = '\0';
|
---|
860 | if (ulBuild == 9023)
|
---|
861 | strcpy(pszBuffer, "Warp 4 GA");
|
---|
862 | else if (ulBuild > 9023 && ulBuild <= 9036)
|
---|
863 | sprintf(pszBuffer, "Warp 4 FP %d", ulBuild - 9024);
|
---|
864 | else if (ulBuild == 14039)
|
---|
865 | strcpy(pszBuffer, "WS4eB GA");
|
---|
866 | else if (ulBuild == 14040)
|
---|
867 | strcpy(pszBuffer, flKernel & KF_W4 ? "Warp 4 FP13" : "WS4eB FP1");
|
---|
868 | else if (ulBuild >= 14041 /*&& ulBuild <= 1406x*/)
|
---|
869 | strcpy(pszBuffer, "Warp 4 FP14");
|
---|
870 | /*
|
---|
871 | else if (ulBuild >= 14048)
|
---|
872 | {
|
---|
873 | if (flKernel & KF_W4)
|
---|
874 | sprintf(pszBuffer, "Warp 4 FP%d", ulBuild - 14049 + 15); //???
|
---|
875 | else
|
---|
876 | sprintf(pszBuffer, "WS4eB FP%d", ulBuild - 14048 + 2); //???
|
---|
877 | }
|
---|
878 | */
|
---|
879 | else if (ulBuild >= 8255 && ulBuild <= 8270)
|
---|
880 | sprintf(pszBuffer, "Warp 3 FP%d", ulBuild - 8255 + 32);
|
---|
881 | else
|
---|
882 | return -1;
|
---|
883 |
|
---|
884 | /*
|
---|
885 | * Check type.
|
---|
886 | */
|
---|
887 | if (pszBuffer[0] != '\0')
|
---|
888 | {
|
---|
889 | char *pszAdd;
|
---|
890 |
|
---|
891 | if (flKernel & KF_SMP)
|
---|
892 | pszAdd = "SMP ";
|
---|
893 | else
|
---|
894 | pszAdd = " ";
|
---|
895 | strcpy(pszBuffer + strlen(pszBuffer), pszAdd);
|
---|
896 |
|
---|
897 | if (flKernel & KF_DEBUG)
|
---|
898 | {
|
---|
899 | if (flKernel & KF_HAS_DEBUGTYPE)
|
---|
900 | pszAdd = (flKernel & KF_ALLSTRICT) ? "(Allstrict)" : "(Halfstrict)";
|
---|
901 | else
|
---|
902 | pszAdd = "(Debug)";
|
---|
903 | }
|
---|
904 | else
|
---|
905 | pszAdd = "(Retail)";
|
---|
906 | strcpy(pszBuffer + strlen(pszBuffer), pszAdd);
|
---|
907 | }
|
---|
908 |
|
---|
909 | return 0;
|
---|
910 | }
|
---|
911 |
|
---|
912 |
|
---|
913 | /**
|
---|
914 | * Upcases a char.
|
---|
915 | * @returns Upper case of the char given in ch.
|
---|
916 | * @param ch Char to capitalize.
|
---|
917 | */
|
---|
918 | #define upcase(ch) ((ch) >= 'a' && (ch) <= 'z' ? (char)((ch) - ('a' - 'A')) : (ch))
|
---|
919 |
|
---|
920 |
|
---|
921 | /**
|
---|
922 | * Searches for a substring in a string.
|
---|
923 | * @returns Pointer to start of substring when found, NULL when not found.
|
---|
924 | * @param pszStr String to be searched.
|
---|
925 | * @param pszSubStr String to be searched.
|
---|
926 | * @remark Depends on the upcase function.
|
---|
927 | */
|
---|
928 | static char *stristr(const char *pszStr, const char *pszSubStr)
|
---|
929 | {
|
---|
930 | int cchSubStr = strlen(pszSubStr);
|
---|
931 | int i = 0;
|
---|
932 |
|
---|
933 | while (*pszStr != '\0' && i < cchSubStr)
|
---|
934 | {
|
---|
935 | i = 0;
|
---|
936 | while (i < cchSubStr && pszStr[i] != '\0' &&
|
---|
937 | (upcase(pszStr[i]) == upcase(pszSubStr[i])))
|
---|
938 | i++;
|
---|
939 | pszStr++;
|
---|
940 | }
|
---|
941 |
|
---|
942 | return (char*)(*pszStr != '\0' ? (char*)pszStr - 1 : NULL);
|
---|
943 | }
|
---|
944 |
|
---|