Exemplo n.º 1
0
void DecodeIns( address *a, mad_disasm_data *dd, int big )
{
    DbgAddr = *a;
    InitCache( DbgAddr, 0x8 );
    DoCode( dd, big );
    a->mach.offset += dd->ins.size;
}
Exemplo n.º 2
0
// Takes ownership of backend.
CachingFileLoader::CachingFileLoader(FileLoader *backend)
	: filesize_(0), filepos_(0), backend_(backend), exists_(-1), isDirectory_(-1), aheadThread_(false) {
	filesize_ = backend->FileSize();
	if (filesize_ > 0) {
		InitCache();
	}
}
Exemplo n.º 3
0
mad_status GetDisasmPrev( address *a )
{
    mad_disasm_data dd;
    addr_off        start;
    addr_off        curr_off;
    addr_off        prev;
    unsigned        backup;
    int             big;

    DbgAddr = *a;
    big = BIG_SEG( DbgAddr );
    backup = ( big ) ? 0x40 : 0x20;
    curr_off = DbgAddr.mach.offset;
    DbgAddr.mach.offset = (curr_off <= backup) ? 0 : (curr_off - backup);
    InitCache( DbgAddr, curr_off - DbgAddr.mach.offset );
    for( start = DbgAddr.mach.offset; start < curr_off; ++start ) {
        DbgAddr.mach.offset = start;
        for( ;; ) {
            prev = DbgAddr.mach.offset;
            DoCode( &dd, big );
            if( dd.ins.size == 0 )
                break;      /* invalid address */
            DbgAddr.mach.offset += dd.ins.size;
            if( DbgAddr.mach.offset == curr_off ) {
                a->mach.offset = prev;
                return( MS_OK );
            }
            if( DbgAddr.mach.offset > curr_off ) break;
            if( DbgAddr.mach.offset < start ) break; /* wrapped around segment */
        }
    }
    /* Couldn't sync instruction stream */
    return( MS_FAIL );
}
Exemplo n.º 4
0
Arquivo: init.c Projeto: berkus/flick
int Init ()
{
/* Start up the file systems (traverse everything) */

  return (InitCache () != -1 &&
	  StartFileSystem () != -1);
}
Exemplo n.º 5
0
void CachingFileLoader::Prepare() {
	std::call_once(preparedFlag_, [this](){
		filesize_ = backend_->FileSize();
		if (filesize_ > 0) {
			InitCache();
		}
	});
}
Exemplo n.º 6
0
void DiskCachingFileLoader::Prepare() {
	if (prepared_) {
		return;
	}
	prepared_ = true;

	filesize_ = backend_->FileSize();
	if (filesize_ > 0) {
		InitCache();
	}
}
Exemplo n.º 7
0
void Tree::FromClust(Clust &C)
	{
	Clear();

	m_uNodeCount = C.GetNodeCount();
	InitCache(m_uNodeCount);

// Cluster is always rooted. An unrooted cluster
// is represented by a pseudo-root, which we fix later.
	m_bRooted = true;
	const unsigned uRoot = C.GetRootNodeIndex();
	m_uRootNodeIndex = uRoot;
	m_uNeighbor1[uRoot] = NULL_NEIGHBOR;
	m_bHasEdgeLength1[uRoot] = false;

	for (unsigned uNodeIndex = 0; uNodeIndex < m_uNodeCount; ++uNodeIndex)
		{
		if (C.IsLeaf(uNodeIndex))
			{
			const char *ptrName = C.GetNodeName(uNodeIndex);
			m_ptrName[uNodeIndex] = strsave(ptrName);
			m_Ids[uNodeIndex] = C.GetNodeId(uNodeIndex);
			continue;
			}

		const unsigned uLeft = C.GetLeftIndex(uNodeIndex);
		const unsigned uRight = C.GetRightIndex(uNodeIndex);

		const double dLeftLength = C.GetLength(uLeft);
		const double dRightLength = C.GetLength(uRight);

		m_uNeighbor2[uNodeIndex] = uLeft;
		m_uNeighbor3[uNodeIndex] = uRight;

		m_dEdgeLength1[uLeft] = dLeftLength;
		m_dEdgeLength1[uRight] = dRightLength;

		m_uNeighbor1[uLeft] = uNodeIndex;
		m_uNeighbor1[uRight] = uNodeIndex;

		m_bHasEdgeLength1[uLeft] = true;
		m_bHasEdgeLength1[uRight] = true;

		m_dEdgeLength2[uNodeIndex] = dLeftLength;
		m_dEdgeLength3[uNodeIndex] = dRightLength;

		m_bHasEdgeLength2[uNodeIndex] = true;
		m_bHasEdgeLength3[uNodeIndex] = true;
		}
	Validate();
	}
Exemplo n.º 8
0
/*!
	\brief	Initializes the heap
	\param	page_size -  Size of virtual page.
	\param	v_alloc - Function Pointer to virtual alloc.
	\param	v_free - Function pointer to virtual free.
	\param 	v_protect -	Function pointer to virtual protect.
	\return	 0 on sucess and -1 on failure
*/
int InitHeap( int page_size, void * (*v_alloc)(int size), 
		int (*v_free)(void * va, int size),
		int (*v_protect)(void * va, int size, int protection)
		)
{
	int i;
	
	VM_PAGE_SHIFT = 0;
	VM_PAGE_SIZE = page_size;
	VM_PAGE_SHIFT = FindFirstSetBitInBitArray( &VM_PAGE_SIZE, sizeof(VM_PAGE_SIZE)*BITS_PER_BYTE);
	VM_ALLOC = v_alloc;
	VM_FREE = v_free;
	VM_PROTECT = v_protect;
	
	if ( InitSlabAllocator(page_size, v_alloc, v_free, v_protect ) == -1 )
		return -1;
	for(i=0; i<MAX_HEAP_BUCKETS; i++ )
		InitCache(&CACHE_FROM_INDEX(i), BUCKET_SIZE(i), 0, 0, 0, NULL, NULL);
	return 0;
}
Exemplo n.º 9
0
static void ReadMem( address a, unsigned s, void *d )
{

    if( a.sect_id == Cache.start.sect_id
     && a.mach.segment == Cache.start.mach.segment
     && a.mach.offset >= Cache.start.mach.offset
     && ( a.mach.offset + s ) < ( Cache.start.mach.offset + Cache.len ) ) {
        memcpy( d, &Cache.data[a.mach.offset-Cache.start.mach.offset], s );
        return;
    }
#if 0
    InitCache( a, Cache.want );
    if( a.sect_id == Cache.start.sect_id
     && a.mach.segment == Cache.start.mach.segment
     && a.mach.offset >= Cache.start.mach.offset
     && (a.mach.offset+s) < (Cache.start.mach.offset+Cache.len) ) {
        memcpy( d, &Cache.data[a.mach.offset-Cache.start.mach.offset], s );
        return;
    }
#endif
    MCReadMem( a, s, d );
}
Exemplo n.º 10
0
BtreeBucket *BtreeCache::ConstructCache(unsigned num_bkts, 
					BtreeSize_t dbkey_size, 
					BtreeNodeOrder_t order)
