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