Changeset 8809 for trunk/src/kernel32/virtual.cpp
- Timestamp:
- Jun 30, 2002, 3:46:46 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/virtual.cpp
r8457 r8809 1 /* $Id: virtual.cpp,v 1.4 4 2002-05-20 13:48:50sandervl Exp $ */1 /* $Id: virtual.cpp,v 1.45 2002-06-30 13:46:46 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <string.h> 24 24 #include <win\virtual.h> 25 #include <win\thread.h> 25 26 #include <heapstring.h> 26 27 #include <handlemanager.h> … … 446 447 DWORD FreeType) 447 448 { 448 DWORD rc; 449 450 SetLastError(ERROR_SUCCESS); 451 452 // verify parameters 453 if ( (FreeType & MEM_RELEASE) && (cbSize != 0) ) 454 { 455 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 456 SetLastError(ERROR_INVALID_PARAMETER); 457 return(FALSE); 458 } 459 460 if ( (FreeType & MEM_DECOMMIT) && 461 (FreeType & MEM_RELEASE) ) 462 { 463 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 464 SetLastError(ERROR_INVALID_PARAMETER); 465 return(FALSE); 466 } 467 468 // decommit memory 469 if (FreeType & MEM_DECOMMIT) 470 { 471 // decommit memory block 472 rc = OSLibDosSetMem(lpvAddress, cbSize, PAG_DECOMMIT); 473 if(rc) 474 { 475 if(rc == 32803) { //SvL: ERROR_ALIAS 476 dprintf(("KERNEL32:VirtualFree:OsLibSetMem rc = #%d; app tries to decommit aliased memory; ignore", rc)); 477 return(TRUE); 478 } 479 dprintf(("KERNEL32:VirtualFree:OsLibSetMem rc = #%d\n", rc)); 480 SetLastError(ERROR_INVALID_ADDRESS); 481 return(FALSE); 482 } 483 } 484 485 // release memory 486 if (FreeType & MEM_RELEASE) 487 { 488 rc = OSLibDosFreeMem(lpvAddress); // free the memory block 489 if(rc) 490 { 491 dprintf(("KERNEL32:VirtualFree:OsLibFreeMem rc = #%d\n", 492 rc)); 493 SetLastError(ERROR_INVALID_ADDRESS); 494 return(FALSE); 495 } 496 } 497 498 return(TRUE); 449 DWORD rc; 450 451 SetLastError(ERROR_SUCCESS); 452 453 // verify parameters 454 if((FreeType & MEM_RELEASE) && (cbSize != 0)) 455 { 456 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 457 SetLastError(ERROR_INVALID_PARAMETER); 458 return(FALSE); 459 } 460 461 if((FreeType & MEM_DECOMMIT) && (FreeType & MEM_RELEASE)) 462 { 463 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 464 SetLastError(ERROR_INVALID_PARAMETER); 465 return(FALSE); 466 } 467 468 // decommit memory 469 if (FreeType & MEM_DECOMMIT) 470 { 471 // check if app wants to decommit stack pages -> don't allow that! 472 TEB *teb = GetThreadTEB(); 473 if(teb) { 474 if(lpvAddress >= teb->stack_low && lpvAddress < teb->stack_top) { 475 //pretend we did was was asked 476 dprintf(("WARNING: app tried to decommit stack pages; pretend success")); 477 return TRUE; 478 } 479 } 480 // decommit memory block 481 rc = OSLibDosSetMem(lpvAddress, cbSize, PAG_DECOMMIT); 482 if(rc) 483 { 484 if(rc == 32803) { //SvL: ERROR_ALIAS 485 dprintf(("KERNEL32:VirtualFree:OsLibSetMem rc = #%d; app tries to decommit aliased memory; ignore", rc)); 486 return(TRUE); 487 } 488 dprintf(("KERNEL32:VirtualFree:OsLibSetMem rc = #%d\n", rc)); 489 SetLastError(ERROR_INVALID_ADDRESS); 490 return(FALSE); 491 } 492 } 493 494 // release memory 495 if (FreeType & MEM_RELEASE) 496 { 497 rc = OSLibDosFreeMem(lpvAddress); // free the memory block 498 if(rc) 499 { 500 dprintf(("KERNEL32:VirtualFree:OsLibFreeMem rc = #%d\n", rc)); 501 SetLastError(ERROR_INVALID_ADDRESS); 502 return(FALSE); 503 } 504 } 505 return TRUE; 499 506 } 500 507 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.