Skip to content

Instantly share code, notes, and snippets.

@nraynaud
Last active February 26, 2022 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nraynaud/99c6343fa3bb00a3b7cd3a4570e41956 to your computer and use it in GitHub Desktop.
Save nraynaud/99c6343fa3bb00a3b7cd3a4570e41956 to your computer and use it in GitHub Desktop.
VMDK grammar for synalyze pro
<?xml version="1.0" encoding="UTF-8"?>
<ufwb version="1.17">
<grammar name="VMDK" start="id:6" author="Nicolas Raynaud" email="nraynaud@gmail.com" fileextension=".vmdk">
<description>VMDK streamOptimized file format. Licenced under Affero GPL, the copyright owner is Vates SAS. This is a work for hire by Nicolas Raynaud.</description>
<scripts>
<script name="Sector64" type="DataType" id="142">
<source language="Python"># custom data type script
def parseByteRange(element, byteView, bitPos, bitLength, results):
# this method parses data starting at bitPos, bitLength bits are remaining
&quot;&quot;&quot;parseByteRange method&quot;&quot;&quot;
num = byteView.readSignedInt(bitPos/8, 8, ENDIAN_LITTLE)
if num &gt; 0:
num *= 512
# create and set new value
value = NumberValue()
value.setSigned(num)
# how many bytes were processed?
processedBytes = 8
iteration = 0
results.addElement(element, processedBytes, iteration, value)
# return number of processed bytes
return processedBytes
def fillByteRange(value, byteArray, bitPos, bitLength):
# this method translates edited values back to the file
&quot;&quot;&quot;fillByteRange method&quot;&quot;&quot;
# write an integer back to file
byteArray.writeSignedInt(value / 512, bitPos / 8, 8, ENDIAN_LITTLE)
</source>
</script>
<script name="Sector32" type="DataType" id="317">
<source language="Python"># custom data type script
def parseByteRange(element, byteView, bitPos, bitLength, results):
# this method parses data starting at bitPos, bitLength bits are remaining
&quot;&quot;&quot;parseByteRange method&quot;&quot;&quot;
num = byteView.readSignedInt(bitPos/8, 4, ENDIAN_LITTLE)
if num &gt; 0:
num *= 512
# create and set new value
value = NumberValue()
value.setSigned(num)
# how many bytes were processed?
processedBytes = 4
iteration = 0
results.addElement(element, processedBytes, iteration, value)
# return number of processed bytes
return processedBytes
def fillByteRange(value, byteArray, bitPos, bitLength):
# this method translates edited values back to the file
&quot;&quot;&quot;fillByteRange method&quot;&quot;&quot;
# write an integer back to file
byteArray.writeSignedInt(value / 512, bitPos / 8, 8, ENDIAN_LITTLE)
</source>
</script>
</scripts>
<structure name="file" id="6" encoding="ISO_8859-1:1987" endian="little" signed="no">
<structref name="header" id="8" fillcolor="EDFF40" structure="id:7"/>
<structure name="Descriptor" id="9" length="0" encoding="ISO_8859-1:1987" endian="big" signed="no">
<string name="descriptor" id="10" fillcolor="8897FF" type="fixed-length" length="descriptorSizeSectors*512"/>
<binary name="padding" id="11" fillcolor="B8D0FF" repeatmin="0" length="metadataOverhead+(-descriptorSizeSectors)*512-descriptorAddress"/>
</structure>
<structure name="MarkedSection" id="13" repeatmax="-1" order="variable">
<structref name="MarkedGD" id="15" repeatmin="0" structure="id:14"/>
<structref name="MarkedTable" id="17" repeatmin="0" structure="id:16"/>
<structure name="grains" id="18" repeatmin="0" consists-of="id:19">
<structref name="MarkedGrain" id="20" repeatmax="-1" structure="id:19"/>
</structure>
</structure>
<structref name="MarkedFooter" id="24" structure="id:23"/>
<structref name="MarkedEOS" id="26" structure="id:25"/>
</structure>
<structure name="Header" id="7" length="512" encoding="ISO_8859-1:1987" endian="little" signed="no">
<string name="magic" id="28" fillcolor="FFA395" type="fixed-length" length="4">
<fixedvalues>
<fixedvalue name="magic" value="KDMV"/>
</fixedvalues>
</string>
<number name="version" id="29" type="integer" length="4"/>
<number name="Flags" id="30" type="integer" length="4" display="binary"/>
<number name="capacitySectors" id="31" type="integer" length="8"/>
<number name="grainSizeSectors" id="32" type="integer" length="8"/>
<custom name="descriptorAddress" id="33" length="8" script="id:142"/>
<number name="descriptorSizeSectors" id="34" type="integer" length="8"/>
<number name="grainTableentries" id="35" type="integer" length="4"/>
<number name="secondaryGDOffsetSectors" id="36" type="integer" length="8"/>
<custom name="grainDirectoryAddress" id="37" length="8" script="id:142"/>
<custom name="metadataOverhead" id="38" fillcolor="FFA395" length="8" script="id:142"/>
<number name="isDirty" id="39" type="integer" length="1"/>
<string name="end of line" id="40" type="fixed-length" length="1"/>
<string name="non EOL" id="41" type="fixed-length" length="1"/>
<string name="carriage return" id="42" type="fixed-length" length="1"/>
<string name="second EOL" id="43" type="fixed-length" length="1"/>
<number name="compressionMethod" id="44" type="integer" length="2">
<fixedvalues>
<fixedvalue name="COMPRESSION_NONE" value="0"/>
<fixedvalue name="COMPRESSION_DEFLATE" value="1"/>
</fixedvalues>
</number>
</structure>
<structure name="MarkedSection" id="46" alignment="0" encoding="ISO_8859-1:1987" endian="little" signed="no">
<number name="markerValue" id="47" fillcolor="FF7CED" type="integer" length="8"/>
<number name="markerSize" id="48" type="integer" length="4"/>
</structure>
<structure name="MarkedGrain" id="19" extends="id:46">
<number name="markerValue" id="50" type="integer" length="8"/>
<number name="markerSize" mustmatch="yes" id="51" type="integer" length="4" minval="1"/>
<binary name="compressedData" id="52" length="markerSize"/>
<binary name="padding" id="53" length="mod(512-mod(markerSize+12, 512), 512)"/>
</structure>
<structure name="MarkedMetadata" id="55" extends="id:46">
<number name="markerValue" id="56" type="integer"/>
<number name="markerSize" id="57" type="integer" maxval="0"/>
<number name="markerType" id="58" type="integer" length="4"/>
<binary name="padding" id="59" strokecolor="152D1B" length="496"/>
</structure>
<structure name="MarkedTable" id="16" extends="id:55" fillcolor="FFD59F">
<number name="markerType" mustmatch="yes" id="63" type="integer">
<fixedvalues>
<fixedvalue name="MARKER_GT" value="1"/>
</fixedvalues>
</number>
<binary name="padding" id="64" fillcolor="FFF79F"/>
<structure name="Entries" id="65" fillcolor="FFD59F">
<custom name="Entry" id="66" fillcolor="FFF69F" repeatmin="markerValue*512/4" repeatmax="markerValue*512/4" length="4" script="id:317"/>
</structure>
</structure>
<structure name="MarkedGD" id="14" extends="id:55">
<number name="markerType" mustmatch="yes" id="71" type="integer">
<fixedvalues>
<fixedvalue name="MARKER_GD" value="2"/>
</fixedvalues>
</number>
<binary name="padding" id="72" fillcolor="ADFFEF"/>
<structure name="Entries" id="73">
<custom name="GDEntry" id="74" fillcolor="C1FFFC" repeatmin="markerValue*512/4" repeatmax="markerValue*512/4" length="4" script="id:317"/>
</structure>
</structure>
<structure name="MarkedFooter" id="23" extends="id:55">
<number name="markerType" mustmatch="yes" id="79" type="integer">
<fixedvalues>
<fixedvalue name="MARKER_FOOTER" value="3"/>
</fixedvalues>
</number>
<binary name="padding" id="80"/>
<structref name="footer" id="81" fillcolor="FFC6E7" structure="id:7"/>
</structure>
<structure name="MarkedEOS" id="25" extends="id:55">
<number name="markerType" mustmatch="yes" id="85" type="integer">
<fixedvalues>
<fixedvalue name="MARKER_EOS" value="0"/>
</fixedvalues>
</number>
<binary name="padding" id="86"/>
</structure>
</grammar>
</ufwb>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment