fork download
  1. from ctypes import*
  2. from my_debugger_defines import*
  3.  
  4. kernel32 = windll.kernel32
  5.  
  6. class debugger():
  7. def __init__(self):
  8. pass
  9. def load(self,path_to_exe):
  10. #dwCreationFlagsにより
  11. #プロセスをどのように生成するかが決まる
  12. creation_flags =DEBUG_PROCESS
  13.  
  14. #構造体をインスタンス化
  15. startupinfo = STARTUPINFO()
  16. process_information = PROCESS_INFORMATION()
  17.  
  18. #次の2つのおぷしょんにより、起動されたプロセスは
  19. #別ウィンドウとして表示される
  20. #STARTUPINFO構造体における設定がデバッグ対象に
  21. #影響を及ぼす例でもある 何言ってるかさっぱりw
  22. startupinfo.dwFlags = 0x1
  23. startupinfo.wShowWindw = 0x0
  24.  
  25. #STARTUPINFO構造体のサイズを表示する変数cbを初期化
  26. startupinfo.cb = sizeof(startupinfo)
  27.  
  28. if kernel32.CreateProcessA(path_to_exe),
  29. None,
  30. None,
  31. None,
  32. None,
  33. creation_flags,
  34. None,
  35. None,
  36. byref(startupinfo),
  37. byref(process_information)):
  38. print "[*] We have successfully launched the process!"
  39. print "[*] PID: %d " % process_information.dwProcessId
  40. else:
  41. print "[*] Error: 0x%08x. " kernel32.GetLastError()
  42.  
  43.  
Runtime error #stdin #stdout 0.08s 10840KB
stdin
Standard input is empty
stdout
Standard output is empty