예제 #1
0
bool ParseDisc()
{
  // Mark the header as used - it's mostly 0s anyways
  MarkAsUsed(0, 0x50000);

  for (int x = 0; x < 4; x++)
  {
    if (!ReadFromVolume(0x40000 + (x * 8) + 0, PartitionGroup[x].numPartitions, false) ||
        !ReadFromVolume(0x40000 + (x * 8) + 4, PartitionGroup[x].PartitionsOffset, false))
      return false;

    // Read all partitions
    for (u32 i = 0; i < PartitionGroup[x].numPartitions; i++)
    {
      SPartition Partition;

      Partition.GroupNumber = x;
      Partition.Number = i;

      if (!ReadFromVolume(PartitionGroup[x].PartitionsOffset + (i * 8) + 0, Partition.Offset,
                          false) ||
          !ReadFromVolume(PartitionGroup[x].PartitionsOffset + (i * 8) + 4, Partition.Type,
                          false) ||
          !ReadFromVolume(Partition.Offset + 0x2a4, Partition.Header.TMDSize, false) ||
          !ReadFromVolume(Partition.Offset + 0x2a8, Partition.Header.TMDOffset, false) ||
          !ReadFromVolume(Partition.Offset + 0x2ac, Partition.Header.CertChainSize, false) ||
          !ReadFromVolume(Partition.Offset + 0x2b0, Partition.Header.CertChainOffset, false) ||
          !ReadFromVolume(Partition.Offset + 0x2b4, Partition.Header.H3Offset, false) ||
          !ReadFromVolume(Partition.Offset + 0x2b8, Partition.Header.DataOffset, false) ||
          !ReadFromVolume(Partition.Offset + 0x2bc, Partition.Header.DataSize, false))
        return false;

      PartitionGroup[x].PartitionsVec.push_back(Partition);
    }

    for (auto& rPartition : PartitionGroup[x].PartitionsVec)
    {
      const SPartitionHeader& rHeader = rPartition.Header;

      MarkAsUsed(rPartition.Offset, 0x2c0);

      MarkAsUsed(rPartition.Offset + rHeader.TMDOffset, rHeader.TMDSize);
      MarkAsUsed(rPartition.Offset + rHeader.CertChainOffset, rHeader.CertChainSize);
      MarkAsUsed(rPartition.Offset + rHeader.H3Offset, 0x18000);
      // This would mark the whole (encrypted) data area
      // we need to parse FST and other crap to find what's free within it!
      // MarkAsUsed(rPartition.Offset + rHeader.DataOffset, rHeader.DataSize);

      // Parse Data! This is where the big gain is
      if (!ParsePartitionData(rPartition))
        return false;
    }
  }

  return true;
}
예제 #2
0
// Write a string
void TortoiseRegistryCache::WriteString(const std::string& key, const std::string& name, 
                                        const std::string& value)
{
   // Update LRU list
   MarkAsUsed(key);

   std::string myKey = key;
   MakeLowerCase(myKey);
   FindAndReplace<std::string>(myKey, "\\", "/");

   // Write values
   std::string regPath = EnsureTrailingDelimiter(m_StoragePath) 
      + EnsureTrailingDelimiter(myKey) + name;
   TortoiseRegistry::WriteString(regPath, value);
}
예제 #3
0
// Compensate for 0x400(SHA-1) per 0x8000(cluster)
void MarkAsUsedE(u64 _PartitionDataOffset, u64 _Offset, u64 _Size)
{
	u64 Offset;
	u64 Size;

	Offset = _Offset / 0x7c00;
	Offset = Offset * CLUSTER_SIZE;
	Offset += _PartitionDataOffset;

	Size = _Size / 0x7c00;
	Size = (Size + 1) * CLUSTER_SIZE;

	// Add on the offset in the first block for the case where data straddles blocks
	Size += _Offset % 0x7c00;

	MarkAsUsed(Offset, Size);
}
예제 #4
0
// Compensate for 0x400 (SHA-1) per 0x8000 (cluster), and round to whole clusters
void MarkAsUsedE(u64 partition_data_offset, u64 offset, u64 size)
{
  u64 first_cluster_start = offset / 0x7c00 * CLUSTER_SIZE + partition_data_offset;

  u64 last_cluster_end;
  if (size == 0)
  {
    // Without this special case, a size of 0 can be rounded to 1 cluster instead of 0
    last_cluster_end = first_cluster_start;
  }
  else
  {
    last_cluster_end = ((offset + size - 1) / 0x7c00 + 1) * CLUSTER_SIZE + partition_data_offset;
  }

  MarkAsUsed(first_cluster_start, last_cluster_end - first_cluster_start);
}