id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
177,472 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
def FindWindowExW(hwndParent = None, hwndChildAfter = None, lpClassName = None, lpWindowName = None):
_FindWindowExW = windll.user32.FindWindowExW
_FindWindowExW.argtypes = [HWND, HWND, LPWSTR, LPWSTR]
_FindWindowExW.restype = HWND
hWnd = _FindWindowExW(hwndParent, hwndChildAfter, lpClassName, lpWindowName)
if not hWnd:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return hWnd | null |
177,473 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetClassNameA(hWnd):
_GetClassNameA = windll.user32.GetClassNameA
_GetClassNameA.argtypes = [HWND, LPSTR, ctypes.c_int]
_GetClassNameA.restype = ctypes.c_int
nMaxCount = 0x1000
dwCharSize = sizeof(CHAR)
while 1:
lpClassName = ctypes.create_string_buffer("", nMaxCount)
nCount = _GetClassNameA(hWnd, lpClassName, nMaxCount)
if nCount == 0:
raise ctypes.WinError()
if nCount < nMaxCount - dwCharSize:
break
nMaxCount += 0x1000
return lpClassName.value | null |
177,474 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetClassNameW(hWnd):
_GetClassNameW = windll.user32.GetClassNameW
_GetClassNameW.argtypes = [HWND, LPWSTR, ctypes.c_int]
_GetClassNameW.restype = ctypes.c_int
nMaxCount = 0x1000
dwCharSize = sizeof(WCHAR)
while 1:
lpClassName = ctypes.create_unicode_buffer(u"", nMaxCount)
nCount = _GetClassNameW(hWnd, lpClassName, nMaxCount)
if nCount == 0:
raise ctypes.WinError()
if nCount < nMaxCount - dwCharSize:
break
nMaxCount += 0x1000
return lpClassName.value | null |
177,475 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetWindowTextA(hWnd):
_GetWindowTextA = windll.user32.GetWindowTextA
_GetWindowTextA.argtypes = [HWND, LPSTR, ctypes.c_int]
_GetWindowTextA.restype = ctypes.c_int
nMaxCount = 0x1000
dwCharSize = sizeof(CHAR)
while 1:
lpString = ctypes.create_string_buffer("", nMaxCount)
nCount = _GetWindowTextA(hWnd, lpString, nMaxCount)
if nCount == 0:
raise ctypes.WinError()
if nCount < nMaxCount - dwCharSize:
break
nMaxCount += 0x1000
return lpString.value | null |
177,476 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetWindowTextW(hWnd):
_GetWindowTextW = windll.user32.GetWindowTextW
_GetWindowTextW.argtypes = [HWND, LPWSTR, ctypes.c_int]
_GetWindowTextW.restype = ctypes.c_int
nMaxCount = 0x1000
dwCharSize = sizeof(CHAR)
while 1:
lpString = ctypes.create_string_buffer("", nMaxCount)
nCount = _GetWindowTextW(hWnd, lpString, nMaxCount)
if nCount == 0:
raise ctypes.WinError()
if nCount < nMaxCount - dwCharSize:
break
nMaxCount += 0x1000
return lpString.value | null |
177,477 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def SetWindowTextA(hWnd, lpString = None):
_SetWindowTextA = windll.user32.SetWindowTextA
_SetWindowTextA.argtypes = [HWND, LPSTR]
_SetWindowTextA.restype = bool
_SetWindowTextA.errcheck = RaiseIfZero
_SetWindowTextA(hWnd, lpString) | null |
177,478 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def SetWindowTextW(hWnd, lpString = None):
_SetWindowTextW = windll.user32.SetWindowTextW
_SetWindowTextW.argtypes = [HWND, LPWSTR]
_SetWindowTextW.restype = bool
_SetWindowTextW.errcheck = RaiseIfZero
_SetWindowTextW(hWnd, lpString) | null |
177,479 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def GetWindowLongA(hWnd, nIndex = 0):
_GetWindowLongA = windll.user32.GetWindowLongA
_GetWindowLongA.argtypes = [HWND, ctypes.c_int]
_GetWindowLongA.restype = DWORD
SetLastError(ERROR_SUCCESS)
retval = _GetWindowLongA(hWnd, nIndex)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,480 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def GetWindowLongW(hWnd, nIndex = 0):
_GetWindowLongW = windll.user32.GetWindowLongW
_GetWindowLongW.argtypes = [HWND, ctypes.c_int]
_GetWindowLongW.restype = DWORD
SetLastError(ERROR_SUCCESS)
retval = _GetWindowLongW(hWnd, nIndex)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,481 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def GetWindowLongPtrA(hWnd, nIndex = 0):
_GetWindowLongPtrA = windll.user32.GetWindowLongPtrA
_GetWindowLongPtrA.argtypes = [HWND, ctypes.c_int]
_GetWindowLongPtrA.restype = SIZE_T
SetLastError(ERROR_SUCCESS)
retval = _GetWindowLongPtrA(hWnd, nIndex)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,482 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
def SetLastError(dwErrCode):
def GetWindowLongPtrW(hWnd, nIndex = 0):
_GetWindowLongPtrW = windll.user32.GetWindowLongPtrW
_GetWindowLongPtrW.argtypes = [HWND, ctypes.c_int]
_GetWindowLongPtrW.restype = DWORD
SetLastError(ERROR_SUCCESS)
retval = _GetWindowLongPtrW(hWnd, nIndex)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,483 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def SetWindowLongA(hWnd, nIndex, dwNewLong):
_SetWindowLongA = windll.user32.SetWindowLongA
_SetWindowLongA.argtypes = [HWND, ctypes.c_int, DWORD]
_SetWindowLongA.restype = DWORD
SetLastError(ERROR_SUCCESS)
retval = _SetWindowLongA(hWnd, nIndex, dwNewLong)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,484 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def SetWindowLongW(hWnd, nIndex, dwNewLong):
_SetWindowLongW = windll.user32.SetWindowLongW
_SetWindowLongW.argtypes = [HWND, ctypes.c_int, DWORD]
_SetWindowLongW.restype = DWORD
SetLastError(ERROR_SUCCESS)
retval = _SetWindowLongW(hWnd, nIndex, dwNewLong)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,485 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def SetWindowLongPtrA(hWnd, nIndex, dwNewLong):
_SetWindowLongPtrA = windll.user32.SetWindowLongPtrA
_SetWindowLongPtrA.argtypes = [HWND, ctypes.c_int, SIZE_T]
_SetWindowLongPtrA.restype = SIZE_T
SetLastError(ERROR_SUCCESS)
retval = _SetWindowLongPtrA(hWnd, nIndex, dwNewLong)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,486 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def SetWindowLongPtrW(hWnd, nIndex, dwNewLong):
_SetWindowLongPtrW = windll.user32.SetWindowLongPtrW
_SetWindowLongPtrW.argtypes = [HWND, ctypes.c_int, SIZE_T]
_SetWindowLongPtrW.restype = SIZE_T
SetLastError(ERROR_SUCCESS)
retval = _SetWindowLongPtrW(hWnd, nIndex, dwNewLong)
if retval == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
return retval | null |
177,487 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetShellWindow():
_GetShellWindow = windll.user32.GetShellWindow
_GetShellWindow.argtypes = []
_GetShellWindow.restype = HWND
_GetShellWindow.errcheck = RaiseIfZero
return _GetShellWindow() | null |
177,488 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetWindowThreadProcessId(hWnd):
_GetWindowThreadProcessId = windll.user32.GetWindowThreadProcessId
_GetWindowThreadProcessId.argtypes = [HWND, LPDWORD]
_GetWindowThreadProcessId.restype = DWORD
_GetWindowThreadProcessId.errcheck = RaiseIfZero
dwProcessId = DWORD(0)
dwThreadId = _GetWindowThreadProcessId(hWnd, byref(dwProcessId))
return (dwThreadId, dwProcessId.value) | null |
177,489 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def GetWindow(hWnd, uCmd):
_GetWindow = windll.user32.GetWindow
_GetWindow.argtypes = [HWND, UINT]
_GetWindow.restype = HWND
SetLastError(ERROR_SUCCESS)
hWndTarget = _GetWindow(hWnd, uCmd)
if not hWndTarget:
winerr = GetLastError()
if winerr != ERROR_SUCCESS:
raise ctypes.WinError(winerr)
return hWndTarget | null |
177,490 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def GetParent(hWnd):
_GetParent = windll.user32.GetParent
_GetParent.argtypes = [HWND]
_GetParent.restype = HWND
SetLastError(ERROR_SUCCESS)
hWndParent = _GetParent(hWnd)
if not hWndParent:
winerr = GetLastError()
if winerr != ERROR_SUCCESS:
raise ctypes.WinError(winerr)
return hWndParent | null |
177,491 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
GA_PARENT = 1
def GetLastError():
def SetLastError(dwErrCode):
def GetAncestor(hWnd, gaFlags = GA_PARENT):
_GetAncestor = windll.user32.GetAncestor
_GetAncestor.argtypes = [HWND, UINT]
_GetAncestor.restype = HWND
SetLastError(ERROR_SUCCESS)
hWndParent = _GetAncestor(hWnd, gaFlags)
if not hWndParent:
winerr = GetLastError()
if winerr != ERROR_SUCCESS:
raise ctypes.WinError(winerr)
return hWndParent | null |
177,492 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def EnableWindow(hWnd, bEnable = True):
_EnableWindow = windll.user32.EnableWindow
_EnableWindow.argtypes = [HWND, BOOL]
_EnableWindow.restype = bool
return _EnableWindow(hWnd, bool(bEnable)) | null |
177,493 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
SW_SHOW = 5
def ShowWindow(hWnd, nCmdShow = SW_SHOW):
_ShowWindow = windll.user32.ShowWindow
_ShowWindow.argtypes = [HWND, ctypes.c_int]
_ShowWindow.restype = bool
return _ShowWindow(hWnd, nCmdShow) | null |
177,494 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
SW_SHOW = 5
def ShowWindowAsync(hWnd, nCmdShow = SW_SHOW):
_ShowWindowAsync = windll.user32.ShowWindowAsync
_ShowWindowAsync.argtypes = [HWND, ctypes.c_int]
_ShowWindowAsync.restype = bool
return _ShowWindowAsync(hWnd, nCmdShow) | null |
177,495 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetDesktopWindow():
_GetDesktopWindow = windll.user32.GetDesktopWindow
_GetDesktopWindow.argtypes = []
_GetDesktopWindow.restype = HWND
_GetDesktopWindow.errcheck = RaiseIfZero
return _GetDesktopWindow() | null |
177,496 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetForegroundWindow():
_GetForegroundWindow = windll.user32.GetForegroundWindow
_GetForegroundWindow.argtypes = []
_GetForegroundWindow.restype = HWND
_GetForegroundWindow.errcheck = RaiseIfZero
return _GetForegroundWindow() | null |
177,497 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsWindow(hWnd):
_IsWindow = windll.user32.IsWindow
_IsWindow.argtypes = [HWND]
_IsWindow.restype = bool
return _IsWindow(hWnd) | null |
177,498 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsWindowVisible(hWnd):
_IsWindowVisible = windll.user32.IsWindowVisible
_IsWindowVisible.argtypes = [HWND]
_IsWindowVisible.restype = bool
return _IsWindowVisible(hWnd) | null |
177,499 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsWindowEnabled(hWnd):
_IsWindowEnabled = windll.user32.IsWindowEnabled
_IsWindowEnabled.argtypes = [HWND]
_IsWindowEnabled.restype = bool
return _IsWindowEnabled(hWnd) | null |
177,500 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsZoomed(hWnd):
_IsZoomed = windll.user32.IsZoomed
_IsZoomed.argtypes = [HWND]
_IsZoomed.restype = bool
return _IsZoomed(hWnd) | null |
177,501 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsIconic(hWnd):
_IsIconic = windll.user32.IsIconic
_IsIconic.argtypes = [HWND]
_IsIconic.restype = bool
return _IsIconic(hWnd) | null |
177,502 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def IsChild(hWnd):
_IsChild = windll.user32.IsChild
_IsChild.argtypes = [HWND]
_IsChild.restype = bool
return _IsChild(hWnd) | null |
177,503 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
def WindowFromPoint(point):
_WindowFromPoint = windll.user32.WindowFromPoint
_WindowFromPoint.argtypes = [POINT]
_WindowFromPoint.restype = HWND
_WindowFromPoint.errcheck = RaiseIfZero
if isinstance(point, tuple):
point = POINT(*point)
return _WindowFromPoint(point) | null |
177,504 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
def ChildWindowFromPoint(hWndParent, point):
_ChildWindowFromPoint = windll.user32.ChildWindowFromPoint
_ChildWindowFromPoint.argtypes = [HWND, POINT]
_ChildWindowFromPoint.restype = HWND
_ChildWindowFromPoint.errcheck = RaiseIfZero
if isinstance(point, tuple):
point = POINT(*point)
return _ChildWindowFromPoint(hWndParent, point) | null |
177,505 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
def RealChildWindowFromPoint(hWndParent, ptParentClientCoords):
_RealChildWindowFromPoint = windll.user32.RealChildWindowFromPoint
_RealChildWindowFromPoint.argtypes = [HWND, POINT]
_RealChildWindowFromPoint.restype = HWND
_RealChildWindowFromPoint.errcheck = RaiseIfZero
if isinstance(ptParentClientCoords, tuple):
ptParentClientCoords = POINT(*ptParentClientCoords)
return _RealChildWindowFromPoint(hWndParent, ptParentClientCoords) | null |
177,506 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class Point(object):
def __init__(self, x = 0, y = 0):
def __iter__(self):
def __len__(self):
def __getitem__(self, index):
def __setitem__(self, index, value):
def _as_parameter_(self):
def screen_to_client(self, hWnd):
def client_to_screen(self, hWnd):
def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
class POINT(Structure):
LPPOINT = PPOINT
def ScreenToClient(hWnd, lpPoint):
_ScreenToClient = windll.user32.ScreenToClient
_ScreenToClient.argtypes = [HWND, LPPOINT]
_ScreenToClient.restype = bool
_ScreenToClient.errcheck = RaiseIfZero
if isinstance(lpPoint, tuple):
lpPoint = POINT(*lpPoint)
else:
lpPoint = POINT(lpPoint.x, lpPoint.y)
_ScreenToClient(hWnd, byref(lpPoint))
return Point(lpPoint.x, lpPoint.y) | null |
177,507 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class Point(object):
"""
Python wrapper over the L{POINT} class.
"""
def __init__(self, x = 0, y = 0):
"""
"""
self.x = x
self.y = y
def __iter__(self):
return (self.x, self.y).__iter__()
def __len__(self):
return 2
def __getitem__(self, index):
return (self.x, self.y) [index]
def __setitem__(self, index, value):
if index == 0:
self.x = value
elif index == 1:
self.y = value
else:
raise IndexError("index out of range")
def _as_parameter_(self):
"""
Compatibility with ctypes.
Allows passing transparently a Point object to an API call.
"""
return POINT(self.x, self.y)
def screen_to_client(self, hWnd):
"""
Translates window screen coordinates to client coordinates.
"""
return ScreenToClient(hWnd, self)
def client_to_screen(self, hWnd):
"""
Translates window client coordinates to screen coordinates.
"""
return ClientToScreen(hWnd, self)
def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
"""
Translate coordinates from one window to another.
L{MapWindowPoints} function instead.
Use C{HWND_DESKTOP} for screen coordinates.
Use C{HWND_DESKTOP} for screen coordinates.
"""
return MapWindowPoints(hWndFrom, hWndTo, [self])
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
LPPOINT = PPOINT
def ClientToScreen(hWnd, lpPoint):
_ClientToScreen = windll.user32.ClientToScreen
_ClientToScreen.argtypes = [HWND, LPPOINT]
_ClientToScreen.restype = bool
_ClientToScreen.errcheck = RaiseIfZero
if isinstance(lpPoint, tuple):
lpPoint = POINT(*lpPoint)
else:
lpPoint = POINT(lpPoint.x, lpPoint.y)
_ClientToScreen(hWnd, byref(lpPoint))
return Point(lpPoint.x, lpPoint.y) | null |
177,508 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class Point(object):
"""
Python wrapper over the L{POINT} class.
"""
def __init__(self, x = 0, y = 0):
"""
"""
self.x = x
self.y = y
def __iter__(self):
return (self.x, self.y).__iter__()
def __len__(self):
return 2
def __getitem__(self, index):
return (self.x, self.y) [index]
def __setitem__(self, index, value):
if index == 0:
self.x = value
elif index == 1:
self.y = value
else:
raise IndexError("index out of range")
def _as_parameter_(self):
"""
Compatibility with ctypes.
Allows passing transparently a Point object to an API call.
"""
return POINT(self.x, self.y)
def screen_to_client(self, hWnd):
"""
Translates window screen coordinates to client coordinates.
"""
return ScreenToClient(hWnd, self)
def client_to_screen(self, hWnd):
"""
Translates window client coordinates to screen coordinates.
"""
return ClientToScreen(hWnd, self)
def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
"""
Translate coordinates from one window to another.
L{MapWindowPoints} function instead.
Use C{HWND_DESKTOP} for screen coordinates.
Use C{HWND_DESKTOP} for screen coordinates.
"""
return MapWindowPoints(hWndFrom, hWndTo, [self])
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
LPPOINT = PPOINT
def MapWindowPoints(hWndFrom, hWndTo, lpPoints):
_MapWindowPoints = windll.user32.MapWindowPoints
_MapWindowPoints.argtypes = [HWND, HWND, LPPOINT, UINT]
_MapWindowPoints.restype = ctypes.c_int
cPoints = len(lpPoints)
lpPoints = (POINT * cPoints)(* lpPoints)
SetLastError(ERROR_SUCCESS)
number = _MapWindowPoints(hWndFrom, hWndTo, byref(lpPoints), cPoints)
if number == 0:
errcode = GetLastError()
if errcode != ERROR_SUCCESS:
raise ctypes.WinError(errcode)
x_delta = number & 0xFFFF
y_delta = (number >> 16) & 0xFFFF
return x_delta, y_delta, [ (Point.x, Point.y) for Point in lpPoints ] | null |
177,509 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def SetForegroundWindow(hWnd):
_SetForegroundWindow = windll.user32.SetForegroundWindow
_SetForegroundWindow.argtypes = [HWND]
_SetForegroundWindow.restype = bool
_SetForegroundWindow.errcheck = RaiseIfZero
return _SetForegroundWindow(hWnd) | null |
177,510 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class WINDOWPLACEMENT(Structure):
PWINDOWPLACEMENT = POINTER(WINDOWPLACEMENT)
class WindowPlacement(object):
def __init__(self, wp = None):
def _as_parameter_(self):
def GetWindowPlacement(hWnd):
_GetWindowPlacement = windll.user32.GetWindowPlacement
_GetWindowPlacement.argtypes = [HWND, PWINDOWPLACEMENT]
_GetWindowPlacement.restype = bool
_GetWindowPlacement.errcheck = RaiseIfZero
lpwndpl = WINDOWPLACEMENT()
lpwndpl.length = sizeof(lpwndpl)
_GetWindowPlacement(hWnd, byref(lpwndpl))
return WindowPlacement(lpwndpl) | null |
177,511 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class WINDOWPLACEMENT(Structure):
_fields_ = [
('length', UINT),
('flags', UINT),
('showCmd', UINT),
('ptMinPosition', POINT),
('ptMaxPosition', POINT),
('rcNormalPosition', RECT),
]
PWINDOWPLACEMENT = POINTER(WINDOWPLACEMENT)
def SetWindowPlacement(hWnd, lpwndpl):
_SetWindowPlacement = windll.user32.SetWindowPlacement
_SetWindowPlacement.argtypes = [HWND, PWINDOWPLACEMENT]
_SetWindowPlacement.restype = bool
_SetWindowPlacement.errcheck = RaiseIfZero
if isinstance(lpwndpl, WINDOWPLACEMENT):
lpwndpl.length = sizeof(lpwndpl)
_SetWindowPlacement(hWnd, byref(lpwndpl)) | null |
177,512 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class Rect(object):
def __init__(self, left = 0, top = 0, right = 0, bottom = 0):
def __iter__(self):
def __len__(self):
def __getitem__(self, index):
def __setitem__(self, index, value):
def _as_parameter_(self):
def __get_width(self):
def __get_height(self):
def __set_width(self, value):
def __set_height(self, value):
def screen_to_client(self, hWnd):
def client_to_screen(self, hWnd):
def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
class RECT(Structure):
LPRECT = PRECT
def GetWindowRect(hWnd):
_GetWindowRect = windll.user32.GetWindowRect
_GetWindowRect.argtypes = [HWND, LPRECT]
_GetWindowRect.restype = bool
_GetWindowRect.errcheck = RaiseIfZero
lpRect = RECT()
_GetWindowRect(hWnd, byref(lpRect))
return Rect(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom) | null |
177,513 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class Rect(object):
"""
Python wrapper over the L{RECT} class.
"""
def __init__(self, left = 0, top = 0, right = 0, bottom = 0):
"""
"""
self.left = left
self.top = top
self.right = right
self.bottom = bottom
def __iter__(self):
return (self.left, self.top, self.right, self.bottom).__iter__()
def __len__(self):
return 2
def __getitem__(self, index):
return (self.left, self.top, self.right, self.bottom) [index]
def __setitem__(self, index, value):
if index == 0:
self.left = value
elif index == 1:
self.top = value
elif index == 2:
self.right = value
elif index == 3:
self.bottom = value
else:
raise IndexError("index out of range")
def _as_parameter_(self):
"""
Compatibility with ctypes.
Allows passing transparently a Point object to an API call.
"""
return RECT(self.left, self.top, self.right, self.bottom)
def __get_width(self):
return self.right - self.left
def __get_height(self):
return self.bottom - self.top
def __set_width(self, value):
self.right = value - self.left
def __set_height(self, value):
self.bottom = value - self.top
width = property(__get_width, __set_width)
height = property(__get_height, __set_height)
def screen_to_client(self, hWnd):
"""
Translates window screen coordinates to client coordinates.
"""
topleft = ScreenToClient(hWnd, (self.left, self.top))
bottomright = ScreenToClient(hWnd, (self.bottom, self.right))
return Rect( topleft.x, topleft.y, bottomright.x, bottomright.y )
def client_to_screen(self, hWnd):
"""
Translates window client coordinates to screen coordinates.
"""
topleft = ClientToScreen(hWnd, (self.left, self.top))
bottomright = ClientToScreen(hWnd, (self.bottom, self.right))
return Rect( topleft.x, topleft.y, bottomright.x, bottomright.y )
def translate(self, hWndFrom = HWND_DESKTOP, hWndTo = HWND_DESKTOP):
"""
Translate coordinates from one window to another.
Use C{HWND_DESKTOP} for screen coordinates.
Use C{HWND_DESKTOP} for screen coordinates.
"""
points = [ (self.left, self.top), (self.right, self.bottom) ]
return MapWindowPoints(hWndFrom, hWndTo, points)
class RECT(Structure):
_fields_ = [
('left', LONG),
('top', LONG),
('right', LONG),
('bottom', LONG),
]
LPRECT = PRECT
def GetClientRect(hWnd):
_GetClientRect = windll.user32.GetClientRect
_GetClientRect.argtypes = [HWND, LPRECT]
_GetClientRect.restype = bool
_GetClientRect.errcheck = RaiseIfZero
lpRect = RECT()
_GetClientRect(hWnd, byref(lpRect))
return Rect(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom) | null |
177,514 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint = True):
_MoveWindow = windll.user32.MoveWindow
_MoveWindow.argtypes = [HWND, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, BOOL]
_MoveWindow.restype = bool
_MoveWindow.errcheck = RaiseIfZero
_MoveWindow(hWnd, X, Y, nWidth, nHeight, bool(bRepaint)) | null |
177,515 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
class GUITHREADINFO(Structure):
LPGUITHREADINFO = PGUITHREADINFO
def GetGUIThreadInfo(idThread):
_GetGUIThreadInfo = windll.user32.GetGUIThreadInfo
_GetGUIThreadInfo.argtypes = [DWORD, LPGUITHREADINFO]
_GetGUIThreadInfo.restype = bool
_GetGUIThreadInfo.errcheck = RaiseIfZero
gui = GUITHREADINFO()
_GetGUIThreadInfo(idThread, byref(gui))
return gui | null |
177,516 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
WNDENUMPROC = WINFUNCTYPE(BOOL, HWND, PVOID)
class __EnumWndProc (__WindowEnumerator):
def GetLastError():
def EnumWindows():
_EnumWindows = windll.user32.EnumWindows
_EnumWindows.argtypes = [WNDENUMPROC, LPARAM]
_EnumWindows.restype = bool
EnumFunc = __EnumWndProc()
lpEnumFunc = WNDENUMPROC(EnumFunc)
if not _EnumWindows(lpEnumFunc, NULL):
errcode = GetLastError()
if errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS):
raise ctypes.WinError(errcode)
return EnumFunc.hwnd | null |
177,517 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
WNDENUMPROC = WINFUNCTYPE(BOOL, HWND, PVOID)
class __EnumThreadWndProc (__WindowEnumerator):
pass
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def EnumThreadWindows(dwThreadId):
_EnumThreadWindows = windll.user32.EnumThreadWindows
_EnumThreadWindows.argtypes = [DWORD, WNDENUMPROC, LPARAM]
_EnumThreadWindows.restype = bool
fn = __EnumThreadWndProc()
lpfn = WNDENUMPROC(fn)
if not _EnumThreadWindows(dwThreadId, lpfn, NULL):
errcode = GetLastError()
if errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS):
raise ctypes.WinError(errcode)
return fn.hwnd | null |
177,518 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
WNDENUMPROC = WINFUNCTYPE(BOOL, HWND, PVOID)
class __EnumChildProc (__WindowEnumerator):
pass
def GetLastError():
_GetLastError = windll.kernel32.GetLastError
_GetLastError.argtypes = []
_GetLastError.restype = DWORD
return _GetLastError()
def SetLastError(dwErrCode):
_SetLastError = windll.kernel32.SetLastError
_SetLastError.argtypes = [DWORD]
_SetLastError.restype = None
_SetLastError(dwErrCode)
def EnumChildWindows(hWndParent = NULL):
_EnumChildWindows = windll.user32.EnumChildWindows
_EnumChildWindows.argtypes = [HWND, WNDENUMPROC, LPARAM]
_EnumChildWindows.restype = bool
EnumFunc = __EnumChildProc()
lpEnumFunc = WNDENUMPROC(EnumFunc)
SetLastError(ERROR_SUCCESS)
_EnumChildWindows(hWndParent, lpEnumFunc, NULL)
errcode = GetLastError()
if errcode != ERROR_SUCCESS and errcode not in (ERROR_NO_MORE_FILES, ERROR_SUCCESS):
raise ctypes.WinError(errcode)
return EnumFunc.hwnd | null |
177,519 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def SendMessageA(hWnd, Msg, wParam = 0, lParam = 0):
_SendMessageA = windll.user32.SendMessageA
_SendMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM]
_SendMessageA.restype = LRESULT
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
return _SendMessageA(hWnd, Msg, wParam, lParam) | null |
177,520 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
def MAKE_LPARAM(lParam):
def SendMessageW(hWnd, Msg, wParam = 0, lParam = 0):
_SendMessageW = windll.user32.SendMessageW
_SendMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM]
_SendMessageW.restype = LRESULT
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
return _SendMessageW(hWnd, Msg, wParam, lParam) | null |
177,521 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
def MAKE_LPARAM(lParam):
def PostMessageA(hWnd, Msg, wParam = 0, lParam = 0):
_PostMessageA = windll.user32.PostMessageA
_PostMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM]
_PostMessageA.restype = bool
_PostMessageA.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_PostMessageA(hWnd, Msg, wParam, lParam) | null |
177,522 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def PostMessageW(hWnd, Msg, wParam = 0, lParam = 0):
_PostMessageW = windll.user32.PostMessageW
_PostMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM]
_PostMessageW.restype = bool
_PostMessageW.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_PostMessageW(hWnd, Msg, wParam, lParam) | null |
177,523 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
def MAKE_LPARAM(lParam):
def PostThreadMessageA(idThread, Msg, wParam = 0, lParam = 0):
_PostThreadMessageA = windll.user32.PostThreadMessageA
_PostThreadMessageA.argtypes = [DWORD, UINT, WPARAM, LPARAM]
_PostThreadMessageA.restype = bool
_PostThreadMessageA.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_PostThreadMessageA(idThread, Msg, wParam, lParam) | null |
177,524 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def PostThreadMessageW(idThread, Msg, wParam = 0, lParam = 0):
_PostThreadMessageW = windll.user32.PostThreadMessageW
_PostThreadMessageW.argtypes = [DWORD, UINT, WPARAM, LPARAM]
_PostThreadMessageW.restype = bool
_PostThreadMessageW.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_PostThreadMessageW(idThread, Msg, wParam, lParam) | null |
177,525 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
def MAKE_LPARAM(lParam):
def SendMessageTimeoutA(hWnd, Msg, wParam = 0, lParam = 0, fuFlags = 0, uTimeout = 0):
_SendMessageTimeoutA = windll.user32.SendMessageTimeoutA
_SendMessageTimeoutA.argtypes = [HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR]
_SendMessageTimeoutA.restype = LRESULT
_SendMessageTimeoutA.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
dwResult = DWORD(0)
_SendMessageTimeoutA(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, byref(dwResult))
return dwResult.value | null |
177,526 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def SendMessageTimeoutW(hWnd, Msg, wParam = 0, lParam = 0):
_SendMessageTimeoutW = windll.user32.SendMessageTimeoutW
_SendMessageTimeoutW.argtypes = [HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR]
_SendMessageTimeoutW.restype = LRESULT
_SendMessageTimeoutW.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
dwResult = DWORD(0)
_SendMessageTimeoutW(hWnd, Msg, wParam, lParam, fuFlags, uTimeout, byref(dwResult))
return dwResult.value | null |
177,527 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
def MAKE_LPARAM(lParam):
def SendNotifyMessageA(hWnd, Msg, wParam = 0, lParam = 0):
_SendNotifyMessageA = windll.user32.SendNotifyMessageA
_SendNotifyMessageA.argtypes = [HWND, UINT, WPARAM, LPARAM]
_SendNotifyMessageA.restype = bool
_SendNotifyMessageA.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_SendNotifyMessageA(hWnd, Msg, wParam, lParam) | null |
177,528 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def SendNotifyMessageW(hWnd, Msg, wParam = 0, lParam = 0):
_SendNotifyMessageW = windll.user32.SendNotifyMessageW
_SendNotifyMessageW.argtypes = [HWND, UINT, WPARAM, LPARAM]
_SendNotifyMessageW.restype = bool
_SendNotifyMessageW.errcheck = RaiseIfZero
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
_SendNotifyMessageW(hWnd, Msg, wParam, lParam) | null |
177,529 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def SendDlgItemMessageA(hDlg, nIDDlgItem, Msg, wParam = 0, lParam = 0):
_SendDlgItemMessageA = windll.user32.SendDlgItemMessageA
_SendDlgItemMessageA.argtypes = [HWND, ctypes.c_int, UINT, WPARAM, LPARAM]
_SendDlgItemMessageA.restype = LRESULT
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
return _SendDlgItemMessageA(hDlg, nIDDlgItem, Msg, wParam, lParam) | null |
177,530 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def MAKE_WPARAM(wParam):
"""
Convert arguments to the WPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
wParam = ctypes.cast(wParam, LPVOID).value
if wParam is None:
wParam = 0
return wParam
def MAKE_LPARAM(lParam):
"""
Convert arguments to the LPARAM type.
Used automatically by SendMessage, PostMessage, etc.
You shouldn't need to call this function.
"""
return ctypes.cast(lParam, LPARAM)
def SendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam = 0, lParam = 0):
_SendDlgItemMessageW = windll.user32.SendDlgItemMessageW
_SendDlgItemMessageW.argtypes = [HWND, ctypes.c_int, UINT, WPARAM, LPARAM]
_SendDlgItemMessageW.restype = LRESULT
wParam = MAKE_WPARAM(wParam)
lParam = MAKE_LPARAM(lParam)
return _SendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam, lParam) | null |
177,531 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def WaitForInputIdle(hProcess, dwMilliseconds = INFINITE):
_WaitForInputIdle = windll.user32.WaitForInputIdle
_WaitForInputIdle.argtypes = [HANDLE, DWORD]
_WaitForInputIdle.restype = DWORD
r = _WaitForInputIdle(hProcess, dwMilliseconds)
if r == WAIT_FAILED:
raise ctypes.WinError()
return r | null |
177,532 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RegisterWindowMessageA(lpString):
_RegisterWindowMessageA = windll.user32.RegisterWindowMessageA
_RegisterWindowMessageA.argtypes = [LPSTR]
_RegisterWindowMessageA.restype = UINT
_RegisterWindowMessageA.errcheck = RaiseIfZero
return _RegisterWindowMessageA(lpString) | null |
177,533 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RegisterWindowMessageW(lpString):
_RegisterWindowMessageW = windll.user32.RegisterWindowMessageW
_RegisterWindowMessageW.argtypes = [LPWSTR]
_RegisterWindowMessageW.restype = UINT
_RegisterWindowMessageW.errcheck = RaiseIfZero
return _RegisterWindowMessageW(lpString) | null |
177,534 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RegisterClipboardFormatA(lpString):
_RegisterClipboardFormatA = windll.user32.RegisterClipboardFormatA
_RegisterClipboardFormatA.argtypes = [LPSTR]
_RegisterClipboardFormatA.restype = UINT
_RegisterClipboardFormatA.errcheck = RaiseIfZero
return _RegisterClipboardFormatA(lpString) | null |
177,535 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RegisterClipboardFormatW(lpString):
_RegisterClipboardFormatW = windll.user32.RegisterClipboardFormatW
_RegisterClipboardFormatW.argtypes = [LPWSTR]
_RegisterClipboardFormatW.restype = UINT
_RegisterClipboardFormatW.errcheck = RaiseIfZero
return _RegisterClipboardFormatW(lpString) | null |
177,536 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetPropA(hWnd, lpString):
_GetPropA = windll.user32.GetPropA
_GetPropA.argtypes = [HWND, LPSTR]
_GetPropA.restype = HANDLE
return _GetPropA(hWnd, lpString) | null |
177,537 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def GetPropW(hWnd, lpString):
_GetPropW = windll.user32.GetPropW
_GetPropW.argtypes = [HWND, LPWSTR]
_GetPropW.restype = HANDLE
return _GetPropW(hWnd, lpString) | null |
177,538 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def SetPropA(hWnd, lpString, hData):
_SetPropA = windll.user32.SetPropA
_SetPropA.argtypes = [HWND, LPSTR, HANDLE]
_SetPropA.restype = BOOL
_SetPropA.errcheck = RaiseIfZero
_SetPropA(hWnd, lpString, hData) | null |
177,539 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def SetPropW(hWnd, lpString, hData):
_SetPropW = windll.user32.SetPropW
_SetPropW.argtypes = [HWND, LPWSTR, HANDLE]
_SetPropW.restype = BOOL
_SetPropW.errcheck = RaiseIfZero
_SetPropW(hWnd, lpString, hData) | null |
177,540 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RemovePropA(hWnd, lpString):
_RemovePropA = windll.user32.RemovePropA
_RemovePropA.argtypes = [HWND, LPSTR]
_RemovePropA.restype = HANDLE
return _RemovePropA(hWnd, lpString) | null |
177,541 | from winappdbg.win32.defines import *
from winappdbg.win32.version import bits
from winappdbg.win32.kernel32 import GetLastError, SetLastError
from winappdbg.win32.gdi32 import POINT, PPOINT, LPPOINT, RECT, PRECT, LPRECT
def RemovePropW(hWnd, lpString):
_RemovePropW = windll.user32.RemovePropW
_RemovePropW.argtypes = [HWND, LPWSTR]
_RemovePropW.restype = HANDLE
return _RemovePropW(hWnd, lpString) | null |
177,542 | from winappdbg.win32.defines import *
def EnumDeviceDrivers():
_EnumDeviceDrivers = windll.psapi.EnumDeviceDrivers
_EnumDeviceDrivers.argtypes = [LPVOID, DWORD, LPDWORD]
_EnumDeviceDrivers.restype = bool
_EnumDeviceDrivers.errcheck = RaiseIfZero
size = 0x1000
lpcbNeeded = DWORD(size)
unit = sizeof(LPVOID)
while 1:
lpImageBase = (LPVOID * (size // unit))()
_EnumDeviceDrivers(byref(lpImageBase), lpcbNeeded, byref(lpcbNeeded))
needed = lpcbNeeded.value
if needed <= size:
break
size = needed
return [ lpImageBase[index] for index in compat.xrange(0, (needed // unit)) ] | null |
177,543 | from winappdbg.win32.defines import *
def EnumProcesses():
_EnumProcesses = windll.psapi.EnumProcesses
_EnumProcesses.argtypes = [LPVOID, DWORD, LPDWORD]
_EnumProcesses.restype = bool
_EnumProcesses.errcheck = RaiseIfZero
size = 0x1000
cbBytesReturned = DWORD()
unit = sizeof(DWORD)
while 1:
ProcessIds = (DWORD * (size // unit))()
cbBytesReturned.value = size
_EnumProcesses(byref(ProcessIds), cbBytesReturned, byref(cbBytesReturned))
returned = cbBytesReturned.value
if returned < size:
break
size = size + 0x1000
ProcessIdList = list()
for ProcessId in ProcessIds:
if ProcessId is None:
break
ProcessIdList.append(ProcessId)
return ProcessIdList | null |
177,544 | from winappdbg.win32.defines import *
def EnumProcessModules(hProcess):
_EnumProcessModules = windll.psapi.EnumProcessModules
_EnumProcessModules.argtypes = [HANDLE, LPVOID, DWORD, LPDWORD]
_EnumProcessModules.restype = bool
_EnumProcessModules.errcheck = RaiseIfZero
size = 0x1000
lpcbNeeded = DWORD(size)
unit = sizeof(HMODULE)
while 1:
lphModule = (HMODULE * (size // unit))()
_EnumProcessModules(hProcess, byref(lphModule), lpcbNeeded, byref(lpcbNeeded))
needed = lpcbNeeded.value
if needed <= size:
break
size = needed
return [ lphModule[index] for index in compat.xrange(0, int(needed // unit)) ] | null |
177,545 | from winappdbg.win32.defines import *
LIST_MODULES_DEFAULT = 0x00
def EnumProcessModulesEx(hProcess, dwFilterFlag = LIST_MODULES_DEFAULT):
_EnumProcessModulesEx = windll.psapi.EnumProcessModulesEx
_EnumProcessModulesEx.argtypes = [HANDLE, LPVOID, DWORD, LPDWORD, DWORD]
_EnumProcessModulesEx.restype = bool
_EnumProcessModulesEx.errcheck = RaiseIfZero
size = 0x1000
lpcbNeeded = DWORD(size)
unit = sizeof(HMODULE)
while 1:
lphModule = (HMODULE * (size // unit))()
_EnumProcessModulesEx(hProcess, byref(lphModule), lpcbNeeded, byref(lpcbNeeded), dwFilterFlag)
needed = lpcbNeeded.value
if needed <= size:
break
size = needed
return [ lphModule[index] for index in compat.xrange(0, (needed // unit)) ] | null |
177,546 | from winappdbg.win32.defines import *
def GetDeviceDriverBaseNameA(ImageBase):
_GetDeviceDriverBaseNameA = windll.psapi.GetDeviceDriverBaseNameA
_GetDeviceDriverBaseNameA.argtypes = [LPVOID, LPSTR, DWORD]
_GetDeviceDriverBaseNameA.restype = DWORD
nSize = MAX_PATH
while 1:
lpBaseName = ctypes.create_string_buffer("", nSize)
nCopied = _GetDeviceDriverBaseNameA(ImageBase, lpBaseName, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpBaseName.value | null |
177,547 | from winappdbg.win32.defines import *
def GetDeviceDriverBaseNameW(ImageBase):
_GetDeviceDriverBaseNameW = windll.psapi.GetDeviceDriverBaseNameW
_GetDeviceDriverBaseNameW.argtypes = [LPVOID, LPWSTR, DWORD]
_GetDeviceDriverBaseNameW.restype = DWORD
nSize = MAX_PATH
while 1:
lpBaseName = ctypes.create_unicode_buffer(u"", nSize)
nCopied = _GetDeviceDriverBaseNameW(ImageBase, lpBaseName, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpBaseName.value | null |
177,548 | from winappdbg.win32.defines import *
def GetDeviceDriverFileNameA(ImageBase):
_GetDeviceDriverFileNameA = windll.psapi.GetDeviceDriverFileNameA
_GetDeviceDriverFileNameA.argtypes = [LPVOID, LPSTR, DWORD]
_GetDeviceDriverFileNameA.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_string_buffer("", nSize)
nCopied = ctypes.windll.psapi.GetDeviceDriverFileNameA(ImageBase, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,549 | from winappdbg.win32.defines import *
def GetDeviceDriverFileNameW(ImageBase):
_GetDeviceDriverFileNameW = windll.psapi.GetDeviceDriverFileNameW
_GetDeviceDriverFileNameW.argtypes = [LPVOID, LPWSTR, DWORD]
_GetDeviceDriverFileNameW.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_unicode_buffer(u"", nSize)
nCopied = ctypes.windll.psapi.GetDeviceDriverFileNameW(ImageBase, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,550 | from winappdbg.win32.defines import *
def GetMappedFileNameA(hProcess, lpv):
_GetMappedFileNameA = ctypes.windll.psapi.GetMappedFileNameA
_GetMappedFileNameA.argtypes = [HANDLE, LPVOID, LPSTR, DWORD]
_GetMappedFileNameA.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_string_buffer("", nSize)
nCopied = _GetMappedFileNameA(hProcess, lpv, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,551 | from winappdbg.win32.defines import *
def GetMappedFileNameW(hProcess, lpv):
_GetMappedFileNameW = ctypes.windll.psapi.GetMappedFileNameW
_GetMappedFileNameW.argtypes = [HANDLE, LPVOID, LPWSTR, DWORD]
_GetMappedFileNameW.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_unicode_buffer(u"", nSize)
nCopied = _GetMappedFileNameW(hProcess, lpv, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,552 | from winappdbg.win32.defines import *
def GetModuleFileNameExA(hProcess, hModule = None):
_GetModuleFileNameExA = ctypes.windll.psapi.GetModuleFileNameExA
_GetModuleFileNameExA.argtypes = [HANDLE, HMODULE, LPSTR, DWORD]
_GetModuleFileNameExA.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_string_buffer("", nSize)
nCopied = _GetModuleFileNameExA(hProcess, hModule, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,553 | from winappdbg.win32.defines import *
def GetModuleFileNameExW(hProcess, hModule = None):
_GetModuleFileNameExW = ctypes.windll.psapi.GetModuleFileNameExW
_GetModuleFileNameExW.argtypes = [HANDLE, HMODULE, LPWSTR, DWORD]
_GetModuleFileNameExW.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_unicode_buffer(u"", nSize)
nCopied = _GetModuleFileNameExW(hProcess, hModule, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,554 | from winappdbg.win32.defines import *
class MODULEINFO(Structure):
_fields_ = [
("lpBaseOfDll", LPVOID), # remote pointer
("SizeOfImage", DWORD),
("EntryPoint", LPVOID), # remote pointer
]
LPMODULEINFO = POINTER(MODULEINFO)
def GetModuleInformation(hProcess, hModule, lpmodinfo = None):
_GetModuleInformation = windll.psapi.GetModuleInformation
_GetModuleInformation.argtypes = [HANDLE, HMODULE, LPMODULEINFO, DWORD]
_GetModuleInformation.restype = bool
_GetModuleInformation.errcheck = RaiseIfZero
if lpmodinfo is None:
lpmodinfo = MODULEINFO()
_GetModuleInformation(hProcess, hModule, byref(lpmodinfo), sizeof(lpmodinfo))
return lpmodinfo | null |
177,555 | from winappdbg.win32.defines import *
def GetProcessImageFileNameA(hProcess):
_GetProcessImageFileNameA = windll.psapi.GetProcessImageFileNameA
_GetProcessImageFileNameA.argtypes = [HANDLE, LPSTR, DWORD]
_GetProcessImageFileNameA.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_string_buffer("", nSize)
nCopied = _GetProcessImageFileNameA(hProcess, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,556 | from winappdbg.win32.defines import *
def GetProcessImageFileNameW(hProcess):
_GetProcessImageFileNameW = windll.psapi.GetProcessImageFileNameW
_GetProcessImageFileNameW.argtypes = [HANDLE, LPWSTR, DWORD]
_GetProcessImageFileNameW.restype = DWORD
nSize = MAX_PATH
while 1:
lpFilename = ctypes.create_unicode_buffer(u"", nSize)
nCopied = _GetProcessImageFileNameW(hProcess, lpFilename, nSize)
if nCopied == 0:
raise ctypes.WinError()
if nCopied < (nSize - 1):
break
nSize = nSize + MAX_PATH
return lpFilename.value | null |
177,557 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
class LDT_ENTRY(Structure):
_pack_ = 1
_fields_ = [
('LimitLow', WORD),
('BaseLow', WORD),
('HighWord', _LDT_ENTRY_HIGHWORD_),
]
LPLDT_ENTRY = PLDT_ENTRY
def GetThreadSelectorEntry(hThread, dwSelector):
_GetThreadSelectorEntry = windll.kernel32.GetThreadSelectorEntry
_GetThreadSelectorEntry.argtypes = [HANDLE, DWORD, LPLDT_ENTRY]
_GetThreadSelectorEntry.restype = bool
_GetThreadSelectorEntry.errcheck = RaiseIfZero
ldt = LDT_ENTRY()
_GetThreadSelectorEntry(hThread, dwSelector, byref(ldt))
return ldt | null |
177,558 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
CONTEXT_AMD64 = 0x00100000
CONTEXT_ALL = (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
class CONTEXT(Structure):
arch = ARCH_AMD64
_pack_ = 16
_fields_ = [
# Register parameter home addresses.
('P1Home', DWORD64),
('P2Home', DWORD64),
('P3Home', DWORD64),
('P4Home', DWORD64),
('P5Home', DWORD64),
('P6Home', DWORD64),
# Control flags.
('ContextFlags', DWORD),
('MxCsr', DWORD),
# Segment Registers and processor flags.
('SegCs', WORD),
('SegDs', WORD),
('SegEs', WORD),
('SegFs', WORD),
('SegGs', WORD),
('SegSs', WORD),
('EFlags', DWORD),
# Debug registers.
('Dr0', DWORD64),
('Dr1', DWORD64),
('Dr2', DWORD64),
('Dr3', DWORD64),
('Dr6', DWORD64),
('Dr7', DWORD64),
# Integer registers.
('Rax', DWORD64),
('Rcx', DWORD64),
('Rdx', DWORD64),
('Rbx', DWORD64),
('Rsp', DWORD64),
('Rbp', DWORD64),
('Rsi', DWORD64),
('Rdi', DWORD64),
('R8', DWORD64),
('R9', DWORD64),
('R10', DWORD64),
('R11', DWORD64),
('R12', DWORD64),
('R13', DWORD64),
('R14', DWORD64),
('R15', DWORD64),
# Program counter.
('Rip', DWORD64),
# Floating point state.
('FltSave', _CONTEXT_FLTSAVE_UNION),
# Vector registers.
('VectorRegister', M128A * 26),
('VectorControl', DWORD64),
# Special debug control registers.
('DebugControl', DWORD64),
('LastBranchToRip', DWORD64),
('LastBranchFromRip', DWORD64),
('LastExceptionToRip', DWORD64),
('LastExceptionFromRip', DWORD64),
]
_others = ('P1Home', 'P2Home', 'P3Home', 'P4Home', 'P5Home', 'P6Home', \
'MxCsr', 'VectorRegister', 'VectorControl')
_control = ('SegSs', 'Rsp', 'SegCs', 'Rip', 'EFlags')
_integer = ('Rax', 'Rcx', 'Rdx', 'Rbx', 'Rsp', 'Rbp', 'Rsi', 'Rdi', \
'R8', 'R9', 'R10', 'R11', 'R12', 'R13', 'R14', 'R15')
_segments = ('SegDs', 'SegEs', 'SegFs', 'SegGs')
_debug = ('Dr0', 'Dr1', 'Dr2', 'Dr3', 'Dr6', 'Dr7', \
'DebugControl', 'LastBranchToRip', 'LastBranchFromRip', \
'LastExceptionToRip', 'LastExceptionFromRip')
_mmx = ('Xmm0', 'Xmm1', 'Xmm2', 'Xmm3', 'Xmm4', 'Xmm5', 'Xmm6', 'Xmm7', \
'Xmm8', 'Xmm9', 'Xmm10', 'Xmm11', 'Xmm12', 'Xmm13', 'Xmm14', 'Xmm15')
# XXX TODO
# Convert VectorRegister and Xmm0-Xmm15 to pure Python types!
def from_dict(cls, ctx):
'Instance a new structure from a Python native type.'
ctx = Context(ctx)
s = cls()
ContextFlags = ctx['ContextFlags']
s.ContextFlags = ContextFlags
for key in cls._others:
if key != 'VectorRegister':
setattr(s, key, ctx[key])
else:
w = ctx[key]
v = (M128A * len(w))()
i = 0
for x in w:
y = M128A()
y.High = x >> 64
y.Low = x - (x >> 64)
v[i] = y
i += 1
setattr(s, key, v)
if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
for key in cls._control:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
for key in cls._integer:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
for key in cls._segments:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
for key in cls._debug:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_MMX_REGISTERS) == CONTEXT_MMX_REGISTERS:
xmm = s.FltSave.xmm
for key in cls._mmx:
y = M128A()
y.High = x >> 64
y.Low = x - (x >> 64)
setattr(xmm, key, y)
return s
def to_dict(self):
'Convert a structure into a Python dictionary.'
ctx = Context()
ContextFlags = self.ContextFlags
ctx['ContextFlags'] = ContextFlags
for key in self._others:
if key != 'VectorRegister':
ctx[key] = getattr(self, key)
else:
ctx[key] = tuple([ (x.Low + (x.High << 64)) for x in getattr(self, key) ])
if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
for key in self._control:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
for key in self._integer:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
for key in self._segments:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
for key in self._debug:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_MMX_REGISTERS) == CONTEXT_MMX_REGISTERS:
xmm = self.FltSave.xmm.to_dict()
for key in self._mmx:
ctx[key] = xmm.get(key)
return ctx
LPCONTEXT = PCONTEXT
class Context(dict):
"""
Register context dictionary for the amd64 architecture.
"""
arch = CONTEXT.arch
def __get_pc(self):
return self['Rip']
def __set_pc(self, value):
self['Rip'] = value
pc = property(__get_pc, __set_pc)
def __get_sp(self):
return self['Rsp']
def __set_sp(self, value):
self['Rsp'] = value
sp = property(__get_sp, __set_sp)
def __get_fp(self):
return self['Rbp']
def __set_fp(self, value):
self['Rbp'] = value
fp = property(__get_fp, __set_fp)
def GetThreadContext(hThread, ContextFlags = None, raw = False):
_GetThreadContext = windll.kernel32.GetThreadContext
_GetThreadContext.argtypes = [HANDLE, LPCONTEXT]
_GetThreadContext.restype = bool
_GetThreadContext.errcheck = RaiseIfZero
if ContextFlags is None:
ContextFlags = CONTEXT_ALL | CONTEXT_AMD64
Context = CONTEXT()
Context.ContextFlags = ContextFlags
_GetThreadContext(hThread, byref(Context))
if raw:
return Context
return Context.to_dict() | null |
177,559 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
class CONTEXT(Structure):
arch = ARCH_AMD64
_pack_ = 16
_fields_ = [
# Register parameter home addresses.
('P1Home', DWORD64),
('P2Home', DWORD64),
('P3Home', DWORD64),
('P4Home', DWORD64),
('P5Home', DWORD64),
('P6Home', DWORD64),
# Control flags.
('ContextFlags', DWORD),
('MxCsr', DWORD),
# Segment Registers and processor flags.
('SegCs', WORD),
('SegDs', WORD),
('SegEs', WORD),
('SegFs', WORD),
('SegGs', WORD),
('SegSs', WORD),
('EFlags', DWORD),
# Debug registers.
('Dr0', DWORD64),
('Dr1', DWORD64),
('Dr2', DWORD64),
('Dr3', DWORD64),
('Dr6', DWORD64),
('Dr7', DWORD64),
# Integer registers.
('Rax', DWORD64),
('Rcx', DWORD64),
('Rdx', DWORD64),
('Rbx', DWORD64),
('Rsp', DWORD64),
('Rbp', DWORD64),
('Rsi', DWORD64),
('Rdi', DWORD64),
('R8', DWORD64),
('R9', DWORD64),
('R10', DWORD64),
('R11', DWORD64),
('R12', DWORD64),
('R13', DWORD64),
('R14', DWORD64),
('R15', DWORD64),
# Program counter.
('Rip', DWORD64),
# Floating point state.
('FltSave', _CONTEXT_FLTSAVE_UNION),
# Vector registers.
('VectorRegister', M128A * 26),
('VectorControl', DWORD64),
# Special debug control registers.
('DebugControl', DWORD64),
('LastBranchToRip', DWORD64),
('LastBranchFromRip', DWORD64),
('LastExceptionToRip', DWORD64),
('LastExceptionFromRip', DWORD64),
]
_others = ('P1Home', 'P2Home', 'P3Home', 'P4Home', 'P5Home', 'P6Home', \
'MxCsr', 'VectorRegister', 'VectorControl')
_control = ('SegSs', 'Rsp', 'SegCs', 'Rip', 'EFlags')
_integer = ('Rax', 'Rcx', 'Rdx', 'Rbx', 'Rsp', 'Rbp', 'Rsi', 'Rdi', \
'R8', 'R9', 'R10', 'R11', 'R12', 'R13', 'R14', 'R15')
_segments = ('SegDs', 'SegEs', 'SegFs', 'SegGs')
_debug = ('Dr0', 'Dr1', 'Dr2', 'Dr3', 'Dr6', 'Dr7', \
'DebugControl', 'LastBranchToRip', 'LastBranchFromRip', \
'LastExceptionToRip', 'LastExceptionFromRip')
_mmx = ('Xmm0', 'Xmm1', 'Xmm2', 'Xmm3', 'Xmm4', 'Xmm5', 'Xmm6', 'Xmm7', \
'Xmm8', 'Xmm9', 'Xmm10', 'Xmm11', 'Xmm12', 'Xmm13', 'Xmm14', 'Xmm15')
# XXX TODO
# Convert VectorRegister and Xmm0-Xmm15 to pure Python types!
def from_dict(cls, ctx):
'Instance a new structure from a Python native type.'
ctx = Context(ctx)
s = cls()
ContextFlags = ctx['ContextFlags']
s.ContextFlags = ContextFlags
for key in cls._others:
if key != 'VectorRegister':
setattr(s, key, ctx[key])
else:
w = ctx[key]
v = (M128A * len(w))()
i = 0
for x in w:
y = M128A()
y.High = x >> 64
y.Low = x - (x >> 64)
v[i] = y
i += 1
setattr(s, key, v)
if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
for key in cls._control:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
for key in cls._integer:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
for key in cls._segments:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
for key in cls._debug:
setattr(s, key, ctx[key])
if (ContextFlags & CONTEXT_MMX_REGISTERS) == CONTEXT_MMX_REGISTERS:
xmm = s.FltSave.xmm
for key in cls._mmx:
y = M128A()
y.High = x >> 64
y.Low = x - (x >> 64)
setattr(xmm, key, y)
return s
def to_dict(self):
'Convert a structure into a Python dictionary.'
ctx = Context()
ContextFlags = self.ContextFlags
ctx['ContextFlags'] = ContextFlags
for key in self._others:
if key != 'VectorRegister':
ctx[key] = getattr(self, key)
else:
ctx[key] = tuple([ (x.Low + (x.High << 64)) for x in getattr(self, key) ])
if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL:
for key in self._control:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER:
for key in self._integer:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS:
for key in self._segments:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS:
for key in self._debug:
ctx[key] = getattr(self, key)
if (ContextFlags & CONTEXT_MMX_REGISTERS) == CONTEXT_MMX_REGISTERS:
xmm = self.FltSave.xmm.to_dict()
for key in self._mmx:
ctx[key] = xmm.get(key)
return ctx
LPCONTEXT = PCONTEXT
def SetThreadContext(hThread, lpContext):
_SetThreadContext = windll.kernel32.SetThreadContext
_SetThreadContext.argtypes = [HANDLE, LPCONTEXT]
_SetThreadContext.restype = bool
_SetThreadContext.errcheck = RaiseIfZero
if isinstance(lpContext, dict):
lpContext = CONTEXT.from_dict(lpContext)
_SetThreadContext(hThread, byref(lpContext)) | null |
177,560 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
class WOW64_LDT_ENTRY (context_i386.LDT_ENTRY):
pass
PWOW64_LDT_ENTRY = POINTER(WOW64_LDT_ENTRY)
def Wow64GetThreadSelectorEntry(hThread, dwSelector):
_Wow64GetThreadSelectorEntry = windll.kernel32.Wow64GetThreadSelectorEntry
_Wow64GetThreadSelectorEntry.argtypes = [HANDLE, DWORD, PWOW64_LDT_ENTRY]
_Wow64GetThreadSelectorEntry.restype = bool
_Wow64GetThreadSelectorEntry.errcheck = RaiseIfZero
lpSelectorEntry = WOW64_LDT_ENTRY()
_Wow64GetThreadSelectorEntry(hThread, dwSelector, byref(lpSelectorEntry))
return lpSelectorEntry | null |
177,561 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
def Wow64ResumeThread(hThread):
_Wow64ResumeThread = windll.kernel32.Wow64ResumeThread
_Wow64ResumeThread.argtypes = [HANDLE]
_Wow64ResumeThread.restype = DWORD
previousCount = _Wow64ResumeThread(hThread)
if previousCount == DWORD(-1).value:
raise ctypes.WinError()
return previousCount | null |
177,562 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
def Wow64SuspendThread(hThread):
_Wow64SuspendThread = windll.kernel32.Wow64SuspendThread
_Wow64SuspendThread.argtypes = [HANDLE]
_Wow64SuspendThread.restype = DWORD
previousCount = _Wow64SuspendThread(hThread)
if previousCount == DWORD(-1).value:
raise ctypes.WinError()
return previousCount | null |
177,563 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
class Context(dict):
"""
Register context dictionary for the amd64 architecture.
"""
arch = CONTEXT.arch
def __get_pc(self):
return self['Rip']
def __set_pc(self, value):
self['Rip'] = value
pc = property(__get_pc, __set_pc)
def __get_sp(self):
return self['Rsp']
def __set_sp(self, value):
self['Rsp'] = value
sp = property(__get_sp, __set_sp)
def __get_fp(self):
return self['Rbp']
def __set_fp(self, value):
self['Rbp'] = value
fp = property(__get_fp, __set_fp)
WOW64_CONTEXT_i386 = long(0x00010000)
WOW64_CONTEXT_ALL = (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
class WOW64_CONTEXT (context_i386.CONTEXT):
pass
PWOW64_CONTEXT = POINTER(WOW64_CONTEXT)
def Wow64GetThreadContext(hThread, ContextFlags = None):
_Wow64GetThreadContext = windll.kernel32.Wow64GetThreadContext
_Wow64GetThreadContext.argtypes = [HANDLE, PWOW64_CONTEXT]
_Wow64GetThreadContext.restype = bool
_Wow64GetThreadContext.errcheck = RaiseIfZero
# XXX doesn't exist in XP 64 bits
Context = WOW64_CONTEXT()
if ContextFlags is None:
Context.ContextFlags = WOW64_CONTEXT_ALL | WOW64_CONTEXT_i386
else:
Context.ContextFlags = ContextFlags
_Wow64GetThreadContext(hThread, byref(Context))
return Context.to_dict() | null |
177,564 | from winappdbg.win32.defines import *
from winappdbg.win32.version import ARCH_AMD64
from winappdbg.win32 import context_i386
class WOW64_CONTEXT (context_i386.CONTEXT):
pass
PWOW64_CONTEXT = POINTER(WOW64_CONTEXT)
def Wow64SetThreadContext(hThread, lpContext):
_Wow64SetThreadContext = windll.kernel32.Wow64SetThreadContext
_Wow64SetThreadContext.argtypes = [HANDLE, PWOW64_CONTEXT]
_Wow64SetThreadContext.restype = bool
_Wow64SetThreadContext.errcheck = RaiseIfZero
# XXX doesn't exist in XP 64 bits
if isinstance(lpContext, dict):
lpContext = WOW64_CONTEXT.from_dict(lpContext)
_Wow64SetThreadContext(hThread, byref(lpContext)) | null |
177,565 | import ctypes
import functools
from winappdbg import compat
try:
ctypes.c_void_p(ctypes.byref(ctypes.c_char())) # this fails in IronPython
byref = ctypes.byref
except TypeError:
byref = ctypes.pointer
import sys
try:
import ctypes
from ctypes import LibraryLoader
windll = LibraryLoader(ctypes.WinDLL)
from ctypes import wintypes
except (AttributeError, ImportError):
windll = None
SetConsoleTextAttribute = lambda *_: None
winapi_test = lambda *_: None
else:
from ctypes import byref, Structure, c_char, POINTER
COORD = wintypes._COORD
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
"""struct in wincon.h."""
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", wintypes.WORD),
("srWindow", wintypes.SMALL_RECT),
("dwMaximumWindowSize", COORD),
]
def __str__(self):
return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
self.dwSize.Y, self.dwSize.X
, self.dwCursorPosition.Y, self.dwCursorPosition.X
, self.wAttributes
, self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
, self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
)
_GetStdHandle = windll.kernel32.GetStdHandle
_GetStdHandle.argtypes = [
wintypes.DWORD,
]
_GetStdHandle.restype = wintypes.HANDLE
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
_GetConsoleScreenBufferInfo.argtypes = [
wintypes.HANDLE,
POINTER(CONSOLE_SCREEN_BUFFER_INFO),
]
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
_SetConsoleTextAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
]
_SetConsoleTextAttribute.restype = wintypes.BOOL
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
_SetConsoleCursorPosition.argtypes = [
wintypes.HANDLE,
COORD,
]
_SetConsoleCursorPosition.restype = wintypes.BOOL
_FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
_FillConsoleOutputCharacterA.argtypes = [
wintypes.HANDLE,
c_char,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputCharacterA.restype = wintypes.BOOL
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
_FillConsoleOutputAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputAttribute.restype = wintypes.BOOL
_SetConsoleTitleW = windll.kernel32.SetConsoleTitleW
_SetConsoleTitleW.argtypes = [
wintypes.LPCWSTR
]
_SetConsoleTitleW.restype = wintypes.BOOL
_GetConsoleMode = windll.kernel32.GetConsoleMode
_GetConsoleMode.argtypes = [
wintypes.HANDLE,
POINTER(wintypes.DWORD)
]
_GetConsoleMode.restype = wintypes.BOOL
_SetConsoleMode = windll.kernel32.SetConsoleMode
_SetConsoleMode.argtypes = [
wintypes.HANDLE,
wintypes.DWORD
]
_SetConsoleMode.restype = wintypes.BOOL
def _winapi_test(handle):
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return bool(success)
def winapi_test():
return any(_winapi_test(h) for h in
(_GetStdHandle(STDOUT), _GetStdHandle(STDERR)))
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
handle = _GetStdHandle(stream_id)
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return csbi
def SetConsoleTextAttribute(stream_id, attrs):
handle = _GetStdHandle(stream_id)
return _SetConsoleTextAttribute(handle, attrs)
def SetConsoleCursorPosition(stream_id, position, adjust=True):
position = COORD(*position)
# If the position is out of range, do nothing.
if position.Y <= 0 or position.X <= 0:
return
# Adjust for Windows' SetConsoleCursorPosition:
# 1. being 0-based, while ANSI is 1-based.
# 2. expecting (x,y), while ANSI uses (y,x).
adjusted_position = COORD(position.Y - 1, position.X - 1)
if adjust:
# Adjust for viewport's scroll position
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
adjusted_position.Y += sr.Top
adjusted_position.X += sr.Left
# Resume normal processing
handle = _GetStdHandle(stream_id)
return _SetConsoleCursorPosition(handle, adjusted_position)
def FillConsoleOutputCharacter(stream_id, char, length, start):
handle = _GetStdHandle(stream_id)
char = c_char(char.encode())
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
success = _FillConsoleOutputCharacterA(
handle, char, length, start, byref(num_written))
return num_written.value
def FillConsoleOutputAttribute(stream_id, attr, length, start):
''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
handle = _GetStdHandle(stream_id)
attribute = wintypes.WORD(attr)
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
return _FillConsoleOutputAttribute(
handle, attribute, length, start, byref(num_written))
def SetConsoleTitle(title):
return _SetConsoleTitleW(title)
def GetConsoleMode(handle):
mode = wintypes.DWORD()
success = _GetConsoleMode(handle, byref(mode))
if not success:
raise ctypes.WinError()
return mode.value
def SetConsoleMode(handle, mode):
success = _SetConsoleMode(handle, mode)
if not success:
raise ctypes.WinError()
The provided code snippet includes necessary dependencies for implementing the `RaiseIfZero` function. Write a Python function `def RaiseIfZero(result, func = None, arguments = ())` to solve the following problem:
Error checking for most Win32 API calls. The function is assumed to return an integer, which is C{0} on error. In that case the C{WindowsError} exception is raised.
Here is the function:
def RaiseIfZero(result, func = None, arguments = ()):
"""
Error checking for most Win32 API calls.
The function is assumed to return an integer, which is C{0} on error.
In that case the C{WindowsError} exception is raised.
"""
if not result:
raise ctypes.WinError()
return result | Error checking for most Win32 API calls. The function is assumed to return an integer, which is C{0} on error. In that case the C{WindowsError} exception is raised. |
177,566 | import ctypes
import functools
from winappdbg import compat
try:
ctypes.c_void_p(ctypes.byref(ctypes.c_char())) # this fails in IronPython
byref = ctypes.byref
except TypeError:
byref = ctypes.pointer
import sys
try:
import ctypes
from ctypes import LibraryLoader
windll = LibraryLoader(ctypes.WinDLL)
from ctypes import wintypes
except (AttributeError, ImportError):
windll = None
SetConsoleTextAttribute = lambda *_: None
winapi_test = lambda *_: None
else:
from ctypes import byref, Structure, c_char, POINTER
COORD = wintypes._COORD
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
"""struct in wincon.h."""
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", wintypes.WORD),
("srWindow", wintypes.SMALL_RECT),
("dwMaximumWindowSize", COORD),
]
def __str__(self):
return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
self.dwSize.Y, self.dwSize.X
, self.dwCursorPosition.Y, self.dwCursorPosition.X
, self.wAttributes
, self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
, self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
)
_GetStdHandle = windll.kernel32.GetStdHandle
_GetStdHandle.argtypes = [
wintypes.DWORD,
]
_GetStdHandle.restype = wintypes.HANDLE
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
_GetConsoleScreenBufferInfo.argtypes = [
wintypes.HANDLE,
POINTER(CONSOLE_SCREEN_BUFFER_INFO),
]
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
_SetConsoleTextAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
]
_SetConsoleTextAttribute.restype = wintypes.BOOL
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
_SetConsoleCursorPosition.argtypes = [
wintypes.HANDLE,
COORD,
]
_SetConsoleCursorPosition.restype = wintypes.BOOL
_FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
_FillConsoleOutputCharacterA.argtypes = [
wintypes.HANDLE,
c_char,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputCharacterA.restype = wintypes.BOOL
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
_FillConsoleOutputAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputAttribute.restype = wintypes.BOOL
_SetConsoleTitleW = windll.kernel32.SetConsoleTitleW
_SetConsoleTitleW.argtypes = [
wintypes.LPCWSTR
]
_SetConsoleTitleW.restype = wintypes.BOOL
_GetConsoleMode = windll.kernel32.GetConsoleMode
_GetConsoleMode.argtypes = [
wintypes.HANDLE,
POINTER(wintypes.DWORD)
]
_GetConsoleMode.restype = wintypes.BOOL
_SetConsoleMode = windll.kernel32.SetConsoleMode
_SetConsoleMode.argtypes = [
wintypes.HANDLE,
wintypes.DWORD
]
_SetConsoleMode.restype = wintypes.BOOL
def _winapi_test(handle):
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return bool(success)
def winapi_test():
return any(_winapi_test(h) for h in
(_GetStdHandle(STDOUT), _GetStdHandle(STDERR)))
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
handle = _GetStdHandle(stream_id)
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return csbi
def SetConsoleTextAttribute(stream_id, attrs):
handle = _GetStdHandle(stream_id)
return _SetConsoleTextAttribute(handle, attrs)
def SetConsoleCursorPosition(stream_id, position, adjust=True):
position = COORD(*position)
# If the position is out of range, do nothing.
if position.Y <= 0 or position.X <= 0:
return
# Adjust for Windows' SetConsoleCursorPosition:
# 1. being 0-based, while ANSI is 1-based.
# 2. expecting (x,y), while ANSI uses (y,x).
adjusted_position = COORD(position.Y - 1, position.X - 1)
if adjust:
# Adjust for viewport's scroll position
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
adjusted_position.Y += sr.Top
adjusted_position.X += sr.Left
# Resume normal processing
handle = _GetStdHandle(stream_id)
return _SetConsoleCursorPosition(handle, adjusted_position)
def FillConsoleOutputCharacter(stream_id, char, length, start):
handle = _GetStdHandle(stream_id)
char = c_char(char.encode())
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
success = _FillConsoleOutputCharacterA(
handle, char, length, start, byref(num_written))
return num_written.value
def FillConsoleOutputAttribute(stream_id, attr, length, start):
''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
handle = _GetStdHandle(stream_id)
attribute = wintypes.WORD(attr)
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
return _FillConsoleOutputAttribute(
handle, attribute, length, start, byref(num_written))
def SetConsoleTitle(title):
return _SetConsoleTitleW(title)
def GetConsoleMode(handle):
mode = wintypes.DWORD()
success = _GetConsoleMode(handle, byref(mode))
if not success:
raise ctypes.WinError()
return mode.value
def SetConsoleMode(handle, mode):
success = _SetConsoleMode(handle, mode)
if not success:
raise ctypes.WinError()
The provided code snippet includes necessary dependencies for implementing the `RaiseIfNotZero` function. Write a Python function `def RaiseIfNotZero(result, func = None, arguments = ())` to solve the following problem:
Error checking for some odd Win32 API calls. The function is assumed to return an integer, which is zero on success. If the return value is nonzero the C{WindowsError} exception is raised. This is mostly useful for free() like functions, where the return value is the pointer to the memory block on failure or a C{NULL} pointer on success.
Here is the function:
def RaiseIfNotZero(result, func = None, arguments = ()):
"""
Error checking for some odd Win32 API calls.
The function is assumed to return an integer, which is zero on success.
If the return value is nonzero the C{WindowsError} exception is raised.
This is mostly useful for free() like functions, where the return value is
the pointer to the memory block on failure or a C{NULL} pointer on success.
"""
if result:
raise ctypes.WinError()
return result | Error checking for some odd Win32 API calls. The function is assumed to return an integer, which is zero on success. If the return value is nonzero the C{WindowsError} exception is raised. This is mostly useful for free() like functions, where the return value is the pointer to the memory block on failure or a C{NULL} pointer on success. |
177,567 | import ctypes
import functools
from winappdbg import compat
try:
ctypes.c_void_p(ctypes.byref(ctypes.c_char())) # this fails in IronPython
byref = ctypes.byref
except TypeError:
byref = ctypes.pointer
ERROR_SUCCESS = 0
import sys
try:
import ctypes
from ctypes import LibraryLoader
windll = LibraryLoader(ctypes.WinDLL)
from ctypes import wintypes
except (AttributeError, ImportError):
windll = None
SetConsoleTextAttribute = lambda *_: None
winapi_test = lambda *_: None
else:
from ctypes import byref, Structure, c_char, POINTER
COORD = wintypes._COORD
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
"""struct in wincon.h."""
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", wintypes.WORD),
("srWindow", wintypes.SMALL_RECT),
("dwMaximumWindowSize", COORD),
]
def __str__(self):
return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
self.dwSize.Y, self.dwSize.X
, self.dwCursorPosition.Y, self.dwCursorPosition.X
, self.wAttributes
, self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
, self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
)
_GetStdHandle = windll.kernel32.GetStdHandle
_GetStdHandle.argtypes = [
wintypes.DWORD,
]
_GetStdHandle.restype = wintypes.HANDLE
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
_GetConsoleScreenBufferInfo.argtypes = [
wintypes.HANDLE,
POINTER(CONSOLE_SCREEN_BUFFER_INFO),
]
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
_SetConsoleTextAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
]
_SetConsoleTextAttribute.restype = wintypes.BOOL
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
_SetConsoleCursorPosition.argtypes = [
wintypes.HANDLE,
COORD,
]
_SetConsoleCursorPosition.restype = wintypes.BOOL
_FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
_FillConsoleOutputCharacterA.argtypes = [
wintypes.HANDLE,
c_char,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputCharacterA.restype = wintypes.BOOL
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
_FillConsoleOutputAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputAttribute.restype = wintypes.BOOL
_SetConsoleTitleW = windll.kernel32.SetConsoleTitleW
_SetConsoleTitleW.argtypes = [
wintypes.LPCWSTR
]
_SetConsoleTitleW.restype = wintypes.BOOL
_GetConsoleMode = windll.kernel32.GetConsoleMode
_GetConsoleMode.argtypes = [
wintypes.HANDLE,
POINTER(wintypes.DWORD)
]
_GetConsoleMode.restype = wintypes.BOOL
_SetConsoleMode = windll.kernel32.SetConsoleMode
_SetConsoleMode.argtypes = [
wintypes.HANDLE,
wintypes.DWORD
]
_SetConsoleMode.restype = wintypes.BOOL
def _winapi_test(handle):
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return bool(success)
def winapi_test():
return any(_winapi_test(h) for h in
(_GetStdHandle(STDOUT), _GetStdHandle(STDERR)))
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
handle = _GetStdHandle(stream_id)
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return csbi
def SetConsoleTextAttribute(stream_id, attrs):
handle = _GetStdHandle(stream_id)
return _SetConsoleTextAttribute(handle, attrs)
def SetConsoleCursorPosition(stream_id, position, adjust=True):
position = COORD(*position)
# If the position is out of range, do nothing.
if position.Y <= 0 or position.X <= 0:
return
# Adjust for Windows' SetConsoleCursorPosition:
# 1. being 0-based, while ANSI is 1-based.
# 2. expecting (x,y), while ANSI uses (y,x).
adjusted_position = COORD(position.Y - 1, position.X - 1)
if adjust:
# Adjust for viewport's scroll position
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
adjusted_position.Y += sr.Top
adjusted_position.X += sr.Left
# Resume normal processing
handle = _GetStdHandle(stream_id)
return _SetConsoleCursorPosition(handle, adjusted_position)
def FillConsoleOutputCharacter(stream_id, char, length, start):
handle = _GetStdHandle(stream_id)
char = c_char(char.encode())
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
success = _FillConsoleOutputCharacterA(
handle, char, length, start, byref(num_written))
return num_written.value
def FillConsoleOutputAttribute(stream_id, attr, length, start):
''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
handle = _GetStdHandle(stream_id)
attribute = wintypes.WORD(attr)
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
return _FillConsoleOutputAttribute(
handle, attribute, length, start, byref(num_written))
def SetConsoleTitle(title):
return _SetConsoleTitleW(title)
def GetConsoleMode(handle):
mode = wintypes.DWORD()
success = _GetConsoleMode(handle, byref(mode))
if not success:
raise ctypes.WinError()
return mode.value
def SetConsoleMode(handle, mode):
success = _SetConsoleMode(handle, mode)
if not success:
raise ctypes.WinError()
The provided code snippet includes necessary dependencies for implementing the `RaiseIfNotErrorSuccess` function. Write a Python function `def RaiseIfNotErrorSuccess(result, func = None, arguments = ())` to solve the following problem:
Error checking for Win32 Registry API calls. The function is assumed to return a Win32 error code. If the code is not C{ERROR_SUCCESS} then a C{WindowsError} exception is raised.
Here is the function:
def RaiseIfNotErrorSuccess(result, func = None, arguments = ()):
"""
Error checking for Win32 Registry API calls.
The function is assumed to return a Win32 error code. If the code is not
C{ERROR_SUCCESS} then a C{WindowsError} exception is raised.
"""
if result != ERROR_SUCCESS:
raise ctypes.WinError(result)
return result | Error checking for Win32 Registry API calls. The function is assumed to return a Win32 error code. If the code is not C{ERROR_SUCCESS} then a C{WindowsError} exception is raised. |
177,568 | import ctypes
import functools
from winappdbg import compat
class GuessStringType(object):
"""
Decorator that guesses the correct version (A or W) to call
based on the types of the strings passed as parameters.
Calls the B{ANSI} version if the only string types are ANSI.
Calls the B{Unicode} version if Unicode or mixed string types are passed.
The default if no string arguments are passed depends on the value of the
L{t_default} class variable.
Possible values are:
- type('') for ANSI
- type(u'') for Unicode
"""
# ANSI and Unicode types
t_ansi = type('')
t_unicode = type(u'')
# Default is ANSI for Python 2.x
t_default = t_ansi
def __init__(self, fn_ansi, fn_unicode):
"""
"""
self.fn_ansi = fn_ansi
self.fn_unicode = fn_unicode
# Copy the wrapped function attributes.
try:
self.__name__ = self.fn_ansi.__name__[:-1] # remove the A or W
except AttributeError:
pass
try:
self.__module__ = self.fn_ansi.__module__
except AttributeError:
pass
try:
self.__doc__ = self.fn_ansi.__doc__
except AttributeError:
pass
def __call__(self, *argv, **argd):
# Shortcut to self.t_ansi
t_ansi = self.t_ansi
# Get the types of all arguments for the function
v_types = [ type(item) for item in argv ]
v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
# Get the appropriate function for the default type
if self.t_default == t_ansi:
fn = self.fn_ansi
else:
fn = self.fn_unicode
# If at least one argument is a Unicode string...
if self.t_unicode in v_types:
# If al least one argument is an ANSI string,
# convert all ANSI strings to Unicode
if t_ansi in v_types:
argv = list(argv)
for index in compat.xrange(len(argv)):
if v_types[index] == t_ansi:
argv[index] = compat.unicode(argv[index])
for (key, value) in argd.items():
if type(value) == t_ansi:
argd[key] = compat.unicode(value)
# Use the W version
fn = self.fn_unicode
# If at least one argument is an ANSI string,
# but there are no Unicode strings...
elif t_ansi in v_types:
# Use the A version
fn = self.fn_ansi
# Call the function and return the result
return fn(*argv, **argd)
import sys
The provided code snippet includes necessary dependencies for implementing the `MakeANSIVersion` function. Write a Python function `def MakeANSIVersion(fn)` to solve the following problem:
Decorator that generates an ANSI version of a Unicode (wide) only API call. @type fn: callable @param fn: Unicode (wide) version of the API function to call.
Here is the function:
def MakeANSIVersion(fn):
"""
Decorator that generates an ANSI version of a Unicode (wide) only API call.
@type fn: callable
@param fn: Unicode (wide) version of the API function to call.
"""
@functools.wraps(fn)
def wrapper(*argv, **argd):
t_ansi = GuessStringType.t_ansi
t_unicode = GuessStringType.t_unicode
v_types = [ type(item) for item in argv ]
v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
if t_ansi in v_types:
argv = list(argv)
for index in compat.xrange(len(argv)):
if v_types[index] == t_ansi:
argv[index] = t_unicode(argv[index])
for key, value in argd.items():
if type(value) == t_ansi:
argd[key] = t_unicode(value)
return fn(*argv, **argd)
return wrapper | Decorator that generates an ANSI version of a Unicode (wide) only API call. @type fn: callable @param fn: Unicode (wide) version of the API function to call. |
177,569 | import ctypes
import functools
from winappdbg import compat
class GuessStringType(object):
"""
Decorator that guesses the correct version (A or W) to call
based on the types of the strings passed as parameters.
Calls the B{ANSI} version if the only string types are ANSI.
Calls the B{Unicode} version if Unicode or mixed string types are passed.
The default if no string arguments are passed depends on the value of the
L{t_default} class variable.
Possible values are:
- type('') for ANSI
- type(u'') for Unicode
"""
# ANSI and Unicode types
t_ansi = type('')
t_unicode = type(u'')
# Default is ANSI for Python 2.x
t_default = t_ansi
def __init__(self, fn_ansi, fn_unicode):
"""
"""
self.fn_ansi = fn_ansi
self.fn_unicode = fn_unicode
# Copy the wrapped function attributes.
try:
self.__name__ = self.fn_ansi.__name__[:-1] # remove the A or W
except AttributeError:
pass
try:
self.__module__ = self.fn_ansi.__module__
except AttributeError:
pass
try:
self.__doc__ = self.fn_ansi.__doc__
except AttributeError:
pass
def __call__(self, *argv, **argd):
# Shortcut to self.t_ansi
t_ansi = self.t_ansi
# Get the types of all arguments for the function
v_types = [ type(item) for item in argv ]
v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
# Get the appropriate function for the default type
if self.t_default == t_ansi:
fn = self.fn_ansi
else:
fn = self.fn_unicode
# If at least one argument is a Unicode string...
if self.t_unicode in v_types:
# If al least one argument is an ANSI string,
# convert all ANSI strings to Unicode
if t_ansi in v_types:
argv = list(argv)
for index in compat.xrange(len(argv)):
if v_types[index] == t_ansi:
argv[index] = compat.unicode(argv[index])
for (key, value) in argd.items():
if type(value) == t_ansi:
argd[key] = compat.unicode(value)
# Use the W version
fn = self.fn_unicode
# If at least one argument is an ANSI string,
# but there are no Unicode strings...
elif t_ansi in v_types:
# Use the A version
fn = self.fn_ansi
# Call the function and return the result
return fn(*argv, **argd)
import sys
The provided code snippet includes necessary dependencies for implementing the `MakeWideVersion` function. Write a Python function `def MakeWideVersion(fn)` to solve the following problem:
Decorator that generates a Unicode (wide) version of an ANSI only API call. @type fn: callable @param fn: ANSI version of the API function to call.
Here is the function:
def MakeWideVersion(fn):
"""
Decorator that generates a Unicode (wide) version of an ANSI only API call.
@type fn: callable
@param fn: ANSI version of the API function to call.
"""
@functools.wraps(fn)
def wrapper(*argv, **argd):
t_ansi = GuessStringType.t_ansi
t_unicode = GuessStringType.t_unicode
v_types = [ type(item) for item in argv ]
v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
if t_unicode in v_types:
argv = list(argv)
for index in compat.xrange(len(argv)):
if v_types[index] == t_unicode:
argv[index] = t_ansi(argv[index])
for key, value in argd.items():
if type(value) == t_unicode:
argd[key] = t_ansi(value)
return fn(*argv, **argd)
return wrapper | Decorator that generates a Unicode (wide) version of an ANSI only API call. @type fn: callable @param fn: ANSI version of the API function to call. |
177,570 | from winappdbg import win32
from winappdbg import compat
from winappdbg.system import System
from winappdbg.textio import HexDump, CrashDump
from winappdbg.util import StaticClass, MemoryAddresses, PathOperations
import sys
import os
import time
import zlib
import warnings
def optimize(picklestring):
return picklestring | null |
177,572 | import sqlite3
import datetime
import warnings
from sqlalchemy import create_engine, Column, ForeignKey, Sequence
from sqlalchemy.engine.url import URL
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.interfaces import PoolListener
from sqlalchemy.orm import sessionmaker, deferred
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
from sqlalchemy.types import Integer, BigInteger, Boolean, DateTime, String, \
LargeBinary, Enum, VARCHAR
from sqlalchemy.sql.expression import asc, desc
from crash import Crash, Marshaller, pickle, HIGHEST_PROTOCOL
from textio import CrashDump
import win32
The provided code snippet includes necessary dependencies for implementing the `decorator` function. Write a Python function `def decorator(w)` to solve the following problem:
The C{decorator} module was not found. You can install it from: U{http://pypi.python.org/pypi/decorator/}
Here is the function:
def decorator(w):
"""
The C{decorator} module was not found. You can install it from:
U{http://pypi.python.org/pypi/decorator/}
"""
def d(fn):
@functools.wraps(fn)
def x(*argv, **argd):
return w(fn, *argv, **argd)
return x
return d | The C{decorator} module was not found. You can install it from: U{http://pypi.python.org/pypi/decorator/} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.