| 1 | /* $Id: win32ktst.c,v 1.10 2001-07-10 05:28:15 bird Exp $
 | 
|---|
| 2 |  *
 | 
|---|
| 3 |  * Win32k test module.
 | 
|---|
| 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 | *   Defined Constants And Macros                                               *
 | 
|---|
| 13 | *******************************************************************************/
 | 
|---|
| 14 | #define INCL_BASE
 | 
|---|
| 15 | #define INCL_OS2KRNL_ALL
 | 
|---|
| 16 | #define INCL_SSTODS
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #define SEL_FLATMASK        0x01fff0000
 | 
|---|
| 19 | #define SEL_FLAT_SHIFT      0x0d
 | 
|---|
| 20 | #define SEL_LDT_RPL3        0x07
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #define SelToFlat(sel, off) \
 | 
|---|
| 23 |     (PVOID)( (((unsigned)(sel) << SEL_FLAT_SHIFT) & SEL_FLAT_MASK) + (unsigned)(off))
 | 
|---|
| 24 | 
 | 
|---|
| 25 | #define FlatToSel(flataddr) \
 | 
|---|
| 26 |     (PVOID)( ( (((unsigned)(flataddr) << 3) & 0xfff80000) | (SEL_LDT_RPL3 << 16) ) | ((unsigned)(flataddr) & 0xffff) )
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #define DWORD   ULONG
 | 
|---|
| 29 | #define WORD    USHORT
 | 
|---|
| 30 | 
 | 
|---|
| 31 | /*******************************************************************************
 | 
|---|
| 32 | *   Internal Functions                                                         *
 | 
|---|
| 33 | *******************************************************************************/
 | 
|---|
| 34 | #include <os2.h>
 | 
|---|
| 35 | #include <exe386.h>
 | 
|---|
| 36 | 
 | 
|---|
| 37 | #include "devSegDf.h"                   /* Win32k segment definitions. */
 | 
|---|
| 38 | 
 | 
|---|
| 39 | #include "malloc.h"
 | 
|---|
| 40 | 
 | 
|---|
| 41 | #include <stdio.h>
 | 
|---|
| 42 | #include <string.h>
 | 
|---|
| 43 | #include <stdlib.h>
 | 
|---|
| 44 | 
 | 
|---|
| 45 | #include "options.h"
 | 
|---|
| 46 | #include "dev1632.h"
 | 
|---|
| 47 | #include "dev32.h"
 | 
|---|
| 48 | #include "devcmd.h"
 | 
|---|
| 49 | #include "os2krnl.h"
 | 
|---|
| 50 | #include "avl.h"
 | 
|---|
| 51 | #include "ldr.h"
 | 
|---|
| 52 | #include "test.h"
 | 
|---|
| 53 | #include "asmutils.h"
 | 
|---|
| 54 | #include "macros.h"
 | 
|---|
| 55 | #include "log.h"
 | 
|---|
| 56 | 
 | 
|---|
| 57 | 
 | 
|---|
| 58 | 
 | 
|---|
| 59 | 
 | 
|---|
| 60 | 
 | 
|---|
| 61 | /** @design Win32k Ring-3 Testing
 | 
|---|
| 62 |  * I'll try to make it possible to test parts or all the win32k code in ring-3.
 | 
|---|
| 63 |  * To archive this the interface against the kernel has to be faked/emulated.
 | 
|---|
| 64 |  * More precisely:
 | 
|---|
| 65 |  *      - DevHelps.
 | 
|---|
| 66 |  *      - Worker routines for imported kernel functions. (calltab.asm jumps to them.)
 | 
|---|
| 67 |  *      - 16-bit stack 1Kb.
 | 
|---|
| 68 |  *      - Strategy calls.
 | 
|---|
| 69 |  *      - Fake module loadings (= testcases).
 | 
|---|
| 70 |  *      - ?
 | 
|---|
| 71 |  *
 | 
|---|
| 72 |  * Some of the initstuff has to be omitted, at least in the start. The first
 | 
|---|
| 73 |  * goal is to be able to test _ldrOpenPath and _ldrOpen.
 | 
|---|
| 74 |  *
 | 
|---|
| 75 |  *
 | 
|---|
| 76 |  * @subsection  Device Helper Routines
 | 
|---|
| 77 |  *
 | 
|---|
| 78 |  * These I think we'll implemented by providing the kernel interface, a far 16:16
 | 
|---|
| 79 |  * pointer to a dh-router. Our router will in most cases thunk back to 32-bit
 | 
|---|
| 80 |  * code and implementet the required devhelp routines in pure C code.
 | 
|---|
| 81 |  *
 | 
|---|
| 82 |  * These are the needed routines:
 | 
|---|
| 83 |  *      - DevHelp_VirtToLin   - ok
 | 
|---|
| 84 |  *      - DevHelp_VMAlloc     - ok
 | 
|---|
| 85 |  *      - DevHelp_VMFree      - ok
 | 
|---|
| 86 |  *      - DevHelp_GetDOSVar   - ok
 | 
|---|
| 87 |  *      - DevHelp_VMLock
 | 
|---|
| 88 |  *      - DevHelp_VMUnLock  ?
 | 
|---|
| 89 |  *      - DevHelp_VMSetMem  ?
 | 
|---|
| 90 |  *      - DevHelp_Yield     ?
 | 
|---|
| 91 |  *
 | 
|---|
| 92 |  *
 | 
|---|
| 93 |  * @subsection  Worker routines for imported kernel functions
 | 
|---|
| 94 |  *
 | 
|---|
| 95 |  * Create worker routines for the imported kernel functions. Calltab will be
 | 
|---|
| 96 |  * set up to jump to them. This is done in d32init.c, in stead of using
 | 
|---|
| 97 |  * the importtab.
 | 
|---|
| 98 |  *
 | 
|---|
| 99 |  * Some of these workers will be parts of testcases. For example g_tkExecPgm
 | 
|---|
| 100 |  * and _LDRQAppType.
 | 
|---|
| 101 |  *
 | 
|---|
| 102 |  * Only the imported functions are implemented on demand. Initially these
 | 
|---|
| 103 |  * functions will be provided:
 | 
|---|
| 104 |  *      - ldrOpen
 | 
|---|
| 105 |  *      - ldrRead
 | 
|---|
| 106 |  *      - ldrClose
 | 
|---|
| 107 |  *      - ldrOpenPath
 | 
|---|
| 108 |  *      - SftFileSize
 | 
|---|
| 109 |  *
 | 
|---|
| 110 |  *
 | 
|---|
| 111 |  * @subsection  16-bit stack
 | 
|---|
| 112 |  *
 | 
|---|
| 113 |  * To make this test real the stack has to be 16-bit and _very_ small (1KB).
 | 
|---|
| 114 |  * TKSSBase have to be implemented by the DevHelp_GetDOSVar DosTable2 stuff.
 | 
|---|
| 115 |  * The stack will be thunked to 16-bit by a thunking procedure called from
 | 
|---|
| 116 |  * main. This procedure thunks the stack (quite easy, we're in tiled memory!),
 | 
|---|
| 117 |  * set the value of TKSSBase, calls a C function which does all the rest of
 | 
|---|
| 118 |  * the testing. When taht function returns, the stack will be thunked back
 | 
|---|
| 119 |  * to 32-bit, TKSSBase will be zeroed, and the procedure returns to main.
 | 
|---|
| 120 |  *
 | 
|---|
| 121 |  *
 | 
|---|
| 122 |  * @subsection  Straegy routine calls (not implemented)
 | 
|---|
| 123 |  *
 | 
|---|
| 124 |  * We'll call the strategy entry points with init request packets. The initiation
 | 
|---|
| 125 |  * will require a replacement for DosDevIOCtl (16-bit) which calls the
 | 
|---|
| 126 |  * $elf strategy routine. We'll also have to provide fakes for kernel probing,
 | 
|---|
| 127 |  * verifing and overloading in d32init.c.
 | 
|---|
| 128 |  *
 | 
|---|
| 129 |  *
 | 
|---|
| 130 |  * @subsection  Order of events
 | 
|---|
| 131 |  *
 | 
|---|
| 132 |  * This is the order this testing environment currently works:
 | 
|---|
| 133 |  *      1) init devhelp subsystem
 | 
|---|
| 134 |  *      2) init workers
 | 
|---|
| 135 |  *      3) thunk stack
 | 
|---|
| 136 |  *      4) Fake 16-bit init. Set TKSSBase, FlatDS, FlatCS, DevHelp pointer....
 | 
|---|
| 137 |  *      5) Call R0Init32().
 | 
|---|
| 138 |  *         (d32init.c is modified a bit to setup the calltab correctly.)
 | 
|---|
| 139 |  *      6) Start testing...
 | 
|---|
| 140 |  *      7) Testing finished - thunk stack back to 32-bit.
 | 
|---|
| 141 |  */
 | 
