Read CompactDisc deduplication tables.

This commit is contained in:
2019-03-17 23:25:45 +00:00
parent d54284db4c
commit 424c30c96b
3 changed files with 44 additions and 2 deletions

View File

@@ -34,6 +34,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
typedef struct dicformatContext
{
@@ -50,10 +51,13 @@ typedef struct dicformatContext
unsigned char *sectorSuffixCorrected;
unsigned char *sectorSubchannel;
unsigned char *mode2Subheaders;
byte shift;
unsigned char shift;
bool inMemoryDdt;
uint64_t *userDataDdt;
size_t mappedMemoryDdtSize;
uint32_t *sectorPrefixDdt;
uint32_t *sectorSuffixDdt;
} dicformatContext;
typedef struct dataLinkedList

View File

@@ -87,6 +87,10 @@ int close(void *context)
{
munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize);
}
free(ctx->sectorPrefixDdt);
free(ctx->sectorSuffixDdt);
free(context);
return 0;

View File

@@ -36,7 +36,6 @@
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <sys/mman.h>
// TODO: Check CRC64 on structures
@@ -423,6 +422,41 @@ void *open(const char *filepath)
}
}
else if(idxEntries[i].dataType == CdSectorPrefixCorrected ||
idxEntries[i].dataType == CdSectorSuffixCorrected)
{
switch(ddtHeader.compression)
{
case None:data = malloc(ddtHeader.entries * sizeof(uint32_t));
if(mediaTag == NULL)
{
fprintf(stderr, "libdicformat: Cannot allocate memory for deduplication table.");
break;
}
readBytes = fread(data, ddtHeader.entries * sizeof(uint32_t), 1, ctx->imageStream);
if(readBytes != ddtHeader.entries * sizeof(uint32_t))
{
free(data);
fprintf(stderr, "Could not read deduplication table, continuing...");
break;
}
if(idxEntries[i].dataType == CdSectorPrefixCorrected)
ctx->sectorPrefixCorrected = data;
else if(idxEntries[i].dataType == CdSectorSuffixCorrected)
ctx->sectorPrefixCorrected = data;
break;
default:
fprintf(stderr,
"libdicformat: Found unknown compression type %d, continuing...",
blockHeader.compression);
break;
}
}
break;
case GeometryBlock:
// TODO