@@ -39,7 +39,9 @@ def initialize(file_handler)
39
39
# Gather the MFT entry corresponding to his number
40
40
#
41
41
def mft_record_from_mft_num ( mft_num )
42
- cluster_from_attribute_non_resident ( mft_record_attribute ( @mft ) [ DATA_ATTRIBUTE_ID ] [ "data" ] , mft_num * @cluster_per_mft_record , @bytes_per_mft_record )
42
+ mft_num_offset = mft_num * @cluster_per_mft_record
43
+ mft_data_attribute = mft_record_attribute ( @mft ) [ DATA_ATTRIBUTE_ID ] [ "data" ]
44
+ cluster_from_attribute_non_resident ( mft_data_attribute , mft_num_offset , @bytes_per_mft_record )
43
45
end
44
46
45
47
#
@@ -73,7 +75,8 @@ def file_content_from_mft_num(mft_num, size)
73
75
if attribute_list [ DATA_ATTRIBUTE_ID ] [ "resident" ]
74
76
return attribute_list [ DATA_ATTRIBUTE_ID ] [ "data" ]
75
77
else
76
- return cluster_from_attribute_non_resident ( attribute_list [ DATA_ATTRIBUTE_ID ] [ "data" ] ) [ 0 , size ]
78
+ data_attribute = attribute_list [ DATA_ATTRIBUTE_ID ] [ "data" ]
79
+ return cluster_from_attribute_non_resident ( data_attribute ) [ 0 , size ]
77
80
end
78
81
end
79
82
@@ -88,7 +91,8 @@ def parse_index(index_entry)
88
91
# mft_offset = index_entry[0.unpack("Q<",:8])[0]
89
92
# work with 4 bytes
90
93
mft_offset = index_entry [ 0 , 4 ] . unpack ( "V" ) [ 0 ]
91
- res [ filename_from_filenameattribute ( filename_attribute ) ] = { "mft_offset" => mft_offset , "file_size" => real_size_from_filenameattribute ( filename_attribute ) }
94
+ res [ filename_from_filenameattribute ( filename_attribute ) ] = { "mft_offset" => mft_offset ,
95
+ "file_size" => real_size_from_filenameattribute ( filename_attribute ) }
92
96
res
93
97
end
94
98
@@ -107,7 +111,9 @@ def parse_index_list(index_record, index_allocation_attribute)
107
111
if index_entry [ 12 , 4 ] . unpack ( "V" ) [ 0 ] & 1 == 1
108
112
# should be 8 bytes length
109
113
vcn = index_entry [ -8 , 4 ] . unpack ( "V" ) [ 0 ]
110
- res_son = parse_index_list ( index_allocation_attribute [ vcn * @bytes_per_cluster + 24 , index_size * @bytes_per_cluster ] , index_allocation_attribute )
114
+ vcn_in_bytes = vcn * @bytes_per_cluster
115
+ index_size_in_bytes = index_size * @bytes_per_cluster
116
+ res_son = parse_index_list ( index_allocation_attribute [ vcn_in_bytes + 24 , index_size_in_bytes ] , index_allocation_attribute )
111
117
res . update ( res_son )
112
118
end
113
119
offset_index_entry_list += index_size
@@ -118,7 +124,9 @@ def parse_index_list(index_record, index_allocation_attribute)
118
124
if index_entry [ 12 , 4 ] . unpack ( "V" ) [ 0 ] & 1 == 1
119
125
# should be 8 bytes length
120
126
vcn = index_entry [ -8 , 4 ] . unpack ( "V" ) [ 0 ]
121
- res_son = parse_index_list ( index_allocation_attribute [ vcn * @bytes_per_cluster + 24 , index_size * @bytes_per_cluster ] , index_allocation_attribute )
127
+ vcn_in_bytes = vcn * @bytes_per_cluster
128
+ index_size_in_bytes = index_size * @bytes_per_cluster
129
+ res_son = parse_index_list ( index_allocation_attribute [ vcn_in_bytes + 24 , index_size_in_bytes ] , index_allocation_attribute )
122
130
res . update ( res_son )
123
131
end
124
132
res
@@ -166,7 +174,8 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
166
174
size_wanted = [ run_length * @bytes_per_cluster , size_max - attribut . length ] . min
167
175
168
176
if cluster_num + ( size_wanted / @bytes_per_cluster ) >= run_list_num && ( cluster_num < run_length + run_list_num )
169
- run_list_offset = ( run_offset + old_offset + [ cluster_num - run_list_num , 0 ] . max ) * @bytes_per_cluster
177
+ run_list_offset_in_cluster = run_offset + old_offset + [ cluster_num - run_list_num , 0 ] . max
178
+ run_list_offset = ( run_list_offset_in_cluster ) * @bytes_per_cluster
170
179
run_list_offset = run_list_offset . to_i
171
180
@file_handler . seek ( run_list_offset )
172
181
@@ -212,7 +221,8 @@ def mft_record_attribute(mft_record)
212
221
end
213
222
end
214
223
if attribute_identifier == DATA_ATTRIBUTE_ID
215
- res [ attribute_identifier ] = { "data" => res [ attribute_identifier ] , "resident" => mft_record [ curs + 8 ] == "\x00 " }
224
+ res [ attribute_identifier ] = { "data" => res [ attribute_identifier ] ,
225
+ "resident" => mft_record [ curs + 8 ] == "\x00 " }
216
226
end
217
227
curs += attribute_size
218
228
attribute_identifier = mft_record [ curs , 4 ] . unpack ( "V" ) [ 0 ]
0 commit comments