// Constructs and initialize and array of buckets. NOTE: This
// implementation uses contiguous memory for the cache buckets.
// Returns a pointer to the bucket array or a null value if an
// error occurs.
{
  if(!IsEmpty()) DestroyCache();
  // Set minimum number of buckets. The gxBtree tree insert function 
  // requires a minimum of 2 cache buckets (left and right pointers)
  // and both delete functions require a minimum of 3 cache buckets 
  // (left, right, and parent pointers).
  if((num_bkts == 0) || (num_bkts < (unsigned)MIN_BTREECACHE_SEGMENTS)) {
    num_bkts = MIN_BTREECACHE_SEGMENTS; 
  }
  num_buckets = num_bkts;
  buckets = new BtreeBucket[num_bkts]; // Construct an array of buckets
  if(buckets) InitCache(dbkey_size, order);
  ResetStats();
  return buckets;
}
Exemplo n.º 11
0
/* Resamples N input maps into 1 output map.
 * For every pixel in the output map all input maps are scanned.
 * The output value of the pixel is determined according to the
 * cells of the input maps at the pixel location. With an optional
 * percentage a minimum coverage area for a non MV can be given.
 * Returns 0 if no error occurs, 1 otherwise.
 */ 
int SampleCont(
	MAP *out,		/* write-only output map */
 	MAP **in,		/* read-only list input maps */
 	double percentage,	/* min. percentage for non-MV */
 	size_t nrMaps,		/* number of input maps */
 	size_t nrRows,		/* number of rows */
 	size_t nrCols,		/* number of columns */
 	BOOL aligned,		/* maps are aligned */
 	REAL8 angle)		/* angle of output map */
 {		
	double r, c;
	size_t nrCoverCells = (size_t)ceil((percentage / 100) * rasterSize
					* rasterSize);
	InitCache(out, in, nrMaps);
	for(r = 0; r < nrRows; r++) 	
	{

		if(nrMaps > 1 && percentage > 0)
	 		raster = NewRaster(nrCoverCells, rasterSize);

	 	/* Print progress information if wanted */
	 	AppRowProgress((int) r);

	 	for(c = 0; c < nrCols; c++) 	
	 	{   /* For every output cell */
		    if(CalcPixel(out, in, nrCoverCells, nrMaps, r, c, aligned, angle)) 
			return 1;	/* allocation failed */
	 	}
	}

	AppEndRowProgress();
	if(nrMaps > 1 && percentage > 0)
		FreeRaster(raster);
	FreeCache(nrMaps);
	return 0;			/* successfully terminated */
 }