|---|
| 142 | 
 | 
|---|
| 143 | 
 | 
|---|
| 144 | /*******************************************************************************
 | 
|---|
| 145 | *   Structures and Typedefs                                                    *
 | 
|---|
| 146 | *******************************************************************************/
 | 
|---|
| 147 | #if !defined(QS_MTE) || defined(QS_MODVER)
 | 
|---|
| 148 |    /* From OS/2 Toolkit v4.5 (BSEDOS.H) */
 | 
|---|
| 149 | 
 | 
|---|
| 150 |    /* Global Record structure
 | 
|---|
| 151 |     * Holds all global system information. Placed first in user buffer
 | 
|---|
| 152 |     */
 | 
|---|
| 153 |    typedef struct qsGrec_s {  /* qsGrec */
 | 
|---|
| 154 |            ULONG         cThrds;
 | 
|---|
| 155 |            ULONG         c32SSem;
 | 
|---|
| 156 |            ULONG         cMFTNodes;
 | 
|---|
| 157 |    }qsGrec_t;
 | 
|---|
| 158 | 
 | 
|---|
| 159 |    /*
 | 
|---|
| 160 |     *      System wide MTE information
 | 
|---|
| 161 |     *      ________________________________
 | 
|---|
| 162 |     *      |       pNextRec                |----|
 | 
|---|
| 163 |     *      |-------------------------------|    |
 | 
|---|
| 164 |     *      |       hmte                    |    |
 | 
|---|
| 165 |     *      |-------------------------------|    |
 | 
|---|
| 166 |     *      |       ctImpMod                |    |
 | 
|---|
| 167 |     *      |-------------------------------|    |
 | 
|---|
| 168 |     *      |       ctObj                   |    |
 | 
|---|
| 169 |     *      |-------------------------------|    |
 | 
|---|
| 170 |     *      |       pObjInfo                |----|----------|
 | 
|---|
| 171 |     *      |-------------------------------|    |          |
 | 
|---|
| 172 |     *      |       pName                   |----|----|     |
 | 
|---|
| 173 |     *      |-------------------------------|    |    |     |
 | 
|---|
| 174 |     *      |       imported module handles |    |    |     |
 | 
|---|
| 175 |     *      |          .                    |    |    |     |
 | 
|---|
| 176 |     *      |          .                    |    |    |     |
 | 
|---|
| 177 |     *      |          .                    |    |    |     |
 | 
|---|
| 178 |     *      |-------------------------------| <--|----|     |
 | 
|---|
| 179 |     *      |       "pathname"              |    |          |
 | 
|---|
| 180 |     *      |-------------------------------| <--|----------|
 | 
|---|
| 181 |     *      |       Object records          |    |
 | 
|---|
| 182 |     *      |       (if requested)          |    |
 | 
|---|
| 183 |     *      |_______________________________|    |
 | 
|---|
| 184 |     *                                      <-----
 | 
|---|
| 185 |     *      NOTE that if the level bit is set to QS_MTE, the base Lib record will be followed
 | 
|---|
| 186 |     *      by a series of object records (qsLObj_t); one for each object of the
 | 
|---|
| 187 |     *      module.
 | 
|---|
| 188 |     */
 | 
|---|
| 189 | 
 | 
|---|
| 190 |    typedef struct qsLObjrec_s {  /* qsLOrec */
 | 
|---|
| 191 |            ULONG         oaddr;  /* object address */
 | 
|---|
| 192 |            ULONG         osize;  /* object size */
 | 
|---|
| 193 |            ULONG         oflags; /* object flags */
 | 
|---|
| 194 |    } qsLObjrec_t;
 | 
|---|
| 195 | 
 | 
|---|
| 196 |    typedef struct qsLrec_s {     /* qsLrec */
 | 
|---|
| 197 |            void  FAR        *pNextRec;      /* pointer to next record in buffer */
 | 
|---|
| 198 |            USHORT           hmte;           /* handle for this mte */
 | 
|---|
| 199 |            USHORT           fFlat;          /* true if 32 bit module */
 | 
|---|
| 200 |            ULONG            ctImpMod;       /* # of imported modules in table */
 | 
|---|
| 201 |            ULONG            ctObj;          /* # of objects in module (mte_objcnt)*/
 | 
|---|
| 202 |            qsLObjrec_t FAR  *pObjInfo;      /* pointer to per object info if any */
 | 
|---|
| 203 |            UCHAR     FAR    *pName;         /* -> name string following struc */
 | 
|---|
| 204 |    } qsLrec_t;
 | 
|---|
| 205 | 
 | 
|---|
| 206 | 
 | 
|---|
| 207 | 
 | 
|---|
| 208 |    /* Pointer Record Structure
 | 
|---|
| 209 |     *      This structure is the first in the user buffer.
 | 
|---|
| 210 |     *      It contains pointers to heads of record types that are loaded
 | 
|---|
| 211 |     *      into the buffer.
 | 
|---|
| 212 |     */
 | 
|---|
| 213 | 
 | 
|---|
| 214 |    typedef struct qsPtrRec_s {   /* qsPRec */
 | 
|---|
| 215 |            qsGrec_t        *pGlobalRec;
 | 
|---|
| 216 |            void            *pProcRec;      /* ptr to head of process records */
 | 
|---|
| 217 |            void            *p16SemRec;     /* ptr to head of 16 bit sem recds */
 | 
|---|
| 218 |            void            *p32SemRec;     /* ptr to head of 32 bit sem recds */
 | 
|---|
| 219 |            void            *pMemRec;       /* ptr to head of shared mem recs */
 | 
|---|
| 220 |            qsLrec_t        *pLibRec;       /* ptr to head of mte records */
 | 
|---|
| 221 |            void            *pShrMemRec;    /* ptr to head of shared mem records */
 | 
|---|
| 222 |            void            *pFSRec;        /* ptr to head of file sys records */
 | 
|---|
| 223 |    } qsPtrRec_t;
 | 
|---|
| 224 | 
 | 
|---|
| 225 | #endif
 | 
|---|
| 226 | 
 | 
|---|
| 227 | 
 | 
|---|
| 228 | /*******************************************************************************
 | 
|---|
| 229 | *   Global Variables                                                           *
 | 
|---|
| 230 | *******************************************************************************/
 | 
|---|
| 231 | extern BOOL     fInited;                /* malloc.c */
 | 
|---|
| 232 | int             cObjectsFake = 14;
 | 
|---|
| 233 | OTE             aKrnlOTE[24];
 | 
|---|
| 234 | 
 | 
|---|
| 235 | 
 | 
|---|
| 236 | /*******************************************************************************
 | 
|---|
| 237 | *   External Functions                                                         *
 | 
|---|
| 238 | *******************************************************************************/
 | 
|---|
| 239 | #ifndef QS_MTE
 | 
|---|
| 240 |    /* from OS/2 Toolkit v4.5 */
 | 
|---|
| 241 | 
 | 
|---|
| 242 |    APIRET APIENTRY DosQuerySysState(ULONG EntityList, ULONG EntityLevel, PID pid,
 | 
|---|
| 243 |                                     TID tid, PVOID pDataBuf, ULONG cbBuf);
 | 
|---|
| 244 |     #define QS_MTE         0x0004
 | 
|---|
| 245 | #endif
 | 
|---|
| 246 | 
 | 
|---|
| 247 | 
 | 
|---|
| 248 | /*******************************************************************************
 | 
|---|
| 249 | *   Internal Functions                                                         *
 | 
|---|
| 250 | *******************************************************************************/
 | 
|---|
| 251 | void    syntax(void);
 | 
|---|
| 252 | int     kernelInit(int iTest, int argc, char **argv);
 | 
|---|
| 253 | void    workersinit(void);
 | 
|---|
| 254 | void    initRPInit(RP32INIT *pRpInit, char *pszInitArgs);
 | 
|---|
| 255 | int     tests(int iTest, int argc, char **argv);
 | 
|---|
| 256 | int     TestCase1(int argc, char **argv);
 | 
|---|
| 257 | int     TestCase2(void);
 | 
|---|
| 258 | int     TestCase3(void);
 | 
|---|
| 259 | int     TestCase4(void);
 | 
|---|
| 260 | int     TestCase5(void);
 | 
|---|
| 261 | int     TestCase6(void);
 | 
|---|
| 262 | int     CompareOptions(struct options *pOpt);
 | 
|---|
| 263 | int     TestCaseExeLoad2(void);
 | 
|---|
| 264 | 
 | 
|---|
| 265 | 
 | 
|---|
| 266 | /**
 | 
|---|
| 267 |  * Main function. Arguments _currently_ unused.
 | 
|---|
| 268 |  */
 | 
