- Timestamp:
- Oct 6, 2000, 5:16:07 PM (25 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/KERNEL32.DEF
r4440 r4445 1 ; $Id: KERNEL32.DEF,v 1.8 8 2000-10-06 11:04:00sandervl Exp $1 ; $Id: KERNEL32.DEF,v 1.89 2000-10-06 15:15:59 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 1033 1033 _RegisterPe2LxDll@12 @1209 1034 1034 1035 _CreateWin32PeLdrExe@ 16@12361035 _CreateWin32PeLdrExe@20 @1236 1036 1036 1037 1037 _RegisterLxExe@8 @1237 -
trunk/src/kernel32/directory.cpp
r4387 r4445 1 /* $Id: directory.cpp,v 1.3 0 2000-10-02 18:39:33 sandervl Exp $ */1 /* $Id: directory.cpp,v 1.31 2000-10-06 15:16:03 sandervl Exp $ */ 2 2 3 3 /* … … 112 112 LPSTR, lpBuffer) 113 113 { 114 return O32_GetCurrentDirectory(nBufferLength, lpBuffer); 114 UINT rc; 115 116 rc = O32_GetCurrentDirectory(nBufferLength, lpBuffer); 117 if(rc) { 118 dprintf(("CurrentDirectory = %s", lpBuffer)); 119 } 120 return rc; 115 121 } 116 122 -
trunk/src/kernel32/winexepeldr.cpp
r4440 r4445 1 /* $Id: winexepeldr.cpp,v 1.1 2 2000-10-06 11:04:01sandervl Exp $ */1 /* $Id: winexepeldr.cpp,v 1.13 2000-10-06 15:16:03 sandervl Exp $ */ 2 2 3 3 /* 4 4 * Win32 PE loader Exe class 5 5 * 6 * Copyright 1998- 1999Sander van Leeuwen (sandervl@xs4all.nl)6 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl) 7 7 * 8 8 * … … 23 23 #include <misc.h> 24 24 #include <win32type.h> 25 #include <win32api.h> 25 26 #include <winexepeldr.h> 26 27 #include <wprocess.h> … … 46 47 //****************************************************************************** 47 48 //Called by ring 3 pe loader to create win32 executable 49 //PE.EXE command line options: 50 // /OPT:[x1=y,x2=z,..] 51 // x = CURDIR -> set current directory to y 52 // (not other options available at this time) 48 53 //****************************************************************************** 49 BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, char *szCmdLine, 54 BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, char *szCmdLine, 55 char *peoptions, 50 56 ULONG reservedMem, BOOL fConsoleApp) 51 57 { … … 67 73 return FALSE; 68 74 } 75 //Handle special pe cmd line options here (/OPT:[x1=y,x2=z,..]) 76 if(peoptions) { 77 char *option; 69 78 79 option = strchr(peoptions, '['); 80 if(option) { 81 option++; 82 option = strstr(option, "CURDIR="); 83 if(option) { 84 char *curdir, *tmp; 85 int curdirlength; 86 87 option += 7; 88 tmp = option; 89 while(*tmp != ']' && *tmp != ',' && *tmp != 0) { 90 tmp++; 91 } 92 curdirlength = (int)(tmp-option); 93 curdir = (char *)malloc(curdirlength+1); 94 memcpy(curdir, option, curdirlength); 95 curdir[curdirlength] = 0; 96 SetCurrentDirectoryA((LPCSTR)curdir); 97 free(curdir); 98 } 99 } 100 } 70 101 //exe length + space + (possibly) 2x'"' + cmd line length + 0 terminator 71 102 szFullCmdLine = (char *)malloc(strlen(szFileName) + 3 + strlen(szCmdLine) + 1); -
trunk/src/kernel32/winexepeldr.h
r4440 r4445 1 /* $Id: winexepeldr.h,v 1. 3 2000-10-06 11:04:02sandervl Exp $ */1 /* $Id: winexepeldr.h,v 1.4 2000-10-06 15:16:04 sandervl Exp $ */ 2 2 3 3 /* … … 16 16 #include <winimagepeldr.h> 17 17 18 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, ULONG, BOOL);18 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, char *, ULONG, BOOL); 19 19 20 20 //Class for executables run by the ring 3 PE loader -
trunk/src/kernel32/winimagepeldr.cpp
r4440 r4445 1 /* $Id: winimagepeldr.cpp,v 1.5 6 2000-10-06 11:04:02sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.57 2000-10-06 15:16:05 sandervl Exp $ */ 2 2 3 3 /* … … 480 480 char *pszName; 481 481 482 switch (i) 483 { 482 if(oh.DataDirectory[i].VirtualAddress && oh.DataDirectory[i].Size) { 483 switch (i) 484 { 484 485 case IMAGE_DIRECTORY_ENTRY_EXPORT: pszName = "Export Directory (IMAGE_DIRECTORY_ENTRY_EXPORT)"; break; 485 486 case IMAGE_DIRECTORY_ENTRY_IMPORT: pszName = "Import Directory (IMAGE_DIRECTORY_ENTRY_IMPORT)"; break; … … 497 498 default: 498 499 pszName = "unknown"; 499 } 500 dprintf((LOG, "directory %s", pszName)); 501 dprintf((LOG, " Address 0x%08x", oh.DataDirectory[i].VirtualAddress)); 502 dprintf((LOG, " Size 0x%08x", oh.DataDirectory[i].Size)); 500 } 501 dprintf((LOG, "directory %s", pszName)); 502 dprintf((LOG, " Address 0x%08x", oh.DataDirectory[i].VirtualAddress)); 503 dprintf((LOG, " Size 0x%08x", oh.DataDirectory[i].Size)); 504 } 503 505 } 504 506 dprintf((LOG, "\n\n")); -
trunk/src/kernel32/winimgres.cpp
r4436 r4445 1 /* $Id: winimgres.cpp,v 1.4 7 2000-10-05 19:38:45sandervl Exp $ */1 /* $Id: winimgres.cpp,v 1.48 2000-10-06 15:16:06 sandervl Exp $ */ 2 2 3 3 /* … … 323 323 } 324 324 325 325 /** 326 * This function finds a resource (sub)directory within a given resource directory. 327 * @returns Pointer to resource directory. NULL if not found or not a directory. 328 * @param pResDirToSearch Pointer to resource directory to search. (any level) 329 * @param lpszName Resource ID string. 330 * @sketch 331 * @status completely implemented 332 * @author knut st. osmundsen 333 */ 334 PIMAGE_RESOURCE_DIRECTORY Win32ImageBase::getResSubDirW(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch, 335 LPCWSTR lpszName) 336 { 337 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 338 int i; 339 int idName = -1; 340 341 if(pResDirToSearch == NULL) { 342 return NULL; 343 } 344 345 /* lpszName */ 346 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszName) != 0) 347 { 348 if (lpszName[0] == '#') 349 { 350 char szBuf[10]; 351 lstrcpynWtoA(szBuf, (WCHAR*)(lpszName + 1), sizeof(szBuf)); 352 idName = atoi(szBuf); 353 } 354 } 355 else 356 idName = (int)lpszName; 357 358 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirToSearch + sizeof(*pResDirToSearch)); 359 if(idName == ID_GETFIRST) { 360 return paResDirEntries[0].u2.s.DataIsDirectory ? 361 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[0].u2.s.OffsetToDirectory + (ULONG)pResRootDir) 362 : NULL; 363 } 364 365 if (idName != -1) 366 { /* idName */ 367 paResDirEntries += pResDirToSearch->NumberOfNamedEntries; 368 369 for (i = 0; i < pResDirToSearch->NumberOfIdEntries; i++) 370 if (paResDirEntries[i].u1.Id == (WORD)idName) 371 return paResDirEntries[i].u2.s.DataIsDirectory ? 372 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir /*?*/ 373 /*- ulRVAResourceSection*/) 374 : NULL; 375 } 376 else 377 { /* string name */ 378 int cusName = lstrlenW(lpszName); 379 380 for (i = 0; i < pResDirToSearch->NumberOfNamedEntries; i++) 381 { 382 PIMAGE_RESOURCE_DIR_STRING_U pResDirStr = 383 (PIMAGE_RESOURCE_DIR_STRING_U)(paResDirEntries[i].u1.s.NameOffset + (ULONG)pResRootDir /*?*/); 384 385 //SvL: Must do case insensitive string compare here 386 if (pResDirStr->Length == cusName 387 && lstrncmpiW(pResDirStr->NameString, lpszName, cusName) == 0) 388 { 389 return paResDirEntries[i].u2.s.DataIsDirectory ? 390 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir 391 /*- ulRVAResourceSection*/) 392 : NULL; 393 } 394 } 395 } 396 397 return NULL; 398 } 399 400 /** 401 * This function finds a resource (sub)directory within a given resource directory. 402 * @returns Pointer to resource directory. NULL if not found or not a directory. 403 * @param pResDirToSearch Pointer to resource directory to search. (any level) 404 * @param lpszName Resource ID string. 405 * @sketch 406 * @status completely implemented 407 * @author knut st. osmundsen 408 */ 409 PIMAGE_RESOURCE_DIRECTORY Win32ImageBase::getResSubDirA(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch, 410 LPCTSTR lpszName) 411 { 412 PIMAGE_RESOURCE_DIRECTORY pResDirRet; 413 LPCWSTR lpszwName; 414 415 if(pResDirToSearch == NULL) { 416 return NULL; 417 } 418 419 /* lpszName */ 420 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszName) != 0) 421 { 422 lpszwName = AsciiToUnicodeString((char*)lpszName); 423 if (lpszwName == NULL) 424 return NULL; 425 } 426 else 427 lpszwName = (LPWSTR)lpszName; 428 429 pResDirRet = getResSubDirW(pResDirToSearch, lpszwName); 430 431 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszwName) != 0) 432 free((void*)lpszwName); 433 434 return pResDirRet; 435 } 436 //****************************************************************************** 437 /** 438 * This function finds a resource data entry within a given resource directory. 439 * @returns Pointer to resource data entry. NULL if not found 440 * @param pResDirToSearch Pointer to resource directory to search. (lang level) 441 * @param language Resource language id 442 * @param fGetDefault TRUE -> get first available resource if not found 443 * @sketch 444 * @status completely implemented 445 * @author Sander van Leeuwen 446 */ 447 //****************************************************************************** 448 PIMAGE_RESOURCE_DATA_ENTRY 449 Win32ImageBase::getResDataLang(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch, 450 ULONG language, BOOL fGetDefault) 451 { 452 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 453 int i; 454 455 if(pResDirToSearch == NULL) { 456 return NULL; 457 } 458 459 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirToSearch + sizeof(*pResDirToSearch)); 460 461 if(pResDirToSearch->NumberOfNamedEntries) { 462 DebugInt3(); 463 } 464 paResDirEntries += pResDirToSearch->NumberOfNamedEntries; 465 466 for (i = 0; i < pResDirToSearch->NumberOfIdEntries; i++) { 467 if (paResDirEntries[i].u1.Id == language) 468 { 469 return (PIMAGE_RESOURCE_DATA_ENTRY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir); 470 } 471 } 472 473 // if nothing found and fGetDefault is true, return first entry 474 if(fGetDefault) 475 { 476 return (PIMAGE_RESOURCE_DATA_ENTRY) (paResDirEntries[0].u2.s.OffsetToDirectory + (ULONG)pResRootDir); 477 } 478 return NULL; 479 } 480 //****************************************************************************** 481 //****************************************************************************** 482 BOOL Win32ImageBase::enumResourceTypesA(HMODULE hmod, ENUMRESTYPEPROCA lpEnumFunc, 483 LONG lParam) 484 { 485 PIMAGE_RESOURCE_DIRECTORY prdType; 486 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde; 487 PIMAGE_RESOURCE_DIR_STRING_U pstring; 488 ULONG i, nameOffset; 489 BOOL fRet; 490 491 if (pResRootDir == NULL) 492 { 493 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 494 return FALSE; 495 } 496 497 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000) 498 { 499 SetLastError(ERROR_NOACCESS); 500 return FALSE; 501 } 502 503 //reminder: 504 //1st level -> types 505 //2nd level -> names 506 //3rd level -> language 507 508 /* set pointer to first resource type entry */ 509 prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResRootDir + sizeof(IMAGE_RESOURCE_DIRECTORY)); 510 511 for (i=0; i<pResRootDir->NumberOfNamedEntries+pResRootDir->NumberOfIdEntries && fRet; i++) 512 { 513 /* locate directory or each resource type */ 514 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResRootDir + (int)prde->u2.OffsetToData); 515 516 if (prde->u1.s.NameIsString) 517 {//name or id entry? 518 //SvL: 30-10-'97, high bit is set, so clear to get real offset 519 nameOffset = prde->u1.Name & ~0x80000000; 520 521 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResRootDir + nameOffset); 522 char *typename = (char *)malloc(pstring->Length+1); 523 lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1); 524 typename[pstring->Length] = 0; 525 526 fRet = lpEnumFunc(hmod, typename, lParam); 527 free(typename); 528 } 529 else { 530 fRet = lpEnumFunc(hmod, (LPSTR)prde->u1.Id, lParam); 531 } 532 533 /* increment to next entry */ 534 prde++; 535 } 536 return fRet > 0 ? TRUE : FALSE; 537 } 538 //****************************************************************************** 539 //****************************************************************************** 540 BOOL Win32ImageBase::enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc, 541 LONG lParam) 542 { 543 PIMAGE_RESOURCE_DIRECTORY prdType; 544 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde; 545 PIMAGE_RESOURCE_DIR_STRING_U pstring; 546 ULONG i, nameOffset; 547 BOOL fRet; 548 LPWSTR lpszType; 549 550 if (pResRootDir == NULL) 551 { 552 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 553 return FALSE; 554 } 555 556 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000) 557 { 558 SetLastError(ERROR_NOACCESS); 559 return FALSE; 560 } 561 562 //reminder: 563 //1st level -> types 564 //2nd level -> names 565 //3rd level -> language 566 567 /* set pointer to first resource type entry */ 568 prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResRootDir + sizeof(IMAGE_RESOURCE_DIRECTORY)); 569 570 for (i=0; i<pResRootDir->NumberOfNamedEntries+pResRootDir->NumberOfIdEntries && fRet; i++) 571 { 572 /* locate directory or each resource type */ 573 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResRootDir + (int)prde->u2.OffsetToData); 574 575 if (prde->u1.s.NameIsString) 576 {//name or id entry? 577 //SvL: 30-10-'97, high bit is set, so clear to get real offset 578 nameOffset = prde->u1.Name & ~0x80000000; 579 580 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResRootDir + nameOffset); 581 582 lpszType = (LPWSTR)malloc((pstring->Length+1) * sizeof(WCHAR)); 583 memcpy(lpszType, pstring->NameString, pstring->Length * sizeof(WCHAR)); 584 lpszType[pstring->Length] = 0; 585 586 fRet = lpEnumFunc(hmod, pstring->NameString, lParam); 587 588 free(lpszType); 589 } 590 else fRet = lpEnumFunc(hmod, (LPWSTR)prde->u1.Id, lParam); 591 592 /* increment to next entry */ 593 prde++; 594 } 595 return fRet > 0 ? TRUE : FALSE; 596 } 326 597 /** 327 598 * The EnumResourceNames function searches a module for each … … 362 633 LONG lParam) 363 634 { 364 365 366 635 BOOL fRet; 636 PIMAGE_RESOURCE_DIRECTORY pResDirOurType; 637 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 367 638 368 639 if (pResRootDir == NULL) … … 484 755 LONG lParam) 485 756 { 486 487 488 757 BOOL fRet; 758 PIMAGE_RESOURCE_DIRECTORY pResDirOurType; 759 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 489 760 490 761 if (pResRootDir == NULL) … … 517 788 { 518 789 unsigned cResEntries; 519 unsigned i ;790 unsigned i, length; 520 791 521 792 fRet = TRUE; … … 524 795 for (i = 0; i < cResEntries && fRet; i++) 525 796 { 526 LPWSTR lpszName; 527 528 if (paResDirEntries[i].u1.s.NameIsString) 797 LPWSTR lpszName, lpszResName; 798 799 if(paResDirEntries[i].u1.s.NameIsString) 800 { 529 801 lpszName = (LPWSTR)(paResDirEntries[i].u1.s.NameOffset + (ULONG)pResRootDir + 2); 530 else 802 length = (int)*(LPWSTR)(paResDirEntries[i].u1.s.NameOffset + (ULONG)pResRootDir); 803 804 lpszResName = (LPWSTR)malloc((length+1) * sizeof(WCHAR)); 805 memcpy(lpszResName, lpszName, length * sizeof(WCHAR)); 806 lpszResName[length] = 0; 807 808 fRet = lpEnumFunc(hmod, lpszType, lpszResName, lParam); 809 free(lpszResName); 810 } 811 else { 531 812 lpszName = (LPWSTR)paResDirEntries[i].u1.Id; 532 533 fRet = lpEnumFunc(hmod, lpszType, lpszName, lParam);813 fRet = lpEnumFunc(hmod, lpszType, lpszName, lParam); 814 } 534 815 } 535 816 } … … 541 822 542 823 return fRet > 0; 543 }544 545 546 547 /**548 * This function finds a resource (sub)directory within a given resource directory.549 * @returns Pointer to resource directory. NULL if not found or not a directory.550 * @param pResDirToSearch Pointer to resource directory to search. (any level)551 * @param lpszName Resource ID string.552 * @sketch553 * @status completely implemented554 * @author knut st. osmundsen555 */556 PIMAGE_RESOURCE_DIRECTORY Win32ImageBase::getResSubDirW(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch,557 LPCWSTR lpszName)558 {559 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries;560 int i;561 int idName = -1;562 563 if(pResDirToSearch == NULL) {564 return NULL;565 }566 567 /* lpszName */568 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszName) != 0)569 {570 if (lpszName[0] == '#')571 {572 char szBuf[10];573 lstrcpynWtoA(szBuf, (WCHAR*)(lpszName + 1), sizeof(szBuf));574 idName = atoi(szBuf);575 }576 }577 else578 idName = (int)lpszName;579 580 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirToSearch + sizeof(*pResDirToSearch));581 if(idName == ID_GETFIRST) {582 return paResDirEntries[0].u2.s.DataIsDirectory ?583 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[0].u2.s.OffsetToDirectory + (ULONG)pResRootDir)584 : NULL;585 }586 587 if (idName != -1)588 { /* idName */589 paResDirEntries += pResDirToSearch->NumberOfNamedEntries;590 591 for (i = 0; i < pResDirToSearch->NumberOfIdEntries; i++)592 if (paResDirEntries[i].u1.Id == (WORD)idName)593 return paResDirEntries[i].u2.s.DataIsDirectory ?594 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir /*?*/595 /*- ulRVAResourceSection*/)596 : NULL;597 }598 else599 { /* string name */600 int cusName = lstrlenW(lpszName);601 602 for (i = 0; i < pResDirToSearch->NumberOfNamedEntries; i++)603 {604 PIMAGE_RESOURCE_DIR_STRING_U pResDirStr =605 (PIMAGE_RESOURCE_DIR_STRING_U)(paResDirEntries[i].u1.s.NameOffset + (ULONG)pResRootDir /*?*/);606 607 //SvL: Must do case insensitive string compare here608 if (pResDirStr->Length == cusName609 && lstrncmpiW(pResDirStr->NameString, lpszName, cusName) == 0)610 {611 return paResDirEntries[i].u2.s.DataIsDirectory ?612 (PIMAGE_RESOURCE_DIRECTORY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir613 /*- ulRVAResourceSection*/)614 : NULL;615 }616 }617 }618 619 return NULL;620 }621 622 /**623 * This function finds a resource (sub)directory within a given resource directory.624 * @returns Pointer to resource directory. NULL if not found or not a directory.625 * @param pResDirToSearch Pointer to resource directory to search. (any level)626 * @param lpszName Resource ID string.627 * @sketch628 * @status completely implemented629 * @author knut st. osmundsen630 */631 PIMAGE_RESOURCE_DIRECTORY Win32ImageBase::getResSubDirA(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch,632 LPCTSTR lpszName)633 {634 PIMAGE_RESOURCE_DIRECTORY pResDirRet;635 LPCWSTR lpszwName;636 637 if(pResDirToSearch == NULL) {638 return NULL;639 }640 641 /* lpszName */642 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszName) != 0)643 {644 lpszwName = AsciiToUnicodeString((char*)lpszName);645 if (lpszwName == NULL)646 return NULL;647 }648 else649 lpszwName = (LPWSTR)lpszName;650 651 pResDirRet = getResSubDirW(pResDirToSearch, lpszwName);652 653 if ((ULONG)lpszName != ID_GETFIRST && HIWORD(lpszwName) != 0)654 free((void*)lpszwName);655 656 return pResDirRet;657 }658 //******************************************************************************659 /**660 * This function finds a resource data entry within a given resource directory.661 * @returns Pointer to resource data entry. NULL if not found662 * @param pResDirToSearch Pointer to resource directory to search. (lang level)663 * @param language Resource language id664 * @param fGetDefault TRUE -> get first available resource if not found665 * @sketch666 * @status completely implemented667 * @author Sander van Leeuwen668 */669 //******************************************************************************670 PIMAGE_RESOURCE_DATA_ENTRY671 Win32ImageBase::getResDataLang(PIMAGE_RESOURCE_DIRECTORY pResDirToSearch,672 ULONG language, BOOL fGetDefault)673 {674 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries;675 int i;676 677 if(pResDirToSearch == NULL) {678 return NULL;679 }680 681 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirToSearch + sizeof(*pResDirToSearch));682 683 if(pResDirToSearch->NumberOfNamedEntries) {684 DebugInt3();685 }686 paResDirEntries += pResDirToSearch->NumberOfNamedEntries;687 688 for (i = 0; i < pResDirToSearch->NumberOfIdEntries; i++) {689 if (paResDirEntries[i].u1.Id == language)690 {691 return (PIMAGE_RESOURCE_DATA_ENTRY) (paResDirEntries[i].u2.s.OffsetToDirectory + (ULONG)pResRootDir);692 }693 }694 695 // if nothing found and fGetDefault is true, return first entry696 if(fGetDefault)697 {698 return (PIMAGE_RESOURCE_DATA_ENTRY) (paResDirEntries[0].u2.s.OffsetToDirectory + (ULONG)pResRootDir);699 }700 return NULL;701 }702 //******************************************************************************703 //******************************************************************************704 BOOL Win32ImageBase::enumResourceTypesA(HMODULE hmod, ENUMRESTYPEPROCA lpEnumFunc,705 LONG lParam)706 {707 PIMAGE_RESOURCE_DIRECTORY prdType;708 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde;709 PIMAGE_RESOURCE_DIR_STRING_U pstring;710 ULONG i, nameOffset;711 BOOL fRet;712 713 if (pResRootDir == NULL)714 {715 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);716 return FALSE;717 }718 719 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000)720 {721 SetLastError(ERROR_NOACCESS);722 return FALSE;723 }724 725 //reminder:726 //1st level -> types727 //2nd level -> names728 //3rd level -> language729 730 /* set pointer to first resource type entry */731 prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResRootDir + sizeof(IMAGE_RESOURCE_DIRECTORY));732 733 for (i=0; i<pResRootDir->NumberOfNamedEntries+pResRootDir->NumberOfIdEntries && fRet; i++)734 {735 /* locate directory or each resource type */736 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResRootDir + (int)prde->u2.OffsetToData);737 738 if (prde->u1.s.NameIsString)739 {//name or id entry?740 //SvL: 30-10-'97, high bit is set, so clear to get real offset741 nameOffset = prde->u1.Name & ~0x80000000;742 743 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResRootDir + nameOffset);744 char *typename = (char *)malloc(pstring->Length+1);745 lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1);746 typename[pstring->Length] = 0;747 748 fRet = lpEnumFunc(hmod, typename, lParam);749 free(typename);750 }751 else {752 fRet = lpEnumFunc(hmod, (LPSTR)prde->u1.Id, lParam);753 }754 755 /* increment to next entry */756 prde++;757 }758 return fRet > 0 ? TRUE : FALSE;759 }760 //******************************************************************************761 //******************************************************************************762 BOOL Win32ImageBase::enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc,763 LONG lParam)764 {765 PIMAGE_RESOURCE_DIRECTORY prdType;766 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde;767 PIMAGE_RESOURCE_DIR_STRING_U pstring;768 ULONG i, nameOffset;769 BOOL fRet;770 771 if (pResRootDir == NULL)772 {773 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);774 return FALSE;775 }776 777 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000)778 {779 SetLastError(ERROR_NOACCESS);780 return FALSE;781 }782 783 //reminder:784 //1st level -> types785 //2nd level -> names786 //3rd level -> language787 788 /* set pointer to first resource type entry */789 prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResRootDir + sizeof(IMAGE_RESOURCE_DIRECTORY));790 791 for (i=0; i<pResRootDir->NumberOfNamedEntries+pResRootDir->NumberOfIdEntries && fRet; i++)792 {793 /* locate directory or each resource type */794 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResRootDir + (int)prde->u2.OffsetToData);795 796 if (prde->u1.s.NameIsString)797 {//name or id entry?798 //SvL: 30-10-'97, high bit is set, so clear to get real offset799 nameOffset = prde->u1.Name & ~0x80000000;800 801 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResRootDir + nameOffset);802 fRet = lpEnumFunc(hmod, pstring->NameString, lParam);803 }804 else fRet = lpEnumFunc(hmod, (LPWSTR)prde->u1.Id, lParam);805 806 /* increment to next entry */807 prde++;808 }809 return fRet > 0 ? TRUE : FALSE;810 824 } 811 825 //****************************************************************************** -
trunk/src/kernel32/wprocess.cpp
r4422 r4445 1 /* $Id: wprocess.cpp,v 1.10 1 2000-10-04 19:36:26sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.102 2000-10-06 15:16:07 sandervl Exp $ */ 2 2 3 3 /* … … 1563 1563 } 1564 1564 cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16); 1565 sprintf(cmdline, " PE.EXE%s %s", lpApplicationName, lpCommandLine);1565 sprintf(cmdline, "%s %s", lpApplicationName, lpCommandLine); 1566 1566 } 1567 1567 else { 1568 1568 cmdline = (char *)malloc(strlen(lpApplicationName) + 16); 1569 sprintf(cmdline, " PE.EXE%s", lpApplicationName);1569 sprintf(cmdline, "%s", lpApplicationName); 1570 1570 } 1571 1571 } 1572 1572 else { 1573 1573 cmdline = (char *)malloc(strlen(lpCommandLine) + 16); 1574 sprintf(cmdline, " PE.EXE%s", lpCommandLine);1574 sprintf(cmdline, "%s", lpCommandLine); 1575 1575 } 1576 1576 char szAppName[255]; 1577 1577 char *exename = szAppName; 1578 strncpy(szAppName, &cmdline[7], sizeof(szAppName)); //skip pe.exe1578 strncpy(szAppName, cmdline, sizeof(szAppName)); 1579 1579 szAppName[254] = 0; 1580 1580 if(*exename == '"') { … … 1600 1600 } 1601 1601 dprintf(("KERNEL32: CreateProcess %s\n", cmdline)); 1602 1603 //SvL: Allright. Before we call O32_CreateProcess, we must take care of 1604 // lpCurrentDirectory ourselves. (Open32 ignores it!) 1605 if(lpCurrentDirectory) { 1606 char *newcmdline; 1607 1608 newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32); 1609 sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline); 1610 free(cmdline); 1611 cmdline = newcmdline; 1612 } 1613 else { 1614 char *newcmdline; 1615 1616 newcmdline = (char *)malloc(strlen(cmdline) + 16); 1617 sprintf(newcmdline, "PE.EXE %s", cmdline); 1618 free(cmdline); 1619 cmdline = newcmdline; 1620 } 1602 1621 rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline,lpProcessAttributes, 1603 1622 lpThreadAttributes, bInheritHandles, dwCreationFlags, 1604 1623 lpEnvironment, lpCurrentDirectory, lpStartupInfo, 1605 1624 lpProcessInfo); 1606 if(rc == TRUE) { 1625 if(rc == TRUE) 1626 { 1607 1627 if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL) 1608 1628 { -
trunk/src/peldr/pe.cpp
r4441 r4445 1 /* $Id: pe.cpp,v 1.2 2 2000-10-06 11:04:42sandervl Exp $ */1 /* $Id: pe.cpp,v 1.23 2000-10-06 15:15:25 sandervl Exp $ */ 2 2 3 3 /* 4 4 * PELDR main exe loader code 5 5 * 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)6 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl) 7 7 * 8 * Command line options: 9 * /OPT:[x1=y,x2=z,..] 10 * x = CURDIR -> set current directory to y 11 * (not other options available at this time) 8 12 * 9 13 * Project Odin Software License can be found in LICENSE.TXT … … 63 67 64 68 //should be the same as in ..\kernel32\winexepeldr.h 65 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, ULONG, BOOL);69 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, char *, ULONG, BOOL); 66 70 67 71 WIN32CTOR CreateWin32Exe = 0; … … 83 87 PTIB ptib; 84 88 PPIB ppib; 85 char *cmdline, *win32cmdline ;89 char *cmdline, *win32cmdline, *peoptions, *newcmdline; 86 90 BOOL fQuote = FALSE; 87 91 int nrTries = 1; … … 92 96 cmdline = ppib->pib_pchcmd; 93 97 cmdline += strlen(cmdline)+1; //skip pe.exe 98 peoptions = strstr(cmdline, "/OPT:["); 99 if(peoptions) { 100 newcmdline = strchr(peoptions, ']'); 101 if(newcmdline) { 102 cmdline = newcmdline+1; 103 } 104 else DebugInt3(); //should not happen! 105 } 94 106 while(*cmdline == ' ') cmdline++; //skip leading space 95 107 if(*cmdline == '"') { … … 186 198 goto fail; 187 199 } 188 rc = DosQueryProcAddr(hmodKernel32, 0, "_CreateWin32PeLdrExe@ 16", (PFN *)&CreateWin32Exe);189 190 if(CreateWin32Exe(exeName, win32cmdline, reservedMemory, fConsoleApp) == FALSE) {200 rc = DosQueryProcAddr(hmodKernel32, 0, "_CreateWin32PeLdrExe@20", (PFN *)&CreateWin32Exe); 201 202 if(CreateWin32Exe(exeName, win32cmdline, peoptions, reservedMemory, fConsoleApp) == FALSE) { 191 203 goto fail; 192 204 }
Note:
See TracChangeset
for help on using the changeset viewer.