| 8 | from binaryninja.enums import ThemeColor |
| 9 | |
| 10 | class EntropyThread(threading.Thread): |
| 11 | def __init__(self, data, image, block_size): |
| 12 | super(EntropyThread, self).__init__() |
| 13 | self.data = data |
| 14 | self.image = image |
| 15 | self.block_size = block_size |
| 16 | self.updated = False |
| 17 | |
| 18 | def run(self): |
| 19 | width = self.image.width() |
| 20 | for i in range(0, width): |
| 21 | v = int(self.data.get_entropy(self.data.start + i * self.block_size, self.block_size)[0] * 255) |
| 22 | if v >= 240: |
| 23 | color = binaryninjaui.getThemeColor(ThemeColor.YellowStandardHighlightColor) |
| 24 | self.image.setPixelColor(i, 0, color) |
| 25 | else: |
| 26 | baseColor = binaryninjaui.getThemeColor(ThemeColor.FeatureMapBaseColor) |
| 27 | entropyColor = binaryninjaui.getThemeColor(ThemeColor.BlueStandardHighlightColor) |
| 28 | color = binaryninjaui.mixColor(baseColor, entropyColor, v) |
| 29 | self.image.setPixelColor(i, 0, color) |
| 30 | self.updated = True |
| 31 | |
| 32 | |
| 33 | class EntropyWidget(QWidget): |