|---|
| 269 | int main(int argc, char **argv)
 | 
|---|
| 270 | {
 | 
|---|
| 271 |     int         iTest;
 | 
|---|
| 272 |     int         rc;
 | 
|---|
| 273 | 
 | 
|---|
| 274 |     /*
 | 
|---|
| 275 |      * Init devhelp subsystems.
 | 
|---|
| 276 |      */
 | 
|---|
| 277 |     dhinit();
 | 
|---|
| 278 | 
 | 
|---|
| 279 |     /*
 | 
|---|
| 280 |      * Parse arguments.
 | 
|---|
| 281 |      * (printf don't work before dhinit is called...)
 | 
|---|
| 282 |      */
 | 
|---|
| 283 |     if (argc < 2 || (iTest = atoi(argv[1])) <= 0)
 | 
|---|
| 284 |     {
 | 
|---|
| 285 |         syntax();
 | 
|---|
| 286 |         printf("syntax error\n");
 | 
|---|
| 287 |         return -1;
 | 
|---|
| 288 |     }
 | 
|---|
| 289 | 
 | 
|---|
| 290 |     /*
 | 
|---|
| 291 |      * Init workers if necessary.
 | 
|---|
| 292 |      */
 | 
|---|
| 293 |     workersinit();
 | 
|---|
| 294 | 
 | 
|---|
| 295 |     /*
 | 
|---|
| 296 |      * Init Kernel
 | 
|---|
| 297 |      */
 | 
|---|
| 298 |     if (!kernelInit(iTest, argc, argv))
 | 
|---|
| 299 |         return -2;
 | 
|---|
| 300 | 
 | 
|---|
| 301 |     /*
 | 
|---|
| 302 |      * Thunk Stack to 16-bits.
 | 
|---|
| 303 |      *
 | 
|---|
| 304 |      * IMPORTANT! From now on SSToDS have to be used when making pointers
 | 
|---|
| 305 |      *            to stack objects.
 | 
|---|
| 306 |      */
 | 
|---|
| 307 |     ThunkStack32To16();
 | 
|---|
| 308 | 
 | 
|---|
| 309 |     rc = tests(iTest, argc, argv);
 | 
|---|
| 310 | 
 | 
|---|
| 311 |     /*
 | 
|---|
| 312 |      * Thunk Stack back to 32-bits.
 | 
|---|
| 313 |      */
 | 
|---|
| 314 |     ThunkStack16To32();
 | 
|---|
| 315 | 
 | 
|---|
| 316 | 
 | 
|---|
| 317 |     /*
 | 
|---|
| 318 |      * To avoid a sfree error message we'll set fInited (heap init flag) to false.
 | 
|---|
| 319 |      */
 | 
|---|
| 320 |     fInited = FALSE;
 | 
|---|
| 321 |     return rc;
 | 
|---|
| 322 | }
 | 
|---|
| 323 | 
 | 
|---|
| 324 | 
 | 
|---|
| 325 | /**
 | 
|---|
| 326 |  * Prints syntax information.
 | 
|---|
| 327 |  * @status  partially implemented.
 | 
|---|
| 328 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 329 |  */
 | 
|---|
| 330 | void    syntax(void)
 | 
|---|
| 331 | {
 | 
|---|
| 332 |     printf(
 | 
|---|
| 333 |            "Win32kTst.exe v%d.%d.%d - Ring 3 testing of win32k.sys\n"
 | 
|---|
| 334 |            "syntax: Win32kTst.exe <testcase number> [optional arguments]\n",
 | 
|---|
| 335 |            0,0,4
 | 
|---|
| 336 |            );
 | 
|---|
| 337 | }
 | 
|---|
| 338 | 
 | 
|---|
| 339 | 
 | 
|---|
| 340 | /**
 | 
|---|
| 341 |  * test case 1: Load the specified kernel
 | 
|---|
| 342 |  * other cases: Load running kernel.
 | 
|---|
| 343 |  * @returns Success indicator. (true/false)
 | 
|---|
| 344 |  * @param   iTest   Testcase number.
 | 
|---|
| 345 |  * @param   argc    main argc
 | 
|---|
| 346 |  * @param   argv    main argv
 | 
|---|
| 347 |  * @status  completely implemented.
 | 
|---|
| 348 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 349 |  */
 | 
|---|
| 350 | int     kernelInit(int iTest, int argc, char **argv)
 | 
|---|
| 351 | {
 | 
|---|
| 352 |     static char     achBuffer[1024*256];
 | 
|---|
| 353 |     char            szError[256];
 | 
|---|
| 354 |     HMODULE         hmod = NULLHANDLE;
 | 
|---|
| 355 |     int             rc;
 | 
|---|
| 356 |     char            szName[CCHMAXPATH];
 | 
|---|
| 357 |     char *          pszSrcName;
 | 
|---|
| 358 |     char *          pszTmp;
 | 
|---|
| 359 |     ULONG           ulAction;
 | 
|---|
| 360 |     HFILE           hFile;
 | 
|---|
| 361 |     struct e32_exe* pe32 = (struct e32_exe*)(void*)&achBuffer[0];
 | 
|---|
| 362 |     qsPtrRec_t *    pPtrRec = (qsPtrRec_t*)(void*)&achBuffer[0];
 | 
|---|
| 363 |     qsLrec_t *      pLrec;
 | 
|---|
| 364 |     int             i;
 | 
|---|
| 365 |     FILESTATUS3     fsts3;
 | 
|---|
| 366 | 
 | 
|---|
| 367 |     /*
 | 
|---|
| 368 |      * If not testcase 1, use the running kernel.
 | 
|---|
| 369 |      */
 | 
|---|
| 370 |     if (iTest != 1)
 | 
|---|
| 371 |     {
 | 
|---|
| 372 |         ULONG   ulBootDrv = 3;
 | 
|---|
| 373 |         pszSrcName = "c:\\os2krnl";
 | 
|---|
| 374 |         DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, SSToDS(&ulBootDrv), sizeof(ulBootDrv));
 | 
|---|
| 375 |         pszSrcName[0] = (char)(ulBootDrv + 'a' - 1);
 | 
|---|
| 376 |     }
 | 
|---|
| 377 |     else
 | 
|---|
| 378 |     {
 | 
|---|
| 379 |         if (argc < 3)
 | 
|---|
| 380 |         {
 | 
|---|
| 381 |             printf("Missing parameter!\n");
 | 
|---|
| 382 |             return FALSE;
 | 
|---|
| 383 |         }
 | 
|---|
| 384 |         pszSrcName = argv[2];
 | 
|---|
| 385 |     }
 | 
|---|
| 386 | 
 | 
|---|
| 387 |     /*
 | 
|---|
| 388 |      * Make a temporary copy of the kernel.
 | 
|---|
| 389 |      */
 | 
|---|
| 390 |     if (DosScanEnv("TMP", &pszTmp) != NO_ERROR || pszTmp == NULL)
 | 
|---|
| 391 |     {
 | 
|---|
| 392 |         printf("Environment variable TMP is not set.\n");
 | 
|---|
| 393 |         return FALSE;
 | 
|---|
| 394 |     }
 | 
|---|
| 395 |     strcpy(szName, pszTmp);
 | 
|---|
| 396 |     if (szName[strlen(pszTmp) - 1] != '\\' && szName[strlen(pszTmp) - 1] != '/')
 | 
|---|
| 397 |         strcat(szName, "\\");
 | 
|---|
| 398 |     strcat(szName, "os2krnl");
 | 
|---|
| 399 |     rc = DosCopy(pszSrcName, szName, DCPY_EXISTING);
 | 
|---|
| 400 |     if (rc != NO_ERROR)
 | 
|---|
| 401 |     {
 | 
|---|
| 402 |         printf("Failed to copy %s to %s.\n", pszSrcName, szName);
 | 
|---|
| 403 |         return FALSE;
 | 
|---|
| 404 |     }
 | 
|---|
| 405 |     if (DosQueryPathInfo(szName, FIL_STANDARD, &fsts3, sizeof(fsts3)) != NO_ERROR
 | 
|---|
| 406 |         ||  !(fsts3.attrFile = FILE_ARCHIVED)
 | 
|---|
| 407 |         ||  DosSetPathInfo(szName, FIL_STANDARD, &fsts3, sizeof(fsts3), 0) != NO_ERROR
 | 
|---|
| 408 |         )
 | 
|---|
| 409 |     {
 | 
|---|
| 410 |         printf("Failed to set attributes for %s.\n", szName);
 | 
|---|
| 411 |         return FALSE;
 | 
|---|
| 412 |     }
 | 
|---|
| 413 | 
 | 
