Changeset 257 for trunk/src


Ignore:
Timestamp:
Jan 8, 2004, 5:43:29 PM (22 years ago)
Author:
umoeller
Message:

Fixes that have piled up in the last three months.

Location:
trunk/src/helpers
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dialog.c

    r235 r257  
    296296 *      the control _sizes_, and everything is layed out automatically.
    297297 *      You may even have the formatter compute the sizes automatically
    298  *      based on the control classes and values; it is possible to
    299  *      create dialogs without specifying a single size also.
     298 *      based on the control classes and values (strings); it is possible
     299 *      to create dialogs without specifying a single size also.
    300300 *
    301301 *      There are several tricks to how this works.
     
    314314 *          (which again goes into ProcessRow and ProcessColumn).
    315315 *          There is no limit to how deep tables may nest, except
    316  *          the stack size of the current thread. ;-)
     316 *          for the stack size of the current thread, of course.
    317317 *
    318318 *      3)  This whole recursive iteration is performed several times.
  • trunk/src/helpers/dosh.c

    r253 r257  
    25882588 *@@changed V0.9.16 (2001-12-18) [umoeller]: fixed error codes
    25892589 *@@changed V1.0.1 (2003-01-10) [umoeller]: now allowing read for all modes
     2590 *@@changed V1.0.2 (2003-11-13) [umoeller]: optimized; now calling doshQueryPathSize only on failure
    25902591 */
    25912592
     
    26152616            // which isn't that meaningful
    26162617            // V0.9.16 (2001-12-08) [umoeller]
    2617             arc = doshQueryPathSize(pcszFilename,
    2618                                     pcbFile);
     2618            /* arc = doshQueryPathSize(pcszFilename,
     2619                                    pcbFile); */
     2620                // moved this down V1.0.2 (2003-11-13) [umoeller]
    26192621        break;
    26202622
     
    26252627                          | OPEN_ACCESS_READWRITE;
    26262628
    2627             arc = doshQueryPathSize(pcszFilename,
    2628                                     pcbFile);
     2629            /* arc = doshQueryPathSize(pcszFilename,
     2630                                    pcbFile); */
     2631                // moved this down V1.0.2 (2003-11-13) [umoeller]
    26292632        break;
    26302633
     
    26462649    }
    26472650
    2648     if ((!arc) && fsOpenFlags && pcbFile && ppFile)
     2651    if (    (!arc)
     2652         && fsOpenFlags
     2653         && pcbFile
     2654         && ppFile
     2655       )
    26492656    {
    26502657        PXFILE pFile;
     
    26952702                pFile->pszFilename = strdup(pcszFilename);
    26962703            }
    2697             #ifdef DEBUG_DOSOPEN
    26982704            else
    2699                  _Pmpf((__FUNCTION__ ": DosOpen returned %d for %s",
     2705            {
     2706                #ifdef DEBUG_DOSOPEN
     2707                    _Pmpf((__FUNCTION__ ": DosOpen returned %d for %s",
    27002708                             arc, pcszFilename));
    2701             #endif
     2709                #endif
     2710
     2711                // open failed: if the file doesn't exist, DosOpen only
     2712                // returns OPEN_FAILED, while ERROR_FILE_NOT_FOUND would
     2713                // be a bit more informative
     2714                // (this check used to be before DosOpen, but is a bit
     2715                // excessive and should only be run if we really have no open)
     2716                if (arc == ERROR_OPEN_FAILED)
     2717                    arc = doshQueryPathSize(pcszFilename,
     2718                                            pcbFile);
     2719            }
    27022720
    27032721            if (arc)
     
    27502768 *@@added V0.9.13 (2001-06-14) [umoeller]
    27512769 *@@changed V0.9.16 (2001-12-18) [umoeller]: now with XFILE, and always using FILE_BEGIN
    2752  *@@chaanged V0.9.19 (2002-04-02) [umoeller]: added params checking
     2770 *@@changed V0.9.19 (2002-04-02) [umoeller]: added params checking
     2771 *@@changed V1.0.2 (2003-11-13) [umoeller]: optimized cache (using realloc)
    27532772 */
    27542773
     
    28282847            #endif
    28292848
     2849#if 0
    28302850            // free old cache
    28312851            if (pFile->pbCache)
     
    28342854            // allocate new cache
    28352855            if (!(pFile->pbCache = (PBYTE)malloc(pFile->cbCache)))
     2856#else
     2857            // realloc is better V1.0.2 (2003-11-13) [umoeller]
     2858            if (!(pFile->pbCache = (PBYTE)realloc(pFile->pbCache,
     2859                                                  pFile->cbCache)))
     2860#endif
    28362861                arc = ERROR_NOT_ENOUGH_MEMORY;
    28372862            else
     
    44874512
    44884513/*
     4514 *@@ doshMyParentPID:
     4515 *      returns the PID of the parent of the current process.
     4516 *
     4517 *      This uses an interesting hack which is way
     4518 *      faster than DosGetInfoBlocks.
     4519 *
     4520 *@@added V1.0.2 (2003-11-13) [umoeller]
     4521 */
     4522
     4523ULONG doshMyParentPID(VOID)
     4524{
     4525    if (!G_pvLocalInfoSeg)
     4526        // first call:
     4527        GetInfoSegs();
     4528
     4529    // parent PID is at offset 2 in the local info seg
     4530    return *(PUSHORT)((PBYTE)G_pvLocalInfoSeg + 2);
     4531}
     4532
     4533/*
    44894534 *@@ doshMyTID:
    44904535 *      returns the TID of the current thread.
  • trunk/src/helpers/exeh.c

    r242 r257  
    266266
    267267        // read old DOS EXE header
    268         if (!(pExec->pDosExeHeader = (PDOSEXEHEADER)malloc(sizeof(DOSEXEHEADER))))
    269             arc = ERROR_NOT_ENOUGH_MEMORY;
    270         else if (!(arc = doshReadAt(pFile,
    271                                     0,
    272                                     &pExec->cbDosExeHeader,      // in/out
    273                                     (PBYTE)pExec->pDosExeHeader,
    274                                     DRFL_FAILIFLESS)))
     268        if ((arc = doshReadAt(pFile,
     269                              0,
     270                              &pExec->cbDosExeHeader,      // in/out
     271                              (PBYTE)&pExec->DosExeHeader,
     272                              DRFL_FAILIFLESS)))
     273            pExec->cbDosExeHeader = 0;
     274        else
    275275        {
    276276            // now check if we really have a DOS header
    277             if (pExec->pDosExeHeader->usDosExeID != 0x5a4d)
     277            if (pExec->DosExeHeader.usDosExeID != 0x5a4d)
    278278            {
    279279                // arc = ERROR_INVALID_EXE_SIGNATURE;
     
    289289                // remove the DOS header info, since we have none
    290290                // V0.9.12 (2001-05-03) [umoeller]
    291                 FREE(pExec->pDosExeHeader);
     291                // FREE(pExec->pDosExeHeader);
    292292                pExec->cbDosExeHeader = 0;
    293293            }
     
    295295            {
    296296                // we have a DOS header:
    297                 if (pExec->pDosExeHeader->usRelocTableOfs < 0x40)
     297                if (pExec->DosExeHeader.usRelocTableOfs < 0x40)
    298298                {
    299299                    // neither LX nor PE nor NE:
     
    305305                    // we have a new header offset:
    306306                    fLoadNewHeader = TRUE;
    307                     ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     307                    ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    308308                }
    309309            }
     
    11991199        ULONG ulNewHeaderOfs = 0;       // V0.9.12 (2001-05-03) [umoeller]
    12001200
    1201         if (pExec->pDosExeHeader)
     1201        if (pExec->cbDosExeHeader)
    12021202            // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    1203             ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     1203            ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    12041204
    12051205        if (pExec->ulExeFormat == EXEFORMAT_LX)
     
    13531353    HFILE hfExe = pExec->pFile->hf;
    13541354
    1355     if (pExec->pDosExeHeader)
     1355    if (pExec->cbDosExeHeader)
    13561356        // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    1357         ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     1357        ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    13581358
    13591359    ENSURE(DosSetFilePtr(hfExe,
     
    15941594    HFILE hfExe = pExec->pFile->hf;
    15951595
    1596     if (pExec->pDosExeHeader)
     1596    if (pExec->cbDosExeHeader)
    15971597        // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    1598         ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     1598        ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    15991599
    16001600    ENSURE(DosSetFilePtr(hfExe,
     
    18011801        ULONG ulNewHeaderOfs = 0; // V0.9.12 (2001-05-03) [umoeller]
    18021802
    1803         if (pExec->pDosExeHeader)
     1803        if (pExec->cbDosExeHeader)
    18041804            // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    1805             ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     1805            ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    18061806
    18071807        if (pExec->ulExeFormat == EXEFORMAT_LX)
     
    19761976        ULONG           ulNewHeaderOfs = 0; // V0.9.12 (2001-05-03) [umoeller]
    19771977
    1978         if (pExec->pDosExeHeader)
     1978        if (pExec->cbDosExeHeader)
    19791979            // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    1980             ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     1980            ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    19811981
    19821982        if (pExec->ulExeFormat == EXEFORMAT_LX)
     
    23712371        ULONG cb;
    23722372
    2373         if (pExec->pDosExeHeader)
     2373        if (pExec->cbDosExeHeader)
    23742374            // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    2375             ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     2375            ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    23762376
    23772377        // resource table
     
    28832883        ULONG ulPageSize = pExec->pLXHeader->ulPageSize;
    28842884
     2885        // if the data is not compressed, we read it directly
     2886        // into caller's pbData buffer (avoid one memcpy)
     2887        // V1.0.2 (2003-11-13) [umoeller]
     2888        PBYTE pbTarget =
     2889            (ulFlags == VALID) ? pbData : pabCompressed;
     2890
    28852891        ulOffset += ulExeOffset;
    28862892
     
    28982904                                    ulOffset,
    28992905                                    &ulSize,
    2900                                     pabCompressed,
     2906                                    pbTarget, // pabCompressed, V1.0.2 (2003-11-13) [umoeller]
    29012907                                    0)))
    29022908        {
     
    29242930                break;
    29252931
     2932                /* V1.0.2 (2003-11-13) [umoeller]
    29262933                case VALID:
    29272934                    // uncompressed
     
    29302937                           ulPageSize);
    29312938                break;
     2939                */
    29322940            }
    29332941        }
     
    29482956 *      type _and_ ID.
    29492957 *
    2950  *      If NO_ERROR is returned, *ppbResData receives
    2951  *      a new buffer with the raw resource data, and
    2952  *      *pcbResData receives the size of that buffer.
    2953  *      The caller must then free() that buffer.
     2958 *      If NO_ERROR is returned,
     2959 *
     2960 *      --  *ppbResData receives a new buffer with
     2961 *          the raw resource data, which the caller
     2962 *          must free();
     2963 *
     2964 *      --  *pulOffset receives an offset into that
     2965 *          buffer, where the actual resource data
     2966 *          starts;
     2967 *
     2968 *      --  *pcbResData receives the size of the
     2969 *          following resource data (what follows
     2970 *          after *pulOffset).
     2971 *
     2972 *      The reason for this slightly complicated
     2973 *      format is to avoid another memcpy since
     2974 *      resource data need not necessarily be on
     2975 *      an LX page boundary.
    29542976 *
    29552977 *      This code will properly unpack compressed
     
    29772999                          ULONG idResource,      // in: resource ID or 0 for first
    29783000                          PBYTE *ppbResData,     // out: resource data (to be free()'d)
     3001                          PULONG pulOffset,      // out: offset of actual data in buffer
    29793002                          PULONG pcbResData)     // out: size of resource data (ptr can be NULL)
    29803003{
     
    29953018        return ERROR_INVALID_EXE_SIGNATURE;
    29963019
    2997     if (pExec->pDosExeHeader)
     3020    if (pExec->cbDosExeHeader)
    29983021        // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    2999         ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     3022        ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    30003023
    30013024    if (!(cResources = pLXHeader->ulResTblCnt))
     
    31363159                        if (!arc)
    31373160                        {
    3138                             // allocate a new buffer for caller
    3139                             if (!(*ppbResData = (PBYTE)malloc(pRsEntry->cb)))
    3140                                 arc = ERROR_NOT_ENOUGH_MEMORY;
    3141                             else
    3142                             {
    3143                                 // copy into that buffer from the offset
    3144                                 // into the first page and the data from
    3145                                 // the subsequent pages too
    3146                                 memcpy(*ppbResData,
    3147                                        pabUncompressed + ulResOffsetInFirstPage,
    3148                                        pRsEntry->cb);
    3149 
    3150                                 if (pcbResData)
    3151                                     *pcbResData = pRsEntry->cb;
    3152                             }
     3161                            // new code without malloc/memcpy V1.0.2 (2003-11-13) [umoeller]
     3162                            *ppbResData = pabUncompressed;
     3163                            *pulOffset = ulResOffsetInFirstPage;
     3164
     3165
     3166                            /*
     3167                                // allocate a new buffer for caller
     3168                                if (!(*ppbResData = (PBYTE)malloc(pRsEntry->cb)))
     3169                                    arc = ERROR_NOT_ENOUGH_MEMORY;
     3170                                else
     3171                                {
     3172                                    // copy into that buffer from the offset
     3173                                    // into the first page and the data from
     3174                                    // the subsequent pages too
     3175                                    memcpy(*ppbResData,
     3176                                           pabUncompressed + ulResOffsetInFirstPage,
     3177                                           pRsEntry->cb);
     3178                                }
     3179                            */
     3180
     3181                            if (pcbResData)
     3182                                *pcbResData = pRsEntry->cb;
    31533183
    31543184                            fPtrFound = TRUE;
    31553185                        }
    3156 
    3157                         FREE(pabUncompressed);
     3186                        else
     3187                            FREE(pabUncompressed);
     3188
    31583189                        FREE(pabCompressed);
    31593190                    }
     
    32393270        ULONG cb;
    32403271
    3241         if (pExec->pDosExeHeader)
     3272        if (pExec->cbDosExeHeader)
    32423273            // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    3243             ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     3274            ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    32443275
    32453276        // resource table
     
    33513382        return ERROR_INVALID_EXE_SIGNATURE;
    33523383
    3353     if (pExec->pDosExeHeader)
     3384    if (pExec->cbDosExeHeader)
    33543385        // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller]
    3355         ulNewHeaderOfs = pExec->pDosExeHeader->ulNewHeaderOfs;
     3386        ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs;
    33563387
    33573388    // _Pmpf((__FUNCTION__ ": entering, checking %d resources", pNEHeader->usResSegmCount));
     
    34543485        char **papsz[] =
    34553486            {
    3456                 (char**)&pExec->pDosExeHeader,
     3487                // (char**)&pExec->pDosExeHeader,
    34573488                (char**)&pExec->pNEHeader,
    34583489                (char**)&pExec->pLXHeader,
  • trunk/src/helpers/helpers_pre.in

    r249 r257  
    4747$(OUTPUTDIR)\xprf.obj\
    4848$(OUTPUTDIR)\xprf2.obj\
     49$(OUTPUTDIR)\xsecapi.obj\
    4950$(OUTPUTDIR)\xstring.obj
    5051
  • trunk/src/helpers/lan.c

    r229 r257  
    213213 *      queries the given service.
    214214 *
     215 *      If NO_ERROR is returned,
     216 +
     217 +          SERVICEBUF.svci2_status & SERVICE_INSTALL_STATE
     218 +
     219 *      can be queried for the service state, which should
     220 *      be one of the following:
     221 *
     222 *      --  SERVICE_UNINSTALLED: not running. For the
     223 *          REQUESTER service, this is only a theoretical
     224 *          value because without it, NERR_WkstaNotStarted
     225 *          (2138) is returned.
     226 *
     227 *      --  SERVICE_INSTALL_PENDING: start in progress
     228 *
     229 *      --  SERVICE_UNINSTALL_PENDING: stop in progress
     230 *
     231 *      --  SERVICE_INSTALLED: running
     232 *
     233 *      Alternatively, call lanServiceControl with the
     234 *      SERVICE_CTRL_INTERROGATE code, which actually asks the
     235 *      service.
     236 *
     237 *      Returns, among others:
     238 *
     239 *      --  NO_ERROR
     240 *
     241 *      --  NERR_WkstaNotStarted (2138): requester is not
     242 *          running.
     243 *
     244 *      --  NERR_ServiceNotInstalled: requested service is
     245 *          not running.
     246 *
    215247 *@@added V1.0.0 (2002-09-24) [umoeller]
    216248 */
     
    240272 *      must be fully qualified so you cannot
    241273 *      abbreviate "requester" with "req", for
    242  *      example (as valid with the net command).
     274 *      example (as valid with the NET START command).
     275 *
     276 *      The name of the service is found in the IBMLAN.INI file.
     277 *      The executable file name of the service is matched to a
     278 *      corresponding entry in the Services section of the
     279 *      IBMLAN.INI file. Any relative file path name supplied
     280 *      for a service is assumed to be relative to the LAN
     281 *      Server root directory (\IBMLAN).
     282 *
     283 *      #Net32ServiceInstall supports a cmdargs argument, which
     284 *      is presently always passed as NULL with this implementation.
    243285 *
    244286 *      Returns, among others:
     
    277319/*
    278320 *@@ lanServiceControl:
    279  *      queries, pauses, resumes, or stops the given service.
     321 *      queries, pauses, resumes, or stops the given service. This
     322 *      has the functionality of the NET STOP command.
    280323 *
    281324 *      opcode must be one of:
    282325 *
    283326 *      --  SERVICE_CTRL_INTERROGATE (0): interrogate service status.
     327 *          This is similar to running lanServiceGetInfo, except
     328 *          that this one actually asks the service for its status,
     329 *          while lanServiceGetInfo simply dumps the status last
     330 *          posted.
    284331 *
    285332 *      --  SERVICE_CTRL_PAUSE (1): pause service.
  • trunk/src/helpers/nls.c

    r249 r257  
    149149                     ++n)
    150150                    G_afLeadByte[n] = TRUE;
     151
    151152                G_fDBCS = TRUE;
    152153            }
  • trunk/src/helpers/nlscache.c

    r243 r257  
    289289 *      After that, this function implements a fast string
    290290 *      cache for various NLS strings. Compared to the
    291  *      standard method, this has the following advantages:
    292  *
    293  *      -- Memory is only consumed for strings that are actually
    294  *         used. The NLSSTRINGS array had become terribly big,
    295  *         and lots of strings were loaded that were never used.
    296  *
    297  *      -- Program startup should be a bit faster because we don't
    298  *         have to load a thousand strings at startup.
    299  *
    300  *      -- The memory buffer holding the string is probably close
    301  *         to the rest of the heap data that the caller allocated,
    302  *         so this might lead to less memory page fragmentation.
    303  *
    304  *      -- To add a new NLS string, before this mechanism existed,
    305  *         three files had to be changed (and kept in sync): common.h
    306  *         to add a field to the NLSSTRINGS structure, dlgids.h to
    307  *         add the string ID, and xfldrXXX.rc to add the resource.
    308  *         With the new mechanism, there's no need to change common.h
    309  *         any more, so the danger of forgetting something is a bit
    310  *         reduced. Anyway, fewer recompiles are needed (maybe),
    311  *         and sending in patches to the code is a bit easier.
     291 *      standard method of preloading all NLS strings at
     292 *      program startup, this method of on-demand string
     293 *      loading has the following advantages:
     294 *
     295 *      --  Memory is only consumed for strings that are actually
     296 *          used.
     297 *
     298 *      --  Program startup should be a bit faster because we don't
     299 *          have to load a thousand strings at startup.
     300 *
     301 *      --  The memory buffer holding the string is probably close
     302 *          to the rest of the heap data that the caller allocated,
     303 *          so this might lead to less memory page fragmentation.
     304 *          (This is a wild guess though.)
     305 *
     306 *      --  To add a new NLS string, before this mechanism existed,
     307 *          three files had to be changed (and kept in sync): common.h
     308 *          to add a field to the NLSSTRINGS structure, dlgids.h to
     309 *          add the string ID, and xfldrXXX.rc to add the resource.
     310 *          With the new mechanism, there's no need to change common.h
     311 *          any more, so the danger of forgetting something is a bit
     312 *          reduced. Anyway, fewer recompiles are needed (maybe),
     313 *          and sending in patches to the code is a bit easier.
    312314 *
    313315 *      On input, specify a string resouce ID that exists
Note: See TracChangeset for help on using the changeset viewer.