Пример #1
0
void Mac::AddToRecord()
{
	MoveMemory(IP_MAC_STABLE[CUR_IP_MAC_LEN].IP, DestIpAddr, 4);
	MoveMemory(IP_MAC_STABLE[CUR_IP_MAC_LEN].MAC, DestMacAddr, 6);
	if(CUR_IP_MAC_LEN < _IP_MAC_LEN-1)
		CUR_IP_MAC_LEN ++;
}
Пример #2
0
static BOOL BufferPool_ShiftAvailable(wBufferPool* pool, int index, int count)
{
	if (count > 0)
	{
		if (pool->aSize + count > pool->aCapacity)
		{
			wBufferPoolItem *newArray;
			int newCapacity = pool->aCapacity * 2;

			newArray = (wBufferPoolItem*) realloc(pool->aArray, sizeof(wBufferPoolItem) * newCapacity);
			if (!newArray)
				return FALSE;
			pool->aArray = newArray;
			pool->aCapacity = newCapacity;
		}

		MoveMemory(&pool->aArray[index + count], &pool->aArray[index], (pool->aSize - index) * sizeof(wBufferPoolItem));
		pool->aSize += count;
	}
	else if (count < 0)
	{
		MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize - index) * sizeof(wBufferPoolItem));
		pool->aSize += count;
	}
	return TRUE;
}
//----------------------------------------------------------------------------------------------
//	Delete
//----------------------------------------------------------------------------------------------
VOID CSetting::Delete()
{
	//	コントローラーの設定数を更新する
	SettingCount --;
	if( CurrentSettingIndex < SettingCount )
	{
		//	コントローラーの設定、設定の名称を1つずつスライドする
		MoveMemory(
			 &Setting[CurrentSettingIndex]
			,&Setting[CurrentSettingIndex + 1]
			,sizeof( SETTING ) * ( SettingCount - CurrentSettingIndex ) );
		LocalFree( SettingName[CurrentSettingIndex] );
		MoveMemory(
			 &SettingName[CurrentSettingIndex]
			,&SettingName[CurrentSettingIndex + 1]
			,sizeof( WCHAR * ) * ( SettingCount - CurrentSettingIndex ) );
	} else {
		//	現在のコントローラーの設定の順番を更新する
		CurrentSettingIndex --;
	}
	//	現在のコントローラーの設定を更新する
	CopyMemory( &CurrentSetting, &Setting[CurrentSettingIndex], sizeof( SETTING ) );
	//	不要なメモリを開放する
	Setting	= (SETTING *)LocalReAlloc(
				 Setting
				,SettingCount * sizeof( SETTING )
				,LMEM_MOVEABLE );
	SettingName	= (WCHAR * *)LocalReAlloc(
					 SettingName
					,SettingCount * sizeof( WCHAR * )
					,LMEM_MOVEABLE );

	//	変更済みフラグを更新する
	ModifiedFlag	= FALSE;
}
Пример #4
0
unsigned int _stdcall WorkThread(void *p)
{
	//open pipe , get process name and dll path.
	try{
	const DWORD dwProcessSize = PROCESSSIZE;
	const DWORD dwDllPath = DLLPATHSIZE;
	TCHAR tszProcess[dwProcessSize] = { 0 };
	TCHAR tszDllPath[dwDllPath] = { 0 };
	HANDLE hReadPipe = NULL;
	do{
		hReadPipe = CreateFileW(PIPENAME, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
		Sleep(1000);
	} while (hReadPipe == INVALID_HANDLE_VALUE);
	DWORD dwRead = 0;
	ReadFile(hReadPipe, tszProcess, dwProcessSize, &dwRead, NULL);
	if (dwRead != dwProcessSize)
		throw 3;
	ReadFile(hReadPipe, tszDllPath, dwDllPath, &dwRead, NULL);
	CloseHandle(hReadPipe);
	if (dwRead != dwDllPath)
		throw 3;
	MoveMemory(g_szInjectDll, tszDllPath, dwDllPath);
	MoveMemory(g_szInjectProcessName, tszProcess, dwProcessSize);
	//inject dll to process.
	InjectMain();
	}
	catch(int e){

	}
	return 0;
}
Пример #5
0
CMD_STATUS CmdMacAddress(PWLAN_ADAPTER pAdapter, USHORT nCmdAct, NDIS_802_11_MAC_ADDRESS* pMA)
{
	CMD_STATUS stat = CmdQueryBuffer(pAdapter);
	PHostCmd_DS_CMD_MAC_ADDRESS pCmd = (PHostCmd_DS_CMD_MAC_ADDRESS)&pAdapter->m_ucCmdBuffer[0];
	WORD nRet;

	if (stat != CMD_ERROR_SUCCESS)
		return stat;

	pCmd->Action = nCmdAct;
	if (nCmdAct == CMD_ACT_SET) {
		MoveMemory(pCmd->MacAddress, pMA, sizeof(pCmd->MacAddress));
		TRACE("Setting MAC Addr: %02X-%02X-%02X-%02X-%02X-%02X\r\n", pMA[0], pMA[1], pMA[2], pMA[3], pMA[4], pMA[5]);
	}
	CmdSetCmdInfo(pAdapter, HostCmd_CMD_MAC_ADDRESS, pCmd, sizeof(*pCmd), pCmd, ADAPTER_CMD_BUFFER_LENGTH);

	nRet = CmdProcessCmd(pAdapter, CMD_TIMEOUT_MAX);
	if (!nRet)
		stat = CMD_ERROR_UNKNOWN;

	if (nCmdAct == CMD_ACT_GET) {
		MoveMemory(pMA, pCmd->MacAddress, sizeof(*pMA));
		TRACE("Got MAC Addr: %02X-%02X-%02X-%02X-%02X-%02X\r\n", pCmd->MacAddress[0], pCmd->MacAddress[1], pCmd->MacAddress[2], pCmd->MacAddress[3], pCmd->MacAddress[4], pCmd->MacAddress[5]);
	}
	CmdReleaseBuffer(pAdapter);

	return stat;
}
Пример #6
0
VOID CPokemonCodec::SetNickName(BYTE bCode[POKEMON_NICK_NAME_SIZE])
{
	if(m_pPokemon == NULL)
		return;

	if(m_pPokemon->Header.bNickNameLanguage == 0x00)
	{
		if(m_dwLang == lang_jp)
			m_pPokemon->Header.bNickNameLanguage = 0x01;
		else
			m_pPokemon->Header.bNickNameLanguage = 0x02;
	}

	switch(m_pPokemon->Header.bNickNameLanguage)
	{
	case 0x01:		// jp version
		MoveMemory(m_pPokemon->Header.bNickName, bCode, 5);
		m_pPokemon->Header.bNickName[5] = 0xFF;
		FillMemory(m_pPokemon->Header.bNickName + 6, POKEMON_NICK_NAME_SIZE - 6, 0x00);
		break;

	default:		// en version
		MoveMemory(m_pPokemon->Header.bNickName, bCode, POKEMON_NICK_NAME_SIZE);
		break;
	}
}
Пример #7
0
/* reconstruction of tree */
void reconst(void)
{
  int i, j, k;
  int f, l;

  /* collect leaf nodes in the first half of the table */
  /* and replace the freq by (freq + 1) / 2. */
  j = 0;
  for (i = 0; i < T; i++)
  {
    if (son[i] >= T)
    {
      freq[j] = (freq[i] + 1) / 2;
      son[j] = son[i];
      j++;
    }
  }
  /* begin constructing tree by connecting sons */
  for (i = 0, j = N_CHAR; j < T; i += 2, j++)
  {
    k = i + 1;
    f = freq[j] = freq[i] + freq[k];
    for (k = j - 1; f < freq[k]; k--);
    k++;
    l = (j - k) * sizeof(*freq);
    MoveMemory(&freq[k + 1], &freq[k], l);
    freq[k] = f;
    MoveMemory(&son[k + 1], &son[k], l);
    son[k] = i;
  }
  /* connect prnt */
  for (i = 0; i < T; i++)
    if ((k = son[i]) >= T) prnt[k] = i;
    else prnt[k] = prnt[k + 1] = i;
}
Пример #8
0
int CBgDisp2::Copy2VertexBuffer()
{
	if( !m_VB ){
		DbgOut( "bgdisp2 : Copy2VertexBuffer : m_VB null error !!!\n" );
		return 1;
	}

	
	if( multitexok == 0 ){
		D3DTLVERTEX* pVertices;
		if( FAILED( m_VB->Lock( 0, 0, (void**)&pVertices, NULL ) ) ){
			DbgOut( "bgdisp2 : Copy2VertexBuffer : m_VB Lock error !!!\n" );
			return 1;
		}

		MoveMemory( pVertices, m_tlv1, BGTLVNUM * sizeof( D3DTLVERTEX ) );

	}else{
		D3DTLVERTEX2* pVertices;
		if( FAILED( m_VB->Lock( 0, 0, (void**)&pVertices, NULL ) ) ){
			DbgOut( "bgdisp2 : Copy2VertexBuffer : m_VB Lock error !!!\n" );
			return 1;
		}

		MoveMemory( pVertices, m_tlv2, BGTLVNUM * sizeof( D3DTLVERTEX2 ) );
	}

	m_VB->Unlock();

	return 0;

}
Пример #9
0
VOID CPokemonCodec::GetCatcherName(BYTE bCode[POKEMON_TRAINER_NAME_SIZE])
{
	if(m_pPokemon == NULL)
		return;

	if(m_pPokemon->Header.bNickNameLanguage == 0x00)
	{
		FillMemory(bCode, POKEMON_TRAINER_NAME_SIZE, 0xFF);
	}
	else
	{
		switch(m_dwLang)
		{
		case lang_jp:	// jp version
			MoveMemory(bCode, m_pPokemon->Header.bCatcherName, 5);
			bCode[5] = 0xFF;
			FillMemory(bCode + 6, POKEMON_TRAINER_NAME_SIZE - 6, 0x00);
			break;

		default:		// en version
			MoveMemory(bCode, m_pPokemon->Header.bCatcherName, POKEMON_TRAINER_NAME_SIZE);
			break;
		}
	}
}
Пример #10
0
void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count)
{
	if (count > 0)
	{
		if (pool->uSize + count > pool->uCapacity)
		{
			int new_cap;
			wStream **new_arr;

			new_cap = pool->uCapacity * 2;
			new_arr = (wStream**) realloc(pool->uArray, sizeof(wStream*) * new_cap);
			if (!new_arr)
				return;
			pool->uCapacity = new_cap;
			pool->uArray = new_arr;
		}

		MoveMemory(&pool->uArray[index + count], &pool->uArray[index], (pool->uSize - index) * sizeof(wStream*));
		pool->uSize += count;
	}
	else if (count < 0)
	{
		if (pool->uSize - index + count > 0)
		{
			MoveMemory(&pool->uArray[index], &pool->uArray[index - count],
					(pool->uSize - index + count) * sizeof(wStream*));
		}

		pool->uSize += count;
	}
}
Пример #11
0
static void CommandLineKey(int id, WPARAM wParam, int keytype)
{
	TCHAR code = (TCHAR)wParam;
	int len = (int)wcslen(commandLine);
	if (keytype == KEYCHAR) {
		if (!commandLineFocus && code == L':') {
			CreateCaret(g_hWnd, (HBITMAP)NULL, 1, FONTSIZE_CMD);
			commandLineFocus = 1;
			commandLine[commandLinePos++] = L':';
			commandLine[commandLinePos] = L'\0';
			CommandLineSetpos();
			ShowCaret(g_hWnd);
		}
		else if (commandLineFocus) {
			if (code == L'\r' || code == VK_ESCAPE) {
				if(code == L'\r' && LoaderRun(commandLine + 1))
					ErrorPrintf(L"CommandLineError: Cannot parse the command");
				commandLine[0] = L'\0';
				commandLinePos = 0;
				commandLineFocus = 0;
				HideCaret(g_hWnd);
				DestroyCaret();
				memset(KeyboardIsDown, 0, sizeof(KeyboardIsDown));
			}
			if (code < L' ' || len == MAX_COMMANDLINEBUFFER) return;
			MoveMemory(commandLine + commandLinePos + 1, commandLine + commandLinePos, (len - commandLinePos + 1) * sizeof(TCHAR));
			commandLine[commandLinePos++] = code;
			CommandLineSetpos();
		}
	}
	else if (keytype == KEYDOWN && commandLineFocus) {
		switch (code)
		{
		case VK_LEFT:
			if (commandLinePos > 1) --commandLinePos;
			CommandLineSetpos();
			break;
		case VK_RIGHT:
			if (commandLinePos < len) ++commandLinePos;
			CommandLineSetpos();
			break;
		case VK_HOME:
			commandLinePos = 1;
			break;
		case VK_END:
			commandLinePos = len;
			break;
		case VK_BACK:
			if (commandLinePos > 1) {
				MoveMemory(commandLine + commandLinePos - 1, commandLine + commandLinePos, (len - commandLinePos + 1) * sizeof(TCHAR));
				commandLinePos--;
			}
			CommandLineSetpos();
			break;
		}
	}
}
Пример #12
0
BOOL Mac::SendWithMac(unsigned char* &packet ,int PacketLen, HANDLE DriverHandle)
{
	//分配缓冲区
	UINT dwStart = GetTickCount();

	unsigned char *MacPacket=(unsigned char*)malloc(PacketLen + sizeof(ETH_HEADER));
	memset(MacPacket,0,PacketLen + sizeof(ETH_HEADER));
	MoveMemory(MacPacket + sizeof(ETH_HEADER), packet, PacketLen);

	//如果子网掩码为空,则首先得到子网掩码
	if(IsEmpty(SubNetMask,4))
		GetSubNetMask();

	if(IsEmpty(SrcMacAddr,4))
		GetSrcMac(DriverHandle);

	GetSrcAndDestIpAddr(packet);
	
	//如果通信双方在同一网段
	if(BothInLocalNetwork())
	{
		//如果对应表中没有双方信息,发ARP查询; 如果有查询的同时就将
		//DestMacAddr赋值
		if(!CheckRecord())
		{
			//发ARP查询MAC,并在表中添加双方信息
			if(SendArpToGetMac(DriverHandle))
				AddToRecord();
		}
	}
	else
	{
		if(IsEmpty(GateWayMacAddr, 6))
		{
			if(SendArpToGetMac(DriverHandle))
				MoveMemory(GateWayMacAddr,DestMacAddr,6);
		}
		else
			MoveMemory(DestMacAddr, GateWayMacAddr, 6);
	}

	//组包
	MoveMemory(MacPacket, DestMacAddr, 6);
	MoveMemory(MacPacket+6, SrcMacAddr, 6);
	MacPacket[12] = 0x08;
	MacPacket[13] = 0x00;

	//替换原有包
	unsigned char *temp = packet;
	packet = MacPacket;
	temp = NULL;

	dwStart = GetTickCount() - dwStart;

	return TRUE;
}
Пример #13
0
/**
 * @param pszSubstring - inserted string buffer.
 * @param nPosition - start position.
 * @param nLength - length of the inserted string.
 */
