- Timestamp:
- Apr 2, 2003, 1:03:33 PM (22 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r9938 r9971 1 /* $Id: HandleManager.cpp,v 1.9 6 2003-03-26 16:02:33sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.97 2003-04-02 11:03:30 sandervl Exp $ */ 2 2 3 3 /* … … 981 981 *****************************************************************************/ 982 982 983 H FILE HMCreateFile(LPCSTR lpFileName,983 HANDLE HMCreateFile(LPCSTR lpFileName, 984 984 DWORD dwDesiredAccess, 985 985 DWORD dwShareMode, … … 1904 1904 *****************************************************************************/ 1905 1905 1906 BOOL HMUnlockFile (H FILEhFile,1906 BOOL HMUnlockFile (HANDLE hFile, 1907 1907 DWORD arg2, 1908 1908 DWORD arg3, -
trunk/src/kernel32/hmmmap.cpp
r9948 r9971 1 /* $Id: hmmmap.cpp,v 1.2 3 2003-03-27 14:19:23sandervl Exp $ */1 /* $Id: hmmmap.cpp,v 1.24 2003-04-02 11:03:31 sandervl Exp $ */ 2 2 3 3 /* … … 51 51 //****************************************************************************** 52 52 DWORD HMDeviceMemMapClass::CreateFileMapping(PHMHANDLEDATA pHMHandleData, 53 H FILE hFile,53 HANDLE hFile, 54 54 SECURITY_ATTRIBUTES *sa, /* [in] Optional security attributes*/ 55 55 DWORD protect, /* [in] Protection for mapping object */ -
trunk/src/kernel32/mmap.cpp
r9946 r9971 1 /* $Id: mmap.cpp,v 1.6 4 2003-03-27 14:13:10sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.65 2003-04-02 11:03:31 sandervl Exp $ */ 2 2 3 3 /* … … 73 73 //****************************************************************************** 74 74 //****************************************************************************** 75 Win32MemMap::Win32MemMap(H FILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName)75 Win32MemMap::Win32MemMap(HANDLE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName) 76 76 : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), 77 77 image(0), pWriteBitmap(NULL) … … 307 307 if(image) { 308 308 return image->commitPage(pageAddr, fWriteAccess); 309 } 310 311 if(fWriteAccess && (mProtFlags & PAGE_WRITECOPY)) 312 {//this is a COW map, call commitGuardPage to handle write faults 313 return commitGuardPage(ulFaultAddr, offset, fWriteAccess); 309 314 } 310 315 … … 407 412 dprintf(("Mark %d page(s) starting at %x as dirty", nrPages, pageAddr)); 408 413 markDirtyPages(startPage, nrPages); 414 415 //Write access means that the next time the corresponding COW page 416 //is touched, we need to reload it. So set the GUARD flags. 417 updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_GUARD); 409 418 } 410 419 } … … 429 438 //Now change all the aliased pages according to their view protection flags 430 439 updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_VIEW); 440 441 //Write access means that the next time the corresponding COW page 442 //is touched, we need to reload it. So set the GUARD flags. 443 updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_GUARD); 431 444 } 432 445 faultsize -= memInfo.RegionSize; … … 443 456 // Win32MemMap::commitGuardPage 444 457 // 445 // Handle a guard page exception 458 // Handle a guard page exception for a copy-on-write view (one page only) 446 459 // 447 460 // Parameters: … … 468 481 //align at page boundary 469 482 ulOffset &= ~0xFFF; 483 484 //commit a single page in the original mapping (pretend read access) 485 ret = commitPage(ulFaultAddr, ulOffset, FALSE, 1); 486 if(ret == FALSE) { 487 DebugInt3(); 488 goto fail; 489 } 490 //clear PAGE_GUARD flag, since this page must now be made accessible 491 dwNewProt = mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY); 492 if(dwNewProt & PAGE_WRITECOPY) { 493 dwNewProt |= PAGE_GUARD; 494 } 495 dwNewProt &= ~PAGE_GUARD; 496 if(VirtualProtect((LPVOID)pageAddr, PAGE_SIZE, dwNewProt, &dwOldProt) == FALSE) { 497 dprintf(("Win32MemMap::commitGuardPage: VirtualProtect %x 0x1000 %x failed!!", pageAddr, dwNewProt)); 498 goto fail; 499 } 500 //copy the data from the original mapping to the COW page 501 memcpy((LPVOID)pageAddr, (char *)pMapping+ulOffset, PAGE_SIZE); 502 503 if(fWriteAccess) 504 {//copy on write; mark pages as private 505 DWORD startpage = (ulOffset) >> PAGE_SHIFT; 506 507 dprintf(("Win32MemMap::commitGuardPage: write access -> mark page as private")); 508 509 Win32MemMapView *view = Win32MemMapView::findView(ulFaultAddr); 510 if(view) 511 { 512 view->markCOWPages(startpage, 1); 513 } 514 else DebugInt3(); //oh, oh 515 } 516 else 517 {//read access; must set the map + all views to READONLY to track write access 518 519 dprintf(("Win32MemMap::commitGuardPage: read access -> set page as READONLY in map + all views")); 520 521 //first the memory map page 522 if(VirtualProtect((LPVOID)pageAddr, PAGE_SIZE, PAGE_READONLY, &dwOldProt) == FALSE) { 523 dprintf(("Win32MemMap::commitGuardPage: VirtualProtect %x 0x1000 %x failed!!", pageAddr, dwNewProt)); 524 goto fail; 525 } 526 //now for any views that exist 527 updateViewPages(ulOffset, PAGE_SIZE, PAGEVIEW_READONLY); 528 } 470 529 471 530 return TRUE; … … 485 544 // PAGEVIEW_READONLY -> set page flags to readonly 486 545 // PAGEVIEW_VIEW -> set page flags to view default 546 // PAGEVIEW_GUARD -> set page flags of COW view to GUARD 487 547 // 488 548 // Returns: … … 535 595 dprintf(("ERROR: Win32MemMap::invalidatePages: VirtualFree failed!!")); 536 596 } 537 return TRUE; 597 //invalidate all shared COW pages too by setting the GUARD flag 598 //(which forces a resync the next time the app touches them) 599 return updateViewPages(offset, size, PAGEVIEW_GUARD); 538 600 } 539 601 //****************************************************************************** -
trunk/src/kernel32/mmap.h
r9946 r9971 1 /* $Id: mmap.h,v 1.2 7 2003-03-27 14:13:11sandervl Exp $ */1 /* $Id: mmap.h,v 1.28 2003-04-02 11:03:32 sandervl Exp $ */ 2 2 3 3 /* … … 54 54 { 55 55 public: 56 Win32MemMap(H FILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName);56 Win32MemMap(HANDLE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName); 57 57 //Use by PE loader image class only: 58 58 Win32MemMap(Win32PeLdrImage *pImage, ULONG lpImageMem, ULONG size); … … 67 67 BOOL allocateMap(); 68 68 69 H FILEgetFileHandle() { return hMemFile; };69 HANDLE getFileHandle() { return hMemFile; }; 70 70 LPSTR getMemName() { return lpszMapName; }; 71 71 DWORD getMapSize() { return mSize; }; … … 122 122 123 123 protected: 124 H FILEhMemFile;125 H FILEhOrgMemFile;124 HANDLE hMemFile; 125 HANDLE hOrgMemFile; 126 126 ULONG mSize; 127 127 ULONG mProtFlags; … … 154 154 { 155 155 public: 156 Win32MemMapDup(Win32MemMap *parent, H FILE hFile, ULONG size, ULONG fdwProtect, LPSTR lpszName);156 Win32MemMapDup(Win32MemMap *parent, HANDLE hFile, ULONG size, ULONG fdwProtect, LPSTR lpszName); 157 157 virtual ~Win32MemMapDup(); 158 158 -
trunk/src/kernel32/mmapdup.cpp
r9946 r9971 1 /* $Id: mmapdup.cpp,v 1. 1 2003-03-27 14:13:11sandervl Exp $ */1 /* $Id: mmapdup.cpp,v 1.2 2003-04-02 11:03:32 sandervl Exp $ */ 2 2 3 3 /* … … 48 48 // 49 49 //****************************************************************************** 50 Win32MemMapDup::Win32MemMapDup(Win32MemMap *parent, H FILE hFile, ULONG size,50 Win32MemMapDup::Win32MemMapDup(Win32MemMap *parent, HANDLE hFile, ULONG size, 51 51 ULONG fdwProtect, LPSTR lpszName) : 52 52 Win32MemMap(hFile, size, fdwProtect, lpszName) … … 221 221 BOOL Win32MemMapDup::commitPage(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess, int nrpages) 222 222 { 223 if(mProtFlags & PAGE_WRITECOPY) 224 {//this is a COW map, call commitGuardPage 225 return commitGuardPage(ulFaultAddr, offset, fWriteAccess); 226 } 223 227 return parent->commitPage(ulFaultAddr, offset, fWriteAccess, nrpages); 224 228 } … … 226 230 // Win32MemMapDup::commitGuardPage 227 231 // 228 // Handle a guard page exception 232 // Handle a guard page exception for a copy-on-write view 229 233 // 230 234 // Parameters: -
trunk/src/kernel32/virtual.cpp
r9911 r9971 1 /* $Id: virtual.cpp,v 1.5 4 2003-03-06 10:44:34sandervl Exp $ */1 /* $Id: virtual.cpp,v 1.55 2003-04-02 11:03:32 sandervl Exp $ */ 2 2 3 3 /* … … 47 47 */ 48 48 HANDLE WINAPI CreateFileMappingA( 49 H FILE hFile, /* [in] Handle of file to map */49 HANDLE hFile, /* [in] Handle of file to map */ 50 50 SECURITY_ATTRIBUTES *sa, /* [in] Optional security attributes*/ 51 51 DWORD protect, /* [in] Protection for mapping object */ … … 67 67 * See CreateFileMapping32A 68 68 */ 69 HANDLE WINAPI CreateFileMappingW( H FILE hFile, LPSECURITY_ATTRIBUTES attr,69 HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES attr, 70 70 DWORD protect, DWORD size_high, 71 71 DWORD size_low, LPCWSTR name ) -
trunk/src/kernel32/winexedummy.cpp
r8887 r9971 1 /* $Id: winexedummy.cpp,v 1. 3 2002-07-18 12:01:33 achimhaExp $ */1 /* $Id: winexedummy.cpp,v 1.4 2003-04-02 11:03:32 sandervl Exp $ */ 2 2 3 3 /* … … 138 138 poh->MajorSubsystemVersion = ODINNT_MAJOR_VERSION; 139 139 poh->MinorSubsystemVersion = ODINNT_MINOR_VERSION; 140 poh-> Reserved1= 0;140 poh->Win32VersionValue = 0; 141 141 poh->SizeOfImage = 0; 142 142 poh->SizeOfHeaders = 1024; -
trunk/src/kernel32/winimagelx.cpp
r9413 r9971 1 /* $Id: winimagelx.cpp,v 1. 19 2002-11-18 14:03:56sandervl Exp $ */1 /* $Id: winimagelx.cpp,v 1.20 2003-04-02 11:03:33 sandervl Exp $ */ 2 2 3 3 /* … … 202 202 poh->MajorSubsystemVersion = ODINNT_MAJOR_VERSION; 203 203 poh->MinorSubsystemVersion = ODINNT_MINOR_VERSION; 204 poh-> Reserved1= 0;204 poh->Win32VersionValue = 0; 205 205 poh->SizeOfImage = 0; 206 206 poh->SizeOfHeaders = 1024; -
trunk/src/kernel32/wprocess.cpp
r9890 r9971 1 /* $Id: wprocess.cpp,v 1.18 5 2003-03-03 16:38:20sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.186 2003-04-02 11:03:33 sandervl Exp $ */ 2 2 3 3 /* … … 855 855 * @remark Forwards to LoadLibraryExA. 856 856 */ 857 HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, H ANDLE hFile, DWORD dwFlags)857 HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, HFILE hFile, DWORD dwFlags) 858 858 { 859 859 HINSTANCE hDll; … … 1265 1265 * @remark Forwards to LoadLibraryExA. 1266 1266 */ 1267 HINSTANCE WIN32API LoadLibraryExW(LPCWSTR lpszLibFile, H ANDLE hFile, DWORD dwFlags)1267 HINSTANCE WIN32API LoadLibraryExW(LPCWSTR lpszLibFile, HFILE hFile, DWORD dwFlags) 1268 1268 { 1269 1269 char * pszAsciiLibFile;
Note:
See TracChangeset
for help on using the changeset viewer.