|---|
| 414 |     /*
 | 
|---|
| 415 |      * Patch the kernel.
 | 
|---|
| 416 |      *      Remove the entrypoint.
 | 
|---|
| 417 |      */
 | 
|---|
| 418 |     ulAction = 0;
 | 
|---|
| 419 |     rc = DosOpen(szName, &hFile, &ulAction, 0, FILE_NORMAL,
 | 
|---|
| 420 |                  OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
 | 
|---|
| 421 |                  OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
 | 
|---|
| 422 |                  NULL);
 | 
|---|
| 423 |     if (rc != NO_ERROR)
 | 
|---|
| 424 |     {
 | 
|---|
| 425 |         printf("Failed to open temporary kernel file. rc = %d\n", rc);
 | 
|---|
| 426 |         return FALSE;
 | 
|---|
| 427 |     }
 | 
|---|
| 428 |     rc = DosRead(hFile, &achBuffer[0], 0x200, &ulAction);
 | 
|---|
| 429 |     if (rc != NO_ERROR)
 | 
|---|
| 430 |     {
 | 
|---|
| 431 |         DosClose(hFile);
 | 
|---|
| 432 |         printf("Failed to read LX header from temporary kernel file.\n");
 | 
|---|
| 433 |         return FALSE;
 | 
|---|
| 434 |     }
 | 
|---|
| 435 |     pe32 = (struct e32_exe*)(void*)&achBuffer[*(unsigned long*)(void*)&achBuffer[0x3c]];
 | 
|---|
| 436 |     if (*(PUSHORT)pe32->e32_magic != E32MAGIC)
 | 
|---|
| 437 |     {
 | 
|---|
| 438 |         DosClose(hFile);
 | 
|---|
| 439 |         printf("Failed to read LX header from temporary kernel file (2).\n");
 | 
|---|
| 440 |         return FALSE;
 | 
|---|
| 441 |     }
 | 
|---|
| 442 |     pe32->e32_eip = 0;
 | 
|---|
| 443 |     pe32->e32_startobj = 0;
 | 
|---|
| 444 |     pe32->e32_mflags &= ~(E32LIBTERM | E32LIBINIT);
 | 
|---|
| 445 |     if ((rc = DosSetFilePtr(hFile, *(unsigned long*)(void*)&achBuffer[0x3c], FILE_BEGIN, &ulAction)) != NO_ERROR
 | 
|---|
| 446 |         || (rc = DosWrite(hFile, pe32, sizeof(struct e32_exe), &ulAction)) != NO_ERROR)
 | 
|---|
| 447 |     {
 | 
|---|
| 448 |         DosClose(hFile);
 | 
|---|
| 449 |         printf("Failed to write patched LX header to temporary kernel file.\n");
 | 
|---|
| 450 |         return FALSE;
 | 
|---|
| 451 |     }
 | 
|---|
| 452 |     DosClose(hFile);
 | 
|---|
| 453 | 
 | 
|---|
| 454 |     /*
 | 
|---|
| 455 |      * Load the module.
 | 
|---|
| 456 |      */
 | 
|---|
| 457 |     rc = DosLoadModule(szError, sizeof(szError), szName, SSToDS(&hmod));
 | 
|---|
| 458 |     if (rc != NO_ERROR && (rc != ERROR_INVALID_PARAMETER && hmod == NULLHANDLE))
 | 
|---|
| 459 |     {
 | 
|---|
| 460 |         printf("Failed to load OS/2 kernel image %s.");
 | 
|---|
| 461 |         return FALSE;
 | 
|---|
| 462 |     }
 | 
|---|
| 463 | 
 | 
|---|
| 464 |     /*
 | 
|---|
| 465 |      * Get object information.
 | 
|---|
| 466 |      */
 | 
|---|
| 467 |     rc = DosQuerySysState(QS_MTE, QS_MTE, 0L, 0L, pPtrRec, sizeof(achBuffer));
 | 
|---|
| 468 |     if (rc != NO_ERROR)
 | 
|---|
| 469 |     {
 | 
|---|
| 470 |         printf("DosQuerySysState failed with rc=%d.\n", rc);
 | 
|---|
| 471 |         return FALSE;
 | 
|---|
| 472 |     }
 | 
|---|
| 473 | 
 | 
|---|
| 474 |     pLrec = pPtrRec->pLibRec;
 | 
|---|
| 475 |     while (pLrec != NULL)
 | 
|---|
| 476 |     {
 | 
|---|
| 477 |         /*
 | 
|---|
| 478 |          * Bug detected in OS/2 FP13. Probably a problem which occurs
 | 
|---|
| 479 |          * in _LDRSysMteInfo when qsCheckCache is calle before writing
 | 
|---|
| 480 |          * object info. The result is that the cache flushed and the
 | 
|---|
| 481 |          * attempt of updating the qsLrec_t next and object pointer is
 | 
|---|
| 482 |          * not done. This used to work earlier and on Aurora AFAIK.
 | 
|---|
| 483 |          *
 | 
|---|
| 484 |          * The fix for this problem is to check if the pObjInfo is NULL
 | 
|---|
| 485 |          * while the number of objects isn't 0 and correct this. pNextRec
 | 
|---|
| 486 |          * will also be NULL at this time. This will be have to corrected
 | 
|---|
| 487 |          * before we exit the loop or moves to the next record.
 | 
|---|
| 488 |          * There is also a nasty alignment of the object info... Hope
 | 
|---|
| 489 |          * I got it right. (This aligment seems new to FP13.)
 | 
|---|
| 490 |          */
 | 
|---|
| 491 |         if (pLrec->pObjInfo == NULL /*&& pLrec->pNextRec == NULL*/ && pLrec->ctObj > 0)
 | 
|---|
| 492 |             {
 | 
|---|
| 493 |             pLrec->pObjInfo = (qsLObjrec_t*)(void*)(
 | 
|---|
| 494 |                 (char*)(void*)pLrec
 | 
|---|
| 495 |                 + ((sizeof(qsLrec_t)                            /* size of the lib record */
 | 
|---|
| 496 |                    + pLrec->ctImpMod * sizeof(short)            /* size of the array of imported modules */
 | 
|---|
| 497 |                    + strlen((char*)(void*)pLrec->pName) + 1     /* size of the filename */
 | 
|---|
| 498 |                    + 3) & ~3));                                 /* the size is align on 4 bytes boundrary */
 | 
|---|
| 499 |             pLrec->pNextRec = (qsLrec_t*)(void*)((char*)(void*)pLrec->pObjInfo
 | 
|---|
| 500 |                                                  + sizeof(qsLObjrec_t) * pLrec->ctObj);
 | 
|---|
| 501 |             }
 | 
|---|
| 502 |         if (pLrec->hmte == hmod)
 | 
|---|
| 503 |             break;
 | 
|---|
| 504 | 
 | 
|---|
| 505 |         /*
 | 
|---|
| 506 |          * Next record
 | 
|---|
| 507 |          */
 | 
|---|
| 508 |         pLrec = (qsLrec_t*)pLrec->pNextRec;
 | 
|---|
| 509 |     }
 | 
|---|
| 510 | 
 | 
|---|
| 511 |     if (pLrec == NULL)
 | 
|---|
| 512 |     {
 | 
|---|
| 513 |         printf("DosQuerySysState(os2krnl): not found\n");
 | 
|---|
| 514 |         return FALSE;
 | 
|---|
| 515 |     }
 | 
|---|
| 516 |     if (pLrec->pObjInfo == NULL)
 | 
|---|
| 517 |     {
 | 
|---|
| 518 |         printf("DosQuerySysState(os2krnl): no object info\n");
 | 
|---|
| 519 |         return FALSE;
 | 
|---|
| 520 |     }
 | 
|---|
| 521 | 
 | 
|---|
| 522 |     /*
 | 
|---|
| 523 |      * Fill the aKrnlOTE array.
 | 
|---|
| 524 |      */
 | 
|---|
| 525 |     for (i = 0; i < pLrec->ctObj; i++)
 | 
|---|
| 526 |     {
 | 
|---|
| 527 |         aKrnlOTE[i].ote_size    = pLrec->pObjInfo[i].osize;
 | 
|---|
| 528 |         aKrnlOTE[i].ote_base    = pLrec->pObjInfo[i].oaddr;
 | 
|---|
| 529 |         aKrnlOTE[i].ote_flags   = pLrec->pObjInfo[i].oflags;
 | 
|---|
| 530 |         aKrnlOTE[i].ote_pagemap = i > 0 ? aKrnlOTE[i-1].ote_pagemap + aKrnlOTE[i-1].ote_mapsize : 0;
 | 
|---|
| 531 |         aKrnlOTE[i].ote_mapsize = (pLrec->pObjInfo[i].osize + 0x0FFF) / 0x1000;
 | 
|---|
| 532 |         aKrnlOTE[i].ote_sel     = (USHORT)FlatToSel(pLrec->pObjInfo[i].oaddr);
 | 
|---|
| 533 |         aKrnlOTE[i].ote_hob     = 0;
 | 
|---|
| 534 |     }
 | 
