Changes

Jump to navigation Jump to search
3,738 bytes added ,  16:00, 13 November 2007
no edit summary
==Changelog==
<pre>
v1.05 - 13.11.2007
thx to rar for fixing dumping of files with characters in non local codepage
 
v1.04 - 10.11.2007
fix for not being able to dump files with japanese characters in the filename
<pre style="font-size: 60%;">
import wx,os,subprocesssubprocessw,sys
class mainFrame(wx.Frame):
dialog.Destroy()
self.filepath.write(path)
self.__options['scanpath'] = path.encode("cp932")
def startClick(self, event):
'''debug option to see what avdump actually get's fed'''
#self.child.info(('%s%s -ac:%s:%s %s') %(self.__options['avdump'], self.__options['param'], self.__options['user'], self.__options['pass'], self.__options['scanpath']))
subprocess.call(arg = (u'%s%s -ac:%s:%s %s') %(self.__options['avdump'], self.__options['param'], self.__options['user'], self.__options['pass'], self.__options['scanpath']) print arg subprocessw.Popen(arg)
def optionsClick(self, event):
app = App(True)
app.MainLoop()
</pre>
 
<pre style="font-size: 60%;">
import subprocess
from subprocess import call, PIPE, STDOUT, list2cmdline, mswindows, STARTF_USESTDHANDLES
import ctypes
import ctypes.wintypes
CreateProcessW = ctypes.windll.kernel32.CreateProcessW
CloseHandle = ctypes.windll.kernel32.CloseHandle
 
__all__ = ["Popen", "PIPE", "STDOUT", "call"]
 
class STARTUPINFOW(ctypes.Structure):
_fields_ = (("cb", ctypes.wintypes.DWORD), # should init to 17*4 maybe?
("lpReserved", ctypes.wintypes.LPWSTR),
("lpDesktop", ctypes.wintypes.LPWSTR),
("lpTitle", ctypes.wintypes.LPWSTR),
("dwX", ctypes.wintypes.DWORD),
("dwY", ctypes.wintypes.DWORD),
("dwXSize", ctypes.wintypes.DWORD),
("dwYSize", ctypes.wintypes.DWORD),
("dwXCountChars", ctypes.wintypes.DWORD),
("dwYCountChars", ctypes.wintypes.DWORD),
("dwFillAttribute", ctypes.wintypes.DWORD),
("dwFlags", ctypes.wintypes.DWORD),
("wShowWindow", ctypes.wintypes.WORD),
("cbReserved2", ctypes.wintypes.WORD),
("lpReserved2", ctypes.wintypes.LPSTR), # actually LPBYTE
("hStdInput", ctypes.wintypes.HANDLE),
("hStdOutput", ctypes.wintypes.HANDLE),
("hStdError", ctypes.wintypes.HANDLE))
 
class PROCESS_INFORMATION(ctypes.Structure):
_fields_ = (("hProcess", ctypes.wintypes.HANDLE),
("hThread", ctypes.wintypes.HANDLE),
("dwProcessId", ctypes.wintypes.DWORD),
("dwThreadId", ctypes.wintypes.DWORD))
 
class Popen(subprocess.Popen):
"""def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=False, shell=False,
cwd=None, env=None, universal_newlines=False,
startupinfo=None, creationflags=0):
print "BOOM"
subprocess.Popen.__init__(self, args, bufsize, executable,
stdin, stdout, stderr, preexec_fn, close_fds, shell,
cwd, env, universal_newlines, startupinfo, creationflags)"""
if mswindows:
def _execute_child(self, args, executable, preexec_fn, close_fds,
cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite):
 
if not isinstance(args, basestring):
args = list2cmdline(args)
if not isinstance(args, unicode):
subprocess.Popen._execute_child(self, args, executable,
preexec_fn, close_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell, p2cread, p2cwrite,
c2pread, c2pwrite, errread, errwrite)
return
 
default_startupinfo = STARTUPINFOW()
if startupinfo == None:
startupinfo = default_startupinfo
else:
raise NotImplementedError("Can't pass startup stuff")
if not None in (p2cread, c2pwrite, errwrite):
raise NotImplementedError("Can't pass file object bits")
startupinfo.dwFlags |= STARTF_USESTDHANDLES
startupinfo.hStdInput = p2cread #.Detatch()
startupinfo.hStdOutput = c2pwrite
startupinfo.hStdError = errwrite
 
if shell:
raise NotImplementedError("Can't pick your own shell for unicode args")
margs = ctypes.create_unicode_buffer(args)
processinfo = PROCESS_INFORMATION()
 
CreateProcessW(executable, margs,
None, None,
1,
creationflags,
env, cwd,
ctypes.byref(startupinfo), ctypes.byref(processinfo))
hp, ht, pid, tid = (processinfo.hProcess, processinfo.hThread,
processinfo.dwProcessId, processinfo.dwThreadId)
# can't wrap this as a _subprocess_handle so scuppered, need sp_handle_new()
self._handle = hp
self.pid = pid
CloseHandle(ht) # ht.Close()
 
if p2cread != None:
p2cread.Close()
if c2pwrite != None:
c2pwrite.Close()
if errwrite != None:
errwrite.Close()
</pre>
[[Category:Avdump]]

Navigation menu

MediaWiki spam blocked by CleanTalk.