Changeset 4090 for branches/GRACE/src/win32k/ldr/ldr.cpp
- Timestamp:
- Aug 25, 2000, 6:47:28 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GRACE/src/win32k/ldr/ldr.cpp
r4068 r4090 1 /* $Id: ldr.cpp,v 1.7.4. 3 2000-08-22 03:00:20bird Exp $1 /* $Id: ldr.cpp,v 1.7.4.4 2000-08-25 04:47:24 bird Exp $ 2 2 * 3 3 * ldr.cpp - Loader helpers. … … 15 15 #define INCL_NOPMAPI 16 16 #define INCL_OS2KRNL_SEM 17 #define INCL_OS2KRNL_PTDA 17 18 18 19 /******************************************************************************* … … 26 27 #include <stdlib.h> 27 28 #include <stddef.h> 29 #include <string.h> 28 30 29 31 #include "log.h" … … 296 298 297 299 /** 300 * Gets the path of the executable being executed. 301 * @returns Pointer to pszPath on success. Path has _NOT_ a trailing slash. 302 * NULL pointer on error. 303 * @param pszPath Pointer to path buffer. Expects CCHMAXPATH length. 304 * @param fExecChild Use hMTE of the PTDAExecChild if present. 305 * @sketch 306 * @status completely implemented. 307 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 308 * @remark The path from the pExeModule might not be fully qualified. 309 */ 310 PSZ ldrGetExePath(PSZ pszPath, BOOL fExecChild) 311 { 312 PCSZ pszFilename; 313 PCSZ psz; 314 315 #if 0 /* getFilename not implemented */ 316 if (pExeModule != NULL) 317 /* 318 * We have the executable object pointer. Let's use it! 319 */ 320 pszFilename = pExeModule->Data.pModule->getFilename(); 321 else 322 #endif 323 { 324 /* 325 * Get the hMTE for the executable using the pPTDAExecChild 326 * Then get the pMTE, and access the smte_path to get a pointer to the executable path. 327 */ 328 PPTDA pPTDACur; /* Pointer to the current (system context) PTDA */ 329 PPTDA pPTDA; /* PTDA in question. */ 330 HMTE hMTE = NULLHANDLE; /* Modulehandle of the executable module. */ 331 PMTE pMTE; /* Pointer to ModuleTableEntry of the executable module. */ 332 333 /* 334 * Get the current PTDA. (Fail if this call failes.) 335 * IF pPTDAExecChild isn't NULL THEN get hMTE for that. 336 * IF no pPTDAExecChild THEN get hMte for the current PTDA. 337 */ 338 pPTDACur = ptdaGetCur(); 339 if (pPTDACur != NULL) 340 { 341 pPTDA = ptdaGet_pPTDAExecChild(pPTDACur); 342 if (pPTDA != NULL && fExecChild) 343 hMTE = ptdaGet_ptda_module(pPTDA); 344 if (hMTE == NULLHANDLE) 345 hMTE = ptdaGet_ptda_module(pPTDACur); 346 } 347 else 348 { /* Not called at task time? No current task! */ 349 kprintf(("ldrGetExePath: Failed to get current PTDA.\n")); 350 return NULL; 351 } 352 353 /* fail if hMTE is NULLHANDLE ie. not found / invalid */ 354 if (hMTE == NULLHANDLE) 355 { 356 kprintf(("ldrGetExePath: Failed to get hMTE from the PTDAs.\n")); 357 return NULL; 358 } 359 360 /* get the pMTE for this hMTE */ 361 pMTE = ldrASMpMTEFromHandle(hMTE); 362 if (pMTE == NULL) 363 { 364 kprintf(("ldrGetExePath: ldrASMpMTEFromHandle failed for hMTE=0x%04.\n", hMTE)); 365 return NULL; 366 } 367 if (pMTE->mte_swapmte == NULL) /* paranoia */ 368 { 369 kprintf(("ldrGetExePath: mte_swapmte is NULL.\n")); 370 return NULL; 371 } 372 373 /* take the filename from the swappable MTE */ 374 pszFilename = pMTE->mte_swapmte->smte_path; 375 if (pszFilename == NULL) 376 { 377 kprintf(("ldrGetExePath: smte_path is NULL.\n")); 378 return NULL; 379 } 380 } 381 382 /* paranoia... */ 383 if (*pszFilename == '\0') 384 { 385 kprintf(("ldrGetExePath: pszFilename is empty!\n")); 386 return NULL; 387 } 388 389 /* 390 * Skip back over the filename. (stops pointing at the slash or ':') 391 */ 392 psz = pszFilename + strlen(pszFilename)-1; 393 while (psz >= pszFilename && *psz != '\\' && *psz != '/' && *psz != ':') 394 psz--; 395 396 /* 397 * If no path the fail. 398 */ 399 if (psz <= pszFilename) 400 { 401 kprintf(("ldrGetExePath: Exepath is empty.\n")); 402 return NULL; 403 } 404 405 /* 406 * Copy path and return. 407 */ 408 memcpy(pszPath, pszFilename, psz - pszFilename); 409 pszPath[psz - pszFilename] = '\0'; 410 return pszPath; 411 } 412 413 414 /** 298 415 * Initiate the loader "sub-system". 299 416 * @returns NO_ERROR on success. !0 on error.
Note:
See TracChangeset
for help on using the changeset viewer.