- Timestamp:
- Dec 13, 2000, 12:57:16 AM (25 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/disk.cpp
r4763 r4796 1 /* $Id: disk.cpp,v 1.2 3 2000-12-07 12:00:23sandervl Exp $ */1 /* $Id: disk.cpp,v 1.24 2000-12-12 23:57:15 sandervl Exp $ */ 2 2 3 3 /* … … 304 304 } 305 305 } 306 if(lpFileSystemNameBuffer || lpMaximumComponentLength ) {306 if(lpFileSystemNameBuffer || lpMaximumComponentLength || lpFileSystemFlags) { 307 307 if(!lpFileSystemNameBuffer) { 308 308 lpFileSystemNameBuffer = tmpstring; -
trunk/src/kernel32/mmap.cpp
r4496 r4796 1 /* $Id: mmap.cpp,v 1.4 5 2000-10-18 17:09:33sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.46 2000-12-12 23:57:16 sandervl Exp $ */ 2 2 3 3 /* … … 57 57 fClosed(FALSE) 58 58 { 59 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);60 next = memmaps;61 memmaps = this;62 globalmapMutex.leave(&hGlobalMapMutex);63 64 hMemFile = hfile;65 66 mSize = size;67 mProtFlags = fdwProtect;68 mProcessId = GetCurrentProcess();69 70 if(lpszName) {71 lpszMapName = (char *)_smalloc(strlen(lpszName)+1);72 strcpy(lpszMapName, lpszName);73 }74 else lpszMapName = NULL;59 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex); 60 next = memmaps; 61 memmaps = this; 62 globalmapMutex.leave(&hGlobalMapMutex); 63 64 hMemFile = hfile; 65 66 mSize = size; 67 mProtFlags = fdwProtect; 68 mProcessId = GetCurrentProcess(); 69 70 if(lpszName) { 71 lpszMapName = (char *)_smalloc(strlen(lpszName)+1); 72 strcpy(lpszMapName, lpszName); 73 } 74 else lpszMapName = NULL; 75 75 } 76 76 //****************************************************************************** … … 81 81 fClosed(FALSE) 82 82 { 83 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);84 next = memmaps;85 memmaps = this;86 globalmapMutex.leave(&hGlobalMapMutex);87 88 hMemFile = -1;89 90 mSize = size;91 mProtFlags = PAGE_READWRITE;92 mProcessId = GetCurrentProcess();93 94 pMapping = (LPVOID)baseAddress;95 96 image = pImage;97 lpszMapName= NULL;83 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex); 84 next = memmaps; 85 memmaps = this; 86 globalmapMutex.leave(&hGlobalMapMutex); 87 88 hMemFile = -1; 89 90 mSize = size; 91 mProtFlags = PAGE_READWRITE; 92 mProcessId = GetCurrentProcess(); 93 94 pMapping = (LPVOID)baseAddress; 95 96 image = pImage; 97 lpszMapName= NULL; 98 98 } 99 99 //****************************************************************************** … … 101 101 BOOL Win32MemMap::Init(HANDLE hMemMap) 102 102 { 103 mapMutex.enter();104 if(hMemFile != -1)105 {103 mapMutex.enter(); 104 if(hMemFile != -1) 105 { 106 106 #if 0 107 107 if(DuplicateHandle(mProcessId, hMemFile, GetCurrentProcess(), 108 108 &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE) 109 109 #else 110 DWORD dwOdinOptions;111 112 if(!(mProtFlags & PAGE_READWRITE)) {113 dwOdinOptions = DUPLICATE_ACCESS_READ | DUPLICATE_SHARE_DENYNONE;114 }115 else dwOdinOptions = DUPLICATE_ACCESS_READWRITE | DUPLICATE_SHARE_DENYNONE;110 DWORD dwOdinOptions; 111 112 if(!(mProtFlags & PAGE_READWRITE)) { 113 dwOdinOptions = DUPLICATE_ACCESS_READ | DUPLICATE_SHARE_DENYNONE; 114 } 115 else dwOdinOptions = DUPLICATE_ACCESS_READWRITE | DUPLICATE_SHARE_DENYNONE; 116 116 117 117 if(HMDuplicateHandleOdin(mProcessId, hMemFile, GetCurrentProcess(), … … 119 119 #endif 120 120 { 121 dprintf(("Win32MemMap::Init: DuplicateHandle failed!"));122 goto fail;123 } 124 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_BEGIN);125 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_END);126 if(mSize == -1) {127 dprintf(("Win32MemMap::init: SetFilePointer failed to set pos end"));128 goto fail;129 }130 //SvL: Temporary limitation of size (Warp Server Advanced doesn't allow121 dprintf(("Win32MemMap::Init: DuplicateHandle failed!")); 122 goto fail; 123 } 124 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_BEGIN); 125 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_END); 126 if(mSize == -1) { 127 dprintf(("Win32MemMap::init: SetFilePointer failed to set pos end")); 128 goto fail; 129 } 130 //SvL: Temporary limitation of size (Warp Server Advanced doesn't allow 131 131 // one to reserve more than 450 MB (unless you override the virtual 132 132 // memory max limit) of continuous memory; (Warp 4 much less)) 133 if(mSize > 64*1024*1024) {134 mSize = 64*1024*1024;135 }136 }137 138 dprintf(("CreateFileMappingA for file %x, prot %x size %d, name %s", hMemFile, mProtFlags, mSize, lpszMapName));139 this->hMemMap = hMemMap;140 mapMutex.leave();141 return TRUE;133 if(mSize > 64*1024*1024) { 134 mSize = 64*1024*1024; 135 } 136 } 137 138 dprintf(("CreateFileMappingA for file %x, prot %x size %d, name %s", hMemFile, mProtFlags, mSize, lpszMapName)); 139 this->hMemMap = hMemMap; 140 mapMutex.leave(); 141 return TRUE; 142 142 fail: 143 mapMutex.leave();144 return FALSE;143 mapMutex.leave(); 144 return FALSE; 145 145 } 146 146 //****************************************************************************** … … 148 148 Win32MemMap::~Win32MemMap() 149 149 { 150 Win32MemMapView::deleteViews(this); //delete all views of our memory mapped file 151 152 dprintf(("Win32MemMap dtor: deleting view %x %x", pMapping, mSize)); 153 154 mapMutex.enter(); 155 if(lpszMapName) { 156 free(lpszMapName); 157 } 158 if(pMapping && !image) { 150 Win32MemMapView::deleteViews(this); //delete all views of our memory mapped file 151 152 dprintf(("Win32MemMap dtor: deleting view %x %x", pMapping, mSize)); 153 154 mapMutex.enter(); 159 155 if(lpszMapName) { 160 OSLibDosFreeMem(pMapping); 161 } 162 else VirtualFree(pMapping, mSize, MEM_RELEASE); 163 164 pMapping = NULL; 165 } 166 if(hMemFile != -1) { 167 dprintf(("Win32MemMap dtor: closing memory file %x", hMemFile)); 168 CloseHandle(hMemFile); 169 hMemFile = -1; 170 } 171 mapMutex.leave(); 172 173 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex); 174 Win32MemMap *map = memmaps; 175 176 if(map == this) { 177 memmaps = next; 178 } 179 else { 180 while(map->next) { 181 if(map->next == this) 182 break; 183 map = map->next; 184 } 185 if(map->next) { 186 map->next = next; 187 } 188 else dprintf(("Win32MemMap::~Win32MemMap: map not found!! (%x)", this)); 189 } 190 globalmapMutex.leave(&hGlobalMapMutex); 156 free(lpszMapName); 157 } 158 if(pMapping && !image) { 159 if(lpszMapName) { 160 OSLibDosFreeMem(pMapping); 161 } 162 else VirtualFree(pMapping, 0, MEM_RELEASE); 163 164 pMapping = NULL; 165 } 166 if(hMemFile != -1) { 167 dprintf(("Win32MemMap dtor: closing memory file %x", hMemFile)); 168 CloseHandle(hMemFile); 169 hMemFile = -1; 170 } 171 mapMutex.leave(); 172 173 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex); 174 Win32MemMap *map = memmaps; 175 176 if(map == this) { 177 memmaps = next; 178 } 179 else { 180 while(map->next) { 181 if(map->next == this) 182 break; 183 map = map->next; 184 } 185 if(map->next) { 186 map->next = next; 187 } 188 else dprintf(("Win32MemMap::~Win32MemMap: map not found!! (%x)", this)); 189 } 190 globalmapMutex.leave(&hGlobalMapMutex); 191 191 } 192 192 //****************************************************************************** … … 196 196 void Win32MemMap::close() 197 197 { 198 fClosed = TRUE; 199 if(nrMappings == 0) { 198 #ifdef DEBUG 199 dprintf(("Win32MemMap::close %s", lpszMapName)); 200 #endif 201 fClosed = TRUE; 202 if(nrMappings == 0) { 200 203 delete this; 201 }204 } 202 205 } 203 206 //****************************************************************************** … … 307 310 BOOL Win32MemMap::unmapViewOfFile(Win32MemMapView *view) 308 311 { 309 dprintf(("Win32MemMap::unmapViewOfFile %x (nrmaps=%d)", view, nrMappings));310 mapMutex.enter();311 312 if(nrMappings == 0)313 goto fail;314 315 delete view;316 317 if(--nrMappings == 0) {318 VirtualFree(pMapping, mSize, MEM_RELEASE);319 pMapping = NULL;320 }321 mapMutex.leave();322 323 //if there are no more mappings left and the memory map's handle has been324 //closed, then delete the object325 if(nrMappings == 0 && fClosed) {326 delete this;327 }328 return TRUE;312 dprintf(("Win32MemMap::unmapViewOfFile %x (nrmaps=%d)", view, nrMappings)); 313 mapMutex.enter(); 314 315 if(nrMappings == 0) 316 goto fail; 317 318 delete view; 319 320 if(--nrMappings == 0) { 321 VirtualFree(pMapping, 0, MEM_RELEASE); 322 pMapping = NULL; 323 } 324 mapMutex.leave(); 325 326 //if there are no more mappings left and the memory map's handle has been 327 //closed, then delete the object 328 if(nrMappings == 0 && fClosed) { 329 delete this; 330 } 331 return TRUE; 329 332 fail: 330 mapMutex.leave();331 if(nrMappings == 0 && fClosed) {332 delete this;333 }334 return FALSE;333 mapMutex.leave(); 334 if(nrMappings == 0 && fClosed) { 335 delete this; 336 } 337 return FALSE; 335 338 } 336 339 //****************************************************************************** … … 340 343 DWORD processId = GetCurrentProcess(); 341 344 342 mapMutex.enter();343 ULONG memFlags = (mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY));344 ULONG fAlloc = 0;345 Win32MemMapView *mapview;346 347 //@@@PH: if(fdwAccess & ~(FILE_MAP_WRITE|FILE_MAP_READ|FILE_MAP_COPY))348 // Docs say FILE_MAP_ALL_ACCESS is same as FILE_MAP_WRITE. Doesn't match reality though.349 if(fdwAccess & ~FILE_MAP_ALL_ACCESS)350 goto parmfail;351 if((fdwAccess & FILE_MAP_WRITE) && !(mProtFlags & PAGE_READWRITE))352 goto parmfail;353 if((fdwAccess & FILE_MAP_READ) && !(mProtFlags & (PAGE_READWRITE|PAGE_READONLY)))354 goto parmfail;355 356 //@@@PH357 if (fdwAccess != FILE_MAP_ALL_ACCESS)358 if((fdwAccess & FILE_MAP_COPY) && !(mProtFlags & PAGE_WRITECOPY))359 goto parmfail;360 361 if(offset+size > mSize && (!(fdwAccess & FILE_MAP_WRITE) || hMemFile == -1))362 goto parmfail;363 364 //SvL: TODO: Doesn't work for multiple views365 if(offset+size > mSize) {366 mSize = offset+size;367 }345 mapMutex.enter(); 346 ULONG memFlags = (mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY)); 347 ULONG fAlloc = 0; 348 Win32MemMapView *mapview; 349 350 //@@@PH: if(fdwAccess & ~(FILE_MAP_WRITE|FILE_MAP_READ|FILE_MAP_COPY)) 351 // Docs say FILE_MAP_ALL_ACCESS is same as FILE_MAP_WRITE. Doesn't match reality though. 352 if(fdwAccess & ~FILE_MAP_ALL_ACCESS) 353 goto parmfail; 354 if((fdwAccess & FILE_MAP_WRITE) && !(mProtFlags & PAGE_READWRITE)) 355 goto parmfail; 356 if((fdwAccess & FILE_MAP_READ) && !(mProtFlags & (PAGE_READWRITE|PAGE_READONLY))) 357 goto parmfail; 358 359 //@@@PH 360 if (fdwAccess != FILE_MAP_ALL_ACCESS) 361 if((fdwAccess & FILE_MAP_COPY) && !(mProtFlags & PAGE_WRITECOPY)) 362 goto parmfail; 363 364 if(offset+size > mSize && (!(fdwAccess & FILE_MAP_WRITE) || hMemFile == -1)) 365 goto parmfail; 366 367 //SvL: TODO: Doesn't work for multiple views 368 if(offset+size > mSize) { 369 mSize = offset+size; 370 } 368 371 369 372 //TODO: If committed, read file into memory 370 373 #if 0 371 if(mProtFlags & SEC_COMMIT)372 fAlloc |= MEM_COMMIT;373 else374 if(mProtFlags & SEC_RESERVE)375 fAlloc |= MEM_RESERVE;374 if(mProtFlags & SEC_COMMIT) 375 fAlloc |= MEM_COMMIT; 376 else 377 if(mProtFlags & SEC_RESERVE) 378 fAlloc |= MEM_RESERVE; 376 379 #else 377 fAlloc = MEM_RESERVE;380 fAlloc = MEM_RESERVE; 378 381 #endif 379 382 380 //Memory has already been allocated for executable image maps (only used internally)381 if(!pMapping && nrMappings == 0) {//if not mapped, reserve/commit entire view382 //SvL: Always read/write access or else ReadFile will crash once we383 // start committing pages.384 // This is most likely an OS/2 bug and doesn't happen in Aurora383 //Memory has already been allocated for executable image maps (only used internally) 384 if(!pMapping && nrMappings == 0) {//if not mapped, reserve/commit entire view 385 //SvL: Always read/write access or else ReadFile will crash once we 386 // start committing pages. 387 // This is most likely an OS/2 bug and doesn't happen in Aurora 385 388 // when allocating memory with the PAG_ANY bit set. (without this 386 389 // flag it will also crash) 387 if(hMemFile == -1 && lpszMapName) { 388 pMapping = VirtualAllocShared(mSize, fAlloc, PAGE_READWRITE, lpszMapName); 389 } 390 else { 391 pMapping = VirtualAlloc(0, mSize, fAlloc, PAGE_READWRITE); 392 } 393 if(pMapping == NULL) { 394 dprintf(("Win32MemMap::mapFileView: VirtualAlloc %x %x %x failed!", mSize, fAlloc, memFlags)); 390 if(hMemFile == -1 && lpszMapName) { 391 pMapping = VirtualAllocShared(mSize, fAlloc, PAGE_READWRITE, lpszMapName); 392 } 393 else { 394 pMapping = VirtualAlloc(0, mSize, fAlloc, PAGE_READWRITE); 395 } 396 if(pMapping == NULL) { 397 dprintf(("Win32MemMap::mapFileView: VirtualAlloc %x %x %x failed!", mSize, fAlloc, memFlags)); 398 goto fail; 399 } 400 //Windows NT seems to commit memory for memory maps, regardsless of the SEC_COMMIT flag 401 if((hMemFile == -1 && !image)) {//commit memory 402 VirtualAlloc(pMapping, mSize, MEM_COMMIT, PAGE_READWRITE); 403 } 404 if(hMemFile != -1 && (mProtFlags & SEC_COMMIT)) { 405 DWORD nrPages = mSize >> PAGE_SHIFT; 406 if(mSize & 0xFFF) 407 nrPages++; 408 409 commitPage(0, FALSE, nrPages); 410 } 411 } 412 mapview = new Win32MemMapView(this, offset, (size == 0) ? mSize : size, fdwAccess); 413 if(mapview == NULL) { 395 414 goto fail; 396 415 } 397 //Windows NT seems to commit memory for memory maps, regardsless of the SEC_COMMIT flag 398 if((hMemFile == -1 && !image)) {//commit memory 399 VirtualAlloc(pMapping, mSize, MEM_COMMIT, PAGE_READWRITE); 400 } 401 if(hMemFile != -1 && (mProtFlags & SEC_COMMIT)) { 402 DWORD nrPages = mSize >> PAGE_SHIFT; 403 if(mSize & 0xFFF) 404 nrPages++; 405 406 commitPage(0, FALSE, nrPages); 407 } 408 } 409 mapview = new Win32MemMapView(this, offset, (size == 0) ? mSize : size, fdwAccess); 410 if(mapview == NULL) { 411 goto fail; 412 } 413 if(mapview->everythingOk() == FALSE) { 414 dprintf(("Win32MemMap::mapFileView: !mapview->everythingOk")); 415 delete mapview; 416 goto fail; 417 } 418 nrMappings++; 419 mapMutex.leave(); 420 return mapview->getViewAddr(); 416 if(mapview->everythingOk() == FALSE) { 417 dprintf(("Win32MemMap::mapFileView: !mapview->everythingOk")); 418 delete mapview; 419 goto fail; 420 } 421 nrMappings++; 422 mapMutex.leave(); 423 return mapview->getViewAddr(); 421 424 422 425 parmfail: 423 dprintf(("Win32MemMap::mapFileView: ERROR_INVALID_PARAMETER"));424 SetLastError(ERROR_INVALID_PARAMETER);426 dprintf(("Win32MemMap::mapFileView: ERROR_INVALID_PARAMETER")); 427 SetLastError(ERROR_INVALID_PARAMETER); 425 428 fail: 426 mapMutex.leave();427 return 0;429 mapMutex.leave(); 430 return 0; 428 431 } 429 432 //****************************************************************************** … … 586 589 Win32MemMapView *tmpview = mapviews; 587 590 588 errorState = 0; 589 mParentMap = map; 590 mSize = size; 591 mOffset = offset; 592 mProcessId = GetCurrentProcess(); 593 594 switch(fdwAccess) { 595 case FILE_MAP_READ: 596 accessAttr = PAG_READ; 597 mfAccess = MEMMAP_ACCESS_READ; 598 break; 599 case FILE_MAP_ALL_ACCESS: 600 case FILE_MAP_WRITE: 601 case FILE_MAP_WRITE|FILE_MAP_READ: 602 case FILE_MAP_COPY: 603 accessAttr = (PAG_READ|PAG_WRITE); 604 mfAccess = MEMMAP_ACCESS_READ | MEMMAP_ACCESS_WRITE; 605 break; 606 } 607 if(map->getMemName() != NULL && map->getFileHandle() == -1) { 608 //shared memory map, so map it into our address space 609 if(OSLibDosGetNamedSharedMem((LPVOID *)&viewaddr, map->getMemName()) != OSLIB_NOERROR) { 610 dprintf(("new OSLibDosGetNamedSharedMem FAILED")); 611 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 612 errorState = 1; 591 errorState = 0; 592 mParentMap = map; 593 mSize = size; 594 mOffset = offset; 595 mProcessId = GetCurrentProcess(); 596 pShareViewAddr = NULL; 597 598 switch(fdwAccess) { 599 case FILE_MAP_READ: 600 accessAttr = PAG_READ; 601 mfAccess = MEMMAP_ACCESS_READ; 602 break; 603 case FILE_MAP_ALL_ACCESS: 604 case FILE_MAP_WRITE: 605 case FILE_MAP_WRITE|FILE_MAP_READ: 606 case FILE_MAP_COPY: 607 accessAttr = (PAG_READ|PAG_WRITE); 608 mfAccess = MEMMAP_ACCESS_READ | MEMMAP_ACCESS_WRITE; 609 break; 610 } 611 if(map->getMemName() != NULL && map->getFileHandle() == -1) { 612 //shared memory map, so map it into our address space 613 if(OSLibDosGetNamedSharedMem((LPVOID *)&viewaddr, map->getMemName()) != OSLIB_NOERROR) { 614 dprintf(("new OSLibDosGetNamedSharedMem FAILED")); 615 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 616 errorState = 1; 617 return; 618 } 619 pShareViewAddr = viewaddr; 620 } 621 622 //view == memory mapping for executable images (only used internally) 623 if(map->getImage()) { 624 pMapView = map->getMappingAddr(); 625 } 626 else { 627 if(OSLibDosAliasMem(viewaddr, size, &pMapView, accessAttr) != OSLIB_NOERROR) { 628 dprintf(("new OSLibDosAliasMem FAILED")); 629 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 630 errorState = 1; 631 return; 632 } 633 } 634 dprintf(("Win32MemMapView::Win32MemMapView: created %x (alias for %x), size %d", pMapView, viewaddr, size)); 635 636 globalviewMutex.enter(); 637 if(tmpview == NULL || tmpview->getViewAddr() > pMapView) { 638 next = mapviews; 639 mapviews = this; 640 } 641 else { 642 while(tmpview->next) { 643 if(tmpview->next->getViewAddr() > pMapView) { 644 break; 645 } 646 tmpview = tmpview->next; 647 } 648 next = tmpview->next; 649 tmpview->next = this; 650 } 651 globalviewMutex.leave(); 652 } 653 //****************************************************************************** 654 //****************************************************************************** 655 Win32MemMapView::~Win32MemMapView() 656 { 657 if(errorState != 0) 613 658 return; 614 } 615 } 616 617 //view == memory mapping for executable images (only used internally) 618 if(map->getImage()) { 619 pMapView = map->getMappingAddr(); 620 } 621 else { 622 if(OSLibDosAliasMem(viewaddr, size, &pMapView, accessAttr) != OSLIB_NOERROR) { 623 dprintf(("new OSLibDosAliasMem FAILED")); 624 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 625 errorState = 1; 626 return; 627 } 628 } 629 630 dprintf(("Win32MemMapView::Win32MemMapView: created %x (alias for %x), size %d", pMapView, viewaddr, size)); 631 632 globalviewMutex.enter(); 633 if(tmpview == NULL || tmpview->getViewAddr() > pMapView) { 634 next = mapviews; 635 mapviews = this; 636 } 637 else { 638 while(tmpview->next) { 639 if(tmpview->next->getViewAddr() > pMapView) { 640 break; 641 } 642 tmpview = tmpview->next; 643 } 644 next = tmpview->next; 645 tmpview->next = this; 646 } 647 globalviewMutex.leave(); 648 } 649 //****************************************************************************** 650 //****************************************************************************** 651 Win32MemMapView::~Win32MemMapView() 652 { 653 if(errorState != 0) 654 return; 655 656 dprintf(("Win32MemMapView dtor: deleting view %x %x", mOffset, mSize)); 657 658 if(mfAccess & MEMMAP_ACCESS_WRITE) 659 mParentMap->flushView(mOffset, mSize); 660 661 //Don't free memory for executable image map views (only used internally) 662 if(!mParentMap->getImage()) 663 OSLibDosFreeMem(pMapView); 664 665 globalviewMutex.enter(); 666 Win32MemMapView *view = mapviews; 667 668 if(view == this) { 669 mapviews = next; 670 } 671 else { 672 while(view->next) { 673 if(view->next == this) 674 break; 675 view = view->next; 676 } 677 if(view->next) { 678 view->next = next; 679 } 680 else dprintf(("Win32MemMapView::~Win32MemMapView: map not found!! (%x)", this)); 681 } 682 globalviewMutex.leave(); 659 660 dprintf(("Win32MemMapView dtor: deleting view %x %x", mOffset, mSize)); 661 662 if(mfAccess & MEMMAP_ACCESS_WRITE) 663 mParentMap->flushView(mOffset, mSize); 664 665 //Don't free memory for executable image map views (only used internally) 666 if(!mParentMap->getImage()) 667 OSLibDosFreeMem(pMapView); 668 669 if(pShareViewAddr) { 670 OSLibDosFreeMem(pShareViewAddr); 671 } 672 673 globalviewMutex.enter(); 674 Win32MemMapView *view = mapviews; 675 676 if(view == this) { 677 mapviews = next; 678 } 679 else { 680 while(view->next) { 681 if(view->next == this) 682 break; 683 view = view->next; 684 } 685 if(view->next) { 686 view->next = next; 687 } 688 else dprintf(("Win32MemMapView::~Win32MemMapView: map not found!! (%x)", this)); 689 } 690 globalviewMutex.leave(); 683 691 } 684 692 //****************************************************************************** -
trunk/src/kernel32/mmap.h
r4496 r4796 1 /* $Id: mmap.h,v 1.1 7 2000-10-18 17:09:33sandervl Exp $ */1 /* $Id: mmap.h,v 1.18 2000-12-12 23:57:16 sandervl Exp $ */ 2 2 3 3 /* … … 17 17 18 18 #ifndef PAGE_SIZE 19 #define PAGE_SIZE 19 #define PAGE_SIZE 4096 20 20 #endif 21 21 #ifndef PAGE_SHIFT 22 #define PAGE_SHIFT 22 #define PAGE_SHIFT 12 23 23 #endif 24 24 25 25 //commit 4 pages at once when the app accesses it 26 #define NRPAGES_TOCOMMIT 26 #define NRPAGES_TOCOMMIT 16 27 27 28 #define MEMMAP_ACCESS_READ 29 #define MEMMAP_ACCESS_WRITE 30 #define MEMMAP_ACCESS_EXECUTE 28 #define MEMMAP_ACCESS_READ 1 29 #define MEMMAP_ACCESS_WRITE 2 30 #define MEMMAP_ACCESS_EXECUTE 4 31 31 32 32 class Win32MemMapView; … … 73 73 74 74 #ifdef __DEBUG_ALLOC__ 75 76 77 78 79 80 81 82 75 void *operator new(size_t size, const char *filename, size_t lineno) 76 { 77 return _umalloc(sharedHeap, size); 78 } 79 void operator delete(void *location, const char *filename, size_t lineno) 80 { 81 free(location); 82 } 83 83 #else 84 85 86 87 88 89 90 91 84 void *operator new(size_t size) 85 { 86 return _umalloc(sharedHeap, size); 87 } 88 void operator delete(void *location) 89 { 90 free(location); 91 } 92 92 #endif 93 93 … … 112 112 private: 113 113 static Win32MemMap *memmaps; 114 114 Win32MemMap *next; 115 115 }; 116 116 //****************************************************************************** … … 138 138 139 139 #ifdef __DEBUG_ALLOC__ 140 141 142 143 144 145 146 147 140 void *operator new(size_t size, const char *filename, size_t lineno) 141 { 142 return _umalloc(sharedHeap, size); 143 } 144 void operator delete(void *location, const char *filename, size_t lineno) 145 { 146 free(location); 147 } 148 148 #else 149 150 151 152 153 154 155 156 149 void *operator new(size_t size) 150 { 151 return _umalloc(sharedHeap, size); 152 } 153 void operator delete(void *location) 154 { 155 free(location); 156 } 157 157 #endif 158 158 … … 161 161 ULONG mProcessId; 162 162 ULONG mfAccess, mOffset; 163 void *pMapView ;163 void *pMapView, *pShareViewAddr; 164 164 165 165 Win32MemMap *mParentMap; -
trunk/src/kernel32/virtual.cpp
r4592 r4796 1 /* $Id: virtual.cpp,v 1.3 7 2000-11-14 21:16:26 sandervl Exp $ */1 /* $Id: virtual.cpp,v 1.38 2000-12-12 23:57:16 sandervl Exp $ */ 2 2 3 3 /* … … 453 453 if ( (FreeType & MEM_RELEASE) && (cbSize != 0) ) 454 454 { 455 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 455 456 SetLastError(ERROR_INVALID_PARAMETER); 456 457 return(FALSE); … … 460 461 (FreeType & MEM_RELEASE) ) 461 462 { 463 dprintf(("WARNING: VirtualFree: invalid parameter!!")); 462 464 SetLastError(ERROR_INVALID_PARAMETER); 463 465 return(FALSE); -
trunk/src/kernel32/wintls.cpp
r4658 r4796 1 /* $Id: wintls.cpp,v 1.1 6 2000-11-21 11:35:09sandervl Exp $ */1 /* $Id: wintls.cpp,v 1.17 2000-12-12 23:57:16 sandervl Exp $ */ 2 2 /* 3 3 * Win32 TLS API functions … … 128 128 tlsmem = TlsGetValue(tlsIndex); 129 129 if(tlsmem) { 130 VirtualFree(tlsmem, tlsTotalSize, MEM_RELEASE);130 VirtualFree(tlsmem, 0, MEM_RELEASE); 131 131 } 132 132 else {
Note:
See TracChangeset
for help on using the changeset viewer.