计算一些值填充的算法是什么?
What is the algorithm to calculate some values padding?
我逆向了一些游戏文件来翻译它并且已经理解了一切,除了如何确定一些块填充。
例如,我在一个文件中有这个(两个条目,每个条目 36 字节,然后零填充。总共 96 字节):
01 08 01 80 00 00 00 09 00 00 08 C0 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
01 08 01 80 00 00 00 09 00 01 94 C0 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
这是另一个(1 个条目 36 个字节,然后是零填充。总共 64 个字节):
01 08 01 80 00 00 00 09 00 00 04 80 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
我试着开始设计 64 by 62, 60, ..., [32], ..., [16], ..., [8], ..., [4], [2 ].
[]中的数字是96和64可以无休止整除的数字。
但是未填充的尺寸(72 和 36)也可以除以 2、4、8。
填充物是什么?如何计算?
在我看来,00
填充字节数应该计算如下:
padding(num_bytes)=ceil(num_bytes/32)*32-num_bytes
然后我们得到第一种情况
padding(2*36) = 24
24 个额外的填充字节(总共 96 个)和第二种情况
padding(36) = 28
28 个额外的填充字节(总共 64 个字节)。
我逆向了一些游戏文件来翻译它并且已经理解了一切,除了如何确定一些块填充。
例如,我在一个文件中有这个(两个条目,每个条目 36 字节,然后零填充。总共 96 字节):
01 08 01 80 00 00 00 09 00 00 08 C0 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
01 08 01 80 00 00 00 09 00 01 94 C0 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
这是另一个(1 个条目 36 个字节,然后是零填充。总共 64 个字节):
01 08 01 80 00 00 00 09 00 00 04 80 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
我试着开始设计 64 by 62, 60, ..., [32], ..., [16], ..., [8], ..., [4], [2 ].
[]中的数字是96和64可以无休止整除的数字。 但是未填充的尺寸(72 和 36)也可以除以 2、4、8。 填充物是什么?如何计算?
在我看来,00
填充字节数应该计算如下:
padding(num_bytes)=ceil(num_bytes/32)*32-num_bytes
然后我们得到第一种情况
padding(2*36) = 24
24 个额外的填充字节(总共 96 个)和第二种情况
padding(36) = 28
28 个额外的填充字节(总共 64 个字节)。