Changeset 1118 for trunk/src/kernel32
- Timestamp:
- Oct 4, 1999, 11:56:04 AM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/os2heap.cpp
r1104 r1118 1 /* $Id: os2heap.cpp,v 1.1 0 1999-10-01 16:03:10sandervl Exp $ */1 /* $Id: os2heap.cpp,v 1.11 1999-10-04 09:55:56 sandervl Exp $ */ 2 2 3 3 /* … … 150 150 heapelem->flags = 0; //only used when allocated with LocalAlloc 151 151 heapelem->lockCnt = 0; //.. .. 152 heapelem->magic = MAGIC_NR_HEAP; 152 153 153 154 if(hmutex) { … … 179 180 return(FALSE); 180 181 182 if(helem->magic != MAGIC_NR_HEAP) 183 { 184 dprintf(("OS2Heap::Lock ERROR BAD HEAP POINTER:%X\n", lpMem)); 185 return FALSE; 186 } 187 181 188 helem->lockCnt++; 182 189 … … 195 202 return(FALSE); 196 203 204 if(helem->magic != MAGIC_NR_HEAP) 205 { 206 dprintf(("OS2Heap::UnLock ERROR BAD HEAP POINTER:%X\n", lpMem)); 207 return FALSE; 208 } 209 197 210 helem->lockCnt--; 198 211 … … 208 221 return(FALSE); 209 222 223 if(helem->magic != MAGIC_NR_HEAP) 224 { 225 dprintf(("OS2Heap::GetFlags ERROR BAD HEAP POINTER:%X\n", lpMem)); 226 return FALSE; 227 } 228 210 229 return(helem->flags); 211 230 } … … 219 238 return(666); 220 239 240 if(helem->magic != MAGIC_NR_HEAP) 241 { 242 dprintf(("OS2Heap::GetLockCnt ERROR BAD HEAP POINTER:%X\n", lpMem)); 243 return FALSE; 244 } 245 221 246 return(helem->lockCnt); 222 247 } … … 235 260 LPVOID OS2Heap::ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes) 236 261 { 262 HEAPELEM *helem = (HEAPELEM *)((char *)lpMem - sizeof(HEAPELEM)); 237 263 LPVOID lpNewMem; 238 264 int i; … … 245 271 // if (lpMem == 0) return NULL; 246 272 273 if (helem->magic != MAGIC_NR_HEAP) 274 { 275 dprintf(("OS2Heap::ReAlloc ERROR BAD HEAP POINTER:%X\n", lpMem)); 276 return lpMem; 277 } 278 247 279 if (Size(0,lpMem) == dwBytes) return lpMem; // if reallocation with same size 248 280 // don't do anything … … 267 299 return(FALSE); 268 300 } 301 302 if(helem->magic != MAGIC_NR_HEAP) 303 { 304 dprintf(("OS2Heap::Free ERROR BAD HEAP POINTER:%X\n", lpMem)); 305 return FALSE; 306 } 307 269 308 #ifdef DEBUG1 270 309 int size = Size(0, lpMem); -
trunk/src/kernel32/os2heap.h
r99 r1118 1 /* $Id: os2heap.h,v 1. 3 1999-06-10 19:11:30 phallerExp $ */1 /* $Id: os2heap.h,v 1.4 1999-10-04 09:55:57 sandervl Exp $ */ 2 2 3 3 /* … … 17 17 #include "vmutex.h" 18 18 19 #define MAGIC_NR_HEAP 0x87654321 19 20 typedef struct _tagHEAPELEM { 21 DWORD magic; //magic number 20 22 struct _tagHEAPELEM *prev; 21 23 struct _tagHEAPELEM *next; -
trunk/src/kernel32/winimgres.cpp
r1016 r1118 1 /* $Id: winimgres.cpp,v 1.1 7 1999-09-23 14:12:14 phallerExp $ */1 /* $Id: winimgres.cpp,v 1.18 1999-10-04 09:55:57 sandervl Exp $ */ 2 2 3 3 /* … … 11 11 * TODO: Check created resource objects before loading the resource! 12 12 * TODO: Is the name id of the version resource always 1? 13 * TODO: Once the resource handling in PE2LX/win32k is changed, 13 * TODO: Once the resource handling in PE2LX/win32k is changed, 14 14 * getVersionStruct/Size can be moved into the Win32ImageBase class 15 15 * … … 36 36 //PE spec says names & ids are sorted; keep on searching just to be sure 37 37 //****************************************************************************** 38 PIMAGE_RESOURCE_DATA_ENTRY 38 PIMAGE_RESOURCE_DATA_ENTRY 39 39 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang) 40 40 { … … 73 73 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData); 74 74 75 if(i < pResDir->NumberOfNamedEntries) 75 if(i < pResDir->NumberOfNamedEntries) 76 76 {//name or id entry? 77 77 //SvL: 30-10-'97, high bit is set, so clear to get real offset … … 82 82 lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1); 83 83 typename[pstring->Length] = 0; 84 84 85 85 if(!fNumType) { 86 86 if(stricmp(typename, (char *)type) == 0) { … … 380 380 HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang) 381 381 { 382 HRSRC hres; 383 char *astring1 = NULL, 384 *astring2 = NULL; 385 BOOL fAllocated1 = FALSE; 386 BOOL fAllocated2 = FALSE; 387 388 if(HIWORD(lpszName) != 0) 389 { 390 astring1 = UnicodeToAsciiString((LPWSTR)lpszName); 391 fAllocated1 = TRUE; 392 } 393 else 394 astring1 = (char *)lpszName; 395 396 if(HIWORD(lpszType) != 0) 397 { 398 astring2 = UnicodeToAsciiString(lpszType); 399 fAllocated2 = TRUE; 400 } 401 else 402 astring2 = (char *)lpszType; 403 hres = (HRSRC) findResourceA(astring1, astring2); 404 405 /* do NOT free untranslated numerical Resource IDs */ 406 if(fAllocated1) FreeAsciiString(astring1); 407 if(fAllocated2) FreeAsciiString(astring2); 408 409 return(hres); 382 HRSRC hres; 383 char *astring1 = NULL, *astring2 = NULL; 384 385 if(HIWORD(lpszName) != 0) { 386 astring1 = UnicodeToAsciiString(lpszName); 387 } 388 else astring1 = (char *)lpszName; 389 390 if(HIWORD(lpszType) != 0) { 391 astring2 = UnicodeToAsciiString(lpszType); 392 } 393 else astring2 = (char *)lpszType; 394 395 hres = (HRSRC) findResourceA(astring1, astring2); 396 397 if(HIWORD(astring1)) FreeAsciiString(astring1); 398 if(HIWORD(astring2)) FreeAsciiString(astring2); 399 400 return(hres); 410 401 } 411 402 //****************************************************************************** … … 427 418 ULONG Win32ImageBase::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang) 428 419 { 429 char *astring1 = NULL, 430 *astring2 = NULL; 431 ULONG ressize; 432 BOOL fAllocated1 = FALSE; 433 BOOL fAllocated2 = FALSE; 434 435 if(HIWORD(lpszName) != 0) 436 { 437 astring1 = UnicodeToAsciiString((LPWSTR)lpszName); 438 fAllocated1 = TRUE; 439 } 440 else 441 astring1 = (char *)lpszName; 442 443 if(HIWORD(lpszType) != 0) 444 { 445 astring2 = UnicodeToAsciiString(lpszType); 446 fAllocated2 = TRUE; 447 } 448 else 449 astring2 = (char *)lpszType; 450 451 ressize = getResourceSizeA(astring1, astring2, lang); 452 453 /* do NOT free untranslated numerical Resource IDs */ 454 if(fAllocated1) FreeAsciiString(astring1); 455 if(fAllocated2) FreeAsciiString(astring2); 456 457 return(ressize); 420 char *astring1 = NULL, *astring2 = NULL; 421 ULONG ressize; 422 423 if(HIWORD(lpszName) != 0) { 424 astring1 = UnicodeToAsciiString((LPWSTR)lpszName); 425 } 426 else astring1 = (char *)lpszName; 427 428 if(HIWORD(lpszType) != 0) { 429 astring2 = UnicodeToAsciiString(lpszType); 430 } 431 else astring2 = (char *)lpszType; 432 433 ressize = getResourceSizeA(astring2, astring1, lang); 434 435 if(HIWORD(astring1)) FreeAsciiString(astring1); 436 if(HIWORD(astring2)) FreeAsciiString(astring2); 437 438 return(ressize); 458 439 } 459 440 //****************************************************************************** … … 489 470 PIMAGE_RESOURCE_DATA_ENTRY pData = NULL; 490 471 472 if(verstruct == NULL || bufLength == 0) { 473 SetLastError(ERROR_INVALID_PARAMETER); 474 return FALSE; 475 } 491 476 pData = getPEResourceEntry(1, NTRT_VERSION); 492 477 if(pData == NULL) { … … 494 479 return 0; 495 480 } 496 return pData->Size; 497 } 498 //****************************************************************************** 499 //****************************************************************************** 481 char *resdata = (char *)((char *)pResDir + pData->OffsetToData - pResourceSectionStart); 482 memcpy(verstruct, resdata, min(bufLength, pData->Size)); 483 return TRUE; 484 } 485 //****************************************************************************** 486 //****************************************************************************** -
trunk/src/kernel32/wprocess.cpp
r1052 r1118 1 /* $Id: wprocess.cpp,v 1.3 3 1999-09-25 17:55:21sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.34 1999-10-04 09:55:57 sandervl Exp $ */ 2 2 3 3 /* … … 646 646 BOOL SYSTEM GetVersionStruct(char *modname, char *verstruct, ULONG bufLength) 647 647 { 648 HINSTANCE hinstance;649 648 Win32ImageBase *winimage; 650 649 651 650 dprintf(("GetVersionStruct")); 652 hinstance = OSLibQueryModuleHandle(modname); 653 if(hinstance == 0) { 654 dprintf(("GetVersionStruct can't find handle for %s\n", modname)); 655 return(FALSE); 656 } 657 if(WinExe && WinExe->getInstanceHandle() == hinstance) { 651 if(WinExe && !strcmp(WinExe->getFullPath(), modname)) { 658 652 winimage = (Win32ImageBase *)WinExe; 659 653 } 660 654 else { 661 winimage = (Win32ImageBase *)Win32DllBase::findModule( hinstance);655 winimage = (Win32ImageBase *)Win32DllBase::findModule(modname); 662 656 if(winimage == NULL) { 663 657 dprintf(("GetVersionStruct can't find Win32Image for %s\n", modname)); … … 671 665 ULONG SYSTEM GetVersionSize(char *modname) 672 666 { 673 HINSTANCE hinstance;674 667 Win32ImageBase *winimage; 675 668 676 669 dprintf(("GetVersionSize of %s\n", modname)); 677 hinstance = OSLibQueryModuleHandle(modname); 678 if(hinstance == 0) { 679 dprintf(("GetVersionSize can't find handle for %s\n", modname)); 680 return(FALSE); 681 } 682 683 if(WinExe && WinExe->getInstanceHandle() == hinstance) { 670 671 if(WinExe && !strcmp(WinExe->getFullPath(), modname)) { 684 672 winimage = (Win32ImageBase *)WinExe; 685 673 } 686 674 else { 687 winimage = (Win32ImageBase *)Win32DllBase::findModule( hinstance);675 winimage = (Win32ImageBase *)Win32DllBase::findModule(modname); 688 676 if(winimage == NULL) { 689 677 dprintf(("GetVersionSize can't find Win32Image for %s\n", modname));
Note:
See TracChangeset
for help on using the changeset viewer.