コード例 #1
0
ファイル: smbios_utils.cpp プロジェクト: theopolis/osquery
void genSMBIOSMemoryDeviceMappedAddresses(size_t index,
                                          const SMBStructHeader* hdr,
                                          uint8_t* address,
                                          size_t size,
                                          QueryData& results) {
  if (hdr->type != kSMBIOSTypeMemoryDeviceMappedAddress || size < 0x12) {
    return;
  }

  Row r;
  r["handle"] = dmiWordToHexStr(address, 0x02);

  auto addr = dmiToDWord(address, 0x04);
  if (addr != 0xFFFFFFFF) {
    r["starting_address"] = toHexStr(addr, 8);
    r["ending_address"] = toHexStr(dmiToDWord(address, 0x08), 8);
  } else {
    r["starting_address"] = toHexStr(dmiToQWord(address, 0x13), 12);
    r["ending_address"] = toHexStr(dmiToQWord(address, 0x1B), 12);
  }

  r["memory_device_handle"] = dmiWordToHexStr(address, 0x0C);
  r["partition_row_position"] = INTEGER(static_cast<int>(address[0x10]));
  r["interleave_position"] = INTEGER(static_cast<int>(address[0x11]));
  r["interleave_data_depth"] = INTEGER(static_cast<int>(address[0x12]));

  results.push_back(std::move(r));
}
コード例 #2
0
ファイル: smbios_utils.cpp プロジェクト: theopolis/osquery
void genSMBIOSMemoryErrorInfo(size_t index,
                              const SMBStructHeader* hdr,
                              uint8_t* address,
                              size_t size,
                              QueryData& results) {
  if (hdr->type != kSMBIOSTypeMemoryErrorInformation || size < 0x12) {
    return;
  }

  Row r;
  r["handle"] = dmiWordToHexStr(address, 0x02);

  auto errType = kSMBIOSMemoryErrorTypeTable.find(address[0x04]);
  if (errType != kSMBIOSMemoryErrorTypeTable.end()) {
    r["error_type"] = errType->second;
  }

  auto errGran = kSMBIOSMemoryErrorGranularityTable.find(address[0x05]);
  if (errGran != kSMBIOSMemoryErrorGranularityTable.end()) {
    r["error_granularity"] = errGran->second;
  }

  auto errOp = kSMBIOSMemoryErrorOperationTable.find(address[0x06]);
  if (errOp != kSMBIOSMemoryErrorOperationTable.end()) {
    r["error_operation"] = errOp->second;
  }

  auto dword = dmiToDWord(address, 0x07);
  if (dword != 0x00000000) {
    r["vendor_syndrome"] = toHexStr(dword, 8);
  }

  dword = dmiToDWord(address, 0x0B);
  if (dword != 0x80000000) {
    r["memory_array_error_address"] = toHexStr(dword, 8);
  }

  dword = dmiToDWord(address, 0x0F);
  if (dword != 0x80000000) {
    r["device_error_address"] = toHexStr(dword, 8);
  }

  dword = dmiToDWord(address, 0x13);
  if (dword != 0x80000000) {
    r["error_resolution"] = toHexStr(dword, 8);
  }

  results.push_back(std::move(r));
}
コード例 #3
0
ファイル: smbios_utils.cpp プロジェクト: theopolis/osquery
void genSMBIOSMemoryArrays(size_t index,
                           const SMBStructHeader* hdr,
                           uint8_t* address,
                           size_t size,
                           QueryData& results) {
  if (hdr->type != kSMBIOSTypeMemoryArray || size < 0x12) {
    return;
  }

  Row r;
  r["handle"] = dmiWordToHexStr(address, 0x02);

  auto location = kSMBIOSMemoryArrayLocationTable.find(address[0x04]);
  if (location != kSMBIOSMemoryArrayLocationTable.end()) {
    r["location"] = location->second;
  }

  auto use = kSMBIOSMemoryArrayUseTable.find(address[0x05]);
  if (use != kSMBIOSMemoryArrayUseTable.end()) {
    r["use"] = use->second;
  }

  auto errCorrection =
      kSMBIOSMemoryArrayErrorCorrectionTypesTable.find(address[0x06]);
  if (errCorrection != kSMBIOSMemoryArrayErrorCorrectionTypesTable.end()) {
    r["memory_error_correction"] = errCorrection->second;
  }

  auto cap = dmiToDWord(address, 0x07);
  // SMBIOS returns capacity in KB or bytes, but we want a more human
  // friendly GB.
  r["max_capacity"] = (cap >= 0x80000000)
                          ? INTEGER(dmiToQWord(address, 0x0F) / 1073741824)
                          : INTEGER(cap / 1048576);

  auto errHandle = dmiToWord(address, 0x0B);
  if (errHandle != 0xFFFE && errHandle != 0xFFFF) {
    r["memory_error_info_handle"] = toHexStr(errHandle);
  }

  r["number_memory_devices"] = INTEGER(dmiToWord(address, 0x0D));

  results.push_back(std::move(r));
}
コード例 #4
0
ファイル: smbios_utils.cpp プロジェクト: theopolis/osquery
static inline std::string dmiWordToHexStr(uint8_t* address, uint8_t offset) {
  auto word = dmiToWord(address, offset);
  return toHexStr(word);
}
コード例 #5
0
ファイル: Formatter.cpp プロジェクト: arthuryuan/mock--
std::string toHexAndDecStr(T val)
{
	oss_t oss;
	oss << toHexStr(val) << "/" << toValStr(val);
	return oss.str();
}
コード例 #6
0
ファイル: Formatter.cpp プロジェクト: arthuryuan/mock--
std::string toHexStr(int val)
{ return toHexStr((unsigned int)val&0xFFFFFFFF); }
コード例 #7
0
ファイル: Formatter.cpp プロジェクト: arthuryuan/mock--
std::string toHexStr(char val)
{ return toHexStr((int)val&0xFF); }