Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit fea17bb

Browse files
authored
Merge pull request #17 from bruce30262/dev
Fix issues in #16
2 parents 3d59591 + 9f4bae4 commit fea17bb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

TWindbg/context.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def print_general_regs(self):
119119
reg_color = self.set_reg_color(reg_name, color_changed=color.red, color_unchanged=color.lime)
120120
pykd.dprint(reg_color(reg_str), dml=True)
121121

122-
if pykd.isValid(reg_data): # reg_data is a pointer
122+
# if reg_data is a valid virtual address and is able to be dereferenced, print it with print_ptrs(), or else just print it directly
123+
if pykd.isValid(reg_data) and ( deref_ptr(reg_data) != None ):
123124
self.print_ptrs(reg_data)
124125
else:
125126
pykd.dprintln("{:#x}".format(reg_data))
@@ -216,12 +217,15 @@ def smart_dereference(self, ptr):
216217
val = deref_ptr(ptr)
217218
if val == None: # no more dereference
218219
break
219-
elif val in ptr_values[:-1:]: # cyclic dereference
220-
ptr_values.append(val)
220+
221+
ptr_values.append(val)
222+
# Check if the newly pushed value is in ptr_values[:-1:]
223+
# If it does means there's a cyclic dereference in the current pointer chain
224+
# Otherwise the newly pushed value will become the new pointer to be dereferenced next
225+
if val in ptr_values[:-1:]:
221226
is_cyclic = True
222227
break
223228
else:
224-
ptr_values.append(val)
225229
ptr = val
226230

227231
return ptr_values, is_cyclic

0 commit comments

Comments
 (0)