Changeset 4702


Ignore:
Timestamp:
Nov 26, 2000, 2:36:53 PM (24 years ago)
Author:
bird
Message:

Added support for updating config.sys.

Location:
trunk/src/win32k/utils
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/win32k/utils/Win32kCC.c

    r4178 r4702  
    1 /* $Id: Win32kCC.c,v 1.3 2000-09-03 23:53:18 bird Exp $
     1/* $Id: Win32kCC.c,v 1.4 2000-11-26 13:36:51 bird Exp $
    22 *
    33 * Win32CC - Win32k Control Center.
     
    3333#define INCL_WINBUTTONS
    3434#define INCL_WINWINDOWMGR
     35#define INCL_DOSMISC
    3536
    3637/*******************************************************************************
     
    4243#include <stdio.h>
    4344#include <stdarg.h>
    44 #include <malloc.h>
     45#include <stdlib.h>
    4546
    4647#include <Win32k.h>
     
    8182*******************************************************************************/
    8283MRESULT EXPENTRY    Win32kCCDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     84ULONG               ShowMessage(HWND hwndOwner, int id, ULONG flStyle);
    8385BOOL                Complain(HWND hwndOwner, int id, ...);
    8486PCSZ                getLastErrorMsg(HAB hab);
    8587PSZ                 getMessage(ULONG id);
    8688int                 GetFixpackDesc(ULONG ulBuild, ULONG flKernel, PSZ pszBuffer);
    87 
     89char *              stristr(const char *pszStr, const char *pszSubStr);
    8890
    8991
     
    310312                    if (!WinSendMsg(hwnd, WM_QUERYCONTROLS, (MPARAM)FALSE, NULL) || pThis->fDirty)
    311313                    {
    312                         if (WinMessageBox(HWND_DESKTOP, hwnd,
    313                                           getMessage(IDM_INFO_DIRTY),
    314                                          "Win32k Control Center", 0, MB_YESNO | MB_WARNING | MB_MOVEABLE)
    315                              != MBID_YES)
     314                        if (ShowMessage(hwnd, IDM_INFO_DIRTY, MB_YESNO | MB_WARNING) != MBID_YES)
    316315                        {
    317316                            fNotExit = TRUE;
     
    324323                    WinPostMsg(hwnd, WM_QUIT, NULL, NULL);
    325324                    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                }
    326423            }
    327424            return NULL;
     
    598695
    599696/**
     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 */
     704ULONG   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/**
    600720 * Pops up a message box displaying some complaint or error.
    601721 * @returns     Success indicator.
     
    758878    return 0;
    759879}
     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 */
     897static 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
  • TabularUnified trunk/src/win32k/utils/Win32kCC.dlg

    r4178 r4702  
    7474        LTEXT           "Used (KB)", TX_HEAP_SWP_USED, 150, 58, 50, 8
    7575        RTEXT           "257", TX_HEAP_SWP_USED_VAL, 206, 58, 46, 8
    76         DEFPUSHBUTTON   "~Refresh", PB_REFRESH, 6, 5, 40, 14
    77         PUSHBUTTON      "Apply", PB_APPLY, 49, 5, 40, 14
    78         PUSHBUTTON      "Close", IDS_ERR_DIALOGLOAD, 92, 5, 40, 14
    7976        LTEXT           "Free (KB)", TX_HEAP_RES_FREE, 22, 50, 50, 8
    8077        RTEXT           "257", TX_HEAP_RES_FREE_VAL, 78, 50, 46, 8
     
    103100        RTEXT           "3", TX_LDR_ELF_MODULES_VAL, 205, 158, 47, 8,
    104101                        WS_DISABLED
     102        DEFPUSHBUTTON   "~Refresh", PB_REFRESH, 6, 5, 40, 14
     103        PUSHBUTTON      "~Apply", PB_APPLY, 49, 5, 40, 14
     104        PUSHBUTTON      "Update Config.sys", PB_UPD_CONFIGSYS, 92, 5, 100, 14
     105        PUSHBUTTON      "~Close", DID_OK, 195, 5, 40, 14
    105106    END
    106107END
  • TabularUnified trunk/src/win32k/utils/Win32kCC.h

    r4178 r4702  
    1 /* $Id: Win32kCC.h,v 1.3 2000-09-03 23:53:19 bird Exp $
     1/* $Id: Win32kCC.h,v 1.4 2000-11-26 13:36:53 bird Exp $
    22 *
    33 *
     
    1717#define PB_APPLY                    0xfffe
    1818#define PB_REFRESH                  0xfffd
     19#define PB_UPD_CONFIGSYS            0xfffc
    1920
    2021
     
    3132#define  IDS_ERR_NO_PE_RADIOBUTTON      8
    3233#define  IDS_ERR_INVALID_INFOLEVEL      9
    33 #define  IDS_ERR_INVALID_MAXHEAPSIZE   10
    34 #define  IDS_ERR_SETPOPTIONS           11
     34#define  IDS_ERR_INVALID_MAXHEAPSIZE    10
     35#define  IDS_ERR_SETPOPTIONS            11
     36#define  IDS_ERR_FOPEN_FAILED           12
     37#define  IDS_FSIZE_FAILED               13
     38#define  IDS_MALLOC_FAILED              14
     39#define  IDS_FWRITE_FAILED              15
     40
    3541
    3642/*
    3743 * Message IDs.
    3844 */
    39 #define  IDM_INFO_DIRTY             1
     45#define  IDM_INFO_DIRTY                 1
     46#define  IDM_CONFIGSYS_UPDATED          2
    4047
    4148
  • TabularUnified trunk/src/win32k/utils/Win32kCC.rc

    r4178 r4702  
    1 /* $Id: Win32kCC.rc,v 1.3 2000-09-03 23:53:19 bird Exp $
     1/* $Id: Win32kCC.rc,v 1.4 2000-11-26 13:36:53 bird Exp $
    22 *
    33 * Resource File for Win32k Control Center.
     
    3131    IDS_ERR_INVALID_MAXHEAPSIZE,"Invalid heapsize."
    3232    IDS_ERR_SETPOPTIONS,        "Error occured in win32k while changing the options. (rc=0x%x)"
     33    IDS_ERR_FOPEN_FAILED,       "Failed to open file %s."
     34    IDS_FSIZE_FAILED,           "Failed to determin size of file %s."
     35    IDS_MALLOC_FAILED,          "Error! malloc or calloc failed to allocate %d bytes of memory."
     36    IDS_FWRITE_FAILED,          "Error! failed to write to file %s."
    3337END
    3438
     
    3943     */
    4044    IDM_INFO_DIRTY,             "You have changed the settings but not applied them. Sure you wan't to exit?"
     45    IDM_CONFIGSYS_UPDATED,      "Config.sys was successfully updated."
    4146END
    4247
Note: See TracChangeset for help on using the changeset viewer.