- Timestamp:
- Dec 14, 1999, 8:14:28 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 4 edited
-
heapstring.cpp (modified) (5 diffs)
-
mmap.cpp (modified) (2 diffs)
-
winexepeldr.cpp (modified) (2 diffs)
-
wprocess.cpp (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/heapstring.cpp
r2032 r2077 1 /* $Id: heapstring.cpp,v 1.2 2 1999-12-09 00:52:20sandervl Exp $ */1 /* $Id: heapstring.cpp,v 1.23 1999-12-14 19:14:27 sandervl Exp $ */ 2 2 3 3 /* … … 138 138 arg2)); 139 139 140 return O32_lstrcat(arg1, arg2); 140 if(arg2 == NULL) 141 return arg1; 142 strcat(arg1, arg2); 143 return arg1; 141 144 } 142 145 … … 159 162 arg1, 160 163 arg2)); 164 165 if(arg2 == NULL) 166 return arg1; 161 167 162 168 UniStrcat( (UniChar*) arg1, (UniChar*) arg2 ); … … 326 332 *****************************************************************************/ 327 333 328 ODINFUNCTION2(LPSTR,lstrcpyA,LPSTR, dest, 329 LPCSTR,src) 334 LPSTR WIN32API lstrcpyA(LPSTR dest, LPCSTR src) 330 335 { 331 336 if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking … … 348 353 *****************************************************************************/ 349 354 350 ODINFUNCTION2(LPWSTR,lstrcpyW,LPWSTR, dest, 351 LPCWSTR,src) 355 LPWSTR WIN32API lstrcpyW(LPWSTR dest, LPCWSTR src) 352 356 { 353 357 if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking -
trunk/src/kernel32/mmap.cpp
r2072 r2077 1 /* $Id: mmap.cpp,v 1. 29 1999-12-14 12:50:45sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.30 1999-12-14 19:14:28 sandervl Exp $ */ 2 2 3 3 /* … … 337 337 goto fail; 338 338 } 339 if(hMemFile == -1 && !image && (mProtFlags & SEC_COMMIT)) {//commit memory 339 //Windows NT seems to commit memory for memory maps, regardsless of the SEC_COMMIT flag 340 if(hMemFile == -1 && !image) {//commit memory 340 341 VirtualAlloc(pMapping, mSize, MEM_COMMIT, PAGE_READWRITE); 341 342 } -
trunk/src/kernel32/winexepeldr.cpp
r1833 r2077 1 /* $Id: winexepeldr.cpp,v 1. 5 1999-11-24 19:31:23sandervl Exp $ */1 /* $Id: winexepeldr.cpp,v 1.6 1999-12-14 19:14:28 sandervl Exp $ */ 2 2 3 3 /* … … 65 65 66 66 WinExe->setCommandLine(szCmdLine); 67 dprintf(("Cmd line: %s", szCmdLine)); 67 68 68 69 if(getenv("WIN32_IOPL2")) { -
trunk/src/kernel32/wprocess.cpp
r2053 r2077 1 /* $Id: wprocess.cpp,v 1.5 7 1999-12-10 14:06:12sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.58 1999-12-14 19:14:28 sandervl Exp $ */ 2 2 3 3 /* … … 8 8 * 9 9 * NOTE: Even though Odin32 OS/2 apps don't switch FS selectors, 10 * we still allocate a TEB to store misc information. 10 * we still allocate a TEB to store misc information. 11 11 * 12 12 * Project Odin Software License can be found in LICENSE.TXT … … 46 46 //****************************************************************************** 47 47 BOOL fFreeLibrary = FALSE; 48 BOOL fIsOS2Image = FALSE; //TRUE -> Odin32 OS/2 application (not converted!)49 //FALSE -> otherwise48 BOOL fIsOS2Image = FALSE; //TRUE -> Odin32 OS/2 application (not converted!) 49 //FALSE -> otherwise 50 50 //Process database 51 51 PDB ProcessPDB = {0}; … … 58 58 { 59 59 if(TIBFlatPtr == NULL) 60 return 0;60 return 0; 61 61 62 62 return (TEB *)*TIBFlatPtr; … … 70 70 71 71 if(TIBFlatPtr == NULL) 72 return 0;72 return 0; 73 73 74 74 winteb = (TEB *)*TIBFlatPtr; 75 75 if(winteb == NULL) { 76 return NULL;76 return NULL; 77 77 } 78 78 thdb = (THDB *)(winteb+1); … … 92 92 //Allocate one dword to store the flat address of our TEB 93 93 if(fMainThread) { 94 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1);95 if(TIBFlatPtr == 0) {96 dprintf(("InitializeTIB: local thread memory alloc failed!!"));97 DebugInt3();98 return NULL;99 }94 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1); 95 if(TIBFlatPtr == 0) { 96 dprintf(("InitializeTIB: local thread memory alloc failed!!")); 97 DebugInt3(); 98 return NULL; 99 } 100 100 } 101 101 if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE) 102 102 { 103 dprintf(("InitializeTIB: selector alloc failed!!"));104 DebugInt3();105 return NULL;103 dprintf(("InitializeTIB: selector alloc failed!!")); 104 DebugInt3(); 105 return NULL; 106 106 } 107 107 winteb = (TEB *)OSLibSelToFlat(tibsel); 108 108 if(winteb == NULL) 109 109 { 110 dprintf(("InitializeTIB: DosSelToFlat failed!!"));111 DebugInt3();112 return NULL;110 dprintf(("InitializeTIB: DosSelToFlat failed!!")); 111 DebugInt3(); 112 return NULL; 113 113 } 114 114 memset(winteb, 0, PAGE_SIZE); … … 136 136 if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM) 137 137 { 138 thdb->flags = 0; //todo gui138 thdb->flags = 0; //todo gui 139 139 } 140 140 else thdb->flags = 0; //todo textmode … … 142 142 if(fMainThread) 143 143 { 144 //todo initialize PDB during process creation144 //todo initialize PDB during process creation 145 145 //todo: initialize TLS array if required 146 146 //TLS in executable always TLS index 0? 147 ProcessTIBSel = tibsel;148 ProcessPDB.exit_code = 0x103; /* STILL_ACTIVE */149 ProcessPDB.threads = 1;150 ProcessPDB.running_threads = 1;151 ProcessPDB.ring0_threads = 1;152 ProcessPDB.system_heap = GetProcessHeap();153 ProcessPDB.parent = 0;154 ProcessPDB.group = &ProcessPDB;155 ProcessPDB.priority = 8; /* Normal */156 ProcessPDB.heap = ProcessPDB.system_heap; /* will be changed later on */157 ProcessPDB.next = NULL;158 ProcessPDB.winver = 0xffff; /* to be determined */147 ProcessTIBSel = tibsel; 148 ProcessPDB.exit_code = 0x103; /* STILL_ACTIVE */ 149 ProcessPDB.threads = 1; 150 ProcessPDB.running_threads = 1; 151 ProcessPDB.ring0_threads = 1; 152 ProcessPDB.system_heap = GetProcessHeap(); 153 ProcessPDB.parent = 0; 154 ProcessPDB.group = &ProcessPDB; 155 ProcessPDB.priority = 8; /* Normal */ 156 ProcessPDB.heap = ProcessPDB.system_heap; /* will be changed later on */ 157 ProcessPDB.next = NULL; 158 ProcessPDB.winver = 0xffff; /* to be determined */ 159 159 ProcessPDB.server_pid = (void *)GetCurrentProcessId(); 160 160 161 GetSystemTime(&ProcessPDB.creationTime);161 GetSystemTime(&ProcessPDB.creationTime); 162 162 163 163 /* Initialize the critical section */ … … 182 182 winteb = (TEB *)*TIBFlatPtr; 183 183 if(winteb) { 184 thdb = (THDB *)(winteb+1);185 orgtibsel = thdb->OrgTIBSel;186 187 //Restore our original FS selector188 SetFS(orgtibsel);189 190 //And free our own191 OSLibFreeSel(thdb->teb_sel);184 thdb = (THDB *)(winteb+1); 185 orgtibsel = thdb->OrgTIBSel; 186 187 //Restore our original FS selector 188 SetFS(orgtibsel); 189 190 //And free our own 191 OSLibFreeSel(thdb->teb_sel); 192 192 } 193 193 else dprintf(("Already destroyed TIB")); … … 214 214 //we don't switch FS selectors 215 215 if(fIsOS2Image) { 216 return;216 return; 217 217 } 218 218 219 219 winteb = (TEB *)*TIBFlatPtr; 220 220 if(winteb) { 221 thdb = (THDB *)(winteb+1);222 orgtibsel = thdb->OrgTIBSel;223 224 //Restore our original FS selector225 SetFS(orgtibsel);221 thdb = (THDB *)(winteb+1); 222 orgtibsel = thdb->OrgTIBSel; 223 224 //Restore our original FS selector 225 SetFS(orgtibsel); 226 226 } 227 227 } … … 237 237 //we don't switch FS selectors 238 238 if(fIsOS2Image) { 239 return GetFS();239 return GetFS(); 240 240 } 241 241 242 242 winteb = (TEB *)*TIBFlatPtr; 243 243 if(winteb) { 244 thdb = (THDB *)(winteb+1);245 win32tibsel = thdb->teb_sel;246 247 //Restore our win32 FS selector248 return SetReturnFS(win32tibsel);244 thdb = (THDB *)(winteb+1); 245 win32tibsel = thdb->teb_sel; 246 247 //Restore our win32 FS selector 248 return SetReturnFS(win32tibsel); 249 249 } 250 250 else { 251 //we didn't create this thread, so allocate a selector now252 //NOTE: Possible memory leak (i.e. DART threads in WINMM)253 winteb = InitializeTIB();254 if(winteb == NULL) {255 DebugInt3();256 return GetFS();257 }258 thdb = (THDB *)(winteb+1);259 win32tibsel = thdb->teb_sel;260 261 //Restore our win32 FS selector262 return SetReturnFS(win32tibsel);251 //we didn't create this thread, so allocate a selector now 252 //NOTE: Possible memory leak (i.e. DART threads in WINMM) 253 winteb = InitializeTIB(); 254 if(winteb == NULL) { 255 DebugInt3(); 256 return GetFS(); 257 } 258 thdb = (THDB *)(winteb+1); 259 win32tibsel = thdb->teb_sel; 260 261 //Restore our win32 FS selector 262 return SetReturnFS(win32tibsel); 263 263 } 264 264 // nested calls are OK, OS2ToWinCallback for instance … … 289 289 290 290 Win32DllExitList(0); 291 291 292 292 //Note: Needs to be done after Win32DllExitList (destruction of exe + dll objects) 293 293 //Flush and delete all open memory mapped files … … 316 316 winmod = Win32DllBase::findModule(hinstance); 317 317 if(winmod) { 318 winmod->Release();319 return(TRUE);318 winmod->Release(); 319 return(TRUE); 320 320 } 321 321 dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance)); … … 338 338 module = Win32DllBase::findModule((LPSTR)lpszLibFile); 339 339 if(module) { 340 module->AddRef();341 dprintf(("iLoadLibrary: found %s -> handle %x", lpszLibFile, module->getInstanceHandle()));342 return module->getInstanceHandle();340 module->AddRef(); 341 dprintf(("iLoadLibrary: found %s -> handle %x", lpszLibFile, module->getInstanceHandle())); 342 return module->getInstanceHandle(); 343 343 } 344 344 … … 359 359 360 360 if(!strstr(modname, ".")) { 361 strcat(modname,".DLL");361 strcat(modname,".DLL"); 362 362 } 363 363 364 364 if(Win32ImageBase::isPEImage((char *)modname)) 365 365 { 366 module = Win32DllBase::findModule((char *)modname);367 if(module) {//don't load it again368 module->AddRef();369 return module->getInstanceHandle();370 }371 372 Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname);373 if(peldrDll == NULL)374 return(0);375 376 peldrDll->init(0);377 if(peldrDll->getError() != NO_ERROR) {378 dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));379 delete(peldrDll);380 return(0);381 }382 if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {383 peldrDll->setNoEntryCalls();384 }385 386 if(peldrDll->attachProcess() == FALSE) {387 dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));388 delete(peldrDll);389 return(0);390 }391 peldrDll->AddRef();392 return peldrDll->getInstanceHandle();366 module = Win32DllBase::findModule((char *)modname); 367 if(module) {//don't load it again 368 module->AddRef(); 369 return module->getInstanceHandle(); 370 } 371 372 Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname); 373 if(peldrDll == NULL) 374 return(0); 375 376 peldrDll->init(0); 377 if(peldrDll->getError() != NO_ERROR) { 378 dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile)); 379 delete(peldrDll); 380 return(0); 381 } 382 if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) { 383 peldrDll->setNoEntryCalls(); 384 } 385 386 if(peldrDll->attachProcess() == FALSE) { 387 dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile)); 388 delete(peldrDll); 389 return(0); 390 } 391 peldrDll->AddRef(); 392 return peldrDll->getInstanceHandle(); 393 393 } 394 394 else return(0); … … 528 528 dprintf(("GetModuleFileName %X", hinstModule)); 529 529 if(hinstModule == 0 || hinstModule == -1 || (WinExe && hinstModule == WinExe->getInstanceHandle())) { 530 module = (Win32ImageBase *)WinExe;530 module = (Win32ImageBase *)WinExe; 531 531 } 532 532 else { 533 module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule);533 module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule); 534 534 } 535 535 536 536 if(module) { 537 fpath = module->getFullPath();537 fpath = module->getFullPath(); 538 538 } 539 539 if(fpath) { 540 //SvL: 13-9-98: +1541 rc = min(strlen(fpath)+1, cchPath);542 strncpy(lpszPath, fpath, rc);540 //SvL: 13-9-98: +1 541 rc = min(strlen(fpath)+1, cchPath); 542 strncpy(lpszPath, fpath, rc); 543 543 } 544 544 else rc = O32_GetModuleFileName(hinstModule, lpszPath, cchPath); … … 574 574 575 575 if(lpszModule == NULL) { 576 if(WinExe)577 hMod = WinExe->getInstanceHandle();578 elsehMod = -1;576 if(WinExe) 577 hMod = WinExe->getInstanceHandle(); 578 else hMod = -1; 579 579 } 580 580 else { 581 strcpy(szModule, OSLibStripPath((char *)lpszModule));582 strupr(szModule);583 if(strstr(szModule, ".DLL")) {584 fDllModule = TRUE;585 }586 else {587 if(!strstr(szModule, ".")) {588 //if there's no extension or trainling dot, we581 strcpy(szModule, OSLibStripPath((char *)lpszModule)); 582 strupr(szModule); 583 if(strstr(szModule, ".DLL")) { 584 fDllModule = TRUE; 585 } 586 else { 587 if(!strstr(szModule, ".")) { 588 //if there's no extension or trainling dot, we 589 589 //assume it's a dll (see Win32 SDK docs) 590 fDllModule = TRUE;591 }592 }593 char *dot = strstr(szModule, ".");594 if(dot)595 *dot = 0;596 597 if(!fDllModule && WinExe && !strcmpi(szModule, WinExe->getModuleName())) {598 hMod = WinExe->getInstanceHandle();599 }600 else {601 windll = Win32DllBase::findModule(szModule);602 if(windll) {603 hMod = windll->getInstanceHandle();604 }605 else hMod = OSLibiGetModuleHandleA((char *)lpszModule);606 }590 fDllModule = TRUE; 591 } 592 } 593 char *dot = strstr(szModule, "."); 594 if(dot) 595 *dot = 0; 596 597 if(!fDllModule && WinExe && !strcmpi(szModule, WinExe->getModuleName())) { 598 hMod = WinExe->getInstanceHandle(); 599 } 600 else { 601 windll = Win32DllBase::findModule(szModule); 602 if(windll) { 603 hMod = windll->getInstanceHandle(); 604 } 605 else hMod = OSLibiGetModuleHandleA((char *)lpszModule); 606 } 607 607 } 608 608 … … 634 634 { 635 635 BOOL rc; 636 char *cmdline; 637 BOOL fAllocStr = FALSE; 636 char *cmdline = NULL; 638 637 639 638 dprintf(("KERNEL32: CreateProcessA %s cline:%s inherit:%d cFlags:%x Env:%x CurDir:%s StartupFlags:%x\n", … … 645 644 lpEnvironment, lpCurrentDirectory, lpStartupInfo, 646 645 lpProcessInfo) == TRUE) 647 return(TRUE);646 return(TRUE); 648 647 649 648 //probably a win32 exe, so run it in the pe loader 650 649 if(lpApplicationName) { 651 if(lpCommandLine) { 652 cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16); 653 sprintf(cmdline, "PE.EXE %s %s", lpApplicationName, lpCommandLine); 654 fAllocStr = TRUE; 655 } 656 else { 657 cmdline = (char *)malloc(strlen(lpApplicationName) + 16); 658 sprintf(cmdline, "PE.EXE %s", lpApplicationName); 659 fAllocStr = TRUE; 660 } 650 if(lpCommandLine) { 651 //skip exe name in lpCommandLine 652 while(*lpCommandLine != 0 && *lpCommandLine != ' ') 653 lpCommandLine++; 654 655 if(*lpCommandLine != 0) { 656 lpCommandLine++; 657 } 658 cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16); 659 sprintf(cmdline, "PE.EXE %s %s", lpApplicationName, lpCommandLine); 660 } 661 else { 662 cmdline = (char *)malloc(strlen(lpApplicationName) + 16); 663 sprintf(cmdline, "PE.EXE %s", lpApplicationName); 664 } 661 665 } 662 666 else { 663 667 cmdline = (char *)malloc(strlen(lpCommandLine) + 16); 664 668 sprintf(cmdline, "PE.EXE %s", lpCommandLine); 665 fAllocStr = TRUE;666 669 } 667 670 dprintf(("KERNEL32: CreateProcess %s\n", cmdline)); … … 670 673 lpEnvironment, lpCurrentDirectory, lpStartupInfo, 671 674 lpProcessInfo); 672 if( fAllocStr)673 free(cmdline);675 if(cmdline) 676 free(cmdline); 674 677 675 678 if(lpProcessInfo) … … 697 700 astring2 = UnicodeToAsciiString(arg2); 698 701 astring3 = UnicodeToAsciiString((LPWSTR)arg8); 699 // NOTE: This will not work as is (needs UNICODE support)700 702 rc = CreateProcessA(astring1, astring2, arg3, arg4, arg5, arg6, arg7, 701 703 astring3, (LPSTARTUPINFOA)arg9, arg10); … … 715 717 startinfo.dwFlags = nCmdShow; 716 718 if(CreateProcessA(NULL, (LPSTR)lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, 717 &startinfo, &procinfo) == FALSE) 719 &startinfo, &procinfo) == FALSE) 718 720 { 719 return 0;721 return 0; 720 722 } 721 723 return procinfo.hProcess; //correct? … … 730 732 731 733 if(hModule == 0 || hModule == -1 || (WinExe && hModule == WinExe->getInstanceHandle())) { 732 winmod = WinExe;734 winmod = WinExe; 733 735 } 734 736 else winmod = (Win32ImageBase *)Win32DllBase::findModule((HINSTANCE)hModule); 735 737 736 738 if(winmod) { 737 ulAPIOrdinal = (ULONG)lpszProc;738 if (ulAPIOrdinal <= 0x0000FFFF) {739 proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal);740 }741 else proc = (FARPROC)winmod->getApi((char *)lpszProc);742 if(proc == 0) {743 SetLastError(ERROR_PROC_NOT_FOUND);744 }745 return proc;739 ulAPIOrdinal = (ULONG)lpszProc; 740 if (ulAPIOrdinal <= 0x0000FFFF) { 741 proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal); 742 } 743 else proc = (FARPROC)winmod->getApi((char *)lpszProc); 744 if(proc == 0) { 745 SetLastError(ERROR_PROC_NOT_FOUND); 746 } 747 return proc; 746 748 } 747 749 proc = O32_GetProcAddress(hModule, lpszProc); 748 if(HIWORD(lpszProc)) 749 dprintf(("KERNEL32: GetProcAddress %s from %X returned %X\n", lpszProc, hModule, proc));750 if(HIWORD(lpszProc)) 751 dprintf(("KERNEL32: GetProcAddress %s from %X returned %X\n", lpszProc, hModule, proc)); 750 752 else dprintf(("KERNEL32: GetProcAddress %x from %X returned %X\n", lpszProc, hModule, proc)); 751 753 return(proc); … … 761 763 dprintf(("GetVersionStruct of module %s", lpszModName)); 762 764 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) { 763 winimage = (Win32ImageBase *)WinExe;765 winimage = (Win32ImageBase *)WinExe; 764 766 } 765 767 else { 766 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);767 if(winimage == NULL)768 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 769 if(winimage == NULL) 768 770 { 769 char modname[CCHMAXPATH];770 771 strcpy(modname, lpszModName);772 //rename dll if necessary (i.e. OLE32 -> OLE32OS2)773 Win32DllBase::renameDll(modname);774 775 if(Win32ImageBase::isPEImage(modname) == FALSE) 771 char modname[CCHMAXPATH]; 772 773 strcpy(modname, lpszModName); 774 //rename dll if necessary (i.e. OLE32 -> OLE32OS2) 775 Win32DllBase::renameDll(modname); 776 777 if(Win32ImageBase::isPEImage(modname) == FALSE) 776 778 { 777 HINSTANCE hInstance;778 779 //must be an LX dll, just load it (app will probably load it anyway)780 hInstance = LoadLibraryA(modname);781 if(hInstance == 0)782 return 0;783 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);784 if(winimage) {785 return winimage->getVersionStruct(verstruct, bufLength);786 }787 return 0;788 }789 //SvL: Try to load it790 rsrcimg = new Win32PeLdrRsrcImg(modname);791 if(rsrcimg == NULL)792 return 0;793 794 rsrcimg->init(0);795 if(rsrcimg->getError() != NO_ERROR)796 {797 dprintf(("GetVersionStruct can't load %s\n", modname));798 delete rsrcimg;799 return(FALSE);800 }801 BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength);802 delete rsrcimg;803 return rc;804 }779 HINSTANCE hInstance; 780 781 //must be an LX dll, just load it (app will probably load it anyway) 782 hInstance = LoadLibraryA(modname); 783 if(hInstance == 0) 784 return 0; 785 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 786 if(winimage) { 787 return winimage->getVersionStruct(verstruct, bufLength); 788 } 789 return 0; 790 } 791 //SvL: Try to load it 792 rsrcimg = new Win32PeLdrRsrcImg(modname); 793 if(rsrcimg == NULL) 794 return 0; 795 796 rsrcimg->init(0); 797 if(rsrcimg->getError() != NO_ERROR) 798 { 799 dprintf(("GetVersionStruct can't load %s\n", modname)); 800 delete rsrcimg; 801 return(FALSE); 802 } 803 BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength); 804 delete rsrcimg; 805 return rc; 806 } 805 807 } 806 808 return winimage->getVersionStruct(verstruct, bufLength); … … 816 818 817 819 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) { 818 winimage = (Win32ImageBase *)WinExe;820 winimage = (Win32ImageBase *)WinExe; 819 821 } 820 822 else { 821 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);822 if(winimage == NULL)823 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 824 if(winimage == NULL) 823 825 { 824 char modname[CCHMAXPATH];825 826 strcpy(modname, lpszModName);827 //rename dll if necessary (i.e. OLE32 -> OLE32OS2)828 Win32DllBase::renameDll(modname);829 830 if(Win32ImageBase::isPEImage(modname) == FALSE) 826 char modname[CCHMAXPATH]; 827 828 strcpy(modname, lpszModName); 829 //rename dll if necessary (i.e. OLE32 -> OLE32OS2) 830 Win32DllBase::renameDll(modname); 831 832 if(Win32ImageBase::isPEImage(modname) == FALSE) 831 833 { 832 HINSTANCE hInstance;833 834 //must be an LX dll, just load it (app will probably load it anyway)835 hInstance = LoadLibraryA(modname);836 if(hInstance == 0)837 return 0;838 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);839 if(winimage) {840 return winimage->getVersionSize();841 }842 return 0;843 }844 845 //SvL: Try to load it846 rsrcimg = new Win32PeLdrRsrcImg(modname);847 if(rsrcimg == NULL)848 return 0;849 850 rsrcimg->init(0);851 if(rsrcimg->getError() != NO_ERROR)852 {853 dprintf(("GetVersionSize can't load %s\n", modname));854 delete rsrcimg;855 return(FALSE);856 }857 int size = rsrcimg->getVersionSize();858 delete rsrcimg;859 return size;860 }834 HINSTANCE hInstance; 835 836 //must be an LX dll, just load it (app will probably load it anyway) 837 hInstance = LoadLibraryA(modname); 838 if(hInstance == 0) 839 return 0; 840 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 841 if(winimage) { 842 return winimage->getVersionSize(); 843 } 844 return 0; 845 } 846 847 //SvL: Try to load it 848 rsrcimg = new Win32PeLdrRsrcImg(modname); 849 if(rsrcimg == NULL) 850 return 0; 851 852 rsrcimg->init(0); 853 if(rsrcimg->getError() != NO_ERROR) 854 { 855 dprintf(("GetVersionSize can't load %s\n", modname)); 856 delete rsrcimg; 857 return(FALSE); 858 } 859 int size = rsrcimg->getVersionSize(); 860 delete rsrcimg; 861 return size; 862 } 861 863 } 862 864 return winimage->getVersionSize();
Note:
See TracChangeset
for help on using the changeset viewer.
