ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
295 stars 72 forks source link

QCN MCDF #101

Closed koyuyesil closed 9 months ago

koyuyesil commented 9 months ago

Qualcomm uses the MCDF structure for NV Items backup files. I'm familiar with the structure of these streams. How can I contribute to this branch? QCNWiew official app for wiewing i want make editor.

QCN

File Version;

Major = br.ReadUInt16();
Minor = br.ReadUInt16();
Revision = br.ReadUInt16();

FeatureMask (Bit Definitons);


public class FeatureMask
{
public List<string> DataBits { get; set; }
public FeatureMask()
{
DataBits = new List<string>();
}

public void Read(BinaryReader br)
{
byte[] unknownByte=br.ReadBytes(2);
while (br.BaseStream.Position != br.BaseStream.Length)
{
string yourByteString = Convert.ToString(br.ReadByte(), 2).PadLeft(8, '0');
DataBits.Add(yourByteString);  
}
}
}

Mobile_Property_Info summary;

public void Read(BinaryReader br)
{
ESN= br.ReadUInt32();
MODEM= br.ReadUInt16();
MajorVersion = br.ReadByte();
MinorVersion = br.ReadByte();
ModemFirmwareVersionLength= br.ReadUInt16();//Pascal String
ModemFirmwareVersion = Encoding.ASCII.GetString(br.ReadBytes(ModemFirmwareVersionLength));
SoftwareVersionLength = br.ReadUInt16();
SoftwareVersion = Encoding.ASCII.GetString(br.ReadBytes(SoftwareVersionLength));
}

Nv Numbered Items


public class NvNumberedItem
{
public UInt16 id { get; set; }
public UInt16 index { get; set; }
public List<byte[]> data { get; set; }
public NvNumberedItem()
{
data = new List<byte[]>();
}
}
public class NvNumberedItems
{
public List<NvNumberedItem> items;
public NvNumberedItems()
{
items = new List<NvNumberedItem>();
}
public void Read(BinaryReader br)
{
while (br.BaseStream.Position != br.BaseStream.Length)
{
NvNumberedItem nvNumberedItem = new NvNumberedItem();
uint baseOffset = br.ReadUInt32();
nvNumberedItem.id = br.ReadUInt16();
nvNumberedItem.index = br.ReadUInt16();
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
nvNumberedItem.data.Add(br.ReadBytes(16));
this.items.Add(nvNumberedItem);
}
}
}
ironfede commented 9 months ago

Hi @koyuyesil , I'm not sure to have fully understood but I think you want to use OpenMcdf to create a specific editor for you use case (let me know if I'm correct). If so you should use OpenMcdf as a dependency/base library in your project because I can't include an editor extension that is too much bound to a specific use case for a general usage library. You should start from the Structured Storage Explorer as template and specialize it for your needs, for example. Please, let me know If I've correctly understood your point or if I've totally missed it and you need help for something different.

Best Regards, Federico

koyuyesil commented 9 months ago

As a base library, it already works very well. Is it possible to make the library more flexible for applications that use the base library but have their own custom data structures? For example, if we program a Structures.DLL and convert the data fragment into this object, how would it work? Like this code snippet:

var str = cf.RootStorage.GetStream("NV_ITEM_ARRAY");
var co = str.AsOLEPropertiesContainer();

But something like AsOleNvItemArray().

ironfede commented 9 months ago

@koyuyesil I think you could implement an extension/wrapper class that uses the same logic of the aforementioned example just as

   public static NvItemArray AsOleNvItemArray(this CFStream cfStream)
   {
       return new NvItemArray(cfStream);
   }

Do you see any specific issue with this approach in your Use Case?