|---|
| 535 |     cObjectsFake = pLrec->ctObj;
 | 
|---|
| 536 | 
 | 
|---|
| 537 |     return TRUE;
 | 
|---|
| 538 | }
 | 
|---|
| 539 | 
 | 
|---|
| 540 | 
 | 
|---|
| 541 | /**
 | 
|---|
| 542 |  * Initiates a init reqest packet.
 | 
|---|
| 543 |  * @param   pRpInit         Pointer to request packet to init.
 | 
|---|
| 544 |  * @param   pszInitArgs     Pointer to init arguments.
 | 
|---|
| 545 |  * @status  completely implemented.
 | 
|---|
| 546 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 547 |  */
 | 
|---|
| 548 | void initRPInit(RP32INIT *pRpInit, char *pszInitArgs)
 | 
|---|
| 549 | {
 | 
|---|
| 550 |     /* $elf */
 | 
|---|
| 551 |     memset(pRpInit, 0, sizeof(RP32INIT));
 | 
|---|
| 552 |     pRpInit->rph.Len  = sizeof(RP32INIT);
 | 
|---|
| 553 |     pRpInit->rph.Cmd  = CMDInit;
 | 
|---|
| 554 |     pRpInit->DevHlpEP = getDHRouterFarPtr();
 | 
|---|
| 555 |     pRpInit->InitArgs = (PSZ)FlatToSel(pszInitArgs);
 | 
|---|
| 556 | }
 | 
|---|
| 557 | 
 | 
|---|
| 558 | 
 | 
|---|
| 559 | /**
 | 
|---|
| 560 |  * Testcase fan-out.
 | 
|---|
| 561 |  * @returns Testcase return value.
 | 
|---|
| 562 |  *          -2 if testcase not found.
 | 
|---|
| 563 |  * @param   iTest   Testcase number.
 | 
|---|
| 564 |  * @param   argc    main argc
 | 
|---|
| 565 |  * @param   argv    main argv
 | 
|---|
| 566 |  * @status  completely implemented.
 | 
|---|
| 567 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 568 |  */
 | 
|---|
| 569 | int tests(int iTest, int argc, char **argv)
 | 
|---|
| 570 | {
 | 
|---|
| 571 |     int     rc;
 | 
|---|
| 572 | 
 | 
|---|
| 573 |     printf("-------------------------------- Testcase %d:\n", iTest);
 | 
|---|
| 574 |     switch (iTest)
 | 
|---|
| 575 |     {
 | 
|---|
| 576 |         case 1:     rc = TestCase1(argc, argv);   break;
 | 
|---|
| 577 |         case 2:     rc = TestCase2();   break;
 | 
|---|
| 578 |         case 3:     rc = TestCase3();   break;
 | 
|---|
| 579 |         case 4:     rc = TestCase4();   break;
 | 
|---|
| 580 |         case 5:     rc = TestCase5();   break;
 | 
|---|
| 581 | 
 | 
|---|
| 582 |         default:
 | 
|---|
| 583 |             printf("testcase no. %d is not found\n", iTest);
 | 
|---|
| 584 |             rc = -2;
 | 
|---|
| 585 |     }
 | 
|---|
| 586 |     printf("result %d -----------------------------------\n", rc);
 | 
|---|
| 587 | 
 | 
|---|
| 588 |     NOREF(argc);
 | 
|---|
| 589 |     NOREF(argv);
 | 
|---|
| 590 |     return rc;
 | 
|---|
| 591 | }
 | 
|---|
| 592 | 
 | 
|---|
| 593 | 
 | 
|---|
| 594 | 
 | 
|---|
| 595 | /**
 | 
|---|
| 596 |  * Test case 1.
 | 
|---|
| 597 |  * Checks that default initiation works fine for a given kernel.
 | 
|---|
| 598 |  *
 | 
|---|
| 599 |  * Syntax:  win32ktst.exe 1 <os2krnl> <majorver> <minorver> <build> <kerneltype: S|U|4> <buildtype: A|H|R> [rev] [os2krnl.sym]
 | 
|---|
| 600 |  *
 | 
|---|
| 601 |  * @sketch  Create init packet with no arguments.
 | 
|---|
| 602 |  *          Initiate elf$
 | 
|---|
| 603 |  *          Create init packet with no arguments.
 | 
|---|
| 604 |  *          Initiate win32k$
 | 
|---|
| 605 |  * @returns 0 on success.
 | 
|---|
| 606 |  *          1 on failure.
 | 
|---|
| 607 |  * @status  completely implemented.
 | 
|---|
| 608 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 609 |  */
 | 
|---|
| 610 | int TestCase1(int argc, char **argv)
 | 
|---|
| 611 | {
 | 
|---|
| 612 |     static char szInitArgs[CCHMAXPATH + 10];
 | 
|---|
| 613 |     int         rc = 1;
 | 
|---|
| 614 |     RP32INIT    rpinit;
 | 
|---|
| 615 | 
 | 
|---|
| 616 |     /* verify argument count */
 | 
|---|
| 617 |     if (argc < 8 || argc > 10)
 | 
|---|
| 618 |     {
 | 
|---|
| 619 |         printf("Invalid parameter count for testcase 1.\n");
 | 
|---|
| 620 |         return ERROR_INVALID_PARAMETER;
 | 
|---|
| 621 |     }
 | 
|---|
| 622 | 
 | 
|---|
| 623 |     /* init fake variabels */
 | 
|---|
| 624 |     _usFakeVerMajor = (USHORT)atoi(argv[3]);
 | 
|---|
| 625 |     _usFakeVerMinor = (USHORT)atoi(argv[4]);
 | 
|---|
| 626 | 
 | 
|---|
| 627 |     /* make init string */
 | 
|---|
| 628 |     strcpy(szInitArgs, "-w3");
 | 
|---|
| 629 |     if (argc >= 9 && argv[argc-1][1] != '\0')
 | 
|---|
| 630 |         strcat(strcat(szInitArgs, " -S:"), argv[argc-1]);
 | 
|---|
| 631 | 
 | 
|---|
| 632 |     /* $elf */
 | 
|---|
| 633 |     initRPInit(SSToDS(&rpinit), szInitArgs);
 | 
|---|
| 634 |     rc = InitElf(&rpinit);              /* no SSToDS! */
 | 
|---|
| 635 |     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 636 |     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 637 |     {
 | 
|---|
| 638 |         /* $win32k */
 | 
|---|
| 639 |         initRPInit(SSToDS(&rpinit), szInitArgs);
 | 
|---|
| 640 |         rc = InitWin32k(&rpinit);       /* no SSToDS! */
 | 
|---|
| 641 |         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 642 |         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 643 |         {
 | 
|---|
| 644 |             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
 | 
|---|
| 645 |             opt.ulInfoLevel = 3;
 | 
|---|
| 646 |             opt.fKernel = 0;
 | 
|---|
| 647 |             if (argv[6][0] == 'S')  opt.fKernel |= KF_SMP;
 | 
|---|
| 648 |             if (argv[6][0] == '4')  opt.fKernel |= KF_W4;
 | 
|---|
| 649 |             if (argv[6][0] == 'U')  opt.fKernel |= KF_UNI;
 | 
|---|
| 650 |             if (argv[7][0] == 'A')  opt.fKernel |= KF_ALLSTRICT;
 | 
|---|
| 651 |             if (argv[7][0] == 'H')  opt.fKernel |= KF_HALFSTRICT;
 | 
|---|
| 652 | 
 | 
|---|
| 653 |             if (argc >= 9 && argv[8][1] == '\0')
 | 
|---|
| 654 |                 switch (argv[8][0])
 | 
|---|
| 655 |                 {
 | 
|---|
| 656 |                     case '\0': break;
 | 
|---|
| 657 |                     default:
 | 
|---|
| 658 |                     opt.fKernel |= (argv[8][0] - (argv[8][0] >= 'a' ? 'a'-1 : 'A'-1)) << KF_REV_SHIFT;
 | 
|---|
| 659 |                 }
 | 
|---|
| 660 |             opt.ulBuild = atoi(argv[5]);
 | 
|---|
| 661 |             opt.usVerMajor = (USHORT)atoi(argv[3]);
 | 
|---|
| 662 |             opt.usVerMinor = (USHORT)atoi(argv[4]);
 | 
|---|
| 663 | 
 | 
|---|
| 664 |             rc = CompareOptions(SSToDS(&opt));
 | 
|---|
| 665 |         }
 | 
|---|
| 666 |         else
 | 
|---|
| 667 |             printf("!failed!\n");
 | 
|---|
| 668 |     }
 | 
|---|
| 669 |     else
 | 
|---|
| 670 |         printf("!failed!\n");
 | 
|---|
| 671 | 
 | 
|---|
| 672 |     return rc;
 | 
|---|
| 673 | }
 | 
