Skip to content

Commit

Permalink
Add custom template for HexFiend
Browse files Browse the repository at this point in the history
This allows to browse change index files
  • Loading branch information
vgrichina committed Feb 14, 2024
1 parent 7d1228d commit dfbf0ad
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions scripts/HexFiend/ChangeIndex.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
proc varint {name {delta 0}} {
# loop through bytes reading protobuf varint
set value 0
set shift 0
set start_offset [pos]
while {1} {
set byte [uint8]
set value [expr {$value | (($byte & 0x7f) << $shift)}]
set shift [expr {$shift + 7}]
if {($byte & 0x80) == 0} {
set value [expr {$value + $delta}]
if {$name ne ""} {
entry $name $value [expr {[pos] - $start_offset}] $start_offset
}

return $value
}
}
}

proc account_id {name} {
set length [varint ""]
if {$length == 0} {
return ""
}
set value [str $length "utf8" $name]
return $value
}

proc buffer {name} {
set length [varint ""]
if {$length == 0} {
return ""
}
set value [hex $length $name]
return $value
}

while {![end]} {
section -collapsed "Account" {
set account [account_id "account"]
if {$account eq ""} {
endsection
break
}
sectionvalue $account

while {1} {
section "Key" {
set key [buffer "key"]
if {[string length $key] == 0} {
endsection
break
}
sectionvalue $key
section "Changes" {
set changes_count [varint "count"]
sectionvalue $changes_count
set prev_change [varint "0"]
for {set i 1} {$i < $changes_count} {incr i} {
varint "$i" $prev_change
}
}
}
}
}
}

0 comments on commit dfbf0ad

Please sign in to comment.