Attaches to an existing process for debugging. @see: L{detach}, L{execv}, L{execl} @type dwProcessId: int @param dwProcessId: Global ID of a process to attach to. @rtype: L{Process} @return: A new Process object. Normally you don't need to use it
(self, dwProcessId)
| 211 | pass |
| 212 | |
| 213 | def attach(self, dwProcessId): |
| 214 | """ |
| 215 | Attaches to an existing process for debugging. |
| 216 | |
| 217 | @see: L{detach}, L{execv}, L{execl} |
| 218 | |
| 219 | @type dwProcessId: int |
| 220 | @param dwProcessId: Global ID of a process to attach to. |
| 221 | |
| 222 | @rtype: L{Process} |
| 223 | @return: A new Process object. Normally you don't need to use it now, |
| 224 | it's best to interact with the process from the event handler. |
| 225 | |
| 226 | @raise WindowsError: Raises an exception on error. |
| 227 | Depending on the circumstances, the debugger may or may not have |
| 228 | attached to the target process. |
| 229 | """ |
| 230 | |
| 231 | # Get the Process object from the snapshot, |
| 232 | # if missing create a new one. |
| 233 | try: |
| 234 | aProcess = self.system.get_process(dwProcessId) |
| 235 | except KeyError: |
| 236 | aProcess = Process(dwProcessId) |
| 237 | |
| 238 | # Warn when mixing 32 and 64 bits. |
| 239 | # This also allows the user to stop attaching altogether, |
| 240 | # depending on how the warnings are configured. |
| 241 | if System.bits != aProcess.get_bits(): |
| 242 | msg = "Mixture of 32 and 64 bits is considered experimental. Use at your own risk!" |
| 243 | warnings.warn(msg, MixedBitsWarning) |
| 244 | |
| 245 | # Attach to the process. |
| 246 | win32.DebugActiveProcess(dwProcessId) |
| 247 | |
| 248 | # Add the new PID to the set of debugees. |
| 249 | self.__attachedDebugees.add(dwProcessId) |
| 250 | |
| 251 | # Match the system kill-on-exit flag to our own. |
| 252 | self.__setSystemKillOnExitMode() |
| 253 | |
| 254 | # If the Process object was not in the snapshot, add it now. |
| 255 | if not self.system.has_process(dwProcessId): |
| 256 | self.system._add_process(aProcess) |
| 257 | |
| 258 | # Scan the process threads and loaded modules. |
| 259 | # This is prefered because the thread and library events do not |
| 260 | # properly give some information, like the filename for each module. |
| 261 | aProcess.scan_threads() |
| 262 | aProcess.scan_modules() |
| 263 | |
| 264 | # Return the Process object, like the execv() and execl() methods. |
| 265 | return aProcess |
| 266 | |
| 267 | def execv(self, argv, **kwargs): |
| 268 | """ |
no test coverage detected