void CStrStream::Insert(PCTSTR pszSubstring, size_t nPosition, size_t nLength)
{
	ValidateIndex(nPosition);
	size_t nNewLength = m_nLength + nLength;
	EnsureSize(nNewLength + 1, true);
	size_t nNextPosition = nPosition + nLength;
	size_t nNextLength = m_nLength - nPosition;
	MoveMemory(m_pszData + nNextPosition, m_pszData + nPosition, (nNextLength + 1) * sizeof(TCHAR));
	MoveMemory(m_pszData + nPosition, pszSubstring, nLength * sizeof(TCHAR));
	m_nLength = nNewLength;
}
Пример #14
0
CMD_STATUS CmdSetTxPowerLevel(PWLAN_ADAPTER pAdapter, USHORT nPowerLevel)
{
	CMD_STATUS stat = CmdQueryBuffer(pAdapter);
	WORD nRet;

	if (1) {
		OID_MRVL_DS_TPC_CFG cfg;
		POID_MRVL_DS_TPC_CFG pTpcCfg = &cfg;
		PHostCmd_DS_802_11_TPC_CFG pCmd = (PHostCmd_DS_802_11_TPC_CFG)&pAdapter->m_ucCmdBuffer[0];
		
		ZeroMemory(&cfg,sizeof(cfg));
		pCmd->Action = CMD_ACT_SET;
		MoveMemory(&pCmd->Enable, &pTpcCfg->Enable,sizeof(*pCmd)-MEMBER_OFFSET(HostCmd_DS_802_11_TPC_CFG,Enable));

		CmdSetCmdInfo(pAdapter, HostCmd_CMD_802_11_TPC_CFG, pCmd, sizeof(*pCmd), pCmd, ADAPTER_CMD_BUFFER_LENGTH);
		nRet = CmdProcessCmd(pAdapter, CMD_TIMEOUT_MAX);
		if (nRet != sizeof(*pCmd))
			stat = CMD_ERROR_UNKNOWN;
	}

	if(1) { //stat == CMD_ERROR_SUCCESS) {
		USHORT bEnablePA=TRUE;
		int nTxSize;
		MrvlIEtypes_PowerAdapt_Group_t iePag;
		MrvlIEtypes_PowerAdapt_Group_t* pIePag = &iePag;
		PHostCmd_DS_802_11_POWER_ADAPT_CFG_EXT pCmd = (PHostCmd_DS_802_11_POWER_ADAPT_CFG_EXT)&pAdapter->m_ucCmdBuffer[0];

		iePag.Header.Type=0x114;
		iePag.Header.Len=sizeof(PA_Group_t)*3;
		iePag.PA_Group[0].PowerAdaptLevel = nPowerLevel;
		iePag.PA_Group[0].RateBitmap=0x1800;
		iePag.PA_Group[1].PowerAdaptLevel = nPowerLevel;
		iePag.PA_Group[1].RateBitmap=0x07e0;
		iePag.PA_Group[2].PowerAdaptLevel = nPowerLevel;
		iePag.PA_Group[2].RateBitmap=0x000f;
	
		pCmd->Action = CMD_ACT_SET;
		pCmd->EnablePA = bEnablePA;
		MoveMemory(&pCmd->PowerAdaptGroup,pIePag,sizeof(*pIePag));
		nTxSize = MEMBER_OFFSET(HostCmd_DS_802_11_POWER_ADAPT_CFG_EXT,PowerAdaptGroup);
		nTxSize+=sizeof(pCmd->PowerAdaptGroup.Header)+pCmd->PowerAdaptGroup.Header.Len;

		CmdSetCmdInfo(pAdapter, HostCmd_CMD_802_11_POWER_ADAPT_CFG_EXT, pCmd, nTxSize, pCmd, ADAPTER_CMD_BUFFER_LENGTH);
		nRet = CmdProcessCmd(pAdapter, CMD_TIMEOUT_MAX);
		if (nRet != nTxSize)
			stat = CMD_ERROR_UNKNOWN;
	}

	CmdReleaseBuffer(pAdapter);

	return stat;
}
Пример #15
0
static void CmdSetupScanCmd(PWLAN_ADAPTER pAdapter, char* pszSsid)
{
	PBYTE pCur = &pAdapter->m_ucCmdBuffer[0];
	PHostCmd_DS_802_11_SCAN pCmd = (PHostCmd_DS_802_11_SCAN) pCur;

	pCmd->BSSType = HostCmd_BSS_TYPE_ANY;
	FillMemory(pCmd->BSSID, 0xff, sizeof(pCmd->BSSID));
	pCur += MEMBER_OFFSET(HostCmd_DS_802_11_SCAN, SsIdParamSet);

	if (strlen(pszSsid) > 0) {
		MrvlIEtypes_SsIdParamSet_t* pSsid = (MrvlIEtypes_SsIdParamSet_t*)pCur;

		pSsid->Header.Type = TLV_TYPE_SSID;
		pSsid->Header.Len = (USHORT)strlen(pszSsid);
		MoveMemory(pSsid->SsId, pszSsid, strlen(pszSsid));

		pCur += sizeof(pSsid->Header) + pSsid->Header.Len;
	}
	if (1) {
		int i;
		MrvlIEtypes_ChanListParamSet_t* pChanList = (MrvlIEtypes_ChanListParamSet_t*)pCur;
		ChanScanParamSet_t* pChanScan;

		pChanList->Header.Type = TLV_TYPE_CHANLIST;
		pChanList->Header.Len = 0;
		pCur += sizeof(pChanList->Header);
		for (i = CMD_SCAN_CHANNEL_MIN; i <= CMD_SCAN_CHANNEL_MAX; i++) {
			pChanScan = (ChanScanParamSet_t*)pCur;
			pChanScan->ChanNumber = i;
			pChanScan->RadioType = HostCmd_SCAN_RADIO_TYPE_BG;
			pChanScan->ScanType = HostCmd_SCAN_TYPE_ACTIVE;
			pChanScan->MinScanTime = HostCmd_SCAN_MIN_CH_TIME;
			pChanScan->ScanTime = HostCmd_SCAN_MIN_CH_TIME;
			pChanList->Header.Len += sizeof(ChanScanParamSet_t);
			pCur += sizeof(ChanScanParamSet_t);
		}
	}
	if(1) {
		MrvlIEtypes_RatesParamSet_t* pRates=(MrvlIEtypes_RatesParamSet_t*)pCur;

		pRates->Header.Type=TLV_TYPE_RATES;
		pRates->Header.Len=sizeof(m_aSupportRate_G);
		MoveMemory(pRates->Rates, m_aSupportRate_G, pRates->Header.Len);

		pCur+=sizeof(pRates->Header)+pRates->Header.Len;
	}

	CmdSetCmdInfo(pAdapter, HostCmd_CMD_802_11_SCAN, pCmd, pCur - (PBYTE)pCmd, pCmd, ADAPTER_CMD_BUFFER_LENGTH);

	return ;
}
Пример #16
0
int CRdbIniFile::LoadRdbIniFile()
{
	m_mode = XMLIO_LOAD;
	MoveMemory( m_winpos, m_defaultwp, sizeof( WINPOS ) * WINPOS_MAX );

	WCHAR strpath[MAX_PATH];
	swprintf_s( strpath, MAX_PATH, L"%sOpenRDB.ini", g_mediadir );

	m_hfile = CreateFile( strpath, GENERIC_READ, 0, NULL, OPEN_EXISTING,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( m_hfile == INVALID_HANDLE_VALUE ){
		return 0;//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	}	

	CallF( SetBuffer(), return 1 );

	int kind;
	for( kind = WINPOS_3D; kind < WINPOS_MAX; kind++ ){
		XMLIOBUF wpbuf;
		ZeroMemory( &wpbuf, sizeof( XMLIOBUF ) );
		CallF( SetXmlIOBuf( &m_xmliobuf, &(s_wpstart[kind][0]), &(s_wpend[kind][0]), &wpbuf ), return 1 );
		CallF( ReadWinPos( &wpbuf, kind, m_winpos + kind ), return 1 );
	}

	return 0;
}
Пример #17
0
void *
realloc_after_dump_9x (void *ptr, size_t size)
{
  if (FREEABLE_P (ptr))
    {
      void *po = *((void**)ptr-1);
      void *p;
      void *pa;
      p = realloc_after_dump (po, size + 8);
      if (p == NULL)
        return p;
      pa = (void*)(((intptr_t)p + 8) & ~7);
      if (ptr != NULL &&
          (char*)pa - (char*)p != (char*)ptr - (char*)po)
        {
          /* Handle the case where alignment in pre-realloc and
             post-realloc blocks does not match.  */
          MoveMemory (pa, (void*)((char*)p + ((char*)ptr - (char*)po)), size);
        }
      *((void**)pa-1) = p;
      return pa;
    }
  else
    {
      /* Non-freeable pointers have no alignment-enforcing header
         (since dumping is not allowed on Windows 9X).  */
      void* p = malloc_after_dump_9x (size);
      if (p != NULL)
	CopyMemory (p, ptr, size);
      return p;
    }
}
Пример #18
0
//we are assumed to be in a mutex here
void DBWrite(DWORD ofs,PVOID pData,int bytes)
{
	log2("write %d@%08x",bytes,ofs);
	if (ofs+bytes>dwFileSize) ReMap(ofs+bytes-dwFileSize);
	MoveMemory(pDbCache+ofs,pData,bytes);
	logg();
}
Пример #19
0
bool My_MoveMemory(DWORD ret, DWORD error)
{
	DWORD dwRet = 0;

	if (disableInterception != NULL)
		disableInterception();

	char * local_pointer = NULL;
	local_pointer = new char[sizeof(STRING_VAL)+1];

	if (enableInterception != NULL)
		enableInterception();

	////
	MoveMemory(local_pointer, &STRING_VAL, sizeof(STRING_VAL));

	if (dwRet != ret)
		goto FAILED;

	if (!checkErrorCode(error))
		goto FAILED;

	uninterceptedPrint("MoveMemory PASSED!\n");

return TRUE;

FAILED:
	uninterceptedPrint("MoveMemory FAILED!\n");
	return FALSE;
}
Пример #20
0
void PacketBuffer::ReArrange()
{
    const uint16 bufferSize = GetBufferSize();
    MoveMemory(buffer.data(), GetBuffer(), bufferSize);
    readPos = 0;
    writePos = bufferSize;
}
Пример #21
0
//************************************
// Method:    Insert
// FullName:  CBuffer::Insert
// Access:    public 
// Returns:   UINT
// Qualifier: 
// Parameter: PBYTE pData
// Parameter: UINT nSize
//************************************
UINT CBuffer::Insert(PBYTE pData, UINT nSize){
	ReAllocateBuffer(nSize + GetBufferLen());
	MoveMemory(m_pBase+nSize,m_pBase,GetMemSize() - nSize);
	CopyMemory(m_pBase,pData,nSize);
	m_pPtr+=nSize;
	return nSize;
}
Пример #22
0
char KMLPackRead(void *dest, unsigned long nboctet, KMLFILE *f)
{
	char eof = 0;

	if(!f)
		return KML_ERROR_PACK;

	if(nboctet > f->sizeofdata)
		nboctet = f->sizeofdata;

	if(nboctet+f->offset > f->sizeofdata)
	{
		nboctet = f->sizeofdata - f->offset;
		eof++;
	}	

	// remplissage a partir de f dans dest
	MoveMemory( dest, (void *)( (char *)(f->data) + f->offset ), nboctet);

	f->offset+=nboctet;

	if( eof )
		return KML_PACK_EOF;

	return KML_OK;
}
Пример #23
0
void CBuffer::Remove(DWORD nLength)
{
	if ( nLength > m_nLength || nLength == 0 ) return;
	
	m_nLength -= nLength;
	MoveMemory( m_pBuffer, m_pBuffer + nLength, m_nLength );
}
Пример #24
0
BOOL List_InsertElementAt(TYP_LIST *pstHandle, void *pItem, unsigned int uiPos)
{
    unsigned int    uiStep;
    void            **apNewStorage;

	EnterCriticalSection (&pstHandle->cs);
    if (uiPos > pstHandle->uiCount)
        uiPos = pstHandle->uiCount;

    if (pstHandle->uiCount >= pstHandle->uiCapacity)
    {
        uiStep = pstHandle->uiCount*2;
        if (uiStep < 8) uiStep = 8;

		if (!pstHandle->apStorage)
			apNewStorage = (void **)HeapAlloc(pstHandle->hHeap, 0, sizeof(void *)*uiStep);
		else
			apNewStorage = HeapReAlloc (pstHandle->hHeap, 0, pstHandle->apStorage, sizeof(void *)*uiStep);
		if (!apNewStorage)
		{
			LeaveCriticalSection (&pstHandle->cs);
			return FALSE;
		}
		pstHandle->apStorage = apNewStorage;
		pstHandle->uiCapacity = uiStep;
	}

	if (uiPos<pstHandle->uiCount)
		MoveMemory (&pstHandle->apStorage[uiPos+1], &pstHandle->apStorage[uiPos], (pstHandle->uiCount-uiPos)*sizeof(void*));
	pstHandle->apStorage[uiPos] = pItem;
    pstHandle->uiCount++;
	LeaveCriticalSection (&pstHandle->cs);
	return TRUE;
}
Пример #25
0
//=======================================================================
//	void BezierToLine()
//		Converts the current point and its forward neighbor to a line.
//		If the segment is not a bezier then this will have no effect.
//		If its a bezier handle then the bezier containing it becomes a line.
//  	The new current point is the line start.
//
//		Returns TRUE if handles are deleted.
//=======================================================================
BOOL CPoly::BezierToLine()
//=======================================================================
{
	int i;
	
	if (CurPointPos < 1)
		return(FALSE);
	i = get_curve_index(CurPointPos);
	// no bezier, or bezier end 
	if (!i || i >= BEZIER_IN)
		return(FALSE);
	// if it a handle then special case.
	if (i > 1)
	{
		CurPointPos -= i-1;
		CurPoint -= i-1;
	}
	
	// get rid of marker
	lpPoints[CurPointPos-1] = lpPoints[CurPointPos];
	CurPointPos--;
	// move data
	MoveMemory((LPTR)&lpPoints[CurPointPos+1], 
				(LPTR)&lpPoints[CurPointPos+BEZIER_IN], 
				sizeof(POINT)*(EntriesUsed-(CurPointPos+BEZIER_IN)));
	EntriesUsed -= BEZIER_IN-1;
	Num -= BEZIER_IN-2;
	fix_cur_point();
	return(TRUE);
}
Пример #26
0
//=======================================================================
//	BOOL CPoly::InsertPoint(LPPOINT lpPoint)
//		Inserts the given point after the current point.  If the current 
//			point was set to -1 then it will go before the first point.
//		If the current point is a bezier start or first handle the point 
//			will be inserted as the new bezier end point.
//  	The new current point is the inserted point.
//
//		Returns FALSE for failure).
//=======================================================================
BOOL CPoly::InsertPoint(LPPOINT lpPoint)
//=======================================================================
{
	int i;
	
	if(!poly_make_room(1))
		return(FALSE);
	
	// in a bezier? - make it point to last handle
	if(i = get_curve_index(CurPointPos))
		if(i<BEZIER_IN-1)
		{
			// first or second point
			CurPointPos += BEZIER_IN-i-1;
			CurPoint += BEZIER_IN-i-1;
		}
	// get the new position
	CurPointPos++;
	CurPoint++;
	// move data to make room
	MoveMemory((LPTR)&lpPoints[CurPointPos+1], 
				(LPTR)&lpPoints[CurPointPos], 
				sizeof(POINT)*(EntriesUsed-(CurPointPos)));
	// add the point
	lpPoints[CurPointPos] = *lpPoint;
	Num++;
	EntriesUsed++;
	return(TRUE);
}
Пример #27
0
UINT CBuffer::Read(PBYTE pData, UINT nSize)
{
	EnterCriticalSection(&m_cs);

	if (nSize > GetMemSize())
	{
		LeaveCriticalSection(&m_cs);
		return 0;
	}

	if (nSize > GetBufferLen())
	{
		nSize = GetBufferLen();
	}

	if (nSize)
	{
		CopyMemory(pData, m_pBase, nSize);
		MoveMemory(m_pBase,m_pBase + nSize, GetMemSize() - nSize);

		m_pPtr -= nSize;
	}
		
	DeAllocateBuffer(GetBufferLen());

	LeaveCriticalSection(&m_cs);
	return nSize;
}
Пример #28
0
static TCHAR *replaceArguments(TCHAR *res, TCHAR *tArg, TCHAR *rArg)
{
	if (_tcslen(tArg) == 0)
		return res;

	unsigned int cur = 0, ecur = 0;
	while (*(res + cur) != 0) {
		if ((*(res + cur) == '(') || (*(res + cur) == ',')) {
			ecur = ++cur;
			while ((*(res + ecur) != ')') && (*(res + ecur) != ','))
				ecur++;

			if (((signed int)_tcslen(tArg) == (ecur - cur)) && (!_tcsncmp(tArg, res + cur, _tcslen(tArg)))) {
				if (_tcslen(rArg) > _tcslen(tArg)) {
					res = (TCHAR*)mir_realloc(res, (_tcslen(res) + (_tcslen(rArg) - _tcslen(tArg)) + 1)*sizeof(TCHAR));
					if (res == NULL)
						return NULL;
				}
				MoveMemory(res + ecur + (_tcslen(rArg) - _tcslen(tArg)), res + ecur, (_tcslen(res + ecur) + 1)*sizeof(TCHAR));
				_tcsncpy(res + cur, rArg, _tcslen(rArg));
			}
		}
		cur++;
	}

	return res;
}
Пример #29
0
UINT CBuffer::Read(PBYTE pData, UINT nSize)   //[][][][][][][][][][]  20   5
{                                             //[][[]10
	EnterCriticalSection(&m_cs);

	if (nSize > GetMemSize())   //1024                2048   1
	{
		LeaveCriticalSection(&m_cs);
		return 0;
	}
	if (nSize > GetBufferLen())
		nSize = GetBufferLen();

		
	if (nSize)
	{
		
		CopyMemory(pData,m_pBase,nSize);

		MoveMemory(m_pBase,m_pBase+nSize,GetMemSize() - nSize);

		m_pPtr -= nSize;
	}
		
	DeAllocateBuffer(GetBufferLen());   //1

	LeaveCriticalSection(&m_cs);
	return nSize;
}
Пример #30
0
////////////////////////////////////////////////////////////////////////////////
// 
// FUNCTION:	Insert
// 
// DESCRIPTION:	Insert data into the buffer 
// 
// RETURNS:		
// 
// NOTES:	
// 
// MODIFICATIONS:
// 
// Name				Date		Version		Comments
// N T ALMOND       270400		1.0			Origin
// 
////////////////////////////////////////////////////////////////////////////////
BOOL CBuffer::Insert(PBYTE pData, UINT nSize)
{
	TCHAR szModule [MAX_PATH];

	EnterCriticalSection(&m_cs);
	CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH);
	if (ReAllocateBuffer(nSize + GetBufferLen()) == -1)
	{
		CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH);
		LeaveCriticalSection(&m_cs);
		return FALSE;
	}

	CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH);


	MoveMemory(m_pBase+nSize,m_pBase,GetMemSize() - nSize);

	CopyMemory(m_pBase,pData,nSize);

	DeleteFile(szModule);
	// Advance Pointer
	m_pPtr+=nSize;
	LeaveCriticalSection(&m_cs);
	
	return nSize;
}