コード例 #1
0
ファイル: iap.c プロジェクト: junstrix/gsoap_websevice
int iap_entry (unsigned char *data,unsigned int length)
{   
    unsigned char ucErr;
	unsigned int i;
   	unsigned char ramData[256]; // 定义变量区 
	if(length > 256) length = 256;
	for(i = 0;i < length;i ++)
	{
		ramData[i]  = data[i];
	}
    IAP_Entry = (void(*)())IAP_ENTER_ADR;                               /* 初始化函数指针IAP_Entry      */

   // __disable_irq();                                                   /* 在IAP操作前必须关闭所有中断  */
    
    parIdRead();                                                        /* 读器件ID                     */
	codeIdBoot();                                                       /* 读Boot版本号                 */

    sectorPrepare(IAP_SECTOR_NUMBER,IAP_SECTOR_NUMBER);                                                 /* 准备扇区1                    */
    sectorErase(IAP_SECTOR_NUMBER,IAP_SECTOR_NUMBER);                                                   /* 擦除扇区1                    */
    blankChk(IAP_SECTOR_NUMBER,IAP_SECTOR_NUMBER) ;                                                     /* 查空扇区1                    */
   
    sectorPrepare(IAP_SECTOR_NUMBER,IAP_SECTOR_NUMBER);                                                 /* 选择扇区1                    */
    ramCopy(IAP_ADDRESS, (unsigned int)ramData, 256);                               /* 写数据到扇区1                */
	ucErr = dataCompare(IAP_ADDRESS, (unsigned int)ramData, 256);                   /* 比较数据                     */
   
   // __enable_irq();
   
    if (ucErr == CMD_SUCCESS) {                                         /* 成功 */    	

    }    
//    while (1);
}
コード例 #2
0
int DataPage::updateData(char *dataPageBuffer,char *oldData,char *newData,int dataPos,short dataType)
{
	// Function returns the total no. of records which matched the data and were updated.....
	// New data integrity check has to be done by the caller... No check will be done here
	if(_slotCounter == 0)
	{
		// Nothing to update.....
		// For sanity check.....
		return -3;
	}
	int i,j,resCount=0;
	for(i=0;i<_slotCounter;i++)
	{
		long slotPointer;
		int slotSize;

		memcpy(&slotPointer,&dataPageBuffer[FIRSTSLOTPTR-(i+1)*sizeof(long)-i*sizeof(int)],sizeof(long));
		memcpy(&slotSize,&dataPageBuffer[FIRSTSLOTPTR-(i+1)*sizeof(long)-(i+1)*sizeof(int)],sizeof(int));

		if(slotSize < 0)
		{
			// Slot has been deleted
			// So no need to check
			continue;
		}

		char * dataBuf = new char [slotSize];
		memcpy(dataBuf,&dataPageBuffer[slotPointer],slotSize);

		short offsetPointer=0,dataPointer=2,offset;

		for(j=0;j<dataPos;j++)
		{
			memcpy(&offset,&dataBuf[offsetPointer],sizeof(short));
			if(j == dataPos-1)
			{
				// This is the position at which data has to be verified....
				char * posData = new char [offset];
				memcpy(posData,&dataBuf[dataPointer],offset);
				if(/*strcmp(posData,oldData)==0*/dataCompare(posData,oldData,dataType)==0)
				{
					cout<<"Data found at slot ID: "<<i;
					resCount++;
					cout<<"Updating the data....";
					memcpy(&dataBuf[dataPointer],newData,offset);
					cout<<endl;
				}
				delete posData;
			}
			offsetPointer = dataPointer+offset;
			dataPointer = offsetPointer+sizeof(short);
		}

		delete dataBuf;
	}
	return resCount;
}
コード例 #3
0
DWORD CSigScan::findPattern(BYTE *bMask, char* szMask)
{
	DWORD dwAddress = m_dwModuleBase;
	for (DWORD i=0; i < m_dwModuleSize; i++)
	{
		if (dataCompare((BYTE*)(dwAddress+i),bMask,szMask))
		{
			return (DWORD)(dwAddress+i);
		}
	}
	return 0;
}