1 | /* $Id: win32ktst.c,v 1.8 2001-02-11 15:28:10 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 | #ifndef QS_MTE
|
---|
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 = (argv[6][0] == 'S' ? KF_SMP : (argv[6][0] == '4' ? KF_W4 | KF_UNI : KF_UNI))
|
---|
647 | | (argv[7][0] == 'A' || argv[7][0] == 'H' ? KF_DEBUG : 0);
|
---|
648 | if (argc >= 9 && argv[8][1] == '\0')
|
---|
649 | switch (argv[8][0])
|
---|
650 | {
|
---|
651 | case 'a': case 'A': opt.fKernel |= KF_REV_A; break;
|
---|
652 | case 'b': case 'B': opt.fKernel |= KF_REV_B; break;
|
---|
653 | case 'c': case 'C': opt.fKernel |= KF_REV_C; break;
|
---|
654 | case 'd': case 'D': opt.fKernel |= KF_REV_D; break;
|
---|
655 | case 'e': case 'E': opt.fKernel |= KF_REV_E; break;
|
---|
656 | default:
|
---|
657 | opt.fKernel = (argv[8][0] - (argv[8][0] >= 'a' ? 'a'-1 : 'A'-1)) << KF_REV_SHIFT;
|
---|
658 | }
|
---|
659 | opt.ulBuild = atoi(argv[5]);
|
---|
660 | opt.usVerMajor = (USHORT)atoi(argv[3]);
|
---|
661 | opt.usVerMinor = (USHORT)atoi(argv[4]);
|
---|
662 |
|
---|
663 | rc = CompareOptions(SSToDS(&opt));
|
---|
664 | }
|
---|
665 | else
|
---|
666 | printf("!failed!\n");
|
---|
667 | }
|
---|
668 | else
|
---|
669 | printf("!failed!\n");
|
---|
670 |
|
---|
671 | return rc;
|
---|
672 | }
|
---|
673 |
|
---|
674 | /**
|
---|
675 | * Test case 2.
|
---|
676 | * Checks that all parameters are read correctly (1).
|
---|
677 | *
|
---|
678 | * @sketch Create init packet with no arguments.
|
---|
679 | * Initiate elf$
|
---|
680 | * Create init packet with no arguments.
|
---|
681 | * Initiate win32k$
|
---|
682 | * @returns 0 on success.
|
---|
683 | * 1 on failure.
|
---|
684 | * @status completely implemented.
|
---|
685 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
686 | */
|
---|
687 | int TestCase2(void)
|
---|
688 | {
|
---|
689 | int rc = 1;
|
---|
690 | RP32INIT rpinit;
|
---|
691 | char * pszInitArgs = "-C1 -L:E -Verbose -Elf:Yes -Pe:Mixed -Script:Yes -W4 -Heap:512000 -ResHeap:0256000 -HeapMax:4096000 -ResHeapMax:0x100000";
|
---|
692 |
|
---|
693 | options.fLogging = TRUE;
|
---|
694 |
|
---|
695 | /* $elf */
|
---|
696 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
697 | rc = InitElf(&rpinit); /* no SSToDS! */
|
---|
698 | printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
|
---|
699 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
700 | {
|
---|
701 | /* $win32k */
|
---|
702 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
703 | rc = InitWin32k(&rpinit); /* no SSToDS! */
|
---|
704 | printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
|
---|
705 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
706 | {
|
---|
707 | struct options opt = DEFAULT_OPTION_ASSIGMENTS;
|
---|
708 | opt.cbSwpHeapInit = 512000;
|
---|
709 | opt.cbSwpHeapMax = 4096000;
|
---|
710 | opt.cbResHeapInit = 0256000;
|
---|
711 | opt.cbResHeapMax = 0x100000;
|
---|
712 | opt.fElf = TRUE;
|
---|
713 | opt.fUNIXScript = TRUE;
|
---|
714 | opt.fPE = FLAGS_PE_MIXED;
|
---|
715 | opt.fQuiet = FALSE;
|
---|
716 | opt.fLogging = TRUE;
|
---|
717 | opt.usCom = OUTPUT_COM1;
|
---|
718 | opt.ulInfoLevel = INFOLEVEL_INFOALL;
|
---|
719 |
|
---|
720 | rc = CompareOptions(SSToDS(&opt));
|
---|
721 | if (rc == NO_ERROR)
|
---|
722 | {
|
---|
723 | rc = TestCaseExeLoad2();
|
---|
724 | }
|
---|
725 | }
|
---|
726 | else
|
---|
727 | printf("!failed!\n");
|
---|
728 | }
|
---|
729 | else
|
---|
730 | printf("!failed!\n");
|
---|
731 |
|
---|
732 | return rc;
|
---|
733 | }
|
---|
734 |
|
---|
735 | /**
|
---|
736 | * Test case 3.
|
---|
737 | * Checks that all parameters are read correctly (1).
|
---|
738 | *
|
---|
739 | * @sketch Create init packet with no arguments.
|
---|
740 | * Initiate elf$
|
---|
741 | * Create init packet with no arguments.
|
---|
742 | * Initiate win32k$
|
---|
743 | * @returns 0 on success.
|
---|
744 | * 1 on failure.
|
---|
745 | * @status completely implemented.
|
---|
746 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
747 | */
|
---|
748 | int TestCase3(void)
|
---|
749 | {
|
---|
750 | int rc = 1;
|
---|
751 | RP32INIT rpinit;
|
---|
752 | 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";
|
---|
753 |
|
---|
754 | /* $elf */
|
---|
755 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
756 | rc = InitElf(&rpinit); /* no SSToDS! */
|
---|
757 | printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
|
---|
758 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
759 | {
|
---|
760 | /* $win32k */
|
---|
761 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
762 | rc = InitWin32k(&rpinit); /* no SSToDS! */
|
---|
763 | printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
|
---|
764 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
765 | {
|
---|
766 | struct options opt = DEFAULT_OPTION_ASSIGMENTS;
|
---|
767 | opt.cbSwpHeapInit = 512000;
|
---|
768 | opt.cbSwpHeapMax = 4096000;
|
---|
769 | opt.cbResHeapInit = 0256000;
|
---|
770 | opt.cbResHeapMax = 0x100000;
|
---|
771 | opt.fElf = TRUE;
|
---|
772 | opt.fUNIXScript = TRUE;
|
---|
773 | opt.fJava = FALSE;
|
---|
774 | opt.fREXXScript = FALSE;
|
---|
775 | opt.fPE = FLAGS_PE_PE;
|
---|
776 | opt.fQuiet = TRUE;
|
---|
777 | opt.fLogging = FALSE;
|
---|
778 | opt.usCom = OUTPUT_COM1;
|
---|
779 | opt.ulInfoLevel = INFOLEVEL_INFOALL;
|
---|
780 |
|
---|
781 | rc = CompareOptions(SSToDS(&opt));
|
---|
782 | if (rc == NO_ERROR)
|
---|
783 | {
|
---|
784 | rc = TestCaseExeLoad2();
|
---|
785 | }
|
---|
786 | }
|
---|
787 | else
|
---|
788 | printf("!failed!\n");
|
---|
789 | }
|
---|
790 | else
|
---|
791 | printf("!failed!\n");
|
---|
792 |
|
---|
793 | return rc;
|
---|
794 | }
|
---|
795 |
|
---|
796 |
|
---|
797 | /**
|
---|
798 | * Test case 4.
|
---|
799 | * Checks that all parameters are read correctly (3).
|
---|
800 | *
|
---|
801 | * @sketch Create init packet with no arguments.
|
---|
802 | * Initiate elf$
|
---|
803 | * Create init packet with no arguments.
|
---|
804 | * Initiate win32k$
|
---|
805 | * @returns 0 on success.
|
---|
806 | * 1 on failure.
|
---|
807 | * @status completely implemented.
|
---|
808 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
809 | */
|
---|
810 | int TestCase4(void)
|
---|
811 | {
|
---|
812 | int rc = 1;
|
---|
813 | RP32INIT rpinit;
|
---|
814 | char * pszInitArgs = "-P:pe";
|
---|
815 |
|
---|
816 | /* $elf */
|
---|
817 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
818 | rc = InitElf(&rpinit); /* no SSToDS! */
|
---|
819 | printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
|
---|
820 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
821 | {
|
---|
822 | /* $win32k */
|
---|
823 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
824 | rc = InitWin32k(&rpinit); /* no SSToDS! */
|
---|
825 | printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
|
---|
826 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
827 | {
|
---|
828 | struct options opt = DEFAULT_OPTION_ASSIGMENTS;
|
---|
829 | opt.fPE = FLAGS_PE_PE;
|
---|
830 |
|
---|
831 | rc = CompareOptions(SSToDS(&opt));
|
---|
832 | /*
|
---|
833 | if (rc == NO_ERROR)
|
---|
834 | {
|
---|
835 | rc = TestCaseExeLoad2();
|
---|
836 | }
|
---|
837 | */
|
---|
838 | }
|
---|
839 | else
|
---|
840 | printf("!failed!\n");
|
---|
841 | }
|
---|
842 | else
|
---|
843 | printf("!failed!\n");
|
---|
844 |
|
---|
845 | return rc;
|
---|
846 | }
|
---|
847 |
|
---|
848 |
|
---|
849 | /**
|
---|
850 | * Test case 5.
|
---|
851 | * Checks that all parameters are read correctly (3).
|
---|
852 | *
|
---|
853 | * @sketch Create init packet with no arguments.
|
---|
854 | * Initiate elf$
|
---|
855 | * Create init packet with no arguments.
|
---|
856 | * Initiate win32k$
|
---|
857 | * @returns 0 on success.
|
---|
858 | * 1 on failure.
|
---|
859 | * @status completely implemented.
|
---|
860 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
861 | */
|
---|
862 | int TestCase5(void)
|
---|
863 | {
|
---|
864 | int rc = 1;
|
---|
865 | RP32INIT rpinit;
|
---|
866 | char * pszInitArgs = "-Pe:pe";
|
---|
867 |
|
---|
868 | /* $elf */
|
---|
869 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
870 | rc = InitElf(&rpinit); /* no SSToDS! */
|
---|
871 | printf("InitElf returned status=0x%04x\n", rpinit.rph.Status);
|
---|
872 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
873 | {
|
---|
874 | /* $win32k */
|
---|
875 | initRPInit(SSToDS(&rpinit), pszInitArgs);
|
---|
876 | rc = InitWin32k(&rpinit); /* no SSToDS! */
|
---|
877 | printf("InitWin32k returned status=0x%04x\n", rpinit.rph.Status);
|
---|
878 | if ((rpinit.rph.Status & (STDON | STERR)) == STDON)
|
---|
879 | {
|
---|
880 | struct options opt = DEFAULT_OPTION_ASSIGMENTS;
|
---|
881 | opt.fPE = FLAGS_PE_PE;
|
---|
882 |
|
---|
883 | rc = CompareOptions(SSToDS(&opt));
|
---|
884 | /*
|
---|
885 | if (rc == NO_ERROR)
|
---|
886 | {
|
---|
887 | rc = TestCaseExeLoad2();
|
---|
888 | }
|
---|
889 | */
|
---|
890 | }
|
---|
891 | else
|
---|
892 | printf("!failed!\n");
|
---|
893 | }
|
---|
894 | else
|
---|
895 | printf("!failed!\n");
|
---|
896 |
|
---|
897 | return rc;
|
---|
898 | }
|
---|
899 |
|
---|
900 |
|
---|
901 | /**
|
---|
902 | * Compares the options with the option struct passed in.
|
---|
903 | * @returns 0 on success.
|
---|
904 | * number of mismatches on error.
|
---|
905 | * @param pOpt
|
---|
906 | * @status completely implemented.
|
---|
907 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
908 | */
|
---|
909 | int CompareOptions(struct options *pOpt)
|
---|
910 | {
|
---|
911 | int rc = 0;
|
---|
912 | /*
|
---|
913 | * Check that the option struct is correct.
|
---|
914 | */
|
---|
915 | if (options.fQuiet != pOpt->fQuiet)
|
---|
916 | printf("fQuiet = %d - should be %d\n", options.fQuiet, pOpt->fQuiet, rc++);
|
---|
917 | if (options.usCom != pOpt->usCom)
|
---|
918 | printf("usCom = %d - should be %d\n", options.usCom, pOpt->usCom, rc++);
|
---|
919 | if (options.fLogging != pOpt->fLogging)
|
---|
920 | printf("fLogging = %d - should be %d\n", options.fLogging, pOpt->fLogging, rc++);
|
---|
921 | if (pOpt->ulBuild != ~0UL)
|
---|
922 | {
|
---|
923 | if (options.fKernel != pOpt->fKernel)
|
---|
924 | printf("fKernel = %x - should be %x\n", options.fKernel, pOpt->fKernel, rc++);
|
---|
925 | if (options.ulBuild != pOpt->ulBuild)
|
---|
926 | printf("ulBuild = %d - should be %d\n", options.ulBuild, pOpt->ulBuild, rc++);
|
---|
927 | if (options.usVerMajor != pOpt->usVerMajor)
|
---|
928 | printf("usVerMajor = %d - should be %d\n", options.usVerMajor, pOpt->usVerMajor, rc++);
|
---|
929 | if (options.usVerMinor != pOpt->usVerMinor)
|
---|
930 | printf("usVerMinor = %d - should be %d\n", options.usVerMinor, pOpt->usVerMinor, rc++);
|
---|
931 | }
|
---|
932 | if (options.fPE != pOpt->fPE)
|
---|
933 | printf("fPE = %d - should be %d\n", options.fPE, pOpt->fPE, rc++);
|
---|
934 | if (options.ulInfoLevel != pOpt->ulInfoLevel)
|
---|
935 | printf("ulInfoLevel = %d - should be %d\n", options.ulInfoLevel, pOpt->ulInfoLevel, rc++);
|
---|
936 | if (options.fElf != pOpt->fElf)
|
---|
937 | printf("fElf = %d - should be %d\n", options.fElf, pOpt->fElf, rc++);
|
---|
938 | if (options.fUNIXScript != pOpt->fUNIXScript)
|
---|
939 | printf("fUNIXScript = %d - should be %d\n", options.fUNIXScript, pOpt->fUNIXScript, rc++);
|
---|
940 | if (options.fREXXScript != pOpt->fREXXScript)
|
---|
941 | printf("fREXXScript = %d - should be %d\n", options.fREXXScript, pOpt->fREXXScript, rc++);
|
---|
942 | if (options.fJava != pOpt->fJava)
|
---|
943 | printf("fJava = %d - should be %d\n", options.fJava, pOpt->fJava, rc++);
|
---|
944 | if (options.fNoLoader != pOpt->fNoLoader)
|
---|
945 | printf("fNoLoader = %d - should be %d\n", options.fNoLoader, pOpt->fNoLoader, rc++);
|
---|
946 | if (options.cbSwpHeapInit != pOpt->cbSwpHeapInit)
|
---|
947 | printf("cbSwpHeapInit = %d - should be %d\n", options.cbSwpHeapInit, pOpt->cbSwpHeapInit, rc++);
|
---|
948 | if (options.cbSwpHeapMax != pOpt->cbSwpHeapMax)
|
---|
949 | printf("cbSwpHeapMax = %d - should be %d\n", options.cbSwpHeapMax, pOpt->cbSwpHeapMax, rc++);
|
---|
950 | if (options.cbResHeapInit != pOpt->cbResHeapInit)
|
---|
951 | printf("cbResHeapInit = %d - should be %d\n", options.cbResHeapInit, pOpt->cbResHeapInit, rc++);
|
---|
952 | if (options.cbResHeapMax != pOpt->cbResHeapMax)
|
---|
953 | printf("cbResHeapMax = %d - should be %d\n", options.cbResHeapMax, pOpt->cbResHeapMax, rc++);
|
---|
954 |
|
---|
955 | return rc;
|
---|
956 | }
|
---|
957 |
|
---|
958 |
|
---|
959 | /**
|
---|
960 | * Simulates a executable loading (no errors).
|
---|
961 | * This test requires a PE executable file named ExecLoad1.exe which
|
---|
962 | * imports the dll ExecLoad1d.dll.
|
---|
963 | *
|
---|
964 | * @returns 0 on success.
|
---|
965 | * > 0 on failure.
|
---|
966 | * @sketch
|
---|
967 | * @status
|
---|
968 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
969 | * @remark
|
---|
970 | */
|
---|
971 | int TestCaseExeLoad2(void)
|
---|
972 | {
|
---|
973 | APIRET rc;
|
---|
974 | int cch;
|
---|
975 | char * psz;
|
---|
976 |
|
---|
977 | /*
|
---|
978 | * Set global parameters... FIXME.
|
---|
979 | */
|
---|
980 |
|
---|
981 | /*
|
---|
982 | * Do the real execution.
|
---|
983 | */
|
---|
984 | printf("--- TestcaseExeLoad2 - loading win32ktst.exe (LX image) ----\n");
|
---|
985 | rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "GLC6000.TMP");
|
---|
986 | if (rc == NO_ERROR)
|
---|
987 | {
|
---|
988 | psz = "BIN\\DEBUG\\LIBCONV.EXE\0";
|
---|
989 | printf("--- TestcaseExeLoad2 - loading libconv.exe (LX image) ----\n");
|
---|
990 | rc = CalltkExecPgm(EXEC_LOAD, NULL, NULL, "bin\\debug\\libconv.exe");
|
---|
991 | if (rc == NO_ERROR)
|
---|
992 | {
|
---|
993 | #if 0 //not implemented by CalltkExecPgm...???
|
---|
994 | /* check result */
|
---|
995 | if (memcmp(achTkExecPgmArguments, psz, strlen(psz) + 1) != 0)
|
---|
996 | {
|
---|
997 | rc = ERROR_BAD_ARGUMENTS;
|
---|
998 | printf("Bad Arguments! (%s)\n", achTkExecPgmArguments);
|
---|
999 | }
|
---|
1000 | #else
|
---|
1001 | psz = psz;
|
---|
1002 | #endif
|
---|
1003 | }
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | if (rc == NO_ERROR)
|
---|
1007 | {
|
---|
1008 | psz = "REXX\\TST.RX\0OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
|
---|
1009 | printf("--- TestcaseExeLoad2 - loading rexx\\tst.rx (REXX script) ----\n");
|
---|
1010 | rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "rexx\\tst.rx");
|
---|
1011 | if (rc == NO_ERROR)
|
---|
1012 | {
|
---|
1013 | /* check result */
|
---|
1014 | psz = "REXX\\TST.RX OriginalArgument1 OriginalArgument2\0OriginalArgument3\0";
|
---|
1015 | cch = strlen(psz);
|
---|
1016 | if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
|
---|
1017 | {
|
---|
1018 | rc = ERROR_BAD_ARGUMENTS;
|
---|
1019 | printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 | if (rc == NO_ERROR)
|
---|
1025 | {
|
---|
1026 | psz = "TEST\\TST.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
|
---|
1027 | printf("--- TestcaseExeLoad2 - loading test\\tst.sh (UNIX shell script) ----\n");
|
---|
1028 | rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst.sh");
|
---|
1029 | if (rc == NO_ERROR)
|
---|
1030 | {
|
---|
1031 | /* check result */
|
---|
1032 | psz = "TEST\\TST.SH OrgArg1 OrgArg2\0OrgArg3\0";
|
---|
1033 | cch = strlen(psz);
|
---|
1034 | if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
|
---|
1035 | {
|
---|
1036 | rc = ERROR_BAD_ARGUMENTS;
|
---|
1037 | printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | if (rc == NO_ERROR)
|
---|
1043 | {
|
---|
1044 | psz = "TEST\\TST2.SH\0OrgArg1 OrgArg2\0OrgArg3\0";
|
---|
1045 | printf("--- TestcaseExeLoad2 - loading test\\tst2.sh (UNIX shell script) ----\n");
|
---|
1046 | rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "test\\tst2.sh");
|
---|
1047 | if (rc == NO_ERROR)
|
---|
1048 | {
|
---|
1049 | /* check result */
|
---|
1050 | psz = "-arg1 -arg2 -arg3 TEST\\TST2.SH OrgArg1 OrgArg2\0OrgArg3\0";
|
---|
1051 | cch = strlen(psz) + 1;
|
---|
1052 | if (memcmp(achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1, psz, cch) != 0)
|
---|
1053 | {
|
---|
1054 | rc = ERROR_BAD_ARGUMENTS;
|
---|
1055 | printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | if (rc == NO_ERROR)
|
---|
1061 | {
|
---|
1062 | psz = "E:\\WIN32PROG\\SOL\\SOL.EXE\0";
|
---|
1063 | printf("--- TestcaseExeLoad2 - loading SOL.EXE (PE image) ----\n");
|
---|
1064 | rc = CalltkExecPgm(EXEC_LOAD, psz, NULL, "e:\\Win32Prog\\Sol\\Sol.exe");
|
---|
1065 | if (rc == NO_ERROR)
|
---|
1066 | {
|
---|
1067 | /* check result */
|
---|
1068 | cch = strlen(psz) + 1 + 1;
|
---|
1069 | if (memcmp(achTkExecPgmArguments, psz, cch) != 0)
|
---|
1070 | {
|
---|
1071 | rc = ERROR_BAD_ARGUMENTS;
|
---|
1072 | printf("Bad Arguments! (achTkExecPgmArguments=%s).\n", achTkExecPgmArguments + strlen(achTkExecPgmArguments) + 1);
|
---|
1073 | }
|
---|
1074 | }
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | /*
|
---|
1078 | * The test is successful if rc == NO_ERROR (== 0).
|
---|
1079 | */
|
---|
1080 | return rc;
|
---|
1081 | }
|
---|
1082 |
|
---|