1 | /* $Id: ldr.h,v 1.2 1999-10-14 01:16:49 bird Exp $
|
---|
2 | *
|
---|
3 | * ldr - loader header file.
|
---|
4 | *
|
---|
5 | * Copyright (c) 1999 knut St. osmundsen
|
---|
6 | *
|
---|
7 | */
|
---|
8 |
|
---|
9 |
|
---|
10 | #ifndef _ldr_h_
|
---|
11 | #define _ldr_h_
|
---|
12 | #ifndef LDR_INCL_INITONLY
|
---|
13 | /* state variable */
|
---|
14 | extern BOOL fQAppType;
|
---|
15 |
|
---|
16 | /***************************************************************/
|
---|
17 | /* handle state - Array of handle states. Four state per byte! */
|
---|
18 | /***************************************************************/
|
---|
19 | #define MAX_FILE_HANDLES 0x10000
|
---|
20 |
|
---|
21 | extern unsigned char achHandleStates[MAX_FILE_HANDLES/8];
|
---|
22 |
|
---|
23 | #define HSTATE_UNUSED 0x00 /* Handle not used (or OS/2). */
|
---|
24 | #define HSTATE_OS2 0x00 /* OS/2 module filehandle. */
|
---|
25 | #define HSTATE_OUR 0x01 /* Our module filehandle. */
|
---|
26 | #define HSTATE_MASK 0xFE
|
---|
27 | #define HSTATE_UMASK 0x01
|
---|
28 |
|
---|
29 | #define GetState(a) (HSTATE_UMASK & (achHandleStates[(a)/8] >> ((a)%8)))
|
---|
30 | #define SetState(a,b) (achHandleStates[(a)/8] = (achHandleStates[(a)/8] & (HSTATE_MASK << ((a)%8) | HSTATE_MASK >> 8-((a)%8)) | ((b) & 0x1) << ((a)%8)))
|
---|
31 |
|
---|
32 |
|
---|
33 | /**************/
|
---|
34 | /* PE handles */
|
---|
35 | /**************/
|
---|
36 | typedef struct _PENode
|
---|
37 | {
|
---|
38 | /* linking stuff */
|
---|
39 | struct _PENode *left;
|
---|
40 | struct _PENode *right;
|
---|
41 |
|
---|
42 | /* key */
|
---|
43 | SFN hFile; /* system file number or file handle if you prefer that */
|
---|
44 |
|
---|
45 | /* misc */
|
---|
46 | PMTE pMTE; /* pointer to MTE if we got one - may be NULL */
|
---|
47 |
|
---|
48 | /* Pe2Lx object */
|
---|
49 | Pe2Lx *pPe2Lx;
|
---|
50 | } PENODE, *PPENODE;
|
---|
51 |
|
---|
52 | #define SIZEOF_NODE (sizeof(NODE))
|
---|
53 |
|
---|
54 | ULONG insertNode(PPENODE pNode);
|
---|
55 | ULONG deleteNode(SFN key); /* removes from tree and freeNode */
|
---|
56 | PPENODE getNodePtr(SFN key);
|
---|
57 | PPENODE findNodePtr(const char *pszFilename);
|
---|
58 | ULONG depthPE(void);
|
---|
59 | PPENODE allocateNode(void);
|
---|
60 | ULONG freeNode(PPENODE pNode); /* don't remove from tree! */
|
---|
61 |
|
---|
62 | /* if sequential insertion - this will give a lower tree. */
|
---|
63 | /* testing shows that 3 gives best results for 27 to 134 nodes */
|
---|
64 | #define ROTATION 3
|
---|
65 | #define AdjustKey(a) ((USHORT)(a << 16-ROTATION) | (USHORT)(a >> ROTATION) )
|
---|
66 | #define UnAdjustKey(a) ((USHORT)(a >> 16-ROTATION) | (USHORT)(a << ROTATION) )
|
---|
67 |
|
---|
68 | #endif
|
---|
69 | /*************/
|
---|
70 | /* functions */
|
---|
71 | /*************/
|
---|
72 | #ifdef __cplusplus
|
---|
73 | extern "C" {
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | ULONG ldrInit(void);
|
---|
77 |
|
---|
78 | #ifdef __cplusplus
|
---|
79 | }
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | #pragma pack()
|
---|
83 |
|
---|
84 | #endif
|
---|