Changeset 21339 for trunk/src/kernel32/virtual.cpp
- Timestamp:
- Aug 14, 2009, 5:18:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/virtual.cpp
r21302 r21339 339 339 if(dwProtect & PAGE_NOACCESS) *lpdwOS2Attr |= PAG_READ; //can't do this in OS/2 340 340 } 341 342 343 #define OBJ_LOCSPECIFIC 0x1000 341 344 //****************************************************************************** 342 345 //NOTE: Do NOT set the last error to ERROR_SUCCESS if successful. Windows … … 377 380 remainder = cbSize & 0xFFF; 378 381 cbSize &= ~0xFFF; 379 if(remainder) 382 if(remainder) 380 383 cbSize += PAGE_SIZE; 381 384 … … 398 401 flag |= PAG_READ|PAG_WRITE; 399 402 } 400 403 401 404 //just do this if other options are used 402 405 if(!(flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE)) || flag == 0) … … 410 413 Win32MemMap *map; 411 414 ULONG offset, nrpages, accessflags = 0; 412 415 413 416 nrpages = cbSize >> PAGE_SHIFT; 414 417 if(cbSize & 0xFFF) … … 431 434 return lpvAddress; 432 435 } 436 /* trying to allocate memory at specified address */ 437 if(fdwAllocationType & MEM_RESERVE) 438 { 439 rc = OSLibDosAllocMem(&Address, cbSize, flag |OBJ_LOCSPECIFIC); 440 dprintf(("Allocation at specified address: %x. rc: %i", Address, rc)); 441 if (rc) 442 { 443 SetLastError(ERROR_OUTOFMEMORY); 444 return NULL; 445 } 446 dprintf(("Allocated at specified address: %x. rc: %i", Address, rc)); 447 return(Address); 448 } 433 449 } 434 450 … … 443 459 //might try to commit larger part with same base address 444 460 if(rc == OSLIB_ERROR_ACCESS_DENIED && cbSize > PAGE_SIZE ) 445 { 446 while(cbSize) 461 { 462 while(cbSize) 447 463 { 448 464 //check if the app tries to commit an already commited part of memory or change the protection flags 449 465 ULONG size = cbSize, os2flags, newrc; 450 466 newrc = OSLibDosQueryMem(lpvAddress, &size, &os2flags); 451 if(newrc == 0) 467 if(newrc == 0) 452 468 { 453 if(os2flags & PAG_COMMIT) 469 if(os2flags & PAG_COMMIT) 454 470 { 455 471 dprintf(("VirtualAlloc: commit on committed memory")); … … 457 473 { //change protection flags 458 474 DWORD tmp; 459 if(VirtualProtect(lpvAddress, size, fdwProtect, &tmp) == FALSE) 475 if(VirtualProtect(lpvAddress, size, fdwProtect, &tmp) == FALSE) 460 476 { 461 477 dprintf(("ERROR: VirtualAlloc: commit on committed memory -> VirtualProtect failed!!")); … … 464 480 } 465 481 } 466 else 482 else 467 483 { //commit this page (or range of pages) 468 484 rc = OSLibDosSetMem(lpvAddress, size, flag); … … 489 505 if(rc == OSLIB_ERROR_INVALID_ADDRESS) { 490 506 rc = OSLibDosAllocMem(&Address, cbSize, flag ); 491 } 507 } 492 508 else { 493 509 if(rc) {
Note:
See TracChangeset
for help on using the changeset viewer.