Opening files with Pydbg while application is running

1.5k Views Asked by At

Using pydbg I'm opening files(ex. c:\\myfile.mnp) within a win32 application(Ex. c:\\myprog.exe) in this way.

  dbg = pydbg()
  dbg.load("c:\\myprog.exe", "c:\\myfile1.mnp") 

If the target application is already running then, is it possible to open a another file(For example c:\myfile2.mnp ) within the same application which is already running without closing that process/apps, using pydbg?

1

There are 1 best solutions below

1
b0nnie On

From personal experience, its better to have python start the application, or attach to it while its running.

import pydbg
from pydbg import *
from pydbg.defines import *
import struct
import utils
dbg = pydbg()
pid = ''
name = ''
found_program = False

for (pid, name) in dbg.enumerate_processes():
    if name.lower() == "program.exe":
        found_program = True
        dbg.attach(pid)

if found_program:  
 dbg.run()

To make python start it:

from os import system
system('start "c:\program.exe"')