Exemplo n.º 12
0
int LoadDatabaseModule(void)
{
	InitializeCriticalSection(&csDbAccess);
	log0("DB logging running");
	{
		DWORD dummy=0;
		hDbFile=CreateFileA(szDbPath,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
		if ( hDbFile == INVALID_HANDLE_VALUE ) {
			return 1;
		}
		if ( !ReadFile(hDbFile,&dbHeader,sizeof(dbHeader),&dummy,NULL) ) {
			CloseHandle(hDbFile);
			return 1;
		}
	}
	//if(ParseCommandLine()) return 1;
	if(InitCache()) return 1;
	if(InitModuleNames()) return 1;
	if(InitContacts()) return 1;
	if(InitSettings()) return 1;
	if(InitEvents()) return 1;
	if(InitCrypt()) return 1;
	return 0;
}
Exemplo n.º 13
0
VOID
CEntryPoint (
  IN  VOID  *MemoryBase,
  IN  UINTN MemorySize,
  IN  VOID  *StackBase,
  IN  UINTN StackSize
  )
{
  VOID *HobBase;

  // Build a basic HOB list
  HobBase      = (VOID *)(UINTN)(FixedPcdGet32(PcdEmbeddedFdBaseAddress) + FixedPcdGet32(PcdEmbeddedFdSize));
  CreateHobList (MemoryBase, MemorySize, HobBase, StackBase);

  //Set up Pin muxing.
  PadConfiguration ();

  // Set up system clocking
  ClockInit ();


  // Enable program flow prediction, if supported.
  ArmEnableBranchPrediction ();

  // Initialize CPU cache
  InitCache ((UINT32)MemoryBase, (UINT32)MemorySize);

  // Add memory allocation hob for relocated FD
  BuildMemoryAllocationHob (FixedPcdGet32(PcdEmbeddedFdBaseAddress), FixedPcdGet32(PcdEmbeddedFdSize), EfiBootServicesData);

  // Add the FVs to the hob list
  BuildFvHob (PcdGet32(PcdFlashFvMainBase), PcdGet32(PcdFlashFvMainSize));

  // Start talking
  UartInit ();
 
  InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL, NULL);
  SaveAndSetDebugTimerInterrupt (TRUE);

  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));

  // Start up a free running timer so that the timer lib will work
  TimerInit ();

  // SEC phase needs to run library constructors by hand.
  ExtractGuidedSectionLibConstructor ();
  LzmaDecompressLibConstructor ();

  // Build HOBs to pass up our version of stuff the DXE Core needs to save space
  BuildPeCoffLoaderHob ();
  BuildExtractSectionHob (
    &gLzmaCustomDecompressGuid,
    LzmaGuidedSectionGetInfo,
    LzmaGuidedSectionExtraction
    );

  // Assume the FV that contains the SEC (our code) also contains a compressed FV.
  DecompressFirstFv ();

  // Load the DXE Core and transfer control to it
  LoadDxeCoreFromFv (NULL, 0);
  
  // DXE Core should always load and never return
  ASSERT (FALSE);
}
Exemplo n.º 14
0
DiskCachingFileLoaderCache::DiskCachingFileLoaderCache(const std::string &path, u64 filesize)
	: refCount_(0), filesize_(filesize), origPath_(path), f_(nullptr), fd_(0) {
	InitCache(path);
}
Exemplo n.º 15
0
int far pascal __loadds  FS_MOUNT(unsigned short usFlag,      /* flag     */
                        struct vpfsi far * pvpfsi,      /* pvpfsi   */
                        struct vpfsd far * pvpfsd,      /* pvpfsd   */
                        unsigned short hVBP,        /* hVPB     */
                        char far *  pBoot       /* pBoot    */)
{
PBOOTSECT pSect;
PVOLINFO  pVolInfo;
PVOLINFO  pNext, pPrev;
USHORT usVolCount;
USHORT hDupVBP;
USHORT rc;
P_DriverCaps pDevCaps;
P_VolChars   pVolChars;

   _asm push es;
   //_asm push bx;

   if (f32Parms.fMessageActive & LOG_FS)
      Message("FS_MOUNT for %c (%d):, flag = %d",
         pvpfsi->vpi_drive + 'A',
         pvpfsi->vpi_unit,
         usFlag);

   switch (usFlag)
      {
      case MOUNT_MOUNT  :

        if (FSH_FINDDUPHVPB(hVBP, &hDupVBP))
           hDupVBP = 0;

        pSect = (PBOOTSECT)pBoot;
        if (memicmp(pSect->FileSystem, "FAT32", 5))
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

        if (pSect->bpb.BytesPerSector != SECTOR_SIZE)
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

        if(( ULONG )pSect->bpb.BytesPerSector * pSect->bpb.SectorsPerCluster > MAX_CLUSTER_SIZE )
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

        pvpfsi->vpi_vid    = pSect->ulVolSerial;
        pvpfsi->vpi_bsize  = pSect->bpb.BytesPerSector;
        pvpfsi->vpi_totsec = pSect->bpb.BigTotalSectors;
        pvpfsi->vpi_trksec = pSect->bpb.SectorsPerTrack;
        pvpfsi->vpi_nhead  = pSect->bpb.Heads;
        memset(pvpfsi->vpi_text, 0, sizeof pvpfsi->vpi_text);
        memcpy(pvpfsi->vpi_text, pSect->VolumeLabel, sizeof pSect->VolumeLabel);

        pVolInfo = gdtAlloc(STORAGE_NEEDED, FALSE);
        if (!pVolInfo)
            {
            rc = ERROR_NOT_ENOUGH_MEMORY;
            goto FS_MOUNT_EXIT;
            }
        rc = FSH_FORCENOSWAP(SELECTOROF(pVolInfo));
        if (rc)
            FatalMessage("FSH_FORCENOSWAP on VOLINFO Segment failed, rc=%u", rc);

         memset(pVolInfo, 0, (size_t)STORAGE_NEEDED);

         InitCache(ulCacheSectors);

         memcpy(&pVolInfo->BootSect, pSect, sizeof (BOOTSECT));

         pVolInfo->ulActiveFatStart = pSect->bpb.ReservedSectors;
         if (pSect->bpb.ExtFlags & 0x0080)
            pVolInfo->ulActiveFatStart +=
               pSect->bpb.BigSectorsPerFat * (pSect->bpb.ExtFlags & 0x000F);
         pVolInfo->ulStartOfData    = pSect->bpb.ReservedSectors +
               pSect->bpb.BigSectorsPerFat * pSect->bpb.NumberOfFATs;

         pVolInfo->pBootFSInfo = (PBOOTFSINFO)(pVolInfo + 1);
         pVolInfo->pbFatSector = (PBYTE)(pVolInfo->pBootFSInfo + 1);
         pVolInfo->ulCurFatSector = -1L;
         pVolInfo->usClusterSize = pSect->bpb.BytesPerSector * pSect->bpb.SectorsPerCluster;
         pVolInfo->ulTotalClusters = (pSect->bpb.BigTotalSectors - pVolInfo->ulStartOfData) / pSect->bpb.SectorsPerCluster;

         pVolInfo->hVBP = hVBP;
         pVolInfo->hDupVBP = hDupVBP;
         pVolInfo->bDrive = pvpfsi->vpi_drive;
         pVolInfo->bUnit  = pvpfsi->vpi_unit;
         pVolInfo->pNextVolInfo = NULL;

         pVolInfo->fFormatInProgress = FALSE;

         if (usDefaultRASectors == 0xFFFF)
            pVolInfo->usRASectors = (pVolInfo->usClusterSize / SECTOR_SIZE ) * 2;
         else
            pVolInfo->usRASectors = usDefaultRASectors;

#if 1
         if( pVolInfo->usRASectors > MAX_RASECTORS )
            pVolInfo->usRASectors = MAX_RASECTORS;
#else
         if (pVolInfo->usRASectors > (pVolInfo->usClusterSize / SECTOR_SIZE) * 4)
            pVolInfo->usRASectors = (pVolInfo->usClusterSize / SECTOR_SIZE ) * 4;
#endif

         if (pSect->bpb.FSinfoSec != 0xFFFF)
            {
            ReadSector(pVolInfo, pSect->bpb.FSinfoSec, 1, pVolInfo->pbFatSector, DVIO_OPNCACHE);
            memcpy(pVolInfo->pBootFSInfo, pVolInfo->pbFatSector + FSINFO_OFFSET, sizeof (BOOTFSINFO));
            }
         else
            memset(pVolInfo->pBootFSInfo, 0, sizeof (BOOTFSINFO));

         *((PVOLINFO *)(pvpfsd->vpd_work)) = pVolInfo;

         if (!pGlobVolInfo)
            {
            pGlobVolInfo = pVolInfo;
            usVolCount = 1;
            }
         else
            {
            pNext = pGlobVolInfo;
            usVolCount = 1;
            if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
               pVolInfo->hDupVBP = pNext->hVBP;
            while (pNext->pNextVolInfo)
               {
               pNext = (PVOLINFO)pNext->pNextVolInfo;
               if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
                  pVolInfo->hDupVBP = pNext->hVBP;
               usVolCount++;
               }
            pNext->pNextVolInfo = pVolInfo;
            usVolCount++;
            }
         if (f32Parms.fMessageActive & LOG_FS)
            Message("%u Volumes mounted!", usVolCount);

         rc = CheckWriteProtect(pVolInfo);
         if (rc && rc != ERROR_WRITE_PROTECT)
            {
            Message("Cannot access drive, rc = %u", rc);
            goto FS_MOUNT_EXIT;
            }
         if (rc == ERROR_WRITE_PROTECT)
            pVolInfo->fWriteProtected = TRUE;

         pVolInfo->fDiskCleanOnMount = pVolInfo->fDiskClean = GetDiskStatus(pVolInfo);
         if (!pVolInfo->fDiskCleanOnMount)
            Message("DISK IS DIRTY!");
         if (pVolInfo->fWriteProtected)
            pVolInfo->fDiskCleanOnMount = TRUE;

         if (!pVolInfo->hDupVBP &&
                (f32Parms.fCalcFree ||
                 pVolInfo->pBootFSInfo->ulFreeClusters == 0xFFFFFFFF ||
               /*!pVolInfo->fDiskClean ||*/
                 pVolInfo->BootSect.bpb.FSinfoSec == 0xFFFF))
            GetFreeSpace(pVolInfo);

         pDevCaps  = pvpfsi->vpi_pDCS;
         pVolChars = pvpfsi->vpi_pVCS;

         if (pDevCaps->Capabilities & GDC_DD_Read2)
            Message("Read2 supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Word)
            Message("DMA on word alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Byte)
            Message("DMA on byte alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_Mirror)
            Message("Disk Mirroring supported");
         if (pDevCaps->Capabilities & GDC_DD_Duplex)
            Message("Disk Duplexing supported");
         if (pDevCaps->Capabilities & GDC_DD_No_Block)
            Message("Strategy2 does not block");
         if (pDevCaps->Capabilities & GDC_DD_16M)
            Message(">16M supported");
         if (pDevCaps->Strategy2)
            {
            Message("Strategy2   address at %lX", pDevCaps->Strategy2);
            Message("ChgPriority address at %lX", pDevCaps->ChgPriority);

            pVolInfo->pfnStrategy = (STRATFUNC)pDevCaps->Strategy2;
            pVolInfo->pfnPriority = (STRATFUNC)pDevCaps->ChgPriority;
            }

         rc = 0;
         break;

      case MOUNT_ACCEPT :

         if (FSH_FINDDUPHVPB(hVBP, &hDupVBP))
           hDupVBP = 0;

         if (pvpfsi->vpi_bsize != SECTOR_SIZE)
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

         pVolInfo = gdtAlloc(STORAGE_NEEDED, FALSE);
         if (!pVolInfo)
            {
            rc = ERROR_NOT_ENOUGH_MEMORY;
            goto FS_MOUNT_EXIT;
            }
         rc = FSH_FORCENOSWAP(SELECTOROF(pVolInfo));
         if (rc)
            FatalMessage("FSH_FORCENOSWAP on VOLINFO Segment failed, rc=%u", rc);

         memset(pVolInfo, 0, (size_t)STORAGE_NEEDED);

         //InitCache(ulCacheSectors);

         memset(&pVolInfo->BootSect, 0, sizeof (BOOTSECT));
         pVolInfo->BootSect.bpb.BigTotalSectors = pvpfsi->vpi_totsec;
         pVolInfo->BootSect.bpb.BytesPerSector  = pvpfsi->vpi_bsize;
         pVolInfo->fWriteProtected   = FALSE;
         pVolInfo->fDiskCleanOnMount = FALSE;

         pVolInfo->hVBP = hVBP;
         pVolInfo->hDupVBP = hDupVBP;
         pVolInfo->bDrive = pvpfsi->vpi_drive;
         pVolInfo->bUnit  = pvpfsi->vpi_unit;
         pVolInfo->pNextVolInfo = NULL;

         // the volume is being formatted
         pVolInfo->fFormatInProgress = TRUE;

         // fake values assuming sector == cluster
         pVolInfo->usClusterSize   = pvpfsi->vpi_bsize;
         pVolInfo->ulTotalClusters = pvpfsi->vpi_totsec;

         pVolInfo->usRASectors = usDefaultRASectors;

         // undefined
         pVolInfo->ulStartOfData = 0;

         //*((PVOLINFO *)(pvpfsd->vpd_work)) = pVolInfo;

         if (!pGlobVolInfo)
            {
            pGlobVolInfo = pVolInfo;
            usVolCount = 1;
            }
         else
            {
            pNext = pGlobVolInfo;
            usVolCount = 1;
            if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
               pVolInfo->hDupVBP = pNext->hVBP;
            while (pNext->pNextVolInfo)
               {
               pNext = (PVOLINFO)pNext->pNextVolInfo;
               if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
                  pVolInfo->hDupVBP = pNext->hVBP;
               usVolCount++;
               }
            pNext->pNextVolInfo = pVolInfo;
            usVolCount++;
            }
         if (f32Parms.fMessageActive & LOG_FS)
            Message("%u Volumes mounted!", usVolCount);

         pDevCaps  = pvpfsi->vpi_pDCS;
         pVolChars = pvpfsi->vpi_pVCS;

         if (pDevCaps->Capabilities & GDC_DD_Read2)
            Message("Read2 supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Word)
            Message("DMA on word alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Byte)
            Message("DMA on byte alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_Mirror)
            Message("Disk Mirroring supported");
         if (pDevCaps->Capabilities & GDC_DD_Duplex)
            Message("Disk Duplexing supported");
         if (pDevCaps->Capabilities & GDC_DD_No_Block)
            Message("Strategy2 does not block");
         if (pDevCaps->Capabilities & GDC_DD_16M)
            Message(">16M supported");
         if (pDevCaps->Strategy2)
            {
            Message("Strategy2   address at %lX", pDevCaps->Strategy2);
            Message("ChgPriority address at %lX", pDevCaps->ChgPriority);

            pVolInfo->pfnStrategy = (STRATFUNC)pDevCaps->Strategy2;
            pVolInfo->pfnPriority = (STRATFUNC)pDevCaps->ChgPriority;
            }

         rc = 0;
         break;

      case MOUNT_VOL_REMOVED:
      case MOUNT_RELEASE:
         pVolInfo = GetVolInfo(hVBP);

         if (!pVolInfo)
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

         //if (!pVolInfo->hDupVBP)
         //{
            usFlushVolume( pVolInfo, FLUSH_DISCARD, TRUE, PRIO_URGENT );

            if (f32Parms.usDirtySectors) // vs
                UpdateFSInfo(pVolInfo);  //

            MarkDiskStatus(pVolInfo, TRUE);
         //}

         // delete pVolInfo from the list
         if (pGlobVolInfo)
            {
            pNext = pPrev = pGlobVolInfo;

            // search for pVolInfo in the list
            while (pNext != pVolInfo)
               {
               pPrev = pNext;
               pNext = (PVOLINFO)pNext->pNextVolInfo;
               }

            // found
            if (pNext == pVolInfo)
               {
               if (pPrev == pVolInfo) // the very 1st list item
                  pGlobVolInfo = NULL;
               else
                  {
                  // delete it
                  pNext = pNext->pNextVolInfo;
                  pPrev->pNextVolInfo = pNext;
                  }
               usVolCount--;
               }
            }    

         RemoveVolume(pVolInfo);
         freeseg(pVolInfo);
         rc = 0;
         break;

      default :
         rc = ERROR_NOT_SUPPORTED;
         break;
      }

FS_MOUNT_EXIT:
   if (f32Parms.fMessageActive & LOG_FS)
      Message("FS_MOUNT returned %u\n", rc);

   //_asm int  3
   //_asm pop  bx;
   _asm pop  es;

   return rc;
}
Exemplo n.º 16
0
static int SystemConstruct(void)
{
  int Result;
  int x,y;

  _harderr(handler);

  ReadDefaultScreenMode();

  if ((Result=LockMouseMemory())<0)
     return(Result);

  TimerInit();
  HandleInitial();
  if ((Result=ChineseLibInitial())<0)
     return(Result);
  if ((Result=ItemInitial())<0)
     return(Result);

  x=getmaxx();  y=getmaxy();
    if ((Result=WindowInitial(x,y-30))<0)
     return(Result);

  if ((Result=GraphInitial())<0)
     return(Result);

  if ((Result=MouseConstruct(x,y))<0 && !fEditor) {
   #ifdef OLD_VERSION
     //printf("I can't find mouse or mouse driver. Press a key ...\n");
     static char MouseErrMsg[]="ÇëÏÈ°²×°Êó±êÇý¶¯³ÌÐò¡£°´<Esc>Í˳ö¡­¡­";
     DisplayString(MouseErrMsg,(x-strlen(MouseErrMsg)*ASC16WIDTH)/2,y/2,
               EGA_LIGHTRED,getbkcolor());
     fflush(stdout);
     getch();
     return(Result);
   #else
     static char MouseErrMsg1[]="δ°²×°Êó±êÇý¶¯³ÌÐò(ÓÐЩ¹¦ÄܱØÐëÓÉ";
     static char MouseErrMsg2[]="Êó±ê²ÅÄÜÍê³É)! Äú¿ÉÍ˳öϵͳ, ÏÈÔËÐÐÊó";
     static char MouseErrMsg3[]="±êÇý¶¯³ÌÐò, Èç:   AMOUSE     [»Ø³µ]";
     static char MouseErrMsg4[]="ÈôÊó±ê×°ÔÚ´®¿Ú¶þÉÏ, Ôò¼üÈë:  AMOUSE/2";
     static char MouseErrMsg5[]="ÏÖÔÚÄú¿É°´<Esc>Í˳ö, ±ðµÄ¼ü½«¼ÌÐø";
     int disp_x=x/2-(strlen(MouseErrMsg2)+4)*ASC16WIDTH/2;
     int disp_y=y/2-10;

     DisplayString(MouseErrMsg1,disp_x+4*ASC16WIDTH,disp_y-3*ASC16HIGHT-4,
               EGA_WHITE,EGA_BLACK);
     DisplayString(MouseErrMsg2,disp_x,disp_y-2*ASC16HIGHT,
               EGA_WHITE,EGA_BLACK);
     DisplayString(MouseErrMsg3,disp_x,disp_y-1*ASC16HIGHT+4,
               EGA_WHITE,EGA_BLACK);
     DisplayString(MouseErrMsg4,disp_x,disp_y-0*ASC16HIGHT+8,
               EGA_WHITE,EGA_BLACK);
     DisplayString(MouseErrMsg5,disp_x,disp_y+1*ASC16HIGHT+20,
               EGA_WHITE,EGA_BLACK);
     fflush(stdout);
     Result=getch();
     if(Result==0) getch();
     else if(Result==ESC) return(-1);

     while (kbhit()) getch();
   #endif
  }

 #ifdef NOT_USED
  if (EMMTest())
    {
        if (EMMMessage()<0) return -1;
    }
 #endif

/*--------
  if ((Result=KeySpeed())<0)
     return(Result);
----*/
  PageInitial();

  if ((Result=FontInitial())<0)
     return(Result);

  InitCache();
  init_paper();             //By zjh

  GetFaxConfig();
  ReturnOK();
}
Exemplo n.º 17
0
static int HeuristicTraceBack(
    address *p_prev_sp,
    address *start,
    address *execution,
    address *frame,
    address *stack )
{
    mad_disasm_data dd;
    int             word_size;
    long            sp_adjust;
    long            bp_adjust;
    long            saved_bp_loc = 0;
    long            bp_to_ra_offset = 0;
//    int             found_inc_bp;
    int             found_mov_bp_sp;
    int             found_push_bp;
    char            *jmplabel;
    address         return_addr_location;
    address         bp_value;
    address         sp_value;
    address         saved_return_location;
    int             found_call;
    int             i;

    InitCache( *start, 100 );
    sp_value = *stack;
    bp_value = *frame;

    DbgAddr = *execution;
    DisAsm( &dd );
    if( dd.ins.type == DI_X86_retf || dd.ins.type == DI_X86_retf2 ) {
        *execution = GetFarAddr( &sp_value );
        found_call = 1;
    } else if( dd.ins.type == DI_X86_ret || dd.ins.type == DI_X86_ret2 ) {
        execution->mach.offset = GetAnOffset( &sp_value );
        found_call = 1;
    } else {
        // Check for ADD SP,n right after current ip and adjust SP if its there
        // because it must be popping parms
        if( dd.ins.type == DI_X86_add3 && ConstOp( dd.ins.op[OP_2] ) && IsSPReg( dd.ins.op[OP_1] ) ){
            sp_value.mach.offset += dd.ins.op[ OP_2 ].value.s._32[I64LO32];
        }
        // Run through code from the known symbol until and collect prolog info
        word_size = Is32BitSegment ? 4 : 2;
        sp_adjust = 0;
        bp_adjust = 0;
//        found_inc_bp = 0;
        found_mov_bp_sp = 0;
        found_push_bp = 0;
        DbgAddr = *start;
        while( DbgAddr.mach.offset != execution->mach.offset ) {
            DisAsm( &dd );
            switch( dd.ins.type ) {
            case DI_INVALID:
                return( 0 );
            case DI_X86_call3:
                jmplabel = ToSegStr( dd.ins.op[ OP_1 ].value.s._32[I64LO32], dd.ins.op[ OP_1 ].extra, 0 );
                if( IdentifyFunc( jmplabel, &sp_adjust ) )
                    continue;
                break;
            case DI_X86_call:
                jmplabel = JmpLabel( dd.ins.op[ OP_1 ].value.s._32[I64LO32], 0 );
                if( IdentifyFunc( jmplabel, &sp_adjust ) )
                    continue;
                break;
            case DI_X86_enter:
                sp_adjust -= word_size; // push bp
                found_push_bp = 1;
                bp_to_ra_offset = sp_adjust; // mov bp,sp
                found_mov_bp_sp = 1;
                saved_bp_loc = 0; // 0[bp]
                sp_adjust -= dd.ins.op[ OP_1 ].value.s._32[I64LO32]; // sub sp,n
                break;
            case DI_X86_inc2:
                if( IsBPReg( dd.ins.op[ OP_1 ] ) ) {
//                    found_inc_bp = 1;
                    continue;
                }
                break;
            case DI_X86_mov:
                if( IsBPReg( dd.ins.op[ OP_1 ] ) && IsSPReg( dd.ins.op[ OP_2 ] ) ) {
                    found_mov_bp_sp = 1;
                    bp_to_ra_offset = sp_adjust;
                    saved_bp_loc -= sp_adjust;
                }
                continue;
            case DI_X86_nop:
                continue;
            case DI_X86_pop:
            case DI_X86_pop2:
            case DI_X86_pop3d:
            case DI_X86_pop3e:
            case DI_X86_pop3s:
            case DI_X86_pop4f:
            case DI_X86_pop4g:
                sp_adjust += word_size;
                continue;
            case DI_X86_push:
            case DI_X86_push2:
            case DI_X86_push3:
            case DI_X86_push4f:
            case DI_X86_push4g:
            case DI_X86_push5:
                sp_adjust -= word_size;
                if( IsBPReg( dd.ins.op[ OP_1 ] ) ) {
                    saved_bp_loc = sp_adjust;
                    found_push_bp = 1;
                }
                continue;
            case DI_X86_sub:
                dd.ins.op[ OP_2 ].value.s._32[I64LO32] = -dd.ins.op[ OP_2 ].value.s._32[I64LO32];
                /* fall through */
            case DI_X86_add:
                if( !ConstOp( dd.ins.op[ OP_2 ] ) )
                    break;
                if( IsSPReg( dd.ins.op[ OP_1 ] ) ) {
                    sp_adjust += dd.ins.op[ OP_2 ].value.s._32[I64LO32];
                    continue;
                } else if( IsBPReg( dd.ins.op[ OP_1 ] ) ) {
                    bp_adjust += dd.ins.op[ OP_2 ].value.s._32[I64LO32];
                    continue;
                }
                break;
            default:
                break;
            }
            break;
        }

        // find the address of the return address (return_addr_location)
        if( found_mov_bp_sp ) {
            return_addr_location = bp_value;
            return_addr_location.mach.offset -= bp_adjust;
            GetBPFromStack( &return_addr_location, &bp_value );
            return_addr_location.mach.offset -= bp_to_ra_offset;
        } else {
            if( found_push_bp ) {
                return_addr_location = sp_value;
                return_addr_location.mach.offset += saved_bp_loc - sp_adjust;
                GetBPFromStack( &return_addr_location, &bp_value );
            }
            return_addr_location = sp_value;
            return_addr_location.mach.offset -= sp_adjust;
        }

        found_call = 0;
        if( found_mov_bp_sp ) {
            found_call = FindCall( execution, &return_addr_location );
            if( !found_call ) {
                return_addr_location = sp_value;
                return_addr_location.mach.offset -= sp_adjust;
            }
        }
        if( !found_call ) {
            saved_return_location = return_addr_location;
            // limit the search to 512*word_size (W2K can cause us to search 4Gb!)
            for( i = 0; return_addr_location.mach.offset >= p_prev_sp->mach.offset && i < 512; ++i ) {
                found_call = FindCall( execution, &return_addr_location );
                if( found_call )
                    break;
                return_addr_location.mach.offset -= word_size;
            }
            if( !found_call ) {
                return_addr_location = saved_return_location;
                for( i = 0; i < 10; ++i ) {
                    return_addr_location.mach.offset += word_size;
                    found_call = FindCall( execution, &return_addr_location );
                    if( found_call ) {
                        break;
                    }
                }
            }
        }
    }
    *stack = DbgAddr;
    *frame = bp_value;
    return( found_call );
}
Exemplo n.º 18
0
int far pascal FS_MOUNT(unsigned short usFlag,		/* flag		*/
                        struct vpfsi far * pvpfsi,		/* pvpfsi	*/
                        struct vpfsd far * pvpfsd,		/* pvpfsd	*/
                        unsigned short hVBP,		/* hVPB		*/
                        char far *	pBoot		/* pBoot	*/)
{
PBOOTSECT pSect;
PVOLINFO  pVolInfo;
PVOLINFO  pNext;
USHORT usVolCount;
USHORT hDupVBP;
USHORT rc;
P_DriverCaps pDevCaps;
P_VolChars   pVolChars;

   if (f32Parms.fMessageActive & LOG_FS)
      Message("FS_MOUNT for %c (%d):, flag = %d",
         pvpfsi->vpi_drive + 'A',
         pvpfsi->vpi_unit,
         usFlag);

   switch (usFlag)
      {
      case MOUNT_MOUNT  :

         if (FSH_FINDDUPHVPB(hVBP, &hDupVBP))
            hDupVBP = 0;

         pSect = (PBOOTSECT)pBoot;
         if (memicmp(pSect->FileSystem, "FAT32", 5))
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

         if (pSect->bpb.BytesPerSector != SECTOR_SIZE)
            {
            rc = ERROR_VOLUME_NOT_MOUNTED;
            goto FS_MOUNT_EXIT;
            }

         pvpfsi->vpi_vid    = pSect->ulVolSerial;
         pvpfsi->vpi_bsize  = pSect->bpb.BytesPerSector;
         pvpfsi->vpi_totsec = pSect->bpb.BigTotalSectors;
         pvpfsi->vpi_trksec = pSect->bpb.SectorsPerTrack;
         pvpfsi->vpi_nhead  = pSect->bpb.Heads;
         memset(pvpfsi->vpi_text, 0, sizeof pvpfsi->vpi_text);
         memcpy(pvpfsi->vpi_text, pSect->VolumeLabel, sizeof pSect->VolumeLabel);

         pVolInfo = gdtAlloc(STORAGE_NEEDED, FALSE);
         if (!pVolInfo)
            {
            rc = ERROR_NOT_ENOUGH_MEMORY;
            goto FS_MOUNT_EXIT;
            }
         rc = FSH_FORCENOSWAP(SELECTOROF(pVolInfo));
         if (rc)
            FatalMessage("FSH_FORCENOSWAP on VOLINFO Segment failed, rc=%u", rc);

         memset(pVolInfo, 0, (size_t)STORAGE_NEEDED);

         InitCache(ulCacheSectors);

         memcpy(&pVolInfo->BootSect, pSect, sizeof (BOOTSECT));
         pVolInfo->ulActiveFatStart = pSect->bpb.ReservedSectors;
         if (pSect->bpb.ExtFlags & 0x0080)
            pVolInfo->ulActiveFatStart +=
               pSect->bpb.BigSectorsPerFat * (pSect->bpb.ExtFlags & 0x000F);
         pVolInfo->ulStartOfData    = pSect->bpb.ReservedSectors +
               pSect->bpb.BigSectorsPerFat * pSect->bpb.NumberOfFATs;

         pVolInfo->pBootFSInfo = (PBOOTFSINFO)(pVolInfo + 1);
         pVolInfo->pbFatSector = (PBYTE)(pVolInfo->pBootFSInfo + 1);
         pVolInfo->ulCurFatSector = -1L;
         pVolInfo->usClusterSize = pSect->bpb.BytesPerSector * pSect->bpb.SectorsPerCluster;
         pVolInfo->ulTotalClusters = (pSect->bpb.BigTotalSectors - pVolInfo->ulStartOfData) / pSect->bpb.SectorsPerCluster;
         pVolInfo->hVBP = hVBP;
         pVolInfo->hDupVBP = hDupVBP;
         pVolInfo->bDrive = pvpfsi->vpi_drive;
         pVolInfo->bUnit  = pvpfsi->vpi_unit;
         pVolInfo->pNextVolInfo = NULL;

         if (usDefaultRASectors == 0xFFFF)
            pVolInfo->usRASectors = (pVolInfo->usClusterSize * 2) / SECTOR_SIZE;
         else
            pVolInfo->usRASectors = usDefaultRASectors;

         if (pVolInfo->usRASectors > (pVolInfo->usClusterSize * 4) / SECTOR_SIZE)
            pVolInfo->usRASectors = (pVolInfo->usClusterSize * 4) / SECTOR_SIZE;

         if (pSect->bpb.FSinfoSec != 0xFFFF)
            {
            ReadSector(pVolInfo, pSect->bpb.FSinfoSec, 1, pVolInfo->pbFatSector, DVIO_OPNCACHE);
            memcpy(pVolInfo->pBootFSInfo, pVolInfo->pbFatSector + FSINFO_OFFSET, sizeof (BOOTFSINFO));
            }
         else
            memset(pVolInfo->pBootFSInfo, 0, sizeof (BOOTFSINFO));

         *((PVOLINFO *)(pvpfsd->vpd_work)) = pVolInfo;

         if (!pGlobVolInfo)
            {
            pGlobVolInfo = pVolInfo;
            usVolCount = 1;
            }
         else
            {
            pNext = pGlobVolInfo;
            usVolCount = 1;
            if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
               pVolInfo->hDupVBP = pNext->hVBP;
            while (pNext->pNextVolInfo)
               {
               pNext = (PVOLINFO)pNext->pNextVolInfo;
               if (pNext->bDrive == pvpfsi->vpi_drive && !pVolInfo->hDupVBP)
                  pVolInfo->hDupVBP = pNext->hVBP;
               usVolCount++;
               }
            pNext->pNextVolInfo = pVolInfo;
            usVolCount++;
            }
         if (f32Parms.fMessageActive & LOG_FS)
            Message("%u Volumes mounted!", usVolCount);
         rc = CheckWriteProtect(pVolInfo);
         if (rc && rc != ERROR_WRITE_PROTECT)
            {
            Message("Cannot access drive, rc = %u", rc);
            goto FS_MOUNT_EXIT;
            }
         if (rc == ERROR_WRITE_PROTECT)
            pVolInfo->fWriteProtected = TRUE;

         pVolInfo->fDiskCleanOnMount = pVolInfo->fDiskClean = GetDiskStatus(pVolInfo);
         if (!pVolInfo->fDiskCleanOnMount)
            Message("DISK IS DIRTY!");
         if (pVolInfo->fWriteProtected)
            pVolInfo->fDiskCleanOnMount = TRUE;

         if (!pVolInfo->hDupVBP &&
            (pVolInfo->pBootFSInfo->ulFreeClusters == 0xFFFFFFFF ||
             !pVolInfo->fDiskClean ||
             pVolInfo->BootSect.bpb.FSinfoSec == 0xFFFF))
            GetFreeSpace(pVolInfo);

         pDevCaps  = pvpfsi->vpi_pDCS;
         pVolChars = pvpfsi->vpi_pVCS;

         if (pDevCaps->Capabilities & GDC_DD_Read2)
            Message("Read2 supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Word)
            Message("DMA on word alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_DMA_Byte)
            Message("DMA on byte alligned buffers supported");
         if (pDevCaps->Capabilities & GDC_DD_Mirror)
            Message("Disk Mirroring supported");
         if (pDevCaps->Capabilities & GDC_DD_Duplex)
            Message("Disk Duplexing supported");
         if (pDevCaps->Capabilities & GDC_DD_No_Block)
            Message("Strategy2 does not block");
         if (pDevCaps->Capabilities & GDC_DD_16M)
            Message(">16M supported");
         if (pDevCaps->Strategy2)
            {
            Message("Strategy2   address at %lX", pDevCaps->Strategy2);
            Message("ChgPriority address at %lX", pDevCaps->ChgPriority);

            pVolInfo->pfnStrategy = (STRATFUNC)pDevCaps->Strategy2;
            pVolInfo->pfnPriority = (STRATFUNC)pDevCaps->ChgPriority;
            }

         rc = 0;
         break;

     case MOUNT_VOL_REMOVED: 
     case MOUNT_RELEASE:
         pVolInfo = GetVolInfo(hVBP);
         if (!pVolInfo->hDupVBP)
            UpdateFSInfo(pVolInfo);
         RemoveVolume(pVolInfo);
         freeseg(pVolInfo);
         rc = 0;
         break;

      default :
         rc = ERROR_NOT_SUPPORTED;
         break;
      }

FS_MOUNT_EXIT:
   if (f32Parms.fMessageActive & LOG_FS)
      Message("FS_MOUNT returned %u\n", rc);
   return rc;
}
Exemplo n.º 19
0
void Tree::PruneTree(const Tree &tree, unsigned Subfams[],
                     unsigned uSubfamCount)
{
    if (!tree.IsRooted())
        Quit("Tree::PruneTree: requires rooted tree");

    Clear();

    m_uNodeCount = 2*uSubfamCount - 1;
    InitCache(m_uNodeCount);

    const unsigned uUnprunedNodeCount = tree.GetNodeCount();

    unsigned *uUnprunedToPrunedIndex = new unsigned[uUnprunedNodeCount];
    unsigned *uPrunedToUnprunedIndex = new unsigned[m_uNodeCount];

    for (unsigned n = 0; n < uUnprunedNodeCount; ++n)
        uUnprunedToPrunedIndex[n] = NULL_NEIGHBOR;

    for (unsigned n = 0; n < m_uNodeCount; ++n)
        uPrunedToUnprunedIndex[n] = NULL_NEIGHBOR;

// Create mapping between unpruned and pruned node indexes
    unsigned uInternalNodeIndex = uSubfamCount;
    for (unsigned uSubfamIndex = 0; uSubfamIndex < uSubfamCount; ++uSubfamIndex)
    {
        unsigned uUnprunedNodeIndex = Subfams[uSubfamIndex];
        uUnprunedToPrunedIndex[uUnprunedNodeIndex] = uSubfamIndex;
        uPrunedToUnprunedIndex[uSubfamIndex] = uUnprunedNodeIndex;
        for (;;)
        {
            uUnprunedNodeIndex = tree.GetParent(uUnprunedNodeIndex);
            if (tree.IsRoot(uUnprunedNodeIndex))
                break;

            // Already visited this node?
            if (NULL_NEIGHBOR != uUnprunedToPrunedIndex[uUnprunedNodeIndex])
                break;

            uUnprunedToPrunedIndex[uUnprunedNodeIndex] = uInternalNodeIndex;
            uPrunedToUnprunedIndex[uInternalNodeIndex] = uUnprunedNodeIndex;

            ++uInternalNodeIndex;
        }
    }

    const unsigned uUnprunedRootIndex = tree.GetRootNodeIndex();
    uUnprunedToPrunedIndex[uUnprunedRootIndex] = uInternalNodeIndex;
    uPrunedToUnprunedIndex[uInternalNodeIndex] = uUnprunedRootIndex;

#if	TRACE
    {
        Log("Pruned to unpruned:\n");
        for (unsigned i = 0; i < m_uNodeCount; ++i)
            Log(" [%u]=%u", i, uPrunedToUnprunedIndex[i]);
        Log("\n");
        Log("Unpruned to pruned:\n");
        for (unsigned i = 0; i < uUnprunedNodeCount; ++i)
        {
            unsigned n = uUnprunedToPrunedIndex[i];
            if (n != NULL_NEIGHBOR)
                Log(" [%u]=%u", i, n);
        }
        Log("\n");
    }
#endif

    if (uInternalNodeIndex != m_uNodeCount - 1)
        Quit("Tree::PruneTree, Internal error");

// Nodes 0, 1 ... are the leaves
    for (unsigned uSubfamIndex = 0; uSubfamIndex < uSubfamCount; ++uSubfamIndex)
    {
        char szName[32];
        sprintf(szName, "Subfam_%u", uSubfamIndex + 1);
        m_ptrName[uSubfamIndex] = strsave(szName);
    }

    for (unsigned uPrunedNodeIndex = uSubfamCount; uPrunedNodeIndex < m_uNodeCount;
            ++uPrunedNodeIndex)
    {
        unsigned uUnprunedNodeIndex = uPrunedToUnprunedIndex[uPrunedNodeIndex];

        const unsigned uUnprunedLeft = tree.GetLeft(uUnprunedNodeIndex);
        const unsigned uUnprunedRight = tree.GetRight(uUnprunedNodeIndex);

        const unsigned uPrunedLeft = uUnprunedToPrunedIndex[uUnprunedLeft];
        const unsigned uPrunedRight = uUnprunedToPrunedIndex[uUnprunedRight];

        const double dLeftLength =
            tree.GetEdgeLength(uUnprunedNodeIndex, uUnprunedLeft);
        const double dRightLength =
            tree.GetEdgeLength(uUnprunedNodeIndex, uUnprunedRight);

        m_uNeighbor2[uPrunedNodeIndex] = uPrunedLeft;
        m_uNeighbor3[uPrunedNodeIndex] = uPrunedRight;

        m_dEdgeLength1[uPrunedLeft] = dLeftLength;
        m_dEdgeLength1[uPrunedRight] = dRightLength;

        m_uNeighbor1[uPrunedLeft] = uPrunedNodeIndex;
        m_uNeighbor1[uPrunedRight] = uPrunedNodeIndex;

        m_bHasEdgeLength1[uPrunedLeft] = true;
        m_bHasEdgeLength1[uPrunedRight] = true;

        m_dEdgeLength2[uPrunedNodeIndex] = dLeftLength;
        m_dEdgeLength3[uPrunedNodeIndex] = dRightLength;

        m_bHasEdgeLength2[uPrunedNodeIndex] = true;
        m_bHasEdgeLength3[uPrunedNodeIndex] = true;
    }

    m_uRootNodeIndex = uUnprunedToPrunedIndex[uUnprunedRootIndex];

    m_bRooted = true;

    Validate();

    delete[] uUnprunedToPrunedIndex;
}