Exemplo n.º 1
0
/*
 * 找寻所有不在链上的内存区域,并归结到链上
 */
__INLINE__ PPROCEDURE __INTERNAL_FUNC__ AnalyzeProcedurePass1DiscoveryUnknowZoon(__memory pMem, PPROCEDURE pProcedureList, PPROGRAM pParents) {
	__integer iCodeSize = pParents->iCodeSegSize;
	__integer iCurrSize = 0, iBlockSize = 0, iRemainSize = iCodeSize;
	__memory pNow = NULL;
	__memory pStart = pParents->pCodeSeg;
	__memory pCurr = pStart;
	__address ImageBase = pParents->ImageBase;
	PPROCEDURE pCurrProcedure = pProcedureList, pUnknowProcedureList = NULL;

	// 产生指令分析分派函数
	g_pAnalyzeDataDispatcher = MakeAnalyzeDataFromInstructionDispatcher();

_new_analyze:
	while (pCurrProcedure) {
		pNow = pCurrProcedure->pFileStartAddress;
		iCurrSize = pCurrProcedure->iSize;

		if (pCurr == pNow) {//如果相当则直接略过
			pCurr += iCurrSize;
			iRemainSize -= iCurrSize;
		} else if (pCurr < pNow) {//分析这个代码块
			iBlockSize = (__integer)(pNow - pCurr);
			iRemainSize -= iBlockSize;
			goto _handler;
		} else {//pCurr > pNow
			// 内联函数
		}
		pCurrProcedure = pCurrProcedure->pNext;
	}

	// 判断是否到达末尾
	if (iRemainSize) {
		iBlockSize = iRemainSize;
		goto _handler;
	}

	// 释放派遣表
	DestroyDispatcherList(&g_pAnalyzeDataDispatcher);
	return pProcedureList;

// 这里为处理函数所在
_handler:
	/*
	 * 这里的处理和前一次处理有个区别就是不知道当前这个区域是
	 * 数据还是代码,所有首先要做数据鉴别
	 */
	pUnknowProcedureList = AnalyzeData(pMem, ImageBase, pCurr, iBlockSize, pProcedureList, pParents);
	pProcedureList = SortProcedureList(pProcedureList);//排序

	// 重新设定所有初始值,然后重新来过
	pCurr = pStart;
	iRemainSize = iCodeSize;//重新设定长度
	pUnknowProcedureList = NULL;
	pCurrProcedure = pProcedureList;
	__PrintProcedureListCount__(pProcedureList);
	goto _new_analyze;//重新进入新的一次分析
}
Exemplo n.º 2
0
//尝试解析
void DeviceConnectCon::TryAnalysis()
{
	do{
		OutputDebugString(L"尝试数据解析\n");
		WORD sPackageLen = ConvertTwoBytes((BYTE*)(m_pRecDataBuf + 1));
		//拷贝数据,进行深度解析
		//解析数据
		BYTE *oneData = (BYTE*)calloc(1, sPackageLen);
		memcpy(oneData, m_pRecDataBuf, sPackageLen);
		RemoveFrontData(sPackageLen);

		AnalyzeData(oneData, sPackageLen);
		free(oneData);
		oneData = NULL;
	} while (m_iDataRear > 1);
	
}
Exemplo n.º 3
0
//AnalyseDC() takes a track, transforms it to bunch of buffer-blocks,
//and executes AnalyzeData on it...
// sets mOffset
bool EffectNormalize::AnalyseDC(WaveTrack * track, wxString msg)
{
   bool rc = true;
   sampleCount s;

   mOffset = 0.0; // we might just return

   if(!mDC)  // don't do analysis if not doing dc removal
      return(rc);

   //Transform the marker timepoints to samples
   sampleCount start = track->TimeToLongSamples(mCurT0);
   sampleCount end = track->TimeToLongSamples(mCurT1);
         
   //Get the length of the buffer (as double). len is
   //used simply to calculate a progress meter, so it is easier
   //to make it a double now than it is to do it later 
   double len = (double)(end - start);

   //Initiate a processing buffer.  This buffer will (most likely)
   //be shorter than the length of the track being processed.
   float *buffer = new float[track->GetMaxBlockSize()];

   mSum = 0.0; // dc offset inits
   mCount = 0;

   //Go through the track one buffer at a time. s counts which
   //sample the current buffer starts at.
   s = start;
   while (s < end) {
      //Get a block of samples (smaller than the size of the buffer)
      sampleCount block = track->GetBestBlockSize(s);
      
      //Adjust the block size if it is the final block in the track
      if (s + block > end)
         block = end - s;
      
      //Get the samples from the track and put them in the buffer
      track->Get((samplePtr) buffer, floatSample, s, block);
      
      //Process the buffer.
      AnalyzeData(buffer, block);
         
      //Increment s one blockfull of samples
      s += block;
      
      //Update the Progress meter
		if (TrackProgress(mCurTrackNum, 
                        ((double)(s - start) / len)/2.0, msg)) {
         rc = false; //lda .. break, not return, so that buffer is deleted
         break;
      }
   }

   //Clean up the buffer
   delete[] buffer;

   mOffset = (float)(-mSum / mCount);  // calculate actual offset (amount that needs to be added on)

   //Return true because the effect processing succeeded ... unless cancelled
   return rc;
}
Exemplo n.º 4
0
//ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
//and executes AnalyzeData, then ProcessData, on it...
bool EffectNormalize::ProcessOne(WaveTrack * track,
                                  sampleCount start, sampleCount end)
{
   bool rc = true;
   
   sampleCount s;
   //Get the length of the buffer (as double). len is
   //used simple to calculate a progress meter, so it is easier
   //to make it a double now than it is to do it later 
   double len = (double)(end - start);

   //Initiate a processing buffer.  This buffer will (most likely)
   //be shorter than the length of the track being processed.
   float *buffer = new float[track->GetMaxBlockSize()];

   int pass;

   for(pass=0; pass<2; pass++)
   {
      if(pass==0 && !mDC)  // we don't need an analysis pass if not doing dc removal
         continue;
      if (pass==0)
         StartAnalysis();  // dc offset only.  Max/min done in Process().
      if (pass==1)
         StartProcessing();

      //Go through the track one buffer at a time. s counts which
      //sample the current buffer starts at.
      s = start;
      while (s < end) {
         //Get a block of samples (smaller than the size of the buffer)
         sampleCount block = track->GetBestBlockSize(s);
         
         //Adjust the block size if it is the final block in the track
         if (s + block > end)
            block = end - s;
         
         //Get the samples from the track and put them in the buffer
         track->Get((samplePtr) buffer, floatSample, s, block);
         
         //Process the buffer.

         if (pass==0)
            AnalyzeData(buffer, block);

         if (pass==1) {
            ProcessData(buffer, block);
         
            //Copy the newly-changed samples back onto the track.
            track->Set((samplePtr) buffer, floatSample, s, block);
         }
            
         //Increment s one blockfull of samples
         s += block;
         
         //Update the Progress meter
			if (TrackProgress(mCurTrackNum, 
									((double)(pass)*0.5) + // Approximate each pass as half.
                           ((double)(s - start) / (len*2)))) {
            rc = false; //lda .. break, not return, so that buffer is deleted
            break;
         }
      }
   }
   //Clean up the buffer
   delete[] buffer;

   //Return true because the effect processing succeeded ... unless cancelled
   return rc;
}