summaryrefslogtreecommitdiffstats
path: root/libpit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlibpit/Source/libpit.cpp (renamed from heimdall/source/PitData.cpp)122
-rwxr-xr-xlibpit/Source/libpit.h (renamed from heimdall/source/PitData.h)43
-rwxr-xr-xlibpit/libpit.vcxproj119
-rwxr-xr-xlibpit/libpit.vcxproj.filters19
4 files changed, 207 insertions, 96 deletions
diff --git a/heimdall/source/PitData.cpp b/libpit/Source/libpit.cpp
index 10e88b7..030a80b 100755
--- a/heimdall/source/PitData.cpp
+++ b/libpit/Source/libpit.cpp
@@ -18,12 +18,10 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
-// Heimdall
-#include "Heimdall.h"
-#include "InterfaceManager.h"
-#include "PitData.h"
+// libpit
+#include "libpit.h"
-using namespace Heimdall;
+using namespace libpit;
PitEntry::PitEntry()
{
@@ -31,11 +29,11 @@ PitEntry::PitEntry()
partitionType = 0;
partitionIdentifier = 0;
partitionFlags = 0;
- unknown2 = 0;
+ unknown1 = 0;
partitionBlockSize = 0;
partitionBlockCount = 0;
+ unknown2 = 0;
unknown3 = 0;
- unknown4 = 0;
memset(partitionName, 0, 32);
memset(filename, 0, 64);
@@ -45,42 +43,6 @@ PitEntry::~PitEntry()
{
}
-void PitEntry::Print(void) const
-{
- InterfaceManager::Print("Unused: %s\n", (unused) ? "Yes" : "No");
-
- const char *partitionTypeText = "Unknown";
-
- if (partitionType == PitEntry::kPartitionTypeRfs)
- partitionTypeText = "RFS";
- else if (partitionType == PitEntry::kPartitionTypeExt4)
- partitionTypeText = "EXT4";
-
- InterfaceManager::Print("Partition Type: %d (%s)\n", partitionType, partitionTypeText);
-
- InterfaceManager::Print("Partition Identifier: %d\n", partitionIdentifier);
-
- InterfaceManager::Print("Partition Flags: %d (", partitionFlags);
-
- if (partitionFlags & PitEntry::kPartitionFlagWrite)
- InterfaceManager::Print("R/W");
- else
- InterfaceManager::Print("R");
-
- InterfaceManager::Print(")\n");
-
- InterfaceManager::Print("Unknown 2: %d\n", unknown2);
-
- InterfaceManager::Print("Partition Block Size: %d\n", partitionBlockSize);
- InterfaceManager::Print("Partition Block Count: %d\n", partitionBlockCount);
-
- InterfaceManager::Print("Unknown 3: %d\n", unknown3);
- InterfaceManager::Print("Unknown 4: %d\n", unknown4);
-
- InterfaceManager::Print("Partition Name: %s\n", partitionName);
- InterfaceManager::Print("Filename: %s\n", filename);
-}
-
PitData::PitData()
@@ -153,7 +115,7 @@ bool PitData::Unpack(const unsigned char *data)
entries[i]->SetPartitionFlags(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 16);
- entries[i]->SetUnknown2(integerValue);
+ entries[i]->SetUnknown1(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 20);
entries[i]->SetPartitionBlockSize(integerValue);
@@ -162,10 +124,10 @@ bool PitData::Unpack(const unsigned char *data)
entries[i]->SetPartitionBlockCount(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 28);
- entries[i]->SetUnknown3(integerValue);
+ entries[i]->SetUnknown2(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 32);
- entries[i]->SetUnknown4(integerValue);
+ entries[i]->SetUnknown3(integerValue);
entries[i]->SetPartitionName((const char *)data + entryOffset + 36);
entries[i]->SetFilename((const char *)data + entryOffset + 36 + PitEntry::kPartitionNameMaxLength);
@@ -204,24 +166,56 @@ void PitData::Pack(unsigned char *data) const
PitData::PackInteger(data, entryOffset + 8, entries[i]->GetPartitionIdentifier());
PitData::PackInteger(data, entryOffset + 12, entries[i]->GetPartitionFlags());
- PitData::PackInteger(data, entryOffset + 16, entries[i]->GetUnknown2());
+ PitData::PackInteger(data, entryOffset + 16, entries[i]->GetUnknown1());
PitData::PackInteger(data, entryOffset + 20, entries[i]->GetPartitionBlockSize());
PitData::PackInteger(data, entryOffset + 24, entries[i]->GetPartitionBlockCount());
- PitData::PackInteger(data, entryOffset + 28, entries[i]->GetUnknown3());
- PitData::PackInteger(data, entryOffset + 32, entries[i]->GetUnknown4());
+ PitData::PackInteger(data, entryOffset + 28, entries[i]->GetUnknown2());
+ PitData::PackInteger(data, entryOffset + 32, entries[i]->GetUnknown3());
memcpy(data + entryOffset + 36, entries[i]->GetPartitionName(), PitEntry::kPartitionNameMaxLength);
memcpy(data + entryOffset + 36 + PitEntry::kPartitionNameMaxLength, entries[i]->GetPartitionName(), PitEntry::kFilenameMaxLength);
}
}
+void PitData::Clear(void)
+{
+ entryCount = 0;
+
+ unknown1 = 0;
+ unknown2 = 0;
+
+ unknown3 = 0;
+ unknown4 = 0;
+
+ unknown5 = 0;
+ unknown6 = 0;
+
+ unknown7 = 0;
+ unknown8 = 0;
+
+ for (unsigned int i = 0; i < entries.size(); i++)
+ delete entries[i];
+
+ entries.clear();
+}
+
+PitEntry *PitData::GetEntry(unsigned int index)
+{
+ return (entries[index]);
+}
+
+const PitEntry *PitData::GetEntry(unsigned int index) const
+{
+ return (entries[index]);
+}
+
PitEntry *PitData::FindEntry(const char *partitionName)
{
for (unsigned int i = 0; i < entries.size(); i++)
{
- if (strcmp(entries[i]->GetPartitionName(), partitionName) == 0)
+ if (!entries[i]->GetUnused() && strcmp(entries[i]->GetPartitionName(), partitionName) == 0)
return (entries[i]);
}
@@ -232,7 +226,7 @@ const PitEntry *PitData::FindEntry(const char *partitionName) const
{
for (unsigned int i = 0; i < entries.size(); i++)
{
- if (strcmp(entries[i]->GetPartitionName(), partitionName) == 0)
+ if (!entries[i]->GetUnused() && strcmp(entries[i]->GetPartitionName(), partitionName) == 0)
return (entries[i]);
}
@@ -243,7 +237,7 @@ PitEntry *PitData::FindEntry(unsigned int partitionIdentifier)
{
for (unsigned int i = 0; i < entries.size(); i++)
{
- if (entries[i]->GetPartitionIdentifier() == partitionIdentifier)
+ if (!entries[i]->GetUnused() && entries[i]->GetPartitionIdentifier() == partitionIdentifier)
return (entries[i]);
}
@@ -254,31 +248,9 @@ const PitEntry *PitData::FindEntry(unsigned int partitionIdentifier) const
{
for (unsigned int i = 0; i < entries.size(); i++)
{
- if (entries[i]->GetPartitionIdentifier() == partitionIdentifier)
+ if (!entries[i]->GetUnused() && entries[i]->GetPartitionIdentifier() == partitionIdentifier)
return (entries[i]);
}
return (nullptr);
}
-
-void PitData::Print(void) const
-{
- InterfaceManager::Print("Entry Count: %d\n", entryCount);
-
- InterfaceManager::Print("Unknown 1: %d\n", unknown1);
- InterfaceManager::Print("Unknown 2: %d\n", unknown2);
- InterfaceManager::Print("Unknown 3: %d\n", unknown3);
- InterfaceManager::Print("Unknown 4: %d\n", unknown4);
- InterfaceManager::Print("Unknown 5: %d\n", unknown5);
- InterfaceManager::Print("Unknown 6: %d\n", unknown6);
- InterfaceManager::Print("Unknown 7: %d\n", unknown7);
- InterfaceManager::Print("Unknown 8: %d\n", unknown8);
-
- for (unsigned int i = 0; i < entryCount; i++)
- {
- InterfaceManager::Print("\n\n--- Entry #%d ---\n", i);
- entries[i]->Print();
- }
-
- InterfaceManager::Print("\n");
-}
diff --git a/heimdall/source/PitData.h b/libpit/Source/libpit.h
index b6a0d2f..636f1e1 100755
--- a/heimdall/source/PitData.h
+++ b/libpit/Source/libpit.h
@@ -18,14 +18,14 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
-#ifndef PITDATA_H
-#define PITDATA_H
+#ifndef LIBPIT_H
+#define LIBPIT_H
// C Standard Library
#include <string.h>
#include <vector>
-namespace Heimdall
+namespace libpit
{
class PitEntry
{
@@ -58,13 +58,13 @@ namespace Heimdall
unsigned int partitionIdentifier;
unsigned int partitionFlags;
- unsigned int unknown2;
+ unsigned int unknown1;
unsigned int partitionBlockSize;
unsigned int partitionBlockCount;
+ unsigned int unknown2;
unsigned int unknown3;
- unsigned int unknown4;
char partitionName[kPartitionNameMaxLength];
char filename[kFilenameMaxLength];
@@ -74,8 +74,6 @@ namespace Heimdall
PitEntry();
~PitEntry();
- void Print(void) const;
-
bool GetUnused(void) const
{
return unused;
@@ -116,14 +114,14 @@ namespace Heimdall
this->partitionFlags = partitionFlags;
}
- unsigned int GetUnknown2(void) const
+ unsigned int GetUnknown1(void) const
{
- return unknown2;
+ return unknown1;
}
- void SetUnknown2(unsigned int unknown2)
+ void SetUnknown1(unsigned int unknown1)
{
- this->unknown2 = unknown2;
+ this->unknown1 = unknown1;
}
unsigned int GetPartitionBlockSize(void) const
@@ -146,24 +144,24 @@ namespace Heimdall
this->partitionBlockCount = partitionBlockCount;
}
- unsigned int GetUnknown3(void) const
+ unsigned int GetUnknown2(void) const
{
- return unknown3;
+ return unknown2;
}
- void SetUnknown3(unsigned int unknown3)
+ void SetUnknown2(unsigned int unknown2)
{
- this->unknown3 = unknown3;
+ this->unknown2 = unknown2;
}
- unsigned int GetUnknown4(void) const
+ unsigned int GetUnknown3(void) const
{
- return unknown4;
+ return unknown3;
}
- void SetUnknown4(unsigned int unknown4)
+ void SetUnknown3(unsigned int unknown3)
{
- this->unknown4 = unknown4;
+ this->unknown3 = unknown3;
}
const char *GetPartitionName(void) const
@@ -287,14 +285,17 @@ namespace Heimdall
bool Unpack(const unsigned char *data);
void Pack(unsigned char *data) const;
+ void Clear(void);
+
+ PitEntry *GetEntry(unsigned int index);
+ const PitEntry *GetEntry(unsigned int index) const;
+
PitEntry *FindEntry(const char *partitionName);
const PitEntry *FindEntry(const char *partitionName) const;
PitEntry *FindEntry(unsigned int partitionIdentifier);
const PitEntry *FindEntry(unsigned int partitionIdentifier) const;
- void Print(void) const;
-
unsigned int GetEntryCount(void) const
{
return entryCount;
diff --git a/libpit/libpit.vcxproj b/libpit/libpit.vcxproj
new file mode 100755
index 0000000..af828bc
--- /dev/null
+++ b/libpit/libpit.vcxproj
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release - Static MSVC|Win32">
+ <Configuration>Release - Static MSVC</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Source\libpit.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Source\libpit.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9506FFE4-3A78-4BEE-A15E-62C5A138E61D}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>libpit</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Static MSVC|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Static MSVC|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\lib\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\lib\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Static MSVC|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\lib\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - Static MSVC|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/libpit/libpit.vcxproj.filters b/libpit/libpit.vcxproj.filters
new file mode 100755
index 0000000..c9ea499
--- /dev/null
+++ b/libpit/libpit.vcxproj.filters
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Source\libpit.h">
+ <Filter>Source</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Source\libpit.cpp">
+ <Filter>Source</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file