- Timestamp:
- Aug 25, 1999, 4:27:07 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r678 r690 1 /* $Id: HandleManager.cpp,v 1.1 5 1999-08-25 10:28:39sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.16 1999-08-25 14:27:04 sandervl Exp $ */ 2 2 3 3 /* … … 57 57 #include "HMSemaphore.h" 58 58 #include "HMMMap.h" 59 #include <winconst.h> 59 60 60 61 /***************************************************************************** … … 631 632 } 632 633 634 635 /***************************************************************************** 636 * Name : HANDLE HMDuplicateHandle 637 * Purpose : replacement for Open32's HMDuplicateHandle function 638 * Parameters: 639 * 640 * Variables : 641 * Result : BOOL fSuccess 642 * Remark : 643 * Status : 644 * 645 * Author : Patrick Haller [Wed, 1998/02/12 20:44] 646 *****************************************************************************/ 647 BOOL HMDuplicateHandle(HANDLE srcprocess, 648 HANDLE srchandle, 649 HANDLE destprocess, 650 PHANDLE desthandle, 651 DWORD fdwAccess, 652 BOOL fInherit, 653 DWORD fdwOptions) 654 { 655 int iIndex; /* index into the handle table */ 656 int iIndexNew; /* index into the handle table */ 657 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 658 PHMHANDLEDATA pHMHandleData; 659 DWORD rc; /* API return code */ 660 661 if(HMHandleValidate(srchandle) != NO_ERROR) { 662 dprintf(("HMDuplicateHandle: invalid handle %x", srchandle)); 663 SetLastError(ERROR_INVALID_HANDLE); /* use this as error message */ 664 return FALSE; 665 } 666 667 pDeviceHandler = TabWin32Handles[srchandle].pDeviceHandler; /* device is predefined */ 668 669 iIndexNew = _HMHandleGetFree(); /* get free handle */ 670 if (-1 == iIndexNew) /* oops, no free handles ! */ 671 { 672 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 673 return FALSE; /* signal error */ 674 } 675 676 /* initialize the complete HMHANDLEDATA structure */ 677 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 678 pHMHandleData->dwType = TabWin32Handles[srchandle].hmHandleData.dwType; 679 if (fdwOptions & DUPLICATE_SAME_ACCESS) { 680 pHMHandleData->dwAccess = TabWin32Handles[srchandle].hmHandleData.dwAccess; 681 } 682 else pHMHandleData->dwAccess = fdwAccess; 683 684 pHMHandleData->dwShare = TabWin32Handles[srchandle].hmHandleData.dwShare; 685 pHMHandleData->dwCreation = TabWin32Handles[srchandle].hmHandleData.dwCreation; 686 pHMHandleData->dwFlags = TabWin32Handles[srchandle].hmHandleData.dwFlags; 687 pHMHandleData->lpHandlerData = TabWin32Handles[srchandle].hmHandleData.lpHandlerData; 688 689 690 /* we've got to mark the handle as occupied here, since another device */ 691 /* could be created within the device handler -> deadlock */ 692 693 /* write appropriate entry into the handle table if open succeeded */ 694 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 695 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 696 697 /* call the device handler */ 698 rc = pDeviceHandler->DuplicateHandle(&TabWin32Handles[iIndexNew].hmHandleData, 699 srcprocess, 700 &TabWin32Handles[srchandle].hmHandleData, 701 destprocess, desthandle, 702 fdwAccess, fInherit, fdwOptions & ~DUPLICATE_CLOSE_SOURCE); 703 704 //Don't let Open32 close it for us, but do it manually (regardless of error; see SDK docs)) 705 if (fdwOptions & DUPLICATE_CLOSE_SOURCE) 706 { 707 CloseHandle(srchandle); 708 } 709 710 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 711 { 712 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 713 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 714 return FALSE; /* signal error */ 715 } 716 *desthandle = iIndexNew; 717 return TRUE; /* return valid handle */ 718 } 633 719 634 720 /***************************************************************************** -
trunk/src/kernel32/KERNEL32.DEF
r687 r690 1 ; $Id: KERNEL32.DEF,v 1. 29 1999-08-25 12:30:47sandervl Exp $1 ; $Id: KERNEL32.DEF,v 1.30 1999-08-25 14:27:06 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 1006 1006 VIRTUAL_MapFileA = _VIRTUAL_MapFileA@8 @1249 1007 1007 VIRTUAL_MapFileW = _VIRTUAL_MapFileW@8 @1250 1008 1009 OS2SetExceptionHandler @1251 1010 OS2UnsetExceptionHandler @1252 -
trunk/src/kernel32/exceptions.cpp
r678 r690 1 /* $Id: exceptions.cpp,v 1.1 2 1999-08-25 10:28:40sandervl Exp $ */1 /* $Id: exceptions.cpp,v 1.13 1999-08-25 14:27:05 sandervl Exp $ */ 2 2 3 3 /* … … 901 901 goto continueFail; 902 902 } 903 map = Win32MemMap::findMap(pERepRec->ExceptionInfo[ 0]);903 map = Win32MemMap::findMap(pERepRec->ExceptionInfo[1]); 904 904 if(map == NULL) { 905 905 goto continueFail; -
trunk/src/kernel32/hmdevice.cpp
r678 r690 1 /* $Id: hmdevice.cpp,v 1. 6 1999-08-25 10:28:40sandervl Exp $ */1 /* $Id: hmdevice.cpp,v 1.7 1999-08-25 14:27:05 sandervl Exp $ */ 2 2 3 3 /* … … 91 91 } 92 92 93 94 /***************************************************************************** 95 * Name : HMDeviceHandler::DuplicateHandle 96 * Purpose : dummy version 97 * Parameters: 98 * various parameters as required 99 * Variables : 100 * Result : 101 * Remark : the standard behaviour is to return an error code for non- 102 * existant request codes 103 * Status : 104 * 105 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 106 *****************************************************************************/ 107 BOOL HMDeviceHandler::DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE srcprocess, 108 PHMHANDLEDATA pHMSrcHandle, 109 HANDLE destprocess, 110 PHANDLE desthandle, 111 DWORD fdwAccess, 112 BOOL fInherit, 113 DWORD fdwOptions) 114 { 115 dprintf(("KERNEL32:HandleManager::DuplicateHandle %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED!!!!!!!!\n", 116 lpHMDeviceName, 117 pHMHandleData, 118 srcprocess, pHMSrcHandle, destprocess, desthandle)); 119 120 return(ERROR_INVALID_FUNCTION); 121 } 93 122 94 123 /***************************************************************************** -
trunk/src/kernel32/hmdevice.h
r678 r690 1 /* $Id: hmdevice.h,v 1. 7 1999-08-25 10:28:40sandervl Exp $ */1 /* $Id: hmdevice.h,v 1.8 1999-08-25 14:27:06 sandervl Exp $ */ 2 2 3 3 /* … … 78 78 ULONG arg4); 79 79 80 virtual BOOL DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE srcprocess, 81 PHMHANDLEDATA pHMSrcHandle, 82 HANDLE destprocess, 83 PHANDLE desthandle, 84 DWORD fdwAccess, 85 BOOL fInherit, 86 DWORD fdwOptions); 87 80 88 /* this is a handler method for calls to CreateFile() */ 81 89 virtual DWORD CreateFile (LPCSTR lpFileName, -
trunk/src/kernel32/hmmmap.cpp
r678 r690 1 /* $Id: hmmmap.cpp,v 1. 4 1999-08-25 10:28:40sandervl Exp $ */1 /* $Id: hmmmap.cpp,v 1.5 1999-08-25 14:27:06 sandervl Exp $ */ 2 2 3 3 /* … … 57 57 58 58 if((hFile == -1 && size_low == 0) || size_high || 59 protect & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|SEC_COMMIT|SEC_IMAGE|SEC_RESERVE|SEC_NOCACHE) ||59 protect & ~(PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|SEC_COMMIT|SEC_IMAGE|SEC_RESERVE|SEC_NOCACHE) || 60 60 (protect & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY)) == 0 || 61 61 (hFile == -1 && (protect & SEC_COMMIT)) || … … 64 64 65 65 dprintf(("CreateFileMappingA: invalid parameter (combination)!")); 66 SetLastError(ERROR_INVALID_PARAMETER); 67 return 0; 66 return ERROR_INVALID_PARAMETER; 68 67 } 69 68 … … 79 78 } 80 79 map->AddRef(); 81 pHMHandleData->dwUserData = (ULONG) this;80 pHMHandleData->dwUserData = (ULONG)map; 82 81 pHMHandleData->dwInternalType = HMTYPE_MEMMAP; 83 82 return NO_ERROR; … … 118 117 } 119 118 map->AddRef(); 120 pHMHandleData->dwUserData = (ULONG) this;119 pHMHandleData->dwUserData = (ULONG)map; 121 120 pHMHandleData->dwInternalType = HMTYPE_MEMMAP; 122 121 return NO_ERROR; -
trunk/src/kernel32/hmopen32.cpp
r278 r690 1 /* $Id: hmopen32.cpp,v 1. 8 1999-07-06 15:48:47 phallerExp $ */1 /* $Id: hmopen32.cpp,v 1.9 1999-08-25 14:27:06 sandervl Exp $ */ 2 2 3 3 /* … … 68 68 } 69 69 70 71 /***************************************************************************** 72 * Name : HMDeviceHandler::DuplicateHandle 73 * Purpose : dummy version 74 * Parameters: 75 * various parameters as required 76 * Variables : 77 * Result : 78 * Remark : the standard behaviour is to return an error code for non- 79 * existant request codes 80 * Status : 81 * 82 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 83 *****************************************************************************/ 84 BOOL HMDeviceOpen32Class::DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE srcprocess, 85 PHMHANDLEDATA pHMSrcHandle, 86 HANDLE destprocess, 87 PHANDLE desthandle, 88 DWORD fdwAccess, 89 BOOL fInherit, 90 DWORD fdwOptions) 91 { 92 BOOL rc; 93 94 dprintf(("KERNEL32:HandleManager::Open32::DuplicateHandle %s(%08x,%08x,%08x,%08x,%08x)\n", 95 lpHMDeviceName, 96 pHMHandleData, 97 srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle)); 98 99 rc = O32_DuplicateHandle(srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle, fdwAccess, fInherit, fdwOptions); 100 101 if(rc == TRUE) { 102 pHMHandleData->hHMHandle = *desthandle; 103 return (NO_ERROR); 104 } 105 else return(O32_GetLastError()); 106 } 70 107 71 108 /***************************************************************************** -
trunk/src/kernel32/hmopen32.h
r278 r690 1 /* $Id: hmopen32.h,v 1. 2 1999-07-06 15:48:47 phallerExp $ */1 /* $Id: hmopen32.h,v 1.3 1999-08-25 14:27:06 sandervl Exp $ */ 2 2 3 3 /* … … 41 41 ULONG arg3, 42 42 ULONG arg4); 43 44 virtual BOOL DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE srcprocess, 45 PHMHANDLEDATA pHMSrcHandle, 46 HANDLE destprocess, 47 PHANDLE desthandle, 48 DWORD fdwAccess, 49 BOOL fInherit, 50 DWORD fdwOptions); 43 51 44 52 /* this is a handler method for calls to CreateFile() */ -
trunk/src/kernel32/kernel32exp.def
r687 r690 1 ; $Id: kernel32exp.def,v 1.1 5 1999-08-25 12:30:47sandervl Exp $1 ; $Id: kernel32exp.def,v 1.16 1999-08-25 14:27:06 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 862 862 _HEAP_strdupA@12 @1247 863 863 _HEAP_strdupW@12 @1248 864 865 OS2SetExceptionHandler @1251 866 OS2UnsetExceptionHandler @1252 -
trunk/src/kernel32/kobjects.cpp
r278 r690 1 /* $Id: kobjects.cpp,v 1. 2 1999-07-06 15:48:48 phallerExp $ */1 /* $Id: kobjects.cpp,v 1.3 1999-08-25 14:27:07 sandervl Exp $ */ 2 2 3 3 /* … … 40 40 #define HMSetHandleCount O32_SetHandleCount 41 41 #define HMGetHandleCount O32_GetHandleCount 42 #define HMDuplicateHandle O32_DuplicateHandle42 //#define HMDuplicateHandle O32_DuplicateHandle 43 43 44 44 -
trunk/src/kernel32/makefile
r687 r690 1 # $Id: makefile,v 1.3 2 1999-08-25 12:30:48sandervl Exp $1 # $Id: makefile,v 1.33 1999-08-25 14:27:07 sandervl Exp $ 2 2 3 3 # … … 258 258 .\hmsemaphore.h \ 259 259 .\hmmmap.h \ 260 $(PDWIN32_INCLUDE)\winconst.h \ 260 261 $(PDWIN32_INCLUDE)\handlemanager.h 261 262 -
trunk/src/kernel32/mmap.cpp
r684 r690 1 /* $Id: mmap.cpp,v 1.1 0 1999-08-25 11:40:18sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.11 1999-08-25 14:27:07 sandervl Exp $ */ 2 2 3 3 /* … … 40 40 { 41 41 globalmapMutex.enter(); 42 next = memmaps; 42 43 memmaps = this; 43 next = memmaps;44 44 globalmapMutex.leave(); 45 45 … … 68 68 goto fail; 69 69 } 70 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_END); 71 if(mSize == -1) { 72 dprintf(("Win32MemMap::init: SetFilePointer failed to set pos end")); 73 goto fail; 74 } 70 75 } 71 76 this->hMemMap = hMemMap; … … 143 148 // mapMutex.enter(); 144 149 newProt = mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY); 145 newProt |= MEM_COMMIT;146 150 147 151 dprintf(("Win32MemMap::commitPage %x (faultaddr %x), nr of pages %d", pageAddr, lpPageFaultAddr, nrpages)); 148 if(Virtual Protect((LPVOID)pageAddr, nrpages*PAGE_SIZE, newProt, &oldProt) == FALSE) {152 if(VirtualAlloc((LPVOID)pageAddr, nrpages*PAGE_SIZE, MEM_COMMIT, newProt) == FALSE) { 149 153 goto fail; 150 154 } … … 201 205 LPVOID mapview; 202 206 203 if( fdwAccess & (FILE_MAP_WRITE|FILE_MAP_ALL_ACCESS) && !(mProtFlags & PAGE_READWRITE))204 goto parmfail; 205 if( fdwAccess & FILE_MAP_READ&& !(mProtFlags & (PAGE_READWRITE|PAGE_READONLY)))206 goto parmfail; 207 if( fdwAccess & FILE_MAP_COPY&& !(mProtFlags & PAGE_WRITECOPY))207 if((fdwAccess & FILE_MAP_WRITE) && !(mProtFlags & PAGE_READWRITE)) 208 goto parmfail; 209 if((fdwAccess & FILE_MAP_READ) && !(mProtFlags & (PAGE_READWRITE|PAGE_READONLY))) 210 goto parmfail; 211 if((fdwAccess & FILE_MAP_COPY) && !(mProtFlags & PAGE_WRITECOPY)) 208 212 goto parmfail; 209 213 -
trunk/src/kernel32/virtual.cpp
r687 r690 1 /* $Id: virtual.cpp,v 1. 6 1999-08-25 12:30:48sandervl Exp $ */1 /* $Id: virtual.cpp,v 1.7 1999-08-25 14:27:07 sandervl Exp $ */ 2 2 3 3 /* … … 199 199 HANDLE WINAPI VIRTUAL_MapFileW( LPCWSTR name , LPVOID *lpMapping) 200 200 { 201 HANDLE hFile, hMapping = 0;201 HANDLE hFile, hMapping = -1; 202 202 203 203 hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, … … 207 207 hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL ); 208 208 CloseHandle( hFile ); 209 if (hMapping )209 if (hMapping != INVALID_HANDLE_VALUE) 210 210 { 211 211 *lpMapping = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 ); … … 224 224 HANDLE WINAPI VIRTUAL_MapFileA( LPCSTR name , LPVOID *lpMapping) 225 225 { 226 HANDLE hFile, hMapping = 0;226 HANDLE hFile, hMapping = -1; 227 227 228 228 hFile = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL, … … 232 232 hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL ); 233 233 CloseHandle( hFile ); 234 if (hMapping )234 if (hMapping != INVALID_HANDLE_VALUE) 235 235 { 236 236 *lpMapping = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
Note:
See TracChangeset
for help on using the changeset viewer.