|---|
| 674 | 
 | 
|---|
| 675 | /**
 | 
|---|
| 676 |  * Test case 2.
 | 
|---|
| 677 |  * Checks that all parameters are read correctly (1).
 | 
|---|
| 678 |  *
 | 
|---|
| 679 |  * @sketch  Create init packet with no arguments.
 | 
|---|
| 680 |  *          Initiate elf$
 | 
|---|
| 681 |  *          Create init packet with no arguments.
 | 
|---|
| 682 |  *          Initiate win32k$
 | 
|---|
| 683 |  * @returns 0 on success.
 | 
|---|
| 684 |  *          1 on failure.
 | 
|---|
| 685 |  * @status  completely implemented.
 | 
|---|
| 686 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 687 |  */
 | 
|---|
| 688 | int TestCase2(void)
 | 
|---|
| 689 | {
 | 
|---|
| 690 |     int         rc = 1;
 | 
|---|
| 691 |     RP32INIT    rpinit;
 | 
|---|
| 692 |     char *      pszInitArgs = "-C1 -L:E -Verbose -Elf:Yes -Pe:Mixed -Script:Yes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
 | 
|---|
| 693 | 
 | 
|---|
| 694 |     options.fLogging = TRUE;
 | 
|---|
| 695 | 
 | 
|---|
| 696 |     /* $elf */
 | 
|---|
| 697 |     initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 698 |     rc = InitElf(&rpinit);              /* no SSToDS! */
 | 
|---|
| 699 |     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 700 |     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 701 |     {
 | 
|---|
| 702 |         /* $win32k */
 | 
|---|
| 703 |         initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 704 |         rc = InitWin32k(&rpinit);       /* no SSToDS! */
 | 
|---|
| 705 |         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 706 |         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 707 |         {
 | 
|---|
| 708 |             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
 | 
|---|
| 709 |             opt.cbSwpHeapInit   = 512000;
 | 
|---|
| 710 |             opt.cbSwpHeapMax    = 4096000;
 | 
|---|
| 711 |             opt.cbResHeapInit   = 0256000;
 | 
|---|
| 712 |             opt.cbResHeapMax    = 0x100000;
 | 
|---|
| 713 |             opt.fElf            = TRUE;
 | 
|---|
| 714 |             opt.fUNIXScript     = TRUE;
 | 
|---|
| 715 |             opt.fPE             = FLAGS_PE_MIXED;
 | 
|---|
| 716 |             opt.fQuiet          = FALSE;
 | 
|---|
| 717 |             opt.fLogging        = TRUE;
 | 
|---|
| 718 |             opt.usCom           = OUTPUT_COM1;
 | 
|---|
| 719 |             opt.ulInfoLevel     = INFOLEVEL_INFOALL;
 | 
|---|
| 720 | 
 | 
|---|
| 721 |             rc = CompareOptions(SSToDS(&opt));
 | 
|---|
| 722 |             if (rc == NO_ERROR)
 | 
|---|
| 723 |             {
 | 
|---|
| 724 |                  rc = TestCaseExeLoad2();
 | 
|---|
| 725 |             }
 | 
|---|
| 726 |         }
 | 
|---|
| 727 |         else
 | 
|---|
| 728 |             printf("!failed!\n");
 | 
|---|
| 729 |     }
 | 
|---|
| 730 |     else
 | 
|---|
| 731 |         printf("!failed!\n");
 | 
|---|
| 732 | 
 | 
|---|
| 733 |     return rc;
 | 
|---|
| 734 | }
 | 
|---|
| 735 | 
 | 
|---|
| 736 | /**
 | 
|---|
| 737 |  * Test case 3.
 | 
|---|
| 738 |  * Checks that all parameters are read correctly (1).
 | 
|---|
| 739 |  *
 | 
|---|
| 740 |  * @sketch  Create init packet with no arguments.
 | 
|---|
| 741 |  *          Initiate elf$
 | 
|---|
| 742 |  *          Create init packet with no arguments.
 | 
|---|
| 743 |  *          Initiate win32k$
 | 
|---|
| 744 |  * @returns 0 on success.
 | 
|---|
| 745 |  *          1 on failure.
 | 
|---|
| 746 |  * @status  completely implemented.
 | 
|---|
| 747 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 748 |  */
 | 
|---|
| 749 | int TestCase3(void)
 | 
|---|
| 750 | {
 | 
|---|
| 751 |     int         rc = 1;
 | 
|---|
| 752 |     RP32INIT    rpinit;
 | 
|---|
| 753 |     char *      pszInitArgs = "-C1 -L:N -Verbose -Quiet -Elf:Yes -Pe:PE -Script:Yes -Rexx:NES -Java:NYes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
 | 
|---|
| 754 | 
 | 
|---|
| 755 |     /* $elf */
 | 
|---|
| 756 |     initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 757 |     rc = InitElf(&rpinit);              /* no SSToDS! */
 | 
|---|
| 758 |     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 759 |     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 760 |     {
 | 
|---|
| 761 |         /* $win32k */
 | 
|---|
| 762 |         initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 763 |         rc = InitWin32k(&rpinit);       /* no SSToDS! */
 | 
|---|
| 764 |         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 765 |         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 766 |         {
 | 
|---|
| 767 |             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
 | 
|---|
| 768 |             opt.cbSwpHeapInit   = 512000;
 | 
|---|
| 769 |             opt.cbSwpHeapMax    = 4096000;
 | 
|---|
| 770 |             opt.cbResHeapInit   = 0256000;
 | 
|---|
| 771 |             opt.cbResHeapMax    = 0x100000;
 | 
|---|
| 772 |             opt.fElf            = TRUE;
 | 
|---|
| 773 |             opt.fUNIXScript     = TRUE;
 | 
|---|
| 774 |             opt.fJava           = FALSE;
 | 
|---|
| 775 |             opt.fREXXScript     = FALSE;
 | 
|---|
| 776 |             opt.fPE             = FLAGS_PE_PE;
 | 
|---|
| 777 |             opt.fQuiet          = TRUE;
 | 
|---|
| 778 |             opt.fLogging        = FALSE;
 | 
|---|
| 779 |             opt.usCom           = OUTPUT_COM1;
 | 
|---|
| 780 |             opt.ulInfoLevel     = INFOLEVEL_INFOALL;
 | 
|---|
| 781 | 
 | 
|---|
| 782 |             rc = CompareOptions(SSToDS(&opt));
 | 
|---|
| 783 |             if (rc == NO_ERROR)
 | 
|---|
| 784 |             {
 | 
|---|
| 785 |                  rc = TestCaseExeLoad2();
 | 
|---|
| 786 |             }
 | 
|---|
| 787 |         }
 | 
|---|
| 788 |         else
 | 
|---|
| 789 |             printf("!failed!\n");
 | 
|---|
| 790 |     }
 | 
|---|
| 791 |     else
 | 
|---|
| 792 |         printf("!failed!\n");
 | 
|---|
| 793 | 
 | 
|---|
| 794 |     return rc;
 | 
|---|
| 795 | }
 | 
|---|
| 796 | 
 | 
|---|
| 797 | 
 | 
|---|
| 798 | /**
 | 
|---|
| 799 |  * Test case 4.
 | 
|---|
| 800 |  * Checks that all parameters are read correctly (3).
 | 
|---|
| 801 |  *
 | 
|---|
| 802 |  * @sketch  Create init packet with no arguments.
 | 
|---|
| 803 |  *          Initiate elf$
 | 
|---|
| 804 |  *          Create init packet with no arguments.
 | 
|---|
| 805 |  *          Initiate win32k$
 | 
|---|
| 806 |  * @returns 0 on success.
 | 
|---|
| 807 |  *          1 on failure.
 | 
|---|
| 808 |  * @status  completely implemented.
 | 
|---|
| 809 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 810 |  */
 | 
|---|
| 811 | int TestCase4(void)
 | 
