source: trunk/src/win32k/include/LdrCalls.h@ 4802

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

Prototyped new imported and overrided kernel functions.

File size: 12.0 KB
Line 
1/* $Id: LdrCalls.h,v 1.7 2000-12-11 06:45:03 bird Exp $
2 *
3 * Prototypes for the loader overrided function.
4 *
5 * Copyright (c) 1998-1999 knut st. osmundsen
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10#ifndef _ldrCalls_h_
11#define _ldrCalls_h_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*******************************************************************************
18* Defined Constants And Macros *
19*******************************************************************************/
20#define LDRCALL __stdcall
21
22/** Additional ldrFindModule flag. Or together with the class. */
23#define SEARCH_FULL_NAME 0x0001
24
25
26/**
27 * _ldrClose
28 */
29extern ULONG LDRCALL ldrClose( /* retd 0x04 */
30 SFN p1 /* ebp + 0x08 */
31 );
32
33ULONG LDRCALL myldrClose(SFN);
34
35
36/**
37 * _ldrOpen
38 */
39extern ULONG LDRCALL ldrOpen( /* retd 0x0c */
40 PSFN p1, /* ebp + 0x08 */
41 PCHAR p2, /* ebp + 0x0c */
42 PULONG p3 /* ebp + 0x10 */
43 );
44
45ULONG LDRCALL myldrOpen(PSFN phFile, PSZ pszFilename, PULONG pfl);
46
47
48/**
49 * _ldrRead
50 */
51extern ULONG LDRCALL ldrRead( /* retd 0x18 */
52 SFN hFile, /* ebp + 0x08 */
53 ULONG ulOffset, /* ebp + 0x0c */
54 PVOID pvBuffer, /* ebp + 0x10 */
55 ULONG fpBuffer, /* ebp + 0x14 */
56 ULONG cbToRead, /* ebp + 0x18 */
57 PMTE pMTE /* ebp + 0x1c */
58 );
59
60ULONG LDRCALL myldrRead(
61 SFN hFile,
62 ULONG ulOffset,
63 PVOID pvBuffer,
64 ULONG fpBuffer,
65 ULONG cbToRead,
66 PMTE pMTE
67 );
68
69
70
71/**
72 * _LDRQAppType
73 */
74extern ULONG LDRCALL LDRQAppType( /* retd 0x08 */
75 ULONG p1, /* ebp + 0x08 */
76 ULONG p2 /* ebp + 0x0c */
77 );
78
79ULONG LDRCALL myLDRQAppType(ULONG,ULONG);
80
81
82/**
83 * ldrEnum32bitRelRecs
84 * @param pMTE Pointer to MTE for this module.
85 * @param iObject Object index. 0-based!
86 * @param iPageTabl Page index. 0-based!
87 * @param pvPage Pointer to page buffer.
88 * @param ulPageAddress Note! Page is not present.
89 * @param pPTDA
90 *
91 */
92extern ULONG LDRCALL ldrEnum32bitRelRecs( /* retd 0x20 */
93 PMTE pMTE, /* ebp + 0x08 */
94 ULONG iObject, /* ebp + 0x0c */
95 ULONG iPageTable, /* ebp + 0x10 */
96 PVOID pvPage, /* ebp + 0x14 */
97 ULONG ulPageAddress, /* ebp + 0x18 */
98 PVOID pvPTDA /* ebp + 0x1c */
99 );
100
101ULONG LDRCALL myldrEnum32bitRelRecs(PMTE, ULONG, ULONG, PVOID, ULONG, PVOID);
102
103
104
105/**
106 * Loader local variables from KERNEL.SDF.
107 */
108typedef struct ldrlv_s /* #memb 12 size 39 (0x027) */
109{
110 PMTE lv_pmte; /* Pointer to mte. (ldrCreateMte/ldrXXX) */
111 ULONG lv_lbufaddr;
112 ULONG lv_sbufaddr;
113 ULONG lv_lrecbufaddr;
114 ULONG lv_srecbufaddr;
115 ULONG lv_new_exe_off;
116 USHORT lv_sfn; /* Handle to the module being loaded */
117 USHORT lv_hobmte;
118 ULONG lv_objnum;
119 ULONG lv_csmte; /* size of the swappable mte heap block. (ldrCreateMte) */
120 USHORT lv_class; /* Object class CLASS_* defines in OS2Krnl (mteflags1) it seems. */
121 /* CLASS_PROGRAM Program class. */
122 /* CLASS_GLOBAL Global class. */
123 /* CLASS_SPECIFIC Specific class, as against global. */
124 /* CLASS_ALL (0) Nonspecific class all modules. */
125 /* CLASS_MASK Class mask. */
126 UCHAR lv_type; /* Type of executable image expected loaded. */
127} ldrlv_t;
128
129
130/*
131 * Values of the lv_type byte. (Qualified guesses.)
132 */
133#define LVTYPE_EXE 0 /* Executable program. */
134#define LVTYPE_DLL 1 /* Dynamic Link Library. */
135#define LVTYPE_DD 2 /* Device Driver. */
136#define LVTYPE_IFS 3 /* Installable Filesystem. */
137#define LVTYPE_VDD 4 /* Virtual Device Driver (for VDMs). */
138
139
140
141/**
142 * ldrOpenPath
143 * pre 14053.
144 * @returns OS2 return code.
145 * pLdrLv->lv_sfn is set to filename handle.
146 * @param pachModname Pointer to modulename. Not zero terminated!
147 * @param cchModname Modulename length.
148 * @param pLdrLv Loader local variables? (Struct from KERNEL.SDF)
149 * @param pfl Pointer to flags which are passed on to ldrOpen.
150 * @sketch
151 * if !CLASS_GLOBAL or miniifs then
152 * ldrOpen(pachModName)
153 * else
154 * loop until no more libpath elements
155 * get next libpath element and add it to the modname.
156 * try open the modname
157 * if successfull then break the loop.
158 * endloop
159 * endif
160 */
161extern ULONG LDRCALL ldrOpenPath_old( /* retd 0x10 */
162 PCHAR pachFilename, /* ebp + 0x08 */
163 USHORT cchFilename, /* ebp + 0x0c */
164 ldrlv_t * plv, /* ebp + 0x10 */
165 PULONG pful /* ebp + 0x14 */
166 );
167
168ULONG LDRCALL myldrOpenPath_old(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful);
169
170
171/**
172 * ldrOpenPath - ldrOpenPath for build 14053 and above.
173 *
174 * @returns OS2 return code.
175 * plv->lv_sfn is set to filename handle.
176 * @param pachFilename Pointer to modulename. Not zero terminated!
177 * @param cchFilename Modulename length.
178 * @param plv Loader local variables? (Struct from KERNEL.SDF)
179 * @param pful Pointer to flags which are passed on to ldrOpen.
180 * @param lLibPath New parameter in build 14053.
181 * ldrGetMte calls with 1
182 * ldrOpenNewExe calls with 3
183 * This is compared to the initial libpath index.
184 * The libpath index is:
185 * BEGINLIBPATH 1
186 * LIBPATH 2
187 * ENDLIBPATH 3
188 * The initial libpath index is either 1 or 2.
189 *
190 * @sketch
191 * This is roughly what the original ldrOpenPath does:
192 * Save pTCBCur->TCBFailErr.
193 * if !CLASS_GLOBAL or miniifs then
194 * ldrOpen(pachFilename)
195 * else
196 * if beglibpath != NULL then path = 1 else path = 2
197 * if (lLibPath < path)
198 * return ERROR_FILE_NOT_FOUND; (2)
199 * Allocate buffer.
200 * loop until no more libpath elements
201 * get next libpath element and add it to the modname.
202 * try open the modname
203 * if successfull then break the loop.
204 * endloop
205 * Free buffer.
206 * endif
207 * Restore pTCBCur->TCBFailErr.
208 */
209extern ULONG LDRCALL ldrOpenPath( /* retd 0x14 */
210 PCHAR pachFilename, /* ebp + 0x08 */
211 USHORT cchFilename, /* ebp + 0x0c */
212 ldrlv_t * plv, /* ebp + 0x10 */
213 PULONG pful, /* ebp + 0x14 */
214 ULONG lLibPath /* ebp + 0x18 */
215 );
216
217ULONG LDRCALL myldrOpenPath(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful, ULONG lLibPath);
218
219
220/**
221 * Finds a module if it's loaded.
222 * @returns NO_ERROR on success.
223 * OS/2 errorcode on error.
224 * @param pachFilename Pointer to module filename.
225 * @param cchFilename Length of modulefilename.
226 * @param usClass Module class. (CLASS_*)
227 * @param ppMTE Pointer to pMTE found.
228 * @sketch
229 */
230ULONG LDRCALL ldrFindModule( /* retd 0x10 */
231 PCHAR pachFilename, /* ebp + 0x08 */
232 USHORT cchFilename, /* ebp + 0x0c */
233 USHORT usClass, /* ebp + 0x10 */
234 PPMTE ppMTE /* ebp + 0x14 */
235 );
236
237ULONG LDRCALL myldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE);
238
239
240/**
241 * LDRClearSem - Clears the loader semaphore.
242 * (It does some garbage collection on release.)
243 * @returns NO_ERROR on success.
244 * OS/2 error on failure. (ERROR_INTERRUPT?)
245 */
246extern ULONG LDRCALL LDRClearSem(void);
247
248
249/**
250 * LDRRequestSem - Requests the loader semaphore..
251 * @returns NO_ERROR if succesfully.
252 * OS2 errorcode on failure. (ERROR_INTERRUPT?)
253 */
254#define LDRRequestSem() KSEMRequestMutex(pLdrSem, (ULONG)-1)
255
256
257/*
258 * Pointer to the loader semaphore.
259 */
260#ifdef _OS2KSEM_h_
261extern PKSEMMTX pLdrSem;
262#endif
263
264
265/**
266 * Validates an hMTE and gets the MTE pointer.
267 * @returns Pointer to MTE on success.
268 * NULL on error.
269 * @param hMTE MTE handle.
270 * @remark If you wan't to this faster:
271 * Use the hMTE as a HOB and get the HOB address (by using VMGetHandleInfo).
272 */
273extern PMTE LDRCALL ldrValidateMteHandle(HMTE hMTE);
274
275
276/**
277 * Gets the pMTE from a hMTE. No checks.
278 * @returns Pointer to the pMTE for a given hMTE.
279 * @param hMTE Module handle.
280 * @sketch
281 */
282extern PMTE KRNLCALL ldrASMpMTEFromHandle(HMTE hMTE);
283
284
285/**
286 * Translates a relative filename to a full qualified filename.
287 * @returns NO_ERROR on success.
288 * Errorcode on error.
289 * @param pszFilename Pointer to nullterminated filename.
290 */
291extern ULONG LDRCALL ldrTransPath(PSZ pszFilename);
292
293
294/**
295 * Sets the VM flags for an executable object.
296 * @returns void
297 * @param pMTE Pointer to the module table entry.
298 * @param flObj LX Object flags.
299 * @param pflFlags1 Pointer to the flFlags1 of VMAllocMem (out).
300 * @param pflFlags2 Pointer to the flFlags2 of VMAllocMem (out).
301 */
302extern VOID LDRCALL ldrSetVMflags( /* retd 0x10 */
303 PMTE pMTE, /* ebp + 0x08 */
304 ULONG flObj, /* ebp + 0x0c */
305 PULONG pflFlags1, /* ebp + 0x10 */
306 PULONG pflFlags2 /* ebp + 0x14 */
307 );
308
309VOID LDRCALL myldrSetVMflags(PMTE pMTE, ULONG flObj, PULONG pflFlags1, PULONG pflFlags2);
310
311
312/**
313 * Checks if the internal name (first name in the resident nametable) matches
314 * the filename.
315 * @returns NO_ERROR on success (the name matched).
316 * ERROR_INVALID_NAME if mismatch.
317 * @param pMTE Pointer to the MTE of the module to check.<br>
318 * Assumes! that the filename for this module is present in ldrpFileNameBuf.
319 */
320extern ULONG LDRCALL ldrCheckInternalName( /* retd 0x04 */
321 PMTE pMTE /* ebp + 0x08 */
322 );
323
324ULONG LDRCALL myldrCheckInternalName(PMTE pMTE);
325
326
327/**
328 * Parses a filename to find the name and extention.
329 * @returns Length of the filename without the extention.
330 * @param pachFilename Pointer to filename to parse - must have path!
331 * @param ppachName Pointer to pointer which should hold the name pointer upon successfull return.
332 * @param ppachExt Pointer to pointer which should hold the extention pointer upon successfull return.
333 */
334extern ULONG LDRCALL ldrGetFileName(PSZ pszFilename, PCHAR *ppchName, PCHAR *ppchExt);
335
336
337/**
338 * Parses a filename to find the name and extention.
339 * @returns Length of the filename without the extention.
340 * @param pachFilename Pointer to filename to parse - path not needed.
341 * @param ppachName Pointer to pointer which should hold the name pointer upon successfull return.
342 * @param ppachExt Pointer to pointer which should hold the extention pointer upon successfull return.
343 */
344extern ULONG LDRCALL ldrGetFileName2(PSZ pszFilename, PCHAR *ppchName, PCHAR *ppchExt);
345
346
347/**
348 * Uppercase a string.
349 * @returns void
350 * @param pach String to uppercase.
351 * @param cch Length of string. (may include terminator)
352 */
353extern VOID LDRCALL ldrUCaseString(PCHAR pch, unsigned cch);
354
355
356/**
357 * Pointer to the loader filename buffer.
358 * Upon return from ldrOpen (and ldrOpenPath which calls ldrOpen) this is
359 * set to the fully qualified filename of the file last opened (successfully).
360 */
361extern PSZ *pldrpFileNameBuf;
362#define ldrpFileNameBuf (*pldrpFileNameBuf)
363
364
365#ifdef __cplusplus
366} /* extern "C" */
367#endif
368
369#endif
370
Note: See TracBrowser for help on using the repository browser.