Handles the breakpoint event on entry of the function. @type event: L{ExceptionEvent} @param event: Breakpoint hit event. @raise WindowsError: An error occured.
(self, event)
| 1166 | # out of those, we need to fall back to this method when needed. |
| 1167 | |
| 1168 | def __call__(self, event): |
| 1169 | """ |
| 1170 | Handles the breakpoint event on entry of the function. |
| 1171 | |
| 1172 | @type event: L{ExceptionEvent} |
| 1173 | @param event: Breakpoint hit event. |
| 1174 | |
| 1175 | @raise WindowsError: An error occured. |
| 1176 | """ |
| 1177 | debug = event.debug |
| 1178 | |
| 1179 | dwProcessId = event.get_pid() |
| 1180 | dwThreadId = event.get_tid() |
| 1181 | aProcess = event.get_process() |
| 1182 | aThread = event.get_thread() |
| 1183 | |
| 1184 | # Get the return address and function arguments. |
| 1185 | ra = self._get_return_address(aProcess, aThread) |
| 1186 | params = self._get_function_arguments(aProcess, aThread) |
| 1187 | |
| 1188 | # Keep the function arguments for later use. |
| 1189 | self.__push_params(dwThreadId, params) |
| 1190 | |
| 1191 | # If we need to hook the return from the function... |
| 1192 | bHookedReturn = False |
| 1193 | if ra is not None and self.__postCB is not None: |
| 1194 | # Try to set a one shot hardware breakpoint at the return address. |
| 1195 | useHardwareBreakpoints = self.useHardwareBreakpoints |
| 1196 | if useHardwareBreakpoints: |
| 1197 | try: |
| 1198 | debug.define_hardware_breakpoint( |
| 1199 | dwThreadId, ra, event.debug.BP_BREAK_ON_EXECUTION, event.debug.BP_WATCH_BYTE, True, self.__postCallAction_hwbp |
| 1200 | ) |
| 1201 | debug.enable_one_shot_hardware_breakpoint(dwThreadId, ra) |
| 1202 | bHookedReturn = True |
| 1203 | except Exception: |
| 1204 | e = sys.exc_info()[1] |
| 1205 | useHardwareBreakpoints = False |
| 1206 | msg = "Failed to set hardware breakpoint at address %s for thread ID %d" |
| 1207 | msg = msg % (HexDump.address(ra), dwThreadId) |
| 1208 | warnings.warn(msg, BreakpointWarning) |
| 1209 | |
| 1210 | # If not possible, set a code breakpoint instead. |
| 1211 | if not useHardwareBreakpoints: |
| 1212 | try: |
| 1213 | debug.break_at(dwProcessId, ra, self.__postCallAction_codebp) |
| 1214 | bHookedReturn = True |
| 1215 | except Exception: |
| 1216 | e = sys.exc_info()[1] |
| 1217 | msg = "Failed to set code breakpoint at address %s for process ID %d" |
| 1218 | msg = msg % (HexDump.address(ra), dwProcessId) |
| 1219 | warnings.warn(msg, BreakpointWarning) |
| 1220 | |
| 1221 | # Call the "pre" callback. |
| 1222 | try: |
| 1223 | self.__callHandler(self.__preCB, event, ra, *params) |
| 1224 | |
| 1225 | # If no "post" callback is defined, forget the function arguments. |
nothing calls this directly
no test coverage detected