Changeset 4116 for branches/GRACE/src/win32k/ldr/myldrOpen.cpp
- Timestamp:
- Aug 30, 2000, 12:52:36 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GRACE/src/win32k/ldr/myldrOpen.cpp
r4111 r4116 1 /* $Id: myldrOpen.cpp,v 1.10.4. 9 2000-08-29 13:02:27bird Exp $1 /* $Id: myldrOpen.cpp,v 1.10.4.10 2000-08-29 22:52:36 bird Exp $ 2 2 * 3 3 * myldrOpen - ldrOpen. … … 340 340 if (*u1.pul == 0xBEBAFECAUL) //CAh FEh BAh BEh 341 341 { 342 char *pszName = NULL; 343 int cchName; 344 342 345 if (isJAVADisabled()) 343 346 goto cleanup_noerror; … … 345 348 /** @sketch 346 349 * Java signature found. 350 * Copy the name to a temporary buffer. (only if necessary) 351 * Remove the extention (.class) and insert a space between the name and the path. 352 * (This is the needed processing of the class filename to make it a classpath 353 * entry (path) and a class name (filename).) 347 354 * Try find the java executor in current dir or PATH: java.exe 348 355 */ 349 356 kprintf(("myldrOpen-%d: Jave image!\n", cNesting)); 350 #if 1 357 358 if (isLdrStateExecPgm() && fTkExecPgm) 359 { 360 cchName = strlen(ldrpFileNameBuf); 361 pszName = (char*)rmalloc(cchName + 2); 362 if (pszName == NULL) 363 { 364 rc = ERROR_NOT_ENOUGH_MEMORY; 365 goto cleanup; 366 } 367 memcpy(pszName, ldrpFileNameBuf, cchName+1); 368 369 psz = pszName + strlen(pszName) - 1; 370 while (psz > pszName && *psz != '.' && *psz != '\\' && *psz != '/') 371 psz--; 372 if (*psz == '.') 373 { 374 cchName = psz - pszName; 375 *psz-- = '\0'; 376 while (psz > pszName && *psz != '\\' && *psz != '/') 377 psz--; 378 379 /* check for root and evt. make room for an extra slash. */ 380 if (psz - pszName == 2) 381 { 382 memmove(psz + 1, psz, cchName - 2); 383 *psz++ = '\\'; 384 } 385 } 386 *psz = ' '; //assume fully qualified path... 387 } 388 351 389 ldrClose(*phFile); 352 strcpy(u1.pach, "JAVA.EXE"); 353 rc = ldrOpen(phFile, u1.pach, pfl); 390 rc = ldrOpen(phFile, ".\\JAVA.EXE", pfl); 354 391 if (rc != NO_ERROR) 355 rc = OpenPATH(phFile, u1.pach, pfl);392 rc = OpenPATH(phFile, "JAVA.EXE", pfl); 356 393 if (rc == NO_ERROR) 357 394 { 358 kprintf(("myldrOpen-%d: java - %s\n", cNesting, u1.pach)); 395 kprintf(("myldrOpen-%d: java - %s\n", cNesting, ldrpFileNameBuf)); 396 359 397 /** @sketch 360 * If we're in tkExecPgm state we'll have to create an extra agrument, the 361 * class name without a .class extention. We'll do this after the filename 362 * in the u1 buffer. This argument is of course added to the front. 363 * Then the Executable name is to be updated. 398 * To be able to execute any given class name we'll have to pass in the 399 * directory as -classpath. But -classpath seems to override the default 400 * and environmental CLASSPATHs. So, we'll have to pass in the value of 401 * the CLASSPATH env.var. or generate the default class path (what ever that is). 402 * 364 403 */ 365 404 if (isLdrStateExecPgm() && fTkExecPgm) 366 405 { 367 psz = u1.pach + 1 + CCHMAXPATH; /* ASSUMES that buffer is at least CCHMAXPATH*2 + 1 */ 368 strcpy(psz, pszFilename); 369 psz2 = psz + strlen(psz); 370 while (psz2 > psz && *psz2 != '\\' && *psz2 != '/') 406 psz = u1.pach; 407 408 /* 409 * Get classpath and add it as a parameter 410 */ 411 strcpy(u1.pach, "-classpath "); 412 psz = u1.pach + strlen(u1.pach); 413 414 psz3 = (char*)ScanEnv(GetEnv(TRUE), "CLASSPATH"); 415 if (psz3 != NULL) 416 { /* environment variable set */ 417 if (strlen(psz3) > 640 - 11 - 1 - cchName) //check for overflow 418 { // TODO? should reallocate... 419 memcpy(psz, psz3, 640 - 11 - 1 - cchName); 420 psz[640 - 11 - 1 - cchName] = '\0'; 421 } 422 else 423 strcpy(psz, psz3); 424 psz += strlen(psz); 425 } 426 else 371 427 { 372 if (*psz2 == '.') 373 { 374 *psz2 = '\0'; 375 break; 376 } 377 psz2--; 428 /* Make default classpath by taking the java.exe path + '..\lib\classes.zip' */ 429 strcpy(psz, ldrpFileNameBuf); 430 psz3 = psz + strlen(psz) - 1; 431 while (psz3 > psz && *psz3 != '\\' && *psz3 != '/') 432 psz3--; 433 strcpy(++psz3, "..\\lib\\classes.zip"); 434 psz = psz3 + strlen(psz3); 378 435 } 379 436 380 rc = AddArgsToFront(1, psz); 437 /* 438 * Add the class directory (as the last classpath entry) and the class name. 439 */ 440 *psz++ = ';'; 441 strcpy(psz, pszName); 442 if (pszName != NULL) 443 rfree(pszName); 444 445 /* 446 * Setup JAVA.EXE as executable with the parameters we've build. 447 */ 448 rc = AddArgsToFront(2, ldrpFileNameBuf, u1.pach); 449 kprintf(("myldrOpen-%d: java - Exe: %s Args: %s\n", cNesting, ldrpFileNameBuf, u1.pach)); 381 450 if (rc == NO_ERROR) 382 451 { 383 rc = AddArgsToFront(1, u1.pach); 384 if (rc == NO_ERROR) 385 { 386 rc = SetExecName(u1.pach); 387 if (rc != NO_ERROR) 388 kprintf(("myldrOpen-%d: java - failed to set java.exe as execname. rc=%d\n", cNesting, rc)); 389 } 390 else 391 kprintf(("myldrOpen-%d: java - failed to add programname as argument. rc=%d\n", cNesting, rc)); 452 rc = SetExecName(ldrpFileNameBuf); 453 if (rc != NO_ERROR) 454 kprintf(("myldrOpen-%d: java - failed to set java.exe as execname. rc=%d\n", cNesting, rc)); 392 455 } 393 456 else 394 kprintf(("myldrOpen-%d: java - failed to add class file as argument. rc=%d\n", cNesting, rc)); 457 kprintf(("myldrOpen-%d: java - failed to setup the parameters. rc=%d\n", cNesting, rc)); 458 395 459 goto cleanup_noerror; 396 460 } … … 399 463 kprintf(("myldrOpen-%d: java - couldn't find/open java.exe\n", cNesting)); 400 464 401 #endif 465 402 466 /** @sketch 403 467 * End of Java loading. (return) 404 468 */ 469 if (pszName != NULL) 470 rfree(pszName); 405 471 goto cleanup; 406 472 }
Note:
See TracChangeset
for help on using the changeset viewer.