|---|
| 812 | {
 | 
|---|
| 813 |     int         rc = 1;
 | 
|---|
| 814 |     RP32INIT    rpinit;
 | 
|---|
| 815 |     char *      pszInitArgs = "-P:pe";
 | 
|---|
| 816 | 
 | 
|---|
| 817 |     /* $elf */
 | 
|---|
| 818 |     initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 819 |     rc = InitElf(&rpinit);              /* no SSToDS! */
 | 
|---|
| 820 |     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 821 |     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 822 |     {
 | 
|---|
| 823 |         /* $win32k */
 | 
|---|
| 824 |         initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 825 |         rc = InitWin32k(&rpinit);       /* no SSToDS! */
 | 
|---|
| 826 |         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 827 |         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 828 |         {
 | 
|---|
| 829 |             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
 | 
|---|
| 830 |             opt.fPE             = FLAGS_PE_PE;
 | 
|---|
| 831 | 
 | 
|---|
| 832 |             rc = CompareOptions(SSToDS(&opt));
 | 
|---|
| 833 |             /*
 | 
|---|
| 834 |             if (rc == NO_ERROR)
 | 
|---|
| 835 |             {
 | 
|---|
| 836 |                  rc = TestCaseExeLoad2();
 | 
|---|
| 837 |             }
 | 
|---|
| 838 |             */
 | 
|---|
| 839 |         }
 | 
|---|
| 840 |         else
 | 
|---|
| 841 |             printf("!failed!\n");
 | 
|---|
| 842 |     }
 | 
|---|
| 843 |     else
 | 
|---|
| 844 |         printf("!failed!\n");
 | 
|---|
| 845 | 
 | 
|---|
| 846 |     return rc;
 | 
|---|
| 847 | }
 | 
|---|
| 848 | 
 | 
|---|
| 849 | 
 | 
|---|
| 850 | /**
 | 
|---|
| 851 |  * Test case 5.
 | 
|---|
| 852 |  * Checks that all parameters are read correctly (3).
 | 
|---|
| 853 |  *
 | 
|---|
| 854 |  * @sketch  Create init packet with no arguments.
 | 
|---|
| 855 |  *          Initiate elf$
 | 
|---|
| 856 |  *          Create init packet with no arguments.
 | 
|---|
| 857 |  *          Initiate win32k$
 | 
|---|
| 858 |  * @returns 0 on success.
 | 
|---|
| 859 |  *          1 on failure.
 | 
|---|
| 860 |  * @status  completely implemented.
 | 
|---|
| 861 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 862 |  */
 | 
|---|
| 863 | int TestCase5(void)
 | 
|---|
| 864 | {
 | 
|---|
| 865 |     int         rc = 1;
 | 
|---|
| 866 |     RP32INIT    rpinit;
 | 
|---|
| 867 |     char *      pszInitArgs = "-Pe:pe";
 | 
|---|
| 868 | 
 | 
|---|
| 869 |     /* $elf */
 | 
|---|
| 870 |     initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 871 |     rc = InitElf(&rpinit);              /* no SSToDS! */
 | 
|---|
| 872 |     printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 873 |     if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 874 |     {
 | 
|---|
| 875 |         /* $win32k */
 | 
|---|
| 876 |         initRPInit(SSToDS(&rpinit), pszInitArgs);
 | 
|---|
| 877 |         rc = InitWin32k(&rpinit);       /* no SSToDS! */
 | 
|---|
| 878 |         printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
 | 
|---|
| 879 |         if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
 | 
|---|
| 880 |         {
 | 
|---|
| 881 |             struct options opt = DEFAULT_OPTION_ASSIGMENTS;
 | 
|---|
| 882 |             opt.fPE             = FLAGS_PE_PE;
 | 
|---|
| 883 | 
 | 
|---|
| 884 |             rc = CompareOptions(SSToDS(&opt));
 | 
|---|
| 885 |             /*
 | 
|---|
| 886 |             if (rc == NO_ERROR)
 | 
|---|
| 887 |             {
 | 
|---|
| 888 |                  rc = TestCaseExeLoad2();
 | 
|---|
| 889 |             }
 | 
|---|
| 890 |             */
 | 
|---|
| 891 |         }
 | 
|---|
| 892 |         else
 | 
|---|
| 893 |             printf("!failed!\n");
 | 
|---|
| 894 |     }
 | 
|---|
| 895 |     else
 | 
|---|
| 896 |         printf("!failed!\n");
 | 
|---|
| 897 | 
 | 
|---|
| 898 |     return rc;
 | 
|---|
| 899 | }
 | 
|---|
| 900 | 
 | 
|---|
| 901 | 
 | 
|---|
| 902 | /**
 | 
|---|
| 903 |  * Compares the options with the option struct passed in.
 | 
|---|
| 904 |  * @returns 0 on success.
 | 
|---|
| 905 |  *          number of mismatches on error.
 | 
|---|
| 906 |  * @param   pOpt
 | 
|---|
| 907 |  * @status  completely implemented.
 | 
|---|
| 908 |  * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 909 |  */
 | 
|---|
| 910 | int CompareOptions(struct options *pOpt)
 | 
|---|
| 911 | {
 | 
|---|
| 912 |     int rc = 0;
 | 
|---|
| 913 |     /*
 | 
|---|
| 914 |      *  Check that the option struct is correct.
 | 
|---|
| 915 |      */
 | 
|---|
| 916 |     if (options.fQuiet != pOpt->fQuiet)
 | 
|---|
| 917 |         printf("fQuiet = %d - should be %d\n", options.fQuiet, pOpt->fQuiet, rc++);
 | 
|---|
| 918 |     if (options.usCom != pOpt->usCom)
 | 
|---|
| 919 |         printf("usCom = %d - should be %d\n", options.usCom, pOpt->usCom, rc++);
 | 
|---|
| 920 |     if (options.fLogging != pOpt->fLogging)
 | 
|---|
| 921 |         printf("fLogging = %d - should be %d\n", options.fLogging, pOpt->fLogging, rc++);
 | 
|---|
| 922 |     if (pOpt->ulBuild != ~0UL)
 | 
|---|
| 923 |     {
 | 
|---|
| 924 |         if (options.fKernel != pOpt->fKernel)
 | 
|---|
| 925 |             printf("fKernel = %x - should be %x\n", options.fKernel, pOpt->fKernel, rc++);
 | 
|---|
| 926 |         if (options.ulBuild != pOpt->ulBuild)
 | 
|---|
| 927 |             printf("ulBuild = %d - should be %d\n", options.ulBuild, pOpt->ulBuild, rc++);
 | 
|---|
| 928 |         if (options.usVerMajor != pOpt->usVerMajor)
 | 
|---|
| 929 |             printf("usVerMajor = %d - should be %d\n", options.usVerMajor, pOpt->usVerMajor, rc++);
 | 
|---|
| 930 |         if (options.usVerMinor != pOpt->usVerMinor)
 | 
|---|
| 931 |             printf("usVerMinor = %d - should be %d\n", options.usVerMinor, pOpt->usVerMinor, rc++);
 | 
|---|
| 932 |     }
 | 
|---|
| 933 |     if (options.fPE != pOpt->fPE)
 | 
|---|
| 934 |         printf("fPE = %d - should be %d\n", options.fPE, pOpt->fPE, rc++);
 | 
|---|
| 935 |     if (options.ulInfoLevel != pOpt->ulInfoLevel)
 | 
|---|
| 936 |         printf("ulInfoLevel = %d - should be %d\n", options.ulInfoLevel, pOpt->ulInfoLevel, rc++);
 | 
|---|
| 937 |     if (options.fElf != pOpt->fElf)
 | 
|---|
| 938 |         printf("fElf = %d - should be %d\n", options.fElf, pOpt->fElf, rc++);
 | 
|---|
| 939 |     if (options.fUNIXScript != pOpt->fUNIXScript)
 | 
|---|
| 940 |         printf("fUNIXScript = %d - should be %d\n", options.fUNIXScript, pOpt->fUNIXScript, rc++);
 | 
|---|
| 941 |     if (options.fREXXScript != pOpt->fREXXScript)
 | 
|---|
| 942 |         printf("fREXXScript = %d - should be %d\n", options.fREXXScript, pOpt->fREXXScript, rc++);
 | 
|---|
| 943 |     if (options.fJava != pOpt->fJava)
 | 
|---|
| 944 |         printf("fJava = %d - should be %d\n", options.fJava, pOpt->fJava, rc++);
 | 
|---|
| 945 |     if (options.fNoLoader != pOpt->fNoLoader)
 | 
|---|
| 946 |         printf("fNoLoader = %d - should be %d\n", options.fNoLoader, pOpt->fNoLoader, rc++);
 | 
|---|
| 947 |     if (options.cbSwpHeapInit != pOpt->cbSwpHeapInit)
 | 
|---|
| 948 |         printf("cbSwpHeapInit = %d - should be %d\n", options.cbSwpHeapInit, pOpt->cbSwpHeapInit, rc++);
 | 
|---|
| 949 |     if (options.cbSwpHeapMax != pOpt->cbSwpHeapMax)
 | 
|---|
| 950 |         printf("cbSwpHeapMax = %d - should be %d\n", options.cbSwpHeapMax, pOpt->cbSwpHeapMax, rc++);
 | 
|---|
| 951 |     if (options.cbResHeapInit != pOpt->cbResHeapInit)
 | 
|---|
| 952 |         printf("cbResHeapInit = %d - should be %d\n", options.cbResHeapInit, pOpt->cbResHeapInit, rc++);
 | 
|---|
| 953 |     if (options.cbResHeapMax != pOpt->cbResHeapMax)
 | 
|---|
| 954 |         printf("cbResHeapMax = %d - should be %d\n", options.cbResHeapMax, pOpt->cbResHeapMax, rc++);
 | 
|---|
| 955 | 
 | 
|---|
| 956 |     return rc;
 | 
|---|
| 957 | }
 | 
|---|
| 958 | 
 | 
|---|
| 959 | 
 | 
|---|
| 960 | /**
 | 
|---|
| 961 |  * Simulates a executable loading (no errors).
 | 
|---|
| 962 |  * This test requires a PE executable file named ExecLoad1.exe which
 | 
|---|
| 963 |  * imports the dll ExecLoad1d.dll.
 | 
|---|
| 964 |  *
 | 
|---|
| 965 |  * @returns 0 on success.
 | 
|---|
| 966 |  *          > 0 on failure.
 | 
|---|
| 967 |  * @sketch
 | 
|---|
| 968 |  * @status
 | 
|---|
| 969 |  * @author    knut st. osmundsen (knut.stange.osmundsen@mynd.no)
 | 
|---|
| 970 |  * @remark
 | 
|---|
| 971 |  */
 | 
|---|
| 972 | int TestCaseExeLoad2(void)
 | 
|---|
| 973 | {
 | 
|---|
| 974 |     APIRET rc;
 | 
|---|
| 975 |     int    cch;
 | 
|---|
| 976 |     char * psz;
 | 
|---|
| 977 | 
 | 
|---|
| 978 |     /*
 | 
|---|
| 979 |      * Set global parameters... FIXME.
 | 
|---|
| 980 |      */
 | 
|---|
| 981 | 
 | 
|---|
| 982 |     /*
 | 
|---|
| 983 |      * Do the real execution.
 | 
|---|
| 984 |      */
 | 
|---|
| 985 |     printf("--- TestcaseExeLoad2 - loading win32ktst.exe (LX image) ----\n");
 | 
|---|
| 986 |     rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "GLC6000.TMP");
 | 
|---|
| 987 |     if (rc == NO_ERROR)
 | 
|---|
| 988 |     {
 | 
|---|
| 989 |         psz = "BIN\\DEBUG\\LIBCONV.EXE\0";
 | 
|---|
| 990 |         printf("--- TestcaseExeLoad2 - loading libconv.exe (LX image) ----\n");
 | 
|---|
| 991 |         rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "bin\\debug\\libconv.exe");
 | 
|---|
| 992 |         if (rc == NO_ERROR)
 | 
|---|
| 993 |         {
 | 
|---|
| 994 |             #if 0 //not implemented by CalltkExecPgm...???
 | 
|---|
| 995 |             /* check result */
 | 
|---|
| 996 |             if (memcmp(achTkExecPgmArguments, psz, strlen(psz) + 1) != 0)
 | 
|---|
| 997 |             {
 | 
|---|
| 998 |                 rc  = ERROR_BAD_ARGUMENTS;
 | 
|---|
| 999 |                 printf("Bad Arguments! (%s)\n", achTkExecPgmArguments);
 | 
|---|
| 1000 |             }
 | 
|---|
| 1001 |             #else
 | 
|---|
| 1002 |             psz = psz;
 | 
|---|
| 1003 |             #endif
 | 
|---|
| 1004 |         }
 | 
|---|
| 1005 |     }
 | 
|---|
| 1006 | 
 | 
|---|
| 1007 |     if (rc == NO_ERROR)
 | 
|---|
| 1008 |     {
 | 
|---|
| 1009 |         psz = "REXX\\TST.RX\0OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
 | 
|---|
| 1010 |         printf("--- TestcaseExeLoad2 - loading rexx\\tst.rx (REXX script) ----\n");
 | 
|---|
| 1011 |         rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "rexx\\tst.rx");
 | 
|---|
| 1012 |         if (rc == NO_ERROR)
 | 
|---|
| 1013 |         {
 | 
|---|
| 1014 |             /* check result */
 | 
|---|
| 1015 |             psz = "REXX\\TST.RX OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
 | 
|---|
| 1016 |             cch = strlen(psz);
 | 
|---|
| 1017 |             if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
 | 
|---|
| 1018 |             {
 | 
|---|
| 1019 |                 rc  = ERROR_BAD_ARGUMENTS;
 | 
|---|
| 1020 |                 printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
 | 
|---|
| 1021 |             }
 | 
|---|
| 1022 |         }
 | 
|---|
| 1023 |     }
 | 
|---|
| 1024 | 
 | 
|---|
| 1025 |     if (rc == NO_ERROR)
 | 
|---|
| 1026 |     {
 | 
|---|
| 1027 |         psz = "TEST\\TST.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
 | 
|---|
| 1028 |         printf("--- TestcaseExeLoad2 - loading test\\tst.sh (UNIX shell script) ----\n");
 | 
|---|
| 1029 |         rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst.sh");
 | 
|---|
| 1030 |         if (rc == NO_ERROR)
 | 
|---|
| 1031 |         {
 | 
|---|
| 1032 |             /* check result */
 | 
|---|
| 1033 |             psz = "TEST\\TST.SH OrgArg1 OrgArg2\0OrgArg3\0";
 | 
|---|
| 1034 |             cch = strlen(psz);
 | 
|---|
| 1035 |             if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
 | 
|---|
| 1036 |             {
 | 
|---|
| 1037 |                 rc  = ERROR_BAD_ARGUMENTS;
 | 
|---|
| 1038 |                 printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
 | 
|---|
| 1039 |             }
 | 
|---|
| 1040 |         }
 | 
|---|
| 1041 |     }
 | 
|---|
| 1042 | 
 | 
|---|
| 1043 |     if (rc == NO_ERROR)
 | 
|---|
| 1044 |     {
 | 
|---|
| 1045 |         psz = "TEST\\TST2.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
 | 
|---|
| 1046 |         printf("--- TestcaseExeLoad2 - loading test\\tst2.sh (UNIX shell script) ----\n");
 | 
|---|
| 1047 |         rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst2.sh");
 | 
|---|
| 1048 |         if (rc == NO_ERROR)
 | 
|---|
| 1049 |         {
 | 
|---|
| 1050 |             /* check result */
 | 
|---|
| 1051 |             psz = "-arg1 -arg2 -arg3 TEST\\TST2.SH OrgArg1 OrgArg2\0OrgArg3\0";
 | 
|---|
| 1052 |             cch = strlen(psz) + 1;
 | 
|---|
| 1053 |             if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
 | 
|---|
| 1054 |             {
 | 
|---|
| 1055 |                 rc  = ERROR_BAD_ARGUMENTS;
 | 
|---|
| 1056 |                 printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
 | 
|---|
| 1057 |             }
 | 
|---|
| 1058 |         }
 | 
|---|
| 1059 |     }
 | 
|---|
| 1060 | 
 | 
|---|
| 1061 |     if (rc == NO_ERROR)
 | 
|---|
| 1062 |     {
 | 
|---|
| 1063 |         psz = "E:\\WIN32PROG\\SOL\\SOL.EXE\0";
 | 
|---|
| 1064 |         printf("--- TestcaseExeLoad2 - loading SOL.EXE (PE image) ----\n");
 | 
|---|
| 1065 |         rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "e:\\Win32Prog\\Sol\\Sol.exe");
 | 
|---|
| 1066 |         if (rc == NO_ERROR)
 | 
|---|
| 1067 |         {
 | 
|---|
| 1068 |             /* check result */
 | 
|---|
| 1069 |             cch = strlen(psz) + 1 + 1;
 | 
|---|
| 1070 |             if (memcmp(achTkExecPgmArguments, psz, cch) != 0)
 | 
|---|
| 1071 |             {
 | 
|---|
| 1072 |                 rc  = ERROR_BAD_ARGUMENTS;
 | 
|---|
| 1073 |                 printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
 | 
|---|
| 1074 |             }
 | 
|---|
| 1075 |         }
 | 
|---|
| 1076 |     }
 | 
|---|
| 1077 | 
 | 
|---|
| 1078 |     /*
 | 
|---|
| 1079 |      * The test is successful if rc == NO_ERROR (== 0).
 | 
|---|
| 1080 |      */
 | 
|---|
| 1081 |     return rc;
 | 
|---|
| 1082 | }
 | 
|---|
| 1083 | 
 | 
|---|