- Timestamp:
- Jan 8, 2004, 5:43:29 PM (22 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r235 r257 296 296 * the control _sizes_, and everything is layed out automatically. 297 297 * You may even have the formatter compute the sizes automatically 298 * based on the control classes and values ; it is possible to299 * 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. 300 300 * 301 301 * There are several tricks to how this works. … … 314 314 * (which again goes into ProcessRow and ProcessColumn). 315 315 * 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. 317 317 * 318 318 * 3) This whole recursive iteration is performed several times. -
trunk/src/helpers/dosh.c
r253 r257 2588 2588 *@@changed V0.9.16 (2001-12-18) [umoeller]: fixed error codes 2589 2589 *@@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 2590 2591 */ 2591 2592 … … 2615 2616 // which isn't that meaningful 2616 2617 // 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] 2619 2621 break; 2620 2622 … … 2625 2627 | OPEN_ACCESS_READWRITE; 2626 2628 2627 arc = doshQueryPathSize(pcszFilename, 2628 pcbFile); 2629 /* arc = doshQueryPathSize(pcszFilename, 2630 pcbFile); */ 2631 // moved this down V1.0.2 (2003-11-13) [umoeller] 2629 2632 break; 2630 2633 … … 2646 2649 } 2647 2650 2648 if ((!arc) && fsOpenFlags && pcbFile && ppFile) 2651 if ( (!arc) 2652 && fsOpenFlags 2653 && pcbFile 2654 && ppFile 2655 ) 2649 2656 { 2650 2657 PXFILE pFile; … … 2695 2702 pFile->pszFilename = strdup(pcszFilename); 2696 2703 } 2697 #ifdef DEBUG_DOSOPEN2698 2704 else 2699 _Pmpf((__FUNCTION__ ": DosOpen returned %d for %s", 2705 { 2706 #ifdef DEBUG_DOSOPEN 2707 _Pmpf((__FUNCTION__ ": DosOpen returned %d for %s", 2700 2708 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 } 2702 2720 2703 2721 if (arc) … … 2750 2768 *@@added V0.9.13 (2001-06-14) [umoeller] 2751 2769 *@@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) 2753 2772 */ 2754 2773 … … 2828 2847 #endif 2829 2848 2849 #if 0 2830 2850 // free old cache 2831 2851 if (pFile->pbCache) … … 2834 2854 // allocate new cache 2835 2855 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 2836 2861 arc = ERROR_NOT_ENOUGH_MEMORY; 2837 2862 else … … 4487 4512 4488 4513 /* 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 4523 ULONG 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 /* 4489 4534 *@@ doshMyTID: 4490 4535 * returns the TID of the current thread. -
trunk/src/helpers/exeh.c
r242 r257 266 266 267 267 // 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/out273 (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 275 275 { 276 276 // now check if we really have a DOS header 277 if (pExec-> pDosExeHeader->usDosExeID != 0x5a4d)277 if (pExec->DosExeHeader.usDosExeID != 0x5a4d) 278 278 { 279 279 // arc = ERROR_INVALID_EXE_SIGNATURE; … … 289 289 // remove the DOS header info, since we have none 290 290 // V0.9.12 (2001-05-03) [umoeller] 291 FREE(pExec->pDosExeHeader);291 // FREE(pExec->pDosExeHeader); 292 292 pExec->cbDosExeHeader = 0; 293 293 } … … 295 295 { 296 296 // we have a DOS header: 297 if (pExec-> pDosExeHeader->usRelocTableOfs < 0x40)297 if (pExec->DosExeHeader.usRelocTableOfs < 0x40) 298 298 { 299 299 // neither LX nor PE nor NE: … … 305 305 // we have a new header offset: 306 306 fLoadNewHeader = TRUE; 307 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;307 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 308 308 } 309 309 } … … 1199 1199 ULONG ulNewHeaderOfs = 0; // V0.9.12 (2001-05-03) [umoeller] 1200 1200 1201 if (pExec-> pDosExeHeader)1201 if (pExec->cbDosExeHeader) 1202 1202 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 1203 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;1203 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 1204 1204 1205 1205 if (pExec->ulExeFormat == EXEFORMAT_LX) … … 1353 1353 HFILE hfExe = pExec->pFile->hf; 1354 1354 1355 if (pExec-> pDosExeHeader)1355 if (pExec->cbDosExeHeader) 1356 1356 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 1357 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;1357 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 1358 1358 1359 1359 ENSURE(DosSetFilePtr(hfExe, … … 1594 1594 HFILE hfExe = pExec->pFile->hf; 1595 1595 1596 if (pExec-> pDosExeHeader)1596 if (pExec->cbDosExeHeader) 1597 1597 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 1598 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;1598 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 1599 1599 1600 1600 ENSURE(DosSetFilePtr(hfExe, … … 1801 1801 ULONG ulNewHeaderOfs = 0; // V0.9.12 (2001-05-03) [umoeller] 1802 1802 1803 if (pExec-> pDosExeHeader)1803 if (pExec->cbDosExeHeader) 1804 1804 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 1805 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;1805 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 1806 1806 1807 1807 if (pExec->ulExeFormat == EXEFORMAT_LX) … … 1976 1976 ULONG ulNewHeaderOfs = 0; // V0.9.12 (2001-05-03) [umoeller] 1977 1977 1978 if (pExec-> pDosExeHeader)1978 if (pExec->cbDosExeHeader) 1979 1979 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 1980 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;1980 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 1981 1981 1982 1982 if (pExec->ulExeFormat == EXEFORMAT_LX) … … 2371 2371 ULONG cb; 2372 2372 2373 if (pExec-> pDosExeHeader)2373 if (pExec->cbDosExeHeader) 2374 2374 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 2375 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;2375 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 2376 2376 2377 2377 // resource table … … 2883 2883 ULONG ulPageSize = pExec->pLXHeader->ulPageSize; 2884 2884 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 2885 2891 ulOffset += ulExeOffset; 2886 2892 … … 2898 2904 ulOffset, 2899 2905 &ulSize, 2900 p abCompressed,2906 pbTarget, // pabCompressed, V1.0.2 (2003-11-13) [umoeller] 2901 2907 0))) 2902 2908 { … … 2924 2930 break; 2925 2931 2932 /* V1.0.2 (2003-11-13) [umoeller] 2926 2933 case VALID: 2927 2934 // uncompressed … … 2930 2937 ulPageSize); 2931 2938 break; 2939 */ 2932 2940 } 2933 2941 } … … 2948 2956 * type _and_ ID. 2949 2957 * 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. 2954 2976 * 2955 2977 * This code will properly unpack compressed … … 2977 2999 ULONG idResource, // in: resource ID or 0 for first 2978 3000 PBYTE *ppbResData, // out: resource data (to be free()'d) 3001 PULONG pulOffset, // out: offset of actual data in buffer 2979 3002 PULONG pcbResData) // out: size of resource data (ptr can be NULL) 2980 3003 { … … 2995 3018 return ERROR_INVALID_EXE_SIGNATURE; 2996 3019 2997 if (pExec-> pDosExeHeader)3020 if (pExec->cbDosExeHeader) 2998 3021 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 2999 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;3022 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 3000 3023 3001 3024 if (!(cResources = pLXHeader->ulResTblCnt)) … … 3136 3159 if (!arc) 3137 3160 { 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; 3153 3183 3154 3184 fPtrFound = TRUE; 3155 3185 } 3156 3157 FREE(pabUncompressed); 3186 else 3187 FREE(pabUncompressed); 3188 3158 3189 FREE(pabCompressed); 3159 3190 } … … 3239 3270 ULONG cb; 3240 3271 3241 if (pExec-> pDosExeHeader)3272 if (pExec->cbDosExeHeader) 3242 3273 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 3243 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;3274 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 3244 3275 3245 3276 // resource table … … 3351 3382 return ERROR_INVALID_EXE_SIGNATURE; 3352 3383 3353 if (pExec-> pDosExeHeader)3384 if (pExec->cbDosExeHeader) 3354 3385 // executable has DOS stub: V0.9.12 (2001-05-03) [umoeller] 3355 ulNewHeaderOfs = pExec-> pDosExeHeader->ulNewHeaderOfs;3386 ulNewHeaderOfs = pExec->DosExeHeader.ulNewHeaderOfs; 3356 3387 3357 3388 // _Pmpf((__FUNCTION__ ": entering, checking %d resources", pNEHeader->usResSegmCount)); … … 3454 3485 char **papsz[] = 3455 3486 { 3456 (char**)&pExec->pDosExeHeader,3487 // (char**)&pExec->pDosExeHeader, 3457 3488 (char**)&pExec->pNEHeader, 3458 3489 (char**)&pExec->pLXHeader, -
trunk/src/helpers/helpers_pre.in
r249 r257 47 47 $(OUTPUTDIR)\xprf.obj\ 48 48 $(OUTPUTDIR)\xprf2.obj\ 49 $(OUTPUTDIR)\xsecapi.obj\ 49 50 $(OUTPUTDIR)\xstring.obj 50 51 -
trunk/src/helpers/lan.c
r229 r257 213 213 * queries the given service. 214 214 * 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 * 215 247 *@@added V1.0.0 (2002-09-24) [umoeller] 216 248 */ … … 240 272 * must be fully qualified so you cannot 241 273 * 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. 243 285 * 244 286 * Returns, among others: … … 277 319 /* 278 320 *@@ 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. 280 323 * 281 324 * opcode must be one of: 282 325 * 283 326 * -- 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. 284 331 * 285 332 * -- SERVICE_CTRL_PAUSE (1): pause service. -
trunk/src/helpers/nls.c
r249 r257 149 149 ++n) 150 150 G_afLeadByte[n] = TRUE; 151 151 152 G_fDBCS = TRUE; 152 153 } -
trunk/src/helpers/nlscache.c
r243 r257 289 289 * After that, this function implements a fast string 290 290 * 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. 312 314 * 313 315 * On input, specify a string resouce ID that exists
Note:
See TracChangeset
for help on using the changeset viewer.