87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/kindlestrip.rb', line 87
def updateEXTH121(srcs_secnum, srcs_cnt, )
mobi_length, = [0x14...0x18].unpack("N")
exth_flag, = [0x80...0x84].unpack("N")
exth = "NONE"
begin
if exth_flag & 0x40 != 0
exth = [16 + mobi_length .. -1]
if exth.length >= 4 && exth[0, 4] == "EXTH"
nitems, = exth[8...12].unpack("N")
pos = 12
nitems.times do
type, size = exth[pos ... pos + 8].unpack("NN")
if type == 121
boundaryptr, = exth[pos + 8 ... pos + size].unpack("N")
if srcs_secnum <= boundaryptr
boundaryptr -= srcs_cnt
prefix = [0, 16 + mobi_length + pos + 8]
suffix = [16 + mobi_length + pos + 8 + 4 .. -1]
nval = [boundaryptr].pack("N")
= prefix + nval + suffix
end
end
pos += size
end
end
end
rescue
end
end
|