source: trunk/src/win32k/dev16/probkrnl.c@ 4222

Last change on this file since 4222 was 4222, checked in by bird, 25 years ago

Removed ldrSetVMflags which am was only experimenting with...

File size: 42.6 KB
Line 
1/* $Id: probkrnl.c,v 1.24 2000-09-08 15:29:01 bird Exp $
2 *
3 * Description: Autoprobes the os2krnl file and os2krnl[*].sym files.
4 * Another Hack!
5 *
6 * 16-bit inittime code.
7 *
8 * All data has to be initiated because this is 16-bit C code
9 * and is to be linked with 32-bit C/C++ code. Uninitiazlied
10 * data ends up in the BSS segment, and that segment can't
11 * both be 32-bit and 16-bit. I have not found any other way
12 * around this problem that initiating all data.
13 *
14 * How this works:
15 * 1. parses the device-line parameters and collects some "SysInfo".
16 * 2. gets the kernel object table and kernel info like build no. (elf$)
17 * 3. if non-debug kernel the symbol database is scanned to get the syms
18 * 4. if Syms not found THEN locates and scans the symbol-file(s) for the
19 * entrypoints which are wanted.
20 * 5. the entry points are verified. (elf$)
21 * 6. finished.
22 *
23 * Copyright (c) 1998-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
24 *
25 * Project Odin Software License can be found in LICENSE.TXT
26 *
27 */
28
29
30/*******************************************************************************
31* Defined Constants And Macros *
32*******************************************************************************/
33/* Disable logging when doing extracts */
34#if defined(EXTRACT) || defined(RING0)
35 #define NOLOGGING 1
36#endif
37
38#define fclose(a) DosClose(a)
39#define SEEK_SET FILE_BEGIN
40#define SEEK_END FILE_END
41
42#define WORD unsigned short int
43#define DWORD unsigned long int
44
45/* "@#IBM:14.039#@ os2krnl... "*/
46/* "@#IBM:8.264#@ os2krnl... "*/
47#define KERNEL_ID_STRING_LENGTH 42
48#define KERNEL_READ_SIZE 512
49
50#define INCL_BASE
51#define INCL_DOS
52#define INCL_NOPMAPI
53
54/*******************************************************************************
55* Header Files *
56*******************************************************************************/
57#include <os2.h>
58
59#include <exe386.h>
60#include <strat2.h>
61#include <reqpkt.h>
62
63#include "devSegDf.h"
64#undef DATA16_INIT
65#define DATA16_INIT
66#undef CODE16_INIT
67#define CODE16_INIT
68#include "os2krnl.h" /* must be included before dev1632.h! */
69#include "sym.h"
70#include "probkrnl.h"
71#include "dev16.h"
72#include "dev1632.h"
73#include "vprntf16.h"
74#include "log.h"
75#include "options.h"
76#include "errors.h"
77
78/*******************************************************************************
79* Global Variables *
80* Note: must be inited or else we'll get BSS segment *
81*******************************************************************************/
82
83
84/*
85 * aImportTab defines the imported and overloaded OS/2 kernel functions.
86 * IMPORTANT: aImportTab has two sibling arrays, one in d32init.c, aulProc, and
87 * the calltab.asm, which must match entry by entry.
88 * When adding/removing/shuffling items in aImportTab, aulProc and
89 * calltab.asm has to be updated immediately!
90 */
91IMPORTKRNLSYM DATA16_GLOBAL aImportTab[NBR_OF_KRNLIMPORTS] =
92{/* iFound cchName offObject usSel fType */
93 /* iObject achName ulAddress cProlog */
94 {FALSE, -1, 8, "_ldrRead", -1, -1, -1, -1, EPT_PROC32}, /* 0 */
95 {FALSE, -1, 8, "_ldrOpen", -1, -1, -1, -1, EPT_PROC32}, /* 1 */
96 {FALSE, -1, 9, "_ldrClose", -1, -1, -1, -1, EPT_PROC32}, /* 2 */
97 {FALSE, -1, 12, "_LDRQAppType", -1, -1, -1, -1, EPT_PROC32}, /* 3 */
98 {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1, -1, -1, -1, EPT_PROC32}, /* 4 */
99 {FALSE, -1, 10, "_IOSftOpen", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 5 */
100 {FALSE, -1, 11, "_IOSftClose", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 6 */
101 {FALSE, -1, 15, "_IOSftTransPath", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 7 */
102 {FALSE, -1, 12, "_IOSftReadAt", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 8 */
103 {FALSE, -1, 13, "_IOSftWriteAt", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 9 */
104 {FALSE, -1, 12, "_SftFileSize", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 10 */
105 {FALSE, -1, 11, "_VMAllocMem", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 11 */
106 {FALSE, -1, 11, "_VMGetOwner", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 12 */
107 {FALSE, -1, 11, "g_tkExecPgm", -1, -1, -1, -1, EPT_PROC32}, /* 13 */
108 {FALSE, -1, 15, "_tkStartProcess", -1, -1, -1, -1, EPT_PROC32}, /* 14 */
109 {FALSE, -1, 11, "f_FuStrLenZ", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 15 */
110 {FALSE, -1, 10, "f_FuStrLen", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 16 */
111 {FALSE, -1, 8, "f_FuBuff", -1, -1, -1, -1, EPT_PROCIMPORT16}, /* 17 */
112 {FALSE, -1, 16, "_VMObjHandleInfo", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 18 */
113 {FALSE, -1, 21, "_ldrASMpMTEFromHandle",-1, -1, -1, -1, EPT_PROCIMPORT32}, /* 19 */
114 {FALSE, -1, 12, "_ldrOpenPath", -1, -1, -1, -1, EPT_PROC32}, /* 20 */
115 {FALSE, -1, 12, "_LDRClearSem", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 21 */
116 {FALSE, -1, 14, "_ldrFindModule", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 22 */
117 {FALSE, -1, 17, "_KSEMRequestMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 23 */
118 {FALSE, -1, 17, "_KSEMReleaseMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 24 */
119 {FALSE, -1, 15, "_KSEMQueryMutex", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 25 */
120 {FALSE, -1, 9, "_KSEMInit", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 26 */
121 {FALSE, -1, 7, "_LdrSem", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 27 */
122 {FALSE, -1, 11, "_LDRLibPath", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 28 */
123 {FALSE, -1, 9, "_TKSuBuff", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 29 */
124 {FALSE, -1, 9, "_TKFuBuff", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 30 */
125 {FALSE, -1, 11, "_TKFuBufLen", -1, -1, -1, -1, EPT_PROCIMPORT32}, /* 31 */
126 {FALSE, -1, 21, "_ldrValidateMteHandle",-1, -1, -1, -1, EPT_PROCIMPORT32}, /* 32 */
127 {FALSE, -1, 8, "_pTCBCur", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 33 */
128 {FALSE, -1, 9, "_pPTDACur", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 34 */
129 {FALSE, -1, 10, "ptda_start", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 35 */
130 {FALSE, -1, 12, "ptda_environ", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 36 */
131 {FALSE, -1, 12, "ptda_ptdasem", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 37 */
132 {FALSE, -1, 11, "ptda_module", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 38 */
133 {FALSE, -1, 18, "ptda_pBeginLIBPATH", -1, -1, -1, -1, EPT_VARIMPORT16}, /* 39 */
134 {FALSE, -1, 16, "_ldrpFileNameBuf", -1, -1, -1, -1, EPT_VARIMPORT32}, /* 40 */
135 {FALSE, -1, 14, "SecPathFromSFN", -1, -1, -1, -1, EPT_PROCIMPORTNR32},/* 41 */
136
137};
138
139/**
140 * szSymbolFile holds the name of the symbol file used.
141 *
142 */
143char DATA16_GLOBAL szSymbolFile[60] = {0};
144
145/**
146 * iProc holds the number of the procedure which failed during verify.
147 */
148int DATA16_GLOBAL iProc = -1; /* The procedure number which failed Verify. */
149
150
151
152/*
153 * privat data
154 */
155static char * DATA16_INIT apszSym[] =
156{
157 {"c:\\os2krnl.sym"}, /* usual for debugkernel */
158 {"c:\\os2\\pdpsi\\pmdf\\warp4\\os2krnlr.sym"}, /* warp 4 */
159 {"c:\\os2\\pdpsi\\pmdf\\warp4\\os2krnld.sym"}, /* warp 4 */
160 {"c:\\os2\\pdpsi\\pmdf\\warp4\\os2krnlb.sym"}, /* warp 4 */
161 {"c:\\os2\\pdpsi\\pmdf\\warp45_u\\os2krnlr.sym"}, /* warp 45 */
162 {"c:\\os2\\pdpsi\\pmdf\\warp45_u\\os2krnld.sym"}, /* warp 45 */
163 {"c:\\os2\\pdpsi\\pmdf\\warp45_u\\os2krnlb.sym"}, /* warp 45 */
164 {"c:\\os2\\pdpsi\\pmdf\\warp45_s\\os2krnlr.sym"}, /* warp 45 */
165 {"c:\\os2\\pdpsi\\pmdf\\warp45_s\\os2krnld.sym"}, /* warp 45 */
166 {"c:\\os2\\pdpsi\\pmdf\\warp45_s\\os2krnlb.sym"}, /* warp 45 */
167 {"c:\\os2\\system\\trace\\os2krnl.sym"}, /* warp 3 ?*/
168 {"c:\\os2\\system\\pmdf\\os2krnlr.sym"}, /* warp 3 ?*/
169 {"c:\\os2krnlr.sym"}, /* custom */
170 {"c:\\os2krnlh.sym"}, /* custom */
171 {"c:\\os2krnld.sym"}, /* custom */
172 NULL
173};
174
175/* Result from GetKernelInfo/ReadOS2Krnl. */
176unsigned char DATA16_INIT cObjects = 0;
177POTE DATA16_INIT paKrnlOTEs = NULL;
178
179
180/*
181 *
182 */
183static struct
184{
185 short sErr;
186 const char *pszMsg;
187} DATA16_INIT aErrorMsgs[] =
188{
189 {ERROR_PROB_KRNL_OPEN_FAILED, "Krnl: Failed to open kernel file."},
190 {ERROR_PROB_KRNL_SEEK_SIZE, "Krnl: Failed to seek to end to of file."},
191 {ERROR_PROB_KRNL_SEEK_FIRST, "Krnl: Failed to start of file."},
192 {ERROR_PROB_KRNL_READ_FIRST, "Krnl: Failed to read (first)."},
193 {ERROR_PROB_KRNL_READ_NEXT, "Krnl: Failed to read."},
194 {ERROR_PROB_KRNL_TAG_NOT_FOUND, "Krnl: Build level tag was not found."},
195 {ERROR_PROB_KRNL_INV_SIGANTURE, "Krnl: Invalid build level signature."},
196 {ERROR_PROB_KRNL_INV_BUILD_NBR, "Krnl: Invalid build level number."},
197 {ERROR_PROB_KRNL_BUILD_VERSION, "Krnl: Invalid build level version."},
198 {ERROR_PROB_KRNL_MZ_SEEK, "Krnl: Failed to seek to start of file. (MZ)"},
199 {ERROR_PROB_KRNL_MZ_READ, "Krnl: Failed to read MZ header."},
200 {ERROR_PROB_KRNL_NEOFF_INVALID, "Krnl: Invalid new-header offset in MZ header."},
201 {ERROR_PROB_KRNL_NEOFF_SEEK, "Krnl: Failed to seek to new-header offset."},
202 {ERROR_PROB_KRNL_LX_READ, "Krnl: Failed to read LX header."},
203 {ERROR_PROB_KRNL_LX_SIGNATURE, "Krnl: Invalid LX header signature."},
204 {ERROR_PROB_KRNL_OBJECT_CNT, "Krnl: Object count don't match the running kernel."},
205 {ERROR_PROB_KRNL_OBJECT_CNR_10, "Krnl: Less than 10 objects - not a valid kernel file!"},
206 {ERROR_PROB_KRNL_OTE_SEEK, "Krnl: Failed to seek to OTEs."},
207 {ERROR_PROB_KRNL_OTE_READ, "Krnl: Failed to read OTEs."},
208 {ERROR_PROB_KRNL_OTE_SIZE_MIS, "Krnl: Size of a OTE didn't match the running kernel."},
209
210 /*
211 * ProbeSymFile error messages + some extra ones.
212 */
213 {ERROR_PROB_SYM_FILE_NOT_FOUND, "Sym: Symbol file was not found."},
214 {ERROR_PROB_SYM_READERROR, "Sym: Read failed."},
215 {ERROR_PROB_SYM_INVALID_MOD_NAME, "Sym: Invalid module name (not OS2KRNL)."},
216 {ERROR_PROB_SYM_SEGS_NE_OBJS, "Sym: Number of segments don't match the object count of the kernel."},
217 {ERROR_PROB_SYM_SEG_DEF_SEEK, "Sym: Failed to seek to a segment definition."},
218 {ERROR_PROB_SYM_SEG_DEF_READ, "Sym: Failed to read a segment definition."},
219 {ERROR_PROB_SYM_IMPORTS_NOTFOUND, "Sym: Some of the imports wasn't found."},
220 {ERROR_PROB_SYM_V_PROC_NOT_FND, "Sym: Verify failed: Procedure not found."},
221 {ERROR_PROB_SYM_V_OBJ_OR_ADDR, "Sym: Verify failed: Invalid object or address."},
222 {ERROR_PROB_SYM_V_ADDRESS, "Sym: Verify failed: Invalid address."},
223 {ERROR_PROB_SYM_V_PROLOG, "Sym: Verify failed: Invalid prolog."},
224 {ERROR_PROB_SYM_V_NOT_IMPL, "Sym: Verify failed: Not implemented."},
225 {ERROR_PROB_SYM_V_GETOS2KRNL, "GetOs2Krnl: failed."},
226 {ERROR_PROB_SYM_V_NO_SWAPMTE, "GetOs2Krnl: No Swap MTE."},
227 {ERROR_PROB_SYM_V_OBJECTS, "GetOs2Krnl: Too many objects."},
228 {ERROR_PROB_SYM_V_OBJECT_TABLE, "GetOs2Krnl: No object table."},
229 {ERROR_PROB_SYM_V_BUILD_INFO, "GetOs2Krnl: Build info not found."},
230 {ERROR_PROB_SYM_V_INVALID_BUILD, "GetOs2Krnl: Unsupported build."},
231 {ERROR_PROB_SYM_V_VERIFY, "importTabInit: Import failed."},
232 {ERROR_PROB_SYM_V_IPE, "importTabInit: Internal-Processing-Error."},
233 {ERROR_PROB_SYM_V_HEAPINIT, "R0Init32: HeapInit Failed."},
234 {ERROR_PROB_SYM_V_D32_LDR_INIT, "R0Init32: ldrInit Failed."},
235
236 {ERROR_PROB_SYMDB_KRNL_NOT_FOUND, "SymDB: Kernel was not found."}
237};
238
239/*
240 * Fake data for Ring-3 testing.
241 */
242#ifdef R3TST
243USHORT DATA16_INIT usFakeVerMajor = 0;
244USHORT DATA16_INIT usFakeVerMinor = 0;
245#ifdef R3TST
246static DATA16_INIT ach[11] = {0}; /* works around compiler/linker bug */
247#endif
248#endif
249
250
251/*******************************************************************************
252* Internal Functions *
253*******************************************************************************/
254/* File an output replacements */
255HFILE fopen(const char * pszFilename, const char * pszIgnored);
256int fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock, HFILE hFile);
257int fseek(HFILE hfile, signed long off, int iOrg);
258unsigned long fsize(HFILE hFile);
259
260/* C-library replacements and additions. */
261void kmemcpy(char *psz1, const char *psz2, int cch);
262char * kstrstr(const char *psz1, const char *psz2);
263int kstrcmp(const char *psz1, const char *psz2);
264int kstrncmp(const char *psz1, const char *psz2, int cch);
265int kstrnicmp(const char *psz1, const char *psz2, int cch);
266int kstrlen(const char *psz);
267char * kstrcpy(char * pszTarget, const char * pszSource);
268int kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
269
270/* Workers */
271int LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects);
272int VerifyPrologs(void);
273int ProbeSymFile(const char *pszFilename);
274int GetKernelInfo(void);
275
276/* Ouput */
277void ShowResult(int rc);
278
279/* Others used while debugging in R3. */
280int VerifyKernelVer(void);
281int ReadOS2Krnl(char *pszFilename);
282int ReadOS2Krnl2(HFILE hKrnl, unsigned long cbKrnl);
283
284
285
286/*******************************************************************************
287* Implementation of Internal Helper Functions *
288*******************************************************************************/
289
290/**
291 * Quick implementation of fopen.
292 * @param pszFilename name of file to open (sz)
293 * @param pszIgnored whatever - it is ignored
294 * @return Handle to file. (not pointer to a FILE stream as in C-library)
295 * @remark binary and readonly is assumed!
296 */
297HFILE fopen(const char * pszFilename, const char * pszIgnored)
298{
299 HFILE hFile = 0;
300 USHORT rc;
301 unsigned short Action = 0;
302
303 rc = DosOpen(
304 (char*)pszFilename,
305 &hFile,
306 &Action,
307 0,
308 FILE_NORMAL,
309 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
310 OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY,
311 NULL);
312
313 pszIgnored = pszIgnored;
314 return hFile;
315}
316
317
318/**
319 * fread emulation
320 * @returns Number of blocks read.
321 * @param pvBuffer Buffer to read into
322 * @param cbBlock Blocksize
323 * @param cBlock Block count
324 * @param hFile Handle to file (HFILE)
325 */
326int fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock, HFILE hFile)
327{
328 USHORT ulRead;
329 USHORT rc;
330
331 rc = DosRead(hFile, pvBuffer, (USHORT)(cbBlock*cBlock), &ulRead);
332 if (rc == 0)
333 rc = (USHORT)cBlock;
334 else
335 rc = 0;
336
337 return rc;
338}
339
340
341/**
342 * fseek emultation
343 * @returns Same as DosChgFilePtr
344 * @param hFile Filehandle
345 * @param off offset into file from origin
346 * @param org origin
347 */
348int fseek(HFILE hFile, signed long off, int iOrg)
349{
350 ULONG ul;
351 return (int)DosChgFilePtr(hFile, off, iOrg, &ul);
352}
353
354
355/**
356 * Get filesize in bytes.
357 * @returns Filesize.
358 * @param hFile Filehandle
359 * @remark This function sets the file position to end of file.
360 */
361unsigned long fsize(HFILE hFile)
362{
363 USHORT rc;
364 unsigned long cb;
365
366 rc = DosChgFilePtr(hFile, 0, FILE_END, &cb);
367
368 return cb;
369}
370
371
372/**
373 * kmemcpy - memory copy - slow!
374 * @param psz1 target
375 * @param psz2 source
376 * @param cch length
377 */
378void kmemcpy(char *psz1, const char *psz2, int cch)
379{
380 while (cch-- != 0)
381 *psz1++ = *psz2++;
382}
383
384
385/**
386 * Finds psz2 in psz2.
387 * @returns Pointer to occurence of psz2 in psz1.
388 * @param psz1 String to be search.
389 * @param psz2 Substring to search for.
390 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
391 */
392char *kstrstr(const char *psz1, const char *psz2)
393{
394 while (*psz1 != '\0')
395 {
396 register int i = 0;
397 while (psz2[i] != '\0' && psz1[i] == psz2[i])
398 i++;
399
400 /* found it? */
401 if (psz2[i] == '\0')
402 return (char*)psz1;
403 if (psz1[i] == '\0' )
404 break;
405 psz1++;
406 }
407
408 return NULL;
409}
410
411
412#if 0 /* not in use */
413/**
414 * kstrcmp - String compare
415 * @returns 0 - equal else !0
416 * @param psz1 String 1
417 * @param psz2 String 2
418 */
419int kstrcmp(const char *psz1, const char *psz2);
420{
421 while (*psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0')
422 {
423 psz1++;
424 psz2++;
425 }
426 return *psz1 - *psz2;
427}
428#endif
429
430
431/**
432 * kstrncmp - String 'n' compare.
433 * @returns 0 - equal else !0
434 * @param p1 String 1
435 * @param p2 String 2
436 * @param len length
437 */
438int kstrncmp(register const char *psz1, register const char *psz2, int cch)
439{
440 int i = 0;
441 while (i < cch && *psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0')
442 {
443 psz1++;
444 psz2++;
445 i++;
446 }
447
448 return i - cch;
449}
450
451
452#if 0 /* not in use */
453/**
454 * kstrnicmp - String 'n' compare, case-insensitive.
455 * @returns 0 - equal else !0
456 * @param p1 String 1
457 * @param p2 String 2
458 * @param len length
459 */
460int kstrnicmp(const char *psz1, const char *psz2, int cch)
461{
462 register char ch1, ch2;
463
464 do
465 {
466 ch1 = *psz1++;
467 if (ch1 >= 'A' && ch1 <= 'Z')
468 ch1 += 'a' - 'A'; /* to lower case */
469 ch2 = *psz2++;
470 if (ch2 >= 'A' && ch2 <= 'Z')
471 ch2 += 'a' - 'A'; /* to lower case */
472 } while (--cch > 0 && ch1 == ch2 && ch1 != '\0' && ch2 != '\0');
473
474 return ch1 - ch2;
475}
476#endif
477
478
479/**
480 * kstrlen - String length.
481 * @returns Length of the string.
482 * @param psz Pointer to string.
483 * @status completely implemented and tested.
484 * @author knut st. osmundsen
485 */
486int kstrlen(register const char * psz)
487{
488 register int cch = 0;
489 while (*psz++ != '\0')
490 cch++;
491 return cch;
492}
493
494
495/**
496 * String copy (strcpy).
497 * @returns Pointer to target string.
498 * @param pszTarget Target string.
499 * @param pszSource Source string.
500 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
501 */
502char * kstrcpy(char * pszTarget, register const char * pszSource)
503{
504 register char *psz = pszTarget;
505
506 while (*pszSource != '\0')
507 *psz++ = *pszSource++;
508 *psz = '\0';
509 return pszTarget;
510}
511
512
513
514
515/**
516 * Copy an argument to a buffer. Ie. "-K[=|:]c:\os2krnl ....". Supports quotes
517 * @returns Number of chars of pszArg that has been processed.
518 * @param pszTarget - pointer to target buffer.
519 * @param pszArg - pointer to source argument string.
520 * @param cchMaxlen - maximum chars to copy.
521 */
522int kargncpy(char * pszTarget, const char * pszArg, unsigned cchMaxlen)
523{
524 int i = 0;
525 int fQuote = FALSE;
526
527 /* skip option word/letter */
528 while (*pszArg != '\0' && *pszArg != ' ' && *pszArg != ':' &&
529 *pszArg != '=' && *pszArg != '-' && *pszArg != '/')
530 {
531 pszArg++;
532 i++;
533 }
534
535 if (*pszArg == ' ' || *pszArg == '-' || *pszArg == '/' || *pszArg == '\0')
536 return 0;
537
538
539 do
540 {
541 pszArg++;
542 i++;
543 } while (*pszArg != '\0' && *pszArg == ' ');
544
545 /* copy maxlen or less */
546 /* check for quotes */
547 if (*pszArg == '"')
548 {
549 fQuote = TRUE;
550 pszArg++;
551 i++;
552 }
553 /* copy loop */
554 while (cchMaxlen > 1 && (fQuote ? *pszArg != '"' : *pszArg != ' ') && *pszArg != '\0')
555 {
556 *pszTarget++ = *pszArg++;
557 i++;
558 cchMaxlen--;
559 }
560
561 /* terminate pszTarget */
562 pszTarget = '\0';
563
564 return i;
565}
566
567
568/**
569 * Get the message text for an error message.
570 * @returns Pointer to error text. NULL if not found.
571 * @param sErr Error code id.
572 * @status completely implemented.
573 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
574 */
575const char * GetErrorMsg(short sErr)
576{
577 int i;
578 for (i = 0; i < sizeof(aErrorMsgs) / sizeof(aErrorMsgs[0]); i++)
579 {
580 if (aErrorMsgs[i].sErr == sErr)
581 return aErrorMsgs[i].pszMsg;
582 }
583 return NULL;
584}
585
586
587
588/*******************************************************************************
589* Implementation Of The Important Functions *
590*******************************************************************************/
591/**
592 * Checks if this kernel is within the kernel symbol database.
593 * If an entry for the kernel is found, the data is copied from the
594 * database entry to aImportTab.
595 * @returns NO_ERROR on succes (0)
596 * 1 if not found.
597 * Error code on error.
598 * @param usBuild Build level.
599 * @param fKernel Kernel (type) flags. (KF_* from options.h)
600 * @param cObjects Count of object in the running kernel.
601 * @sketch Loop thru the table.
602 * @status completely implemented.
603 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
604 */
605int LookupKrnlEntry(unsigned short usBuild, unsigned short fKernel, unsigned char cObjects)
606{
607 int i;
608
609 /*
610 * Loop tru the DB entries until a NULL pointer is found.
611 */
612 for (i = 0; aKrnlSymDB[i].usBuild != 0; i++)
613 {
614 if ( aKrnlSymDB[i].usBuild == usBuild
615 && aKrnlSymDB[i].fKernel == fKernel
616 && aKrnlSymDB[i].cObjects == cObjects)
617 { /* found matching entry! */
618 int j;
619 int rc;
620 register PKRNLDBENTRY pEntry = &aKrnlSymDB[i];
621
622 dprintf(("LookUpKrnlEntry - found entry for this kernel!\n"));
623
624 /*
625 * Copy symbol data from the DB to aImportTab.
626 */
627 for (j = 0; j < NBR_OF_KRNLIMPORTS; j++)
628 {
629 aImportTab[j].offObject = pEntry->aSyms[j].offObject;
630 aImportTab[j].iObject = pEntry->aSyms[j].iObject;
631 aImportTab[j].ulAddress = paKrnlOTEs[pEntry->aSyms[j].iObject].ote_base
632 + pEntry->aSyms[j].offObject;
633 aImportTab[j].usSel = paKrnlOTEs[pEntry->aSyms[j].iObject].ote_sel;
634 aImportTab[j].fFound = (char)((aImportTab[j].offObject != 0xFFFFFFFFUL) ? 1 : 0);
635 dprintf((" %-3d addr=0x%08lx off=0x%08lx %s\n",
636 j, aImportTab[j].ulAddress, aImportTab[j].offObject,
637 aImportTab[j].achName));
638 }
639
640 /* Verify prologs*/
641 rc = VerifyPrologs();
642
643 /* set sym name on success or complain on error */
644 if (rc == 0)
645 kstrcpy(szSymbolFile, "Win32k Symbol Database");
646 else
647 {
648 printf16("Warning: The Win32k Symbol Database entry found.\n"
649 " But, VerifyPrologs() returned rc=0x%x and iProc=%d\n", rc, iProc);
650 DosSleep(3000);
651 }
652
653 return rc;
654 }
655 }
656
657 /* not found */
658 return ERROR_PROB_SYMDB_KRNL_NOT_FOUND;
659}
660
661
662/**
663 * Verifies the that the addresses in aImportTab are valid.
664 * This is done at Ring-0 of course.
665 * @returns NO_ERROR (ie. 0) on success. iProc = -1
666 * The appropriate OS/2 or Win32k return code on success. iProc
667 * is set to the failing procedure (if appliable).
668 */
669int VerifyPrologs(void)
670{
671#if !defined(EXTRACT)
672 APIRET rc;
673 HFILE hDev0 = 0;
674 USHORT usAction = 0;
675
676 /* Set the failing procedure number to -1. */
677 iProc = -1;
678
679 /* Open the elf device driver. */
680 rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
681 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
682 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
683 0UL);
684 if (rc == NO_ERROR)
685 {
686 D16VERIFYIMPORTTABDATA Data = {0};
687
688 /* Issue the VerifyImportTab IOCtl call. */
689 rc = DosDevIOCtl(&Data, "", D16_IOCTL_VERIFYIMPORTTAB, D16_IOCTL_CAT, hDev0);
690 DosClose(hDev0);
691 if (rc == NO_ERROR)
692 {
693 if (Data.usRc != NO_ERROR)
694 {
695 /* set the appropriate return values. */
696 rc = (Data.usRc & ERROR_D32_ERROR_MASK) + ERROR_PROB_SYM_D32_FIRST;
697 if (Data.usRc & ERROR_D32_PROC_FLAG)
698 iProc = (Data.usRc & ERROR_D32_PROC_MASK) >> ERROR_D32_PROC_SHIFT;
699 }/* else success */
700 }
701 else
702 {
703 dprintf(("DosDevIOCtl failed with rc=%d\n", rc));
704 DosSleep(3000);
705 }
706 }
707 else
708 {
709 dprintf(("DosOpen Failed with rc=%d\n", rc));
710 DosSleep(3000);
711 }
712
713 return rc;
714#else
715 return 0;
716#endif
717}
718
719
720/**
721 * Check a symbol file. Searches for the wanted entry-point addresses.
722 * @returns 0 on success - something else on failiure.
723 * @param pszFilename Name of file to probe.
724 * @precond Must be called after kernel-file is found and processed.
725 * @remark Error codes starts at -50.
726 */
727int ProbeSymFile(const char * pszFilename)
728{
729 HFILE hSym; /* Filehandle */
730 int cLeftToFind; /* Symbols left to find */
731 unsigned long iSeg; /* Outer search loop: Segment number */
732 unsigned iSym; /* Middle search loop: Symbol number */
733 unsigned i; /* Inner search loop: ProcTab index */
734 int rc;
735
736 MAPDEF MapDef; /* Mapfile header */
737 SEGDEF SegDef; /* Segment header */
738 SYMDEF32 SymDef32; /* Symbol definition 32-bit */
739 SYMDEF16 SymDef16; /* Symbol definition 16-bit */
740 char achBuffer[256]; /* Name buffer */
741 unsigned long offSegment; /* Segment definition offset */
742 unsigned long offSymPtr; /* Symbol pointer(offset) offset */
743 unsigned short offSym; /* Symbol definition offset */
744
745
746 /*
747 * Open the symbol file
748 */
749 hSym = fopen(pszFilename, "rb");
750 if (hSym==0)
751 {
752 dprintf(("Error opening file %s\n", pszFilename));
753 return ERROR_PROB_SYM_FILE_NOT_FOUND;
754 }
755 dprintf(("\nSuccessfully opened symbolfile: %s\n", pszFilename));
756
757
758 /*
759 * (Open were successfully.)
760 * Now read header and display it.
761 */
762 rc = fread(&MapDef, sizeof(MAPDEF), 1, hSym);
763 if (!rc)
764 { /* oops! read failed, close file and fail. */
765 fclose(hSym);
766 return ERROR_PROB_SYM_READERROR;
767 }
768 achBuffer[0] = MapDef.achModName[0];
769 fread(&achBuffer[1], 1, MapDef.cbModName, hSym);
770 achBuffer[MapDef.cbModName] = '\0';
771 dprintf(("*Module name: %s\n", achBuffer));
772 dprintf(("*Segments: %d\n*MaxSymbolLength: %d\n", MapDef.cSegs, MapDef.cbMaxSym));
773 dprintf(("*ppNextMap: 0x%x\n", MapDef.ppNextMap ));
774
775
776 /*
777 * Verify that the modulename of the symbol file is OS2KRNL.
778 */
779 if (MapDef.cbModName == 7 && kstrncmp(achBuffer, "OS2KRNL", 7) != 0)
780 { /* modulename was not OS2KRNL, fail. */
781 dprintf(("Modulename verify failed\n"));
782 fclose(hSym);
783 return ERROR_PROB_SYM_INVALID_MOD_NAME;
784 }
785
786
787 /*
788 * Verify that the number of segments is equal to the number objects in OS2KRNL.
789 */
790 #ifndef EXTRACT
791 if (MapDef.cSegs != cObjects)
792 { /* incorrect count of segments. */
793 dprintf(("Segment No. verify failed\n"));
794 fclose(hSym);
795 return ERROR_PROB_SYM_SEGS_NE_OBJS;
796 }
797 #endif /* !EXTRACT */
798
799
800 /*
801 * Reset ProcTab
802 */
803 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
804 {
805 aImportTab[i].fFound = 0;
806 #ifdef DEBUG
807 aImportTab[i].offObject = 0;
808 aImportTab[i].ulAddress = 0;
809 aImportTab[i].usSel = 0;
810 #endif
811 }
812
813
814 /*
815 * Fileoffset of the first segment.
816 * And set cLeftToFind.
817 */
818 offSegment = SEGDEFOFFSET(MapDef);
819 cLeftToFind = NBR_OF_KRNLIMPORTS;
820
821 /*
822 * Search thru the entire file, segment by segment.
823 *
824 * ASSUME: last segment is the only 32-bit code segment.
825 *
826 */
827 for (iSeg = 0; iSeg < MapDef.cSegs; iSeg++, offSegment = NEXTSEGDEFOFFSET(SegDef))
828 {
829 int fSegEPTBitType; /* Type of segment, 16 or 32 bit, expressed in EPT_XXBIT flags */
830 int fCode; /* Set if this is a code segment, else clear. */
831
832 /*
833 * Read the segment definition.
834 */
835 if (fseek(hSym, offSegment, SEEK_SET))
836 { /* Failed to seek to the segment definition, fail! */
837 fclose(hSym);
838 return ERROR_PROB_SYM_SEG_DEF_SEEK;
839 }
840 rc = fread(&SegDef, sizeof(SEGDEF), 1, hSym);
841 if (!rc)
842 { /* Failed to read the segment definition, fail! */
843 fclose(hSym);
844 return ERROR_PROB_SYM_SEG_DEF_READ;
845 }
846
847 /*
848 * Some debugging info.
849 */
850 achBuffer[0] = SegDef.achSegName[0];
851 fread(&achBuffer[1], 1, SegDef.cbSegName, hSym);
852 achBuffer[SegDef.cbSegName] = '\0';
853 dprintf(("Segment %.2li Flags=0x%02x cSymbols=0x%04x Name=%s\n",
854 iSeg, SegDef.bFlags, SegDef.cSymbols, &achBuffer[0]));
855
856 /*
857 * Determin segment bit type.
858 */
859 fSegEPTBitType = SEG32BitSegment(SegDef) ? EPT_32BIT : EPT_16BIT;
860 fCode = kstrstr(achBuffer, "CODE") != NULL;
861
862 /*
863 * Search thru all the symbols in this segment
864 * while we look for the requested symbols in aImportTab.
865 */
866 for (iSym = 0; iSym < SegDef.cSymbols && cLeftToFind; iSym++)
867 {
868 IMPORTKRNLSYM * pImport;
869 unsigned cchName;
870
871 /*
872 * Fileoffset of the current symbol.
873 * Set filepointer to that position.
874 * Read word (which is the offset of the symbol).
875 */
876 offSymPtr = SYMDEFOFFSET(offSegment, SegDef, iSym);
877 rc = fseek(hSym, offSymPtr, SEEK_SET);
878 if (rc)
879 { /* Symboloffset seek failed, try read next symbol. */
880 dprintf(("Warning: Seek failed (offSymPtr=%d, rc=%d)\n", offSymPtr, rc));
881 continue;
882 }
883 rc = fread(&offSym, sizeof(unsigned short int), 1, hSym);
884 if (!rc)
885 { /* Symboloffset read failed, try read next symbol. */
886 dprintf(("Warning: read failed (offSymPtr=%d, rc=%d)\n", offSymPtr, rc));
887 continue;
888 }
889 rc = fseek(hSym, offSym + offSegment, SEEK_SET);
890 if (rc)
891 { /* Symbol Seek failed, try read next symbol. */
892 dprintf(("Warning: Seek failed (offSym=%d, rc=%d)\n", offSym, rc));
893 continue;
894 }
895
896
897 /*
898 * Read symbol and symbolname.
899 */
900 if (SegDef.bFlags & 0x01)
901 rc = fread(&SymDef32, sizeof(SYMDEF32), 1, hSym);
902 else
903 rc = fread(&SymDef16, sizeof(SYMDEF16), 1, hSym);
904 if (!rc)
905 { /* Symbol read failed, try read next symbol */
906 dprintf(("Warning: Read(1) failed (offSym=%d, rc=%d)\n", offSym, rc));
907 continue;
908 }
909 achBuffer[0] = (SegDef.bFlags & 0x01) ? SymDef32.achSymName[0] : SymDef16.achSymName[0];
910 cchName = (SegDef.bFlags & 0x01) ? SymDef32.cbSymName : SymDef16.cbSymName;
911 rc = fread(&achBuffer[1], 1, cchName, hSym);
912 if (!rc)
913 { /* Symbol read failed, try read next symbol */
914 dprintf(("Warning: Read(2) failed (offSym=%d, rc=%d)\n", offSym, rc));
915 continue;
916 }
917 achBuffer[cchName] = '\0';
918
919
920 /*
921 * Search proctable.
922 */
923 for (i = 0, pImport = &aImportTab[0]; i < NBR_OF_KRNLIMPORTS; i++, pImport++)
924 {
925 if (!pImport->fFound /* Not allready found */
926 && (pImport->fType & EPT_VARIMPORT ? !fCode : fCode) /* Don't look for code in a data segment */
927 && pImport->cchName == cchName /* Equal name length */
928 && kstrncmp(pImport->achName, achBuffer, cchName) == 0 /* Equal name */
929 )
930 { /* Symbol was found */
931 pImport->offObject = (SegDef.bFlags & 0x01 ? SymDef32.wSymVal : SymDef16.wSymVal);
932 pImport->ulAddress = pImport->offObject + paKrnlOTEs[iSeg].ote_base;
933 pImport->iObject = (unsigned char)iSeg;
934 pImport->usSel = paKrnlOTEs[iSeg].ote_sel;
935 dprintf(("debug: base=%lx, size=%lx iSeg=%d\n", paKrnlOTEs[iSeg].ote_base, paKrnlOTEs[iSeg].ote_size, iSeg));
936
937 /* Paranoia test! */
938 #ifndef EXTRACT
939 if (pImport->offObject < paKrnlOTEs[iSeg].ote_size)
940 {
941 pImport->fFound = TRUE;
942 cLeftToFind--;
943 dprintf(("Found: %s at off 0x%lx addr 0x%lx, sel=0x%x\n",
944 pImport->achName, pImport->offObject,
945 pImport->ulAddress, pImport->usSel));
946 }
947 else/* test failed, continue on next symbol*/
948 dprintf(("Error: Paranoia test failed for %s\n", pImport->achName));;
949 #else
950 pImport->fFound = TRUE;
951 cLeftToFind--;
952 #endif /* !EXTRACT */
953 break;
954 }
955
956 } /* aImportTab for-loop */
957
958 } /* Symbol for-loop */
959
960 } /* Segment for-loop */
961
962 /*
963 * Close symbol file.
964 */
965 fclose(hSym);
966
967 /*
968 * If not all procedures were found fail.
969 */
970 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
971 if (!aImportTab[i].fFound && !(aImportTab[i].fType & EPT_NOT_REQ))
972 return ERROR_PROB_SYM_IMPORTS_NOTFOUND;
973
974 /*
975 * Verify function prologs and return.
976 */
977 return VerifyPrologs();
978}
979
980
981/**
982 * Get kernelinformation (OTEs (object table entries), build, type, debug...)
983 * @returns 0 on success.
984 * options.ulBuild, fchType, fDebug, cObjects and paKrnlOTEs is set on successful return.
985 * Not 0 on error.
986 */
987int GetKernelInfo(void)
988{
989#if !defined(EXTRACT) /* This IOCtl is not available after inittime! */
990 static KRNLINFO DATA16_INIT KrnlInfo = {0};
991 APIRET rc;
992 HFILE hDev0 = 0;
993 USHORT usAction = 0;
994
995 /*
996 * Issue an IOCtl to elf$ to query kernel information.
997 */
998 rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
999 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
1000 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
1001 0UL);
1002 if (rc == NO_ERROR)
1003 {
1004 rc = DosDevIOCtl(&KrnlInfo, "", D16_IOCTL_GETKRNLINFO, D16_IOCTL_CAT, hDev0);
1005 if (rc == NO_ERROR)
1006 {
1007 #ifdef DEBUG
1008 unsigned i;
1009 #endif
1010
1011 /*
1012 * Set the exported parameters
1013 */
1014 options.ulBuild = KrnlInfo.ulBuild;
1015 options.fKernel = KrnlInfo.fKernel;
1016 cObjects = KrnlInfo.cObjects;
1017 paKrnlOTEs = &KrnlInfo.aObjects[0];
1018
1019 /*
1020 * If debugging probkrnl dump kernel OTEs.
1021 */
1022 #ifdef DEBUG
1023 dprintf(("debug: kernel OTE:\n"));
1024 for (i = 0; i < cObjects; i++)
1025 dprintf(("debug: no.%2d base=%lx size=%lx sel=%x\n",
1026 i,
1027 paKrnlOTEs[i].ote_base,
1028 paKrnlOTEs[i].ote_size,
1029 paKrnlOTEs[i].ote_sel));
1030 #endif
1031 }
1032 DosClose(hDev0);
1033 }
1034
1035 if (rc != NO_ERROR)
1036 printf16("Failed to get kernel OTEs. rc=%d\n", rc);
1037
1038 return rc;
1039
1040#else
1041 return 0;
1042#endif
1043}
1044
1045
1046/**
1047 * Shows result of kernelprobing if not quiet or on error.
1048 * @param rc Return code.
1049 */
1050void ShowResult(int rc)
1051{
1052 int i;
1053
1054 /*
1055 * Complain even if quiet on error
1056 */
1057 if (!options.fQuiet || rc != NO_ERROR)
1058 {
1059 printf16("Win32k - Odin32 support driver.\n");
1060
1061 /*
1062 * kernel stuff
1063 */
1064 if (rc == NO_ERROR || rc > ERROR_PROB_KRNL_LAST)
1065 printf16(" Build: %ld - v%d.%d\n",
1066 options.ulBuild, options.usVerMajor, options.usVerMinor);
1067 else if (rc >= ERROR_PROB_KRNL_FIRST)
1068 printf16(" Kernel probing failed with rc=%d.\n", rc);
1069 else
1070 printf16(" Failed before probing kernel.\n");
1071
1072 /*
1073 * symbol-file
1074 */
1075 if (rc == NO_ERROR || (rc > ERROR_PROB_SYM_LAST && szSymbolFile[0] != '\0'))
1076 printf16(" Found symbolfile: %s\n", (NPSZ)szSymbolFile);
1077 else if (rc >= ERROR_PROB_SYM_FIRST)
1078 printf16(" Failed to find symbolfile!\n");
1079 else
1080 printf16(" Failed before searching for symbolfile.\n");
1081
1082 /*
1083 * function listing
1084 */
1085 if (options.fLogging)/* || rc != NO_ERROR)*/
1086 {
1087 for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
1088 {
1089 printf16(" %-21s at ", aImportTab[i].achName);
1090 if (aImportTab[i].fFound)
1091 printf16("0x%08lx%s", aImportTab[i].ulAddress, (i % 2) == 0 ? "" : "\n");
1092 else
1093 printf16("not found!%s", (i % 2) == 0 ? "" : "\n");
1094 }
1095 if (i % 2) printf16("\n");
1096 }
1097
1098 /*
1099 * Display error code.
1100 */
1101 if (rc != NO_ERROR)
1102 {
1103 const char *psz = GetErrorMsg(rc);
1104 printf16("ProbeKernel failed with rc=%d. iProc=%x\n", rc, iProc);
1105 if (psz) printf16("%s\n", psz);
1106 }
1107 }
1108}
1109
1110
1111/**
1112 * "main" function.
1113 * Note that the option -Noloader causes nothing to be done.
1114 * @returns 0 on success, something else on error.
1115 * @param pReqPack Pointer to init request packet
1116 * @remark
1117 */
1118int ProbeKernel(PRPINITIN pReqPack)
1119{
1120 int rc;
1121 int i;
1122 int n;
1123 SEL selGIS;
1124 SEL selLIS;
1125 PGINFOSEG pGIS;
1126 PLINFOSEG pLIS;
1127 USHORT usBootDrive;
1128
1129 /*----------------*/
1130 /* parse InitArgs */
1131 /*----------------*/
1132 if (pReqPack != NULL && pReqPack->InitArgs != NULL)
1133 {
1134 n = kstrlen(pReqPack->InitArgs);
1135 for (i = 0; i < n; i++)
1136 {
1137 if ((pReqPack->InitArgs[i] == '/' || pReqPack->InitArgs[i] == '-') && (i+1) < n)
1138 {
1139 i++;
1140 switch (pReqPack->InitArgs[i])
1141 {
1142 case 'n':
1143 case 'N': /* NoLoader */
1144 options.fNoLoader = TRUE;
1145 return 0;
1146
1147 case 'q':
1148 case 'Q': /* Quiet */
1149 options.fQuiet = TRUE;
1150 break;
1151
1152 case 's':
1153 case 'S': /* Symbol file */
1154 i++;
1155 if ( pReqPack->InitArgs[i] != 'c' && pReqPack->InitArgs[i] != 'C'
1156 && pReqPack->InitArgs[i] != 'm' && pReqPack->InitArgs[i] != 'M'
1157 ) /* -script and -smp is ignored */
1158 i += kargncpy(szSymbolFile, &pReqPack->InitArgs[i], sizeof(szSymbolFile));
1159 break;
1160
1161 case 'v':
1162 case 'V': /* Verbose */
1163 options.fQuiet = FALSE;
1164 break;
1165 }
1166 }
1167 }
1168 }
1169
1170 /*---------------------*/
1171 /* determin boot drive */
1172 /*---------------------*/
1173 rc = DosGetInfoSeg(&selGIS, &selLIS);
1174 if (rc != NO_ERROR)
1175 return rc;
1176
1177 pLIS = MAKEPLINFOSEG(selLIS);
1178 pGIS = MAKEPGINFOSEG(selGIS);
1179 usBootDrive = pGIS->bootdrive;
1180#ifndef R3TST
1181 options.usVerMajor = pGIS->uchMajorVersion;
1182 options.usVerMinor = pGIS->uchMinorVersion;
1183#else
1184 if (usFakeVerMajor == 0)
1185 {
1186 usFakeVerMajor = pGIS->uchMajorVersion;
1187 usFakeVerMinor = pGIS->uchMinorVersion;
1188 }
1189 options.usVerMajor = usFakeVerMajor;
1190 options.usVerMinor = usFakeVerMinor;
1191#endif
1192 dprintf(("BootDrive: %d\n", usBootDrive));
1193
1194 /* set driveletter in constants strings */
1195 usBootDrive = (char)usBootDrive + (char)'a' - 1;
1196 for (i = 0; apszSym[i] != NULL; i++)
1197 apszSym[i][0] = (char)usBootDrive;
1198
1199 /*-----------------*/
1200 /* get kernel info */
1201 /*-----------------*/
1202 rc = GetKernelInfo();
1203
1204 /*--------------*/
1205 /* read symfile */
1206 /*--------------*/
1207 if (!rc)
1208 {
1209 rc = 1;
1210 if (szSymbolFile[0] != '\0')
1211 {
1212 rc = ProbeSymFile(szSymbolFile);
1213 if (rc)
1214 {
1215 printf16("Warning: Invalid symbol file specified. rc=%x iProc=%d\n"
1216 " Tries defaults.\n", rc, iProc);
1217 szSymbolFile[0] = '\0';
1218 DosSleep(3000);
1219 }
1220 }
1221 if (rc != NO_ERROR) /* if user sym failed or don't exists. */
1222 {
1223 /*
1224 * Check database - only if not a debug kernel!
1225 * You usually have a .sym-file when using a debug kernel.
1226 * (This is because I am unable to distinguish between half and
1227 * all strict kernels...)
1228 */
1229 if ((options.fKernel & KF_DEBUG) ||
1230 (rc = LookupKrnlEntry((unsigned short)options.ulBuild,
1231 (unsigned short)options.fKernel,
1232 cObjects)
1233 ) != NO_ERROR
1234 )
1235 {
1236 #if 1 /* ndef R3TST */
1237 APIRET rc2;
1238 /* search on disk */
1239 i = 0;
1240 while (apszSym[i] != NULL
1241 && (rc2 = ProbeSymFile(apszSym[i])) != NO_ERROR
1242 )
1243 {
1244 i++;
1245 if (rc2 >= ERROR_PROB_SYM_D32_FIRST)
1246 rc = rc2;
1247 }
1248 if (rc == NO_ERROR)
1249 kstrcpy(szSymbolFile, apszSym[i]);
1250 else if (rc == 1 || rc2 == NO_ERROR)
1251 rc = rc2;
1252 #endif
1253 }
1254 }
1255 }
1256
1257 /* Show the result and set return-value */
1258 dprintf(("rc=%d(0x%x); i=%d; iProc=%d\n", rc, rc, i, iProc));
1259 ShowResult(rc);
1260
1261 return rc;
1262}
1263
Note: See TracBrowser for help on using the repository browser.