void PDumpInitCommon(void) { (void)GetTempBuffer(); PDumpInit(); }
PVRSRV_ERROR PDumpMemUM(PVRSRV_PER_PROCESS_DATA * psPerProc, void *pvAltLinAddrUM, void *pvLinAddrUM, PVRSRV_KERNEL_MEM_INFO * psMemInfo, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) { void *pvAddrUM; void *pvAddrKM; u32 ui32BytesDumped; u32 ui32CurrentOffset; if (psMemInfo->pvLinAddrKM != NULL && pvAltLinAddrUM == NULL) { return PDumpMemKM(NULL, psMemInfo, ui32Offset, ui32Bytes, ui32Flags, hUniqueTag); } pvAddrUM = (pvAltLinAddrUM != NULL) ? pvAltLinAddrUM : ((pvLinAddrUM != NULL) ? VPTR_PLUS(pvLinAddrUM, ui32Offset) : NULL); pvAddrKM = GetTempBuffer(); PVR_ASSERT(pvAddrUM != NULL && pvAddrKM != NULL); if (pvAddrUM == NULL || pvAddrKM == NULL) { PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: Nothing to dump")); return PVRSRV_ERROR_GENERIC; } if (ui32Bytes > PDUMP_TEMP_BUFFER_SIZE) { PDumpCommentWithFlags(ui32Flags, "Dumping 0x%8.8lx bytes of memory, in blocks of 0x%8.8lx bytes", ui32Bytes, (u32) PDUMP_TEMP_BUFFER_SIZE); } ui32CurrentOffset = ui32Offset; for (ui32BytesDumped = 0; ui32BytesDumped < ui32Bytes;) { PVRSRV_ERROR eError; u32 ui32BytesToDump = MIN(PDUMP_TEMP_BUFFER_SIZE, ui32Bytes - ui32BytesDumped); eError = OSCopyFromUser(psPerProc, pvAddrKM, pvAddrUM, ui32BytesToDump); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: OSCopyFromUser failed (%d), eError")); return PVRSRV_ERROR_GENERIC; } eError = PDumpMemKM(pvAddrKM, psMemInfo, ui32CurrentOffset, ui32BytesToDump, ui32Flags, hUniqueTag); if (eError != PVRSRV_OK) { if (ui32BytesDumped != 0) { PVR_DPF((PVR_DBG_ERROR, "PDumpMemUM: PDumpMemKM failed (%d)", eError)); } PVR_ASSERT(ui32BytesDumped == 0); return eError; } VPTR_INC(pvAddrUM, ui32BytesToDump); ui32CurrentOffset += ui32BytesToDump; ui32BytesDumped += ui32BytesToDump; } return PVRSRV_OK; }
pascal OSErr NameFileSearch(ConstStr255Param volName, short vRefNum, ConstStr255Param fileName, FSSpecPtr matches, long reqMatchCount, long *actMatchCount, Boolean newSearch, Boolean partial) { CInfoPBRec searchInfo1, searchInfo2; HParamBlockRec pb; OSErr error; static CatPositionRec catPosition; static short lastVRefNum = 0; /* get the real volume reference number */ error = DetermineVRefNum(volName, vRefNum, &vRefNum); if ( error != noErr ) return ( error ); pb.csParam.ioNamePtr = NULL; pb.csParam.ioVRefNum = vRefNum; pb.csParam.ioMatchPtr = matches; pb.csParam.ioReqMatchCount = reqMatchCount; if ( partial ) /* tell CatSearch what we're looking for: */ { pb.csParam.ioSearchBits = fsSBPartialName + fsSBFlAttrib; /* partial name file matches or */ } else { pb.csParam.ioSearchBits = fsSBFullName + fsSBFlAttrib; /* full name file matches */ } pb.csParam.ioSearchInfo1 = &searchInfo1; pb.csParam.ioSearchInfo2 = &searchInfo2; pb.csParam.ioSearchTime = 0; if ( (newSearch) || /* If caller specified new search */ (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */ { catPosition.initialize = 0; /* then search from beginning of catalog */ } pb.csParam.ioCatPosition = catPosition; pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize); /* search for fileName */ searchInfo1.hFileInfo.ioNamePtr = (StringPtr)fileName; searchInfo2.hFileInfo.ioNamePtr = NULL; /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; error = PBCatSearchSyncCompat((CSParamPtr)&pb); if ( (error == noErr) || /* If no errors or the end of catalog was */ (error == eofErr) ) /* found, then the call was successful so */ { *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */ } else { *actMatchCount = 0; /* else no matches found */ } if ( (error == noErr) || /* If no errors */ (error == catChangedErr) ) /* or there was a change in the catalog */ { catPosition = pb.csParam.ioCatPosition; lastVRefNum = vRefNum; /* we can probably start the next search where we stopped this time */ } else { catPosition.initialize = 0; /* start the next search from beginning of catalog */ } if ( pb.csParam.ioOptBuffer != NULL ) { DisposePtr(pb.csParam.ioOptBuffer); } return ( error ); }
pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, short vRefNum, OSType creator, OSType fileType, FSSpecPtr matches, long reqMatchCount, long *actMatchCount, Boolean newSearch) { CInfoPBRec searchInfo1, searchInfo2; HParamBlockRec pb; OSErr error; static CatPositionRec catPosition; static short lastVRefNum = 0; /* get the real volume reference number */ error = DetermineVRefNum(volName, vRefNum, &vRefNum); if ( error != noErr ) return ( error ); pb.csParam.ioNamePtr = NULL; pb.csParam.ioVRefNum = vRefNum; pb.csParam.ioMatchPtr = matches; pb.csParam.ioReqMatchCount = reqMatchCount; pb.csParam.ioSearchBits = fsSBFlAttrib + fsSBFlFndrInfo; /* Looking for finder info file matches */ pb.csParam.ioSearchInfo1 = &searchInfo1; pb.csParam.ioSearchInfo2 = &searchInfo2; pb.csParam.ioSearchTime = 0; if ( (newSearch) || /* If caller specified new search */ (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */ { catPosition.initialize = 0; /* then search from beginning of catalog */ } pb.csParam.ioCatPosition = catPosition; pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize); /* no fileName */ searchInfo1.hFileInfo.ioNamePtr = NULL; searchInfo2.hFileInfo.ioNamePtr = NULL; /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; /* search for creator; if creator = 0x00000000, ignore creator */ searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator; if ( creator == (OSType)0x00000000 ) { searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0x00000000; } else { searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0xffffffff; } /* search for fileType; if fileType = 0x00000000, ignore fileType */ searchInfo1.hFileInfo.ioFlFndrInfo.fdType = fileType; if ( fileType == (OSType)0x00000000 ) { searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0x00000000; } else { searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0xffffffff; } /* zero all other FInfo fields */ searchInfo1.hFileInfo.ioFlFndrInfo.fdFlags = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdFldr = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdFlags = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdFldr = 0; error = PBCatSearchSyncCompat((CSParamPtr)&pb); if ( (error == noErr) || /* If no errors or the end of catalog was */ (error == eofErr) ) /* found, then the call was successful so */ { *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */ } else { *actMatchCount = 0; /* else no matches found */ } if ( (error == noErr) || /* If no errors */ (error == catChangedErr) ) /* or there was a change in the catalog */ { catPosition = pb.csParam.ioCatPosition; lastVRefNum = vRefNum; /* we can probably start the next search where we stopped this time */ } else { catPosition.initialize = 0; /* start the next search from beginning of catalog */ } if ( pb.csParam.ioOptBuffer != NULL ) { DisposePtr(pb.csParam.ioOptBuffer); } return ( error ); }
void* WrapperDLL::StreamFile_GetTempBuffer(void* self){ auto self_ = (StreamFile*)self; auto ret = self_->GetTempBuffer(); return ret; };