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