Conversation
|
|
||
| try: | ||
| t.halt() | ||
| pass |
There was a problem hiding this comment.
Lines 11-11 refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass)
| registers = [] | ||
| register_list = ["eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", "eip"] | ||
| for reg in register_list: | ||
| registers.append((reg, thread.arch_register(reg))) | ||
| return registers | ||
| return [(reg, thread.arch_register(reg)) for reg in register_list] |
There was a problem hiding this comment.
Function get_registers refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
|
|
There was a problem hiding this comment.
Function print_registers refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| ret = t.mem(ss.ToHex() + ":" + reg("esp").ToHex(), 4) | ||
| ret = t.mem(f"{ss.ToHex()}:" + reg("esp").ToHex(), 4) |
There was a problem hiding this comment.
Function pop refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| segment = GDTEntry(t.memblock(str(base.ToUInt32() + 8 * idx.ToUInt32()) + "L", 8, 1)) | ||
| segment = GDTEntry( | ||
| t.memblock(f"{str(base.ToUInt32() + 8 * idx.ToUInt32())}L", 8, 1) | ||
| ) | ||
| limit = segment.limit | ||
| print("ESP : %s" % esp.ToHex()) | ||
| print(f"ESP : {esp.ToHex()}") | ||
| esp = esp & ~0xF | ||
| t.memdump(ss.ToHex() + ":" + esp.ToHex(), limit - esp, 1) | ||
| t.memdump(f"{ss.ToHex()}:{esp.ToHex()}", limit - esp, 1) |
There was a problem hiding this comment.
Function printStackContent refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def __init__(self, bits): | ||
| self.bits = bits | ||
| self.rpl = bits[0:1] | ||
| self.rpl = bits[:1] |
There was a problem hiding this comment.
Function Selector.__init__ refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index)
| self.base_addr.Append(bits[32:39]) | ||
| self.base_addr.Append(bits[56:63]) | ||
| self.limit = bits[0:15] | ||
| self.limit = bits[:15] |
There was a problem hiding this comment.
Function GDTEntry.__init__ refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index)
| self.offset = bits[0:15] | ||
| self.offset = bits[:15] | ||
| self.offset.Append(bits[48:63]) | ||
| self.selector = bits[16:31] | ||
| self.zero = bits[32:39] | ||
| self.type_attr = bits[40:47] | ||
| self.gate_type = self.type_attr[0:3] | ||
| self.gate_type = self.type_attr[:3] |
There was a problem hiding this comment.
Function IDTEntry.__init__ refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] [×2] (
remove-redundant-slice-index)
| segment = t.memblock(str(base.ToUInt32() + 8 * i) + "L", 8, 1) | ||
| if name == "IDT": | ||
| entry = IDTEntry(segment) | ||
| else: | ||
| entry = GDTEntry(segment) | ||
| segment = t.memblock(f"{str(base.ToUInt32() + 8 * i)}L", 8, 1) | ||
| entry = IDTEntry(segment) if name == "IDT" else GDTEntry(segment) | ||
| if entry.pr: | ||
| print("**** %s Entry %d ****" % (name, i)) | ||
| print("%s" % str(entry)) | ||
| print(f"{str(entry)}") |
There was a problem hiding this comment.
Function print_segment refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Replace if statement with if expression (
assign-if-exp) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| segment = t.memblock(str(base.ToUInt32() + 8 * idx) + "L", 8, 1) | ||
| segment = t.memblock(f"{str(base.ToUInt32() + 8 * idx)}L", 8, 1) | ||
| entry = GDTEntry(segment) | ||
| if addr < entry.limit: | ||
| return entry.base_addr + addr | ||
| else: | ||
| return None | ||
| return entry.base_addr + addr if addr < entry.limit else None |
There was a problem hiding this comment.
Function segment_addr_to_linear refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Replace if statement with if expression (
assign-if-exp)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run:Help us improve this pull request!