- Timestamp:
- Aug 14, 2009, 5:18:10 PM (16 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r21332 r21339 85 85 // this is the size of our currently static handle table 86 86 #define MAX_OS2_HMHANDLES (4*1024) 87 87 #define ERROR_SYS_INTERNAL 328 88 88 89 89 /***************************************************************************** … … 589 589 if (HMGlobals.fIsInitialized != TRUE) 590 590 { 591 592 #ifdef RAS 593 RasRegisterObjectTracking(&rthHandles, "KERNEL32 handles", 594 0, RAS_TRACK_FLAG_LOGOBJECTCONTENT, 591 592 #ifdef RAS 593 RasRegisterObjectTracking(&rthHandles, "KERNEL32 handles", 594 0, RAS_TRACK_FLAG_LOGOBJECTCONTENT, 595 595 LogObjectContent_Handle, NULL); 596 596 #endif … … 1504 1504 1505 1505 /* 1506 * Based on testcase (5) and MSDN: 1506 * Based on testcase (5) and MSDN: 1507 1507 * "OF_PARSE Fills the OFSTRUCT structure but carries out no other action." 1508 1508 */ … … 1778 1778 1779 1779 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1780 1781 if (!pHMHandle || !pHMHandle->pDeviceHandler) 1782 return ERROR_SYS_INTERNAL; 1783 1780 1784 fResult = pHMHandle->pDeviceHandler->ReadFile(&pHMHandle->hmHandleData, 1781 1785 lpBuffer, … … 1829 1833 1830 1834 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1835 1836 if (!pHMHandle || !pHMHandle->pDeviceHandler) 1837 return ERROR_SYS_INTERNAL; 1838 1831 1839 fResult = pHMHandle->pDeviceHandler->WriteFile(&pHMHandle->hmHandleData, 1832 1840 lpBuffer, … … 1866 1874 1867 1875 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1876 1877 if (!pHMHandle || !pHMHandle->pDeviceHandler) 1878 return ERROR_SYS_INTERNAL; 1879 1868 1880 dwResult = pHMHandle->pDeviceHandler->GetFileType(&pHMHandle->hmHandleData); 1869 1881 … … 1906 1918 1907 1919 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1920 1921 if (!pHMHandle || !pHMHandle->pDeviceHandler) 1922 return ERROR_SYS_INTERNAL; 1923 1908 1924 dwResult = pHMHandle->pDeviceHandler->_DeviceRequest(&pHMHandle->hmHandleData, 1909 1925 ulRequestCode, … … 1912 1928 arg3, 1913 1929 arg4); 1914 1915 1930 return (dwResult); /* deliver return code */ 1916 1931 } … … 1945 1960 1946 1961 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1962 1963 if (!pHMHandle || !pHMHandle->pDeviceHandler) 1964 return ERROR_SYS_INTERNAL; 1965 1947 1966 dwResult = pHMHandle->pDeviceHandler->GetFileInformationByHandle(&pHMHandle->hmHandleData, 1948 1967 pHFI); … … 1979 1998 1980 1999 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2000 2001 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2002 return ERROR_SYS_INTERNAL; 2003 1981 2004 bResult = pHMHandle->pDeviceHandler->SetEndOfFile(&pHMHandle->hmHandleData); 1982 2005 … … 2015 2038 2016 2039 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2040 2041 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2042 return ERROR_SYS_INTERNAL; 2043 2017 2044 bResult = pHMHandle->pDeviceHandler->SetFileTime(&pHMHandle->hmHandleData, 2018 2045 (LPFILETIME)pFT1, … … 2051 2078 2052 2079 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2080 2081 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2082 return ERROR_SYS_INTERNAL; 2083 2053 2084 bResult = pHMHandle->pDeviceHandler->GetFileTime(&pHMHandle->hmHandleData, 2054 2085 (LPFILETIME)pFT1, … … 2087 2118 2088 2119 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2120 2121 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2122 return ERROR_SYS_INTERNAL; 2123 2089 2124 dwResult = pHMHandle->pDeviceHandler->GetFileSize(&pHMHandle->hmHandleData, 2090 2125 pSize); … … 2133 2168 2134 2169 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2170 2171 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2172 return ERROR_SYS_INTERNAL; 2173 2135 2174 dwResult = pHMHandle->pDeviceHandler->SetFilePointer(&pHMHandle->hmHandleData, 2136 2175 lDistanceToMove, … … 2195 2234 2196 2235 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2236 2237 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2238 return ERROR_SYS_INTERNAL; 2239 2197 2240 dwResult = pHMHandle->pDeviceHandler->LockFile(&pHMHandle->hmHandleData, 2198 2241 arg2, … … 2242 2285 2243 2286 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2287 2288 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2289 return ERROR_SYS_INTERNAL; 2290 2244 2291 dwResult = pHMHandle->pDeviceHandler->LockFileEx(&pHMHandle->hmHandleData, 2245 2292 dwFlags, … … 2285 2332 2286 2333 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2334 2335 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2336 return ERROR_SYS_INTERNAL; 2337 2287 2338 dwResult = pHMHandle->pDeviceHandler->UnlockFile(&pHMHandle->hmHandleData, 2288 2339 arg2, … … 2330 2381 2331 2382 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2383 2384 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2385 return ERROR_SYS_INTERNAL; 2386 2332 2387 dwResult = pHMHandle->pDeviceHandler->UnlockFileEx(&pHMHandle->hmHandleData, 2333 2388 dwReserved, … … 2430 2485 } 2431 2486 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2487 2488 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2489 return ERROR_SYS_INTERNAL; 2490 2432 2491 dwResult = pHMHandle->pDeviceHandler->WaitForSingleObject(&pHMHandle->hmHandleData, 2433 2492 dwTimeout); … … 2466 2525 2467 2526 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2527 2528 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2529 return ERROR_SYS_INTERNAL; 2530 2468 2531 dwResult = pHMHandle->pDeviceHandler->WaitForSingleObjectEx(&pHMHandle->hmHandleData, 2469 2532 dwTimeout, … … 2501 2564 2502 2565 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2566 2567 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2568 return ERROR_SYS_INTERNAL; 2569 2503 2570 dwResult = pHMHandle->pDeviceHandler->FlushFileBuffers(&pHMHandle->hmHandleData); 2504 2571 … … 2537 2604 2538 2605 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2606 2607 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2608 return ERROR_SYS_INTERNAL; 2609 2539 2610 dwResult = pHMHandle->pDeviceHandler->GetOverlappedResult(&pHMHandle->hmHandleData, 2540 2611 lpOverlapped, … … 2573 2644 2574 2645 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2646 2647 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2648 return ERROR_SYS_INTERNAL; 2649 2575 2650 dwResult = pHMHandle->pDeviceHandler->ReleaseMutex(&pHMHandle->hmHandleData); 2576 2651 … … 2920 2995 2921 2996 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2997 2998 if (!pHMHandle || !pHMHandle->pDeviceHandler) 2999 return ERROR_SYS_INTERNAL; 3000 2922 3001 dwResult = pHMHandle->pDeviceHandler->ReleaseSemaphore(&pHMHandle->hmHandleData, 2923 3002 cReleaseCount, … … 3108 3187 3109 3188 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3189 3190 if (!pHMHandle || !pHMHandle->pDeviceHandler) 3191 return NULL; 3192 3110 3193 lpResult = pHMHandle->pDeviceHandler->MapViewOfFileEx(&pHMHandle->hmHandleData, 3111 3194 dwDesiredAccess, … … 3320 3403 3321 3404 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3405 3406 if (!pHMHandle || !pHMHandle->pDeviceHandler) 3407 return ERROR_SYS_INTERNAL; 3408 3322 3409 fResult = pHMHandle->pDeviceHandler->DeviceIoControl(&pHMHandle->hmHandleData, 3323 3410 dwIoControlCode, … … 3371 3458 3372 3459 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3460 3461 if (!pHMHandle || !pHMHandle->pDeviceHandler) 3462 return ERROR_SYS_INTERNAL; 3463 3373 3464 fResult = pHMHandle->pDeviceHandler->CancelIo(&pHMHandle->hmHandleData); 3374 3465 -
trunk/src/kernel32/dbglog.cpp
r21302 r21339 258 258 259 259 static BOOL fDisableThread[5] = {0}; 260 static BOOL fFlushLines = FALSE;260 static BOOL fFlushLines = TRUE; 261 261 262 262 static char *pszLastLogEntry = NULL; … … 275 275 #endif 276 276 277 //#define LOG_TIME277 #define LOG_TIME 278 278 //#define SHOW_FPU_CONTROLREG 279 279 #define WIN32_IP_LOGGING -
trunk/src/kernel32/oslibdos.cpp
r21336 r21339 1332 1332 // PH Note: for a negative 32-bit seek, the OS/2 64-bit version 1333 1333 // needs to be skipped. 1334 if( (f64BitIO) && (OffsetHigh) && 1334 #if 0 /* doesnt works at all with flash 10 */ 1335 if( (f64BitIO) && (OffsetHigh) && ((DWORD)OffsetHigh != 0xAAAAAAAA) && 1335 1336 (*OffsetHigh != 0xAAAAAAAA) && 1336 1337 (*OffsetHigh != 0)) //workaround for flash10 video … … 1345 1346 } 1346 1347 else 1348 #endif 1347 1349 rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset); 1348 1350 -
trunk/src/kernel32/oslibmem.cpp
r21302 r21339 204 204 return 0; 205 205 } 206 207 //*************************************************************************** 208 //Allocation memory at address helper 209 //*************************************************************************** 210 #define OBJ_LOCSPECIFIC 0x00001000UL 211 212 int allocAtAddress(void *pvReq, ULONG cbReq, ULONG fReq) 213 { 214 dprintf(("DosAllocMemEx pvReq=%p cbReq=%lu fReq=%#lx\n", pvReq, cbReq, fReq)); 215 PVOID apvTmps[3000]; 216 ULONG cbTmp; 217 ULONG fTmp; 218 int iTmp; 219 int rcRet = ERROR_NOT_ENOUGH_MEMORY; 220 221 /* 222 * Adjust flags and size. 223 */ 224 if ((ULONG)pvReq < 0x20000000 /*512MB*/) 225 fReq &= ~OBJ_ANY; 226 else 227 fReq |= OBJ_ANY; 228 cbReq = (cbReq + 0xfff) & ~0xfff; 229 230 /* 231 * Allocation loop. 232 * This algorithm is not optimal! 233 */ 234 fTmp = fReq & ~(PAG_COMMIT); 235 cbTmp = 1*1024*1024; /* 1MB*/ 236 for (iTmp = 0; iTmp < sizeof(apvTmps) / sizeof(apvTmps[0]); iTmp++) 237 { 238 PVOID pvNew = NULL; 239 int rc; 240 241 /* Allocate chunk. */ 242 rc = DosAllocMem(&pvNew, cbReq, fReq); 243 apvTmps[iTmp] = pvNew; 244 if (rc) 245 break; 246 247 /* 248 * Passed it? 249 * Then retry with the requested size. 250 */ 251 if (pvNew > pvReq) 252 { 253 if (cbTmp <= cbReq) 254 break; 255 DosFreeMem(pvNew); 256 cbTmp = cbReq; 257 iTmp--; 258 continue; 259 } 260 261 /* 262 * Does the allocated object touch into the requested one? 263 */ 264 if ((char *)pvNew + cbTmp > (char *)pvReq) 265 { 266 /* 267 * Yes, we've found the requested address! 268 */ 269 apvTmps[iTmp] = NULL; 270 DosFreeMem(pvNew); 271 272 /* 273 * Adjust the allocation size to fill the gap between the 274 * one we just got and the requested one. 275 * If no gap we'll attempt the real allocation. 276 */ 277 cbTmp = (ULONG)pvReq - (ULONG)pvNew; 278 if (cbTmp) 279 { 280 iTmp--; 281 continue; 282 } 283 284 rc = DosAllocMem(&pvNew, cbReq, fReq); 285 if (rc || (char *)pvNew > (char *)pvReq) 286 break; /* we failed! */ 287 if (pvNew == pvReq) 288 { 289 rcRet = 0; 290 break; 291 } 292 293 /* 294 * We've got an object which start is below the one we 295 * requested. This is probably caused by the requested object 296 * fitting in somewhere our tmp objects didn't. 297 * So, we'll have loop and retry till all such holes are filled. 298 */ 299 apvTmps[iTmp] = pvNew; 300 } 301 } 302 303 /* 304 * Cleanup reserved memory and return. 305 */ 306 while (iTmp-- > 0) 307 if (apvTmps[iTmp]) 308 DosFreeMem(apvTmps[iTmp]); 309 310 return rcRet; 311 } 312 206 313 //****************************************************************************** 207 314 //Allocate memory aligned at 64kb boundary … … 239 346 */ 240 347 241 rc = DosAllocMem(&pvMemAddr, cbSize, flFlags | fMemFlags); 348 if (flFlags & OBJ_LOCSPECIFIC) 349 { 350 rc = allocAtAddress(&pvMemAddr, cbSize, (flFlags & ~OBJ_LOCSPECIFIC) | fMemFlags); 351 } else 352 { 353 rc = DosAllocMem(&pvMemAddr, cbSize, flFlags | fMemFlags); 354 } 242 355 if(rc) { 243 356 dprintf(("!ERROR!: DosAllocMem failed with rc %d", rc)); -
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) { -
trunk/src/kernel32/winimagebase.cpp
r10397 r21339 413 413 *fNEExe = FALSE; 414 414 415 if (!findDll( szFileName, filename, sizeof(filename)))415 if (!findDll(ODINHelperStripUNC(szFileName), filename, sizeof(filename))) 416 416 { 417 417 dprintf(("KERNEL32:Win32ImageBase::isPEImage(%s) findDll failed to find the file.\n", -
trunk/src/kernel32/wprocess.cpp
r21302 r21339 946 946 * Endif 947 947 */ 948 strcpy(szModname, lpszLibFile);948 strcpy(szModname, ODINHelperStripUNC((char*)lpszLibFile)); 949 949 strupr(szModname); 950 950 dot = strchr(szModname, '.');
Note:
See TracChangeset
for help on using the changeset viewer.