Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Classes | Functions | Variables
miasm2.os_dep.win_api_x86_32 Namespace Reference

Classes

class  c_winobjs
 
class  find_data_mngr
 
class  handle_generator
 
class  hobj
 
class  mdl
 
class  systeminfo
 
class  whandle
 
class  win32_find_data
 

Functions

def whoami
 
def kernel32_HeapAlloc
 
def kernel32_HeapFree
 
def kernel32_GlobalAlloc
 
def kernel32_LocalFree
 
def kernel32_LocalAlloc
 
def kernel32_GlobalFree
 
def kernel32_IsDebuggerPresent
 
def kernel32_CreateToolhelp32Snapshot
 
def kernel32_GetCurrentProcess
 
def kernel32_GetCurrentProcessId
 
def kernel32_Process32First
 
def kernel32_Process32Next
 
def kernel32_GetTickCount
 
def kernel32_GetVersion
 
def kernel32_GetVersionEx
 
def kernel32_GetPriorityClass
 
def kernel32_SetPriorityClass
 
def kernel32_CloseHandle
 
def user32_GetForegroundWindow
 
def user32_FindWindowA
 
def user32_GetTopWindow
 
def user32_BlockInput
 
def advapi32_CryptAcquireContext
 
def advapi32_CryptAcquireContextA
 
def advapi32_CryptAcquireContextW
 
def advapi32_CryptCreateHash
 
def advapi32_CryptHashData
 
def advapi32_CryptGetHashParam
 
def advapi32_CryptReleaseContext
 
def advapi32_CryptDeriveKey
 
def advapi32_CryptDestroyHash
 
def advapi32_CryptDecrypt
 
def kernel32_CreateFile
 
def kernel32_CreateFileA
 
def kernel32_CreateFileW
 
def kernel32_ReadFile
 
def kernel32_GetFileSize
 
def kernel32_GetFileSizeEx
 
def kernel32_FlushInstructionCache
 
def kernel32_VirtualProtect
 
def kernel32_VirtualAlloc
 
def kernel32_VirtualFree
 
def user32_GetWindowLongA
 
def user32_SetWindowLongA
 
def kernel32_GetModuleFileName
 
def kernel32_GetModuleFileNameA
 
def kernel32_GetModuleFileNameW
 
def kernel32_CreateMutex
 
def kernel32_CreateMutexA
 
def kernel32_CreateMutexW
 
def shell32_SHGetSpecialFolderLocation
 
def kernel32_SHGetPathFromIDList
 
def shell32_SHGetPathFromIDListW
 
def shell32_SHGetPathFromIDListA
 
def kernel32_GetLastError
 
def kernel32_SetLastError
 
def kernel32_RestoreLastError
 
def kernel32_LoadLibraryA
 
def kernel32_LoadLibraryExA
 
def kernel32_GetProcAddress
 
def kernel32_LoadLibraryW
 
def kernel32_GetModuleHandle
 
def kernel32_GetModuleHandleA
 
def kernel32_GetModuleHandleW
 
def kernel32_VirtualLock
 
def kernel32_GetSystemInfo
 
def kernel32_IsWow64Process
 
def kernel32_GetCommandLineA
 
def kernel32_GetCommandLineW
 
def shell32_CommandLineToArgvW
 
def cryptdll_MD5Init
 
def cryptdll_MD5Update
 
def cryptdll_MD5Final
 
def ntdll_RtlInitAnsiString
 
def ntdll_RtlHashUnicodeString
 
def kernel32_RtlMoveMemory
 
def ntdll_RtlAnsiCharToUnicodeChar
 
def ntdll_RtlFindCharInUnicodeString
 
def ntdll_RtlComputeCrc32
 
def ntdll_RtlExtendedIntegerMultiply
 
def ntdll_RtlLargeIntegerAdd
 
def ntdll_RtlLargeIntegerShiftRight
 
def ntdll_RtlEnlargedUnsignedMultiply
 
def ntdll_RtlLargeIntegerSubtract
 
def ntdll_RtlCompareMemory
 
def user32_GetMessagePos
 
def kernel32_Sleep
 
def ntdll_ZwUnmapViewOfSection
 
def kernel32_IsBadReadPtr
 
def ntoskrnl_KeInitializeEvent
 
def ntoskrnl_RtlGetVersion
 
def ntoskrnl_RtlVerifyVersionInfo
 
def hal_ExAcquireFastMutex
 
def mdl2ad
 
def ad2mdl
 
def ntoskrnl_IoAllocateMdl
 
def ntoskrnl_MmProbeAndLockPages
 
def ntoskrnl_MmMapLockedPagesSpecifyCache
 
def ntoskrnl_MmProtectMdlSystemAddress
 
def ntoskrnl_MmUnlockPages
 
def ntoskrnl_IoFreeMdl
 
def hal_ExReleaseFastMutex
 
def ntoskrnl_RtlQueryRegistryValues
 
def ntoskrnl_ExAllocatePoolWithTagPriority
 
def my_lstrcmp
 
def kernel32_lstrcmpA
 
def kernel32_lstrcmpiA
 
def kernel32_lstrcmpW
 
def kernel32_lstrcmpiW
 
def kernel32_lstrcmpi
 
def my_strcpy
 
def kernel32_lstrcpyW
 
def kernel32_lstrcpyA
 
def kernel32_lstrcpy
 
def kernel32_lstrcpyn
 
def my_strlen
 
def kernel32_lstrlenA
 
def kernel32_lstrlenW
 
def kernel32_lstrlen
 
def my_lstrcat
 
def kernel32_lstrcatA
 
def kernel32_lstrcatW
 
def kernel32_GetUserGeoID
 
def my_GetVolumeInformation
 
def kernel32_GetVolumeInformationA
 
def kernel32_GetVolumeInformationW
 
def kernel32_MultiByteToWideChar
 
def my_GetEnvironmentVariable
 
def my_GetSystemDirectory
 
def kernel32_GetSystemDirectoryA
 
def kernel32_GetSystemDirectoryW
 
def my_CreateDirectory
 
def kernel32_CreateDirectoryW
 
def kernel32_CreateDirectoryA
 
def kernel32_GetEnvironmentVariableA
 
def kernel32_GetEnvironmentVariableW
 
def my_CreateEvent
 
def kernel32_CreateEventA
 
def kernel32_CreateEventW
 
def kernel32_WaitForSingleObject
 
def kernel32_SetFileAttributesA
 
def ntdll_RtlMoveMemory
 
def ntdll_ZwQuerySystemInformation
 
def ntdll_ZwProtectVirtualMemory
 
def ntdll_ZwAllocateVirtualMemory
 
def ntdll_ZwFreeVirtualMemory
 
def ntdll_RtlInitString
 
def ntdll_RtlAnsiStringToUnicodeString
 
def ntdll_LdrLoadDll
 
def ntdll_RtlFreeUnicodeString
 
def ntdll_LdrGetProcedureAddress
 
def ntdll_memset
 
def msvcrt_memset
 
def msvcrt_memcpy
 
def msvcrt_memcmp
 
def shlwapi_PathFindExtensionA
 
def shlwapi_PathRemoveFileSpecW
 
def shlwapi_PathIsPrefixW
 
def shlwapi_PathIsDirectoryW
 
def shlwapi_PathIsFileSpec
 
def shlwapi_PathGetDriveNumber
 
def shlwapi_PathGetDriveNumberA
 
def shlwapi_PathGetDriveNumberW
 
def shlwapi_PathIsFileSpecA
 
def shlwapi_PathIsFileSpecW
 
def shlwapi_StrToIntA
 
def shlwapi_StrToInt64Ex
 
def shlwapi_StrToInt64ExA
 
def shlwapi_StrToInt64ExW
 
def user32_IsCharAlpha
 
def user32_IsCharAlphaA
 
def user32_IsCharAlphaW
 
def user32_IsCharAlphaNumericA
 
def shlwapi_StrCmpNIA
 
def advapi32_RegOpenKeyEx
 
def advapi32_RegOpenKeyExA
 
def advapi32_RegOpenKeyExW
 
def advapi32_RegSetValue
 
def advapi32_RegSetValueA
 
def advapi32_RegSetValueW
 
def kernel32_GetThreadLocale
 
def kernel32_GetLocaleInfo
 
def kernel32_GetLocaleInfoA
 
def kernel32_GetLocaleInfoW
 
def kernel32_TlsAlloc
 
def kernel32_TlsFree
 
def kernel32_TlsSetValue
 
def kernel32_TlsGetValue
 
def user32_GetKeyboardType
 
def kernel32_GetStartupInfo
 
def kernel32_GetStartupInfoA
 
def kernel32_GetStartupInfoW
 
def kernel32_GetCurrentThreadId
 
def kernel32_InitializeCriticalSection
 
def user32_GetSystemMetrics
 
def wsock32_WSAStartup
 
def kernel32_GetLocalTime
 
def kernel32_GetSystemTime
 
def kernel32_CreateFileMapping
 
def kernel32_CreateFileMappingA
 
def kernel32_CreateFileMappingW
 
def kernel32_MapViewOfFile
 
def kernel32_UnmapViewOfFile
 
def kernel32_GetDriveType
 
def kernel32_GetDriveTypeA
 
def kernel32_GetDriveTypeW
 
def kernel32_GetDiskFreeSpace
 
def kernel32_GetDiskFreeSpaceA
 
def kernel32_GetDiskFreeSpaceW
 
def kernel32_VirtualQuery
 
def kernel32_GetProcessAffinityMask
 
def msvcrt_rand
 
def kernel32_SetFilePointer
 
def kernel32_SetFilePointerEx
 
def kernel32_SetEndOfFile
 
def kernel32_FlushFileBuffers
 
def kernel32_WriteFile
 
def user32_IsCharUpperA
 
def user32_IsCharLowerA
 
def kernel32_GetSystemDefaultLangID
 
def msvcrt_malloc
 
def msvcrt_free
 
def msvcrt_fseek
 
def msvcrt_ftell
 
def msvcrt_rewind
 
def msvcrt_fread
 
def msvcrt_fclose
 
def msvcrt_atexit
 
def user32_MessageBoxA
 
def kernel32_myGetTempPath
 
def kernel32_GetTempPathA
 
def kernel32_GetTempPathW
 
def kernel32_GetTempFileNameA
 
def kernel32_FindFirstFileA
 
def kernel32_FindNextFileA
 
def kernel32_GetNativeSystemInfo
 
def raw2guid
 
def int2base
 
def msvcrt__ultow
 
def msvcrt_myfopen
 
def msvcrt__wfopen
 
def msvcrt_fopen
 
def msvcrt_strlen
 

Variables

tuple log = logging.getLogger("win_api_x86_32")
 
tuple console_handler = logging.StreamHandler()
 
int MAX_PATH = 260
 
dictionary access_dict
 
tuple access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
 
tuple winobjs = c_winobjs()
 
list process_list
 
tuple kernel32_GetVersionExA
 
tuple kernel32_GetVersionExW
 
int temp_num = 0
 
 digs = string.digits+string.lowercase
 

Function Documentation

def miasm2.os_dep.win_api_x86_32.ad2mdl (   ad)

Definition at line 1278 of file win_api_x86_32.py.

1279 def ad2mdl(ad):
1280  return ((ad - winobjs.nt_mdl_ad) & 0xFFFFFFFFL) / 0x10
1281 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_CryptAcquireContext (   jitter,
  funcname,
  get_str 
)

Definition at line 401 of file win_api_x86_32.py.

402 def advapi32_CryptAcquireContext(jitter, funcname, get_str):
403  ret_ad, args = jitter.func_args_stdcall(["phprov", "pszcontainer",
404  "pszprovider", "dwprovtype",
405  "dwflags"])
406  prov = get_str(jitter, args.pszprovider) if args.pszprovider else "NONE"
407  log.debug('prov: %r', prov)
408  jitter.vm.set_mem(args.phprov, pck32(winobjs.cryptcontext_hwnd))
409  jitter.func_ret_stdcall(ret_ad, 1)
410 
tuple pck32
Definition: utils.py:12

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_CryptAcquireContextA (   jitter)

Definition at line 411 of file win_api_x86_32.py.

413  advapi32_CryptAcquireContext(jitter, whoami(), get_str_ansi)
414 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_CryptAcquireContextW (   jitter)

Definition at line 415 of file win_api_x86_32.py.

417  advapi32_CryptAcquireContext(jitter, whoami(), get_str_unic)
418 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_CryptCreateHash (   jitter)

Definition at line 419 of file win_api_x86_32.py.

420 def advapi32_CryptCreateHash(jitter):
421  ret_ad, args = jitter.func_args_stdcall(["hprov", "algid", "hkey",
422  "dwflags", "phhash"])
423 
424  winobjs.cryptcontext_num += 1
425 
426  if args.algid == 0x00008003:
427  log.debug('algo is MD5')
428  jitter.vm.set_mem(
429  args.phhash,
430  pck32(winobjs.cryptcontext_bnum + winobjs.cryptcontext_num)
431  )
432  winobjs.cryptcontext[
433  winobjs.cryptcontext_bnum + winobjs.cryptcontext_num] = hobj()
434  winobjs.cryptcontext[
435  winobjs.cryptcontext_bnum + winobjs.cryptcontext_num].h = MD5.new()
436  elif args.algid == 0x00008004:
437  log.debug('algo is SHA1')
438  jitter.vm.set_mem(
439  args.phhash,
440  pck32(winobjs.cryptcontext_bnum + winobjs.cryptcontext_num)
441  )
442  winobjs.cryptcontext[
443  winobjs.cryptcontext_bnum + winobjs.cryptcontext_num] = hobj()
444  winobjs.cryptcontext[
445  winobjs.cryptcontext_bnum + winobjs.cryptcontext_num].h = SHA.new()
446  else:
447  raise ValueError('un impl algo1')
448  jitter.func_ret_stdcall(ret_ad, 1)
449 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.advapi32_CryptDecrypt (   jitter)

Definition at line 507 of file win_api_x86_32.py.

508 def advapi32_CryptDecrypt(jitter):
509  ret_ad, _ = jitter.func_args_stdcall(["hkey", "hhash", "final",
510  "dwflags", "pbdata",
511  "pdwdatalen"])
512  raise ValueError("Not implemented")
513  # jitter.func_ret_stdcall(ret_ad, 1)
514 
def miasm2.os_dep.win_api_x86_32.advapi32_CryptDeriveKey (   jitter)

Definition at line 487 of file win_api_x86_32.py.

488 def advapi32_CryptDeriveKey(jitter):
489  ret_ad, args = jitter.func_args_stdcall(["hprov", "algid", "hbasedata",
490  "dwflags", "phkey"])
491 
492  if args.algid == 0x6801:
493  log.debug('using DES')
494  else:
495  raise ValueError('un impl algo2')
496  h = winobjs.cryptcontext[args.hbasedata].h.digest()
497  log.debug('hash %r', h)
498  winobjs.cryptcontext[args.hbasedata].h_result = h
499  jitter.vm.set_mem(args.phkey, pck32(args.hbasedata))
500  jitter.func_ret_stdcall(ret_ad, 1)
501 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.advapi32_CryptDestroyHash (   jitter)

Definition at line 502 of file win_api_x86_32.py.

503 def advapi32_CryptDestroyHash(jitter):
504  ret_ad, _ = jitter.func_args_stdcall(["hhash"])
505  jitter.func_ret_stdcall(ret_ad, 1)
506 
def miasm2.os_dep.win_api_x86_32.advapi32_CryptGetHashParam (   jitter)

Definition at line 464 of file win_api_x86_32.py.

465 def advapi32_CryptGetHashParam(jitter):
466  ret_ad, args = jitter.func_args_stdcall(["hhash", "param", "pbdata",
467  "dwdatalen", "dwflags"])
468 
469  if not args.hhash in winobjs.cryptcontext:
470  raise ValueError("unknown crypt context")
471 
472  if args.param == 2:
473  # XXX todo: save h state?
474  h = winobjs.cryptcontext[args.hhash].h.digest()
475  else:
476  raise ValueError('not impl', args.param)
477  jitter.vm.set_mem(args.pbdata, h)
478  jitter.vm.set_mem(args.dwdatalen, pck32(len(h)))
479 
480  jitter.func_ret_stdcall(ret_ad, 1)
481 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.advapi32_CryptHashData (   jitter)

Definition at line 450 of file win_api_x86_32.py.

451 def advapi32_CryptHashData(jitter):
452  ret_ad, args = jitter.func_args_stdcall(["hhash", "pbdata", "dwdatalen",
453  "dwflags"])
454 
455  if not args.hhash in winobjs.cryptcontext:
456  raise ValueError("unknown crypt context")
457 
458  data = jitter.vm.get_mem(args.pbdata, args.dwdatalen)
459  log.debug('will hash %X', args.dwdatalen)
460  log.debug(repr(data[:10]) + "...")
461  winobjs.cryptcontext[args.hhash].h.update(data)
462  jitter.func_ret_stdcall(ret_ad, 1)
463 
def miasm2.os_dep.win_api_x86_32.advapi32_CryptReleaseContext (   jitter)

Definition at line 482 of file win_api_x86_32.py.

483 def advapi32_CryptReleaseContext(jitter):
484  ret_ad, _ = jitter.func_args_stdcall(["hhash", "flags"])
485  jitter.func_ret_stdcall(ret_ad, 0)
486 
def miasm2.os_dep.win_api_x86_32.advapi32_RegOpenKeyEx (   jitter,
  funcname,
  get_str 
)

Definition at line 1979 of file win_api_x86_32.py.

1980 def advapi32_RegOpenKeyEx(jitter, funcname, get_str):
1981  ret_ad, args = jitter.func_args_stdcall(["hkey", "subkey",
1982  "reserved", "access",
1983  "phandle"])
1984  s_subkey = get_str(jitter, args.subkey).lower() if args.subkey else ""
1985 
1986  ret_hkey = 0
1987  ret = 2
1988  if args.hkey in winobjs.hkey_handles:
1989  if s_subkey:
1990  h = hash(s_subkey) & 0xffffffff
1991  if h in winobjs.hkey_handles:
1992  ret_hkey = h
1993  ret = 0
1994  else:
1995  log.error('unknown skey')
1996 
1997  jitter.vm.set_mem(args.phandle, pck32(ret_hkey))
1998 
1999  jitter.func_ret_stdcall(ret_ad, ret)
2000 
tuple pck32
Definition: utils.py:12

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_RegOpenKeyExA (   jitter)

Definition at line 2001 of file win_api_x86_32.py.

2002 def advapi32_RegOpenKeyExA(jitter):
2003  advapi32_RegOpenKeyEx(jitter, whoami(), get_str_ansi)
2004 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_RegOpenKeyExW (   jitter)

Definition at line 2005 of file win_api_x86_32.py.

2006 def advapi32_RegOpenKeyExW(jitter):
2007  advapi32_RegOpenKeyEx(jitter, whoami(), get_str_unic)
2008 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_RegSetValue (   jitter,
  funcname,
  get_str 
)

Definition at line 2009 of file win_api_x86_32.py.

2010 def advapi32_RegSetValue(jitter, funcname, get_str):
2011  ret_ad, args = jitter.func_args_stdcall(["hkey", "psubkey",
2012  "valuetype", "pvalue",
2013  "vlen"])
2014  # subkey = get_str(jitter, args.psubkey).lower() if args.psubkey else ""
2015  # value = jitter.vm.get_mem(args.pvalue, args.vlen) if args.pvalue else None
2016  jitter.func_ret_stdcall(ret_ad, 0)
2017 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_RegSetValueA (   jitter)

Definition at line 2018 of file win_api_x86_32.py.

2019 def advapi32_RegSetValueA(jitter):
2020  advapi32_RegSetValue(jitter, whoami(), get_str_ansi)
2021 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.advapi32_RegSetValueW (   jitter)

Definition at line 2022 of file win_api_x86_32.py.

2023 def advapi32_RegSetValueW(jitter):
2024  advapi32_RegSetValue(jitter, whoami(), get_str_unic)
2025 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.cryptdll_MD5Final (   jitter)

Definition at line 1070 of file win_api_x86_32.py.

1071 def cryptdll_MD5Final(jitter):
1072  ret_ad, args = jitter.func_args_stdcall(["ad_ctx"])
1073 
1074  index = jitter.vm.get_mem(args.ad_ctx, 4)
1075  index = upck32(index)
1076  if not index in winobjs.cryptdll_md5_h:
1077  raise ValueError('unknown h context', index)
1078  h = winobjs.cryptdll_md5_h[index].digest()
1079  jitter.vm.set_mem(args.ad_ctx + 88, h)
1080  jitter.func_ret_stdcall(ret_ad, 0)
1081 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.cryptdll_MD5Init (   jitter)

Definition at line 1045 of file win_api_x86_32.py.

1046 def cryptdll_MD5Init(jitter):
1047  ret_ad, args = jitter.func_args_stdcall(["ad_ctx"])
1048  index = len(winobjs.cryptdll_md5_h)
1049  h = MD5.new()
1050  winobjs.cryptdll_md5_h[index] = h
1051 
1052  jitter.vm.set_mem(args.ad_ctx, pck32(index))
1053  jitter.func_ret_stdcall(ret_ad, 0)
1054 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.cryptdll_MD5Update (   jitter)

Definition at line 1055 of file win_api_x86_32.py.

1056 def cryptdll_MD5Update(jitter):
1057  ret_ad, args = jitter.func_args_stdcall(["ad_ctx", "ad_input", "inlen"])
1058 
1059  index = jitter.vm.get_mem(args.ad_ctx, 4)
1060  index = upck32(index)
1061  if not index in winobjs.cryptdll_md5_h:
1062  raise ValueError('unknown h context', index)
1063 
1064  data = jitter.vm.get_mem(args.ad_input, args.inlen)
1065  winobjs.cryptdll_md5_h[index].update(data)
1066  log.debug(hexdump(data))
1067 
1068  jitter.func_ret_stdcall(ret_ad, 0)
1069 
tuple upck32
Definition: utils.py:8

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.hal_ExAcquireFastMutex (   jitter)

Definition at line 1269 of file win_api_x86_32.py.

1270 def hal_ExAcquireFastMutex(jitter):
1271  ret_ad, _ = jitter.func_args_stdcall(0)
1272  jitter.func_ret_stdcall(ret_ad, 0)
1273 
def miasm2.os_dep.win_api_x86_32.hal_ExReleaseFastMutex (   jitter)

Definition at line 1335 of file win_api_x86_32.py.

1336 def hal_ExReleaseFastMutex(jitter):
1337  ret_ad, _ = jitter.func_args_stdcall(0)
1338  jitter.func_ret_stdcall(ret_ad, 0)
1339 
def miasm2.os_dep.win_api_x86_32.int2base (   x,
  base 
)

Definition at line 2693 of file win_api_x86_32.py.

2694 def int2base(x, base):
2695  if x < 0:
2696  sign = -1
2697  elif x == 0:
2698  return '0'
2699  else:
2700  sign = 1
2701  x *= sign
2702  digits = []
2703  while x:
2704  digits.append(digs[x % base])
2705  x /= base
2706  if sign < 0:
2707  digits.append('-')
2708  digits.reverse()
2709  return ''.join(digits)
2710 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CloseHandle (   jitter)

Definition at line 376 of file win_api_x86_32.py.

377 def kernel32_CloseHandle(jitter):
378  ret_ad, _ = jitter.func_args_stdcall(["hwnd"])
379  jitter.func_ret_stdcall(ret_ad, 1)
380 
def miasm2.os_dep.win_api_x86_32.kernel32_CreateDirectoryA (   jitter)

Definition at line 1560 of file win_api_x86_32.py.

1561 def kernel32_CreateDirectoryA(jitter):
1562  my_CreateDirectory(jitter, whoami(), get_str_ansi)
1563 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateDirectoryW (   jitter)

Definition at line 1556 of file win_api_x86_32.py.

1557 def kernel32_CreateDirectoryW(jitter):
1558  my_CreateDirectory(jitter, whoami(), get_str_unic)
1559 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateEventA (   jitter)

Definition at line 1591 of file win_api_x86_32.py.

1592 def kernel32_CreateEventA(jitter):
1593  my_CreateEvent(jitter, whoami(), get_str_ansi)
1594 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateEventW (   jitter)

Definition at line 1595 of file win_api_x86_32.py.

1596 def kernel32_CreateEventW(jitter):
1597  my_CreateEvent(jitter, whoami(), get_str_unic)
1598 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFile (   jitter,
  funcname,
  get_str 
)

Definition at line 515 of file win_api_x86_32.py.

516 def kernel32_CreateFile(jitter, funcname, get_str):
517  ret_ad, args = jitter.func_args_stdcall(["lpfilename", "access",
518  "dwsharedmode",
519  "lpsecurityattr",
520  "dwcreationdisposition",
521  "dwflagsandattr",
522  "htemplatefile"])
523  if args.lpfilename == 0:
524  jitter.func_ret_stdcall(ret_ad, 0xffffffff)
525  return
526 
527  fname = get_str(jitter, args.lpfilename)
528  log.debug('fname %s', fname)
529  ret = 0xffffffff
530 
531  log.debug("%r %r", fname.lower(), winobjs.module_path.lower())
532  is_original_file = fname.lower() == winobjs.module_path.lower()
533 
534  if fname.upper() in [r"\\.\SICE", r"\\.\NTICE", r"\\.\SIWVID"]:
535  pass
536  elif fname.upper() in ['NUL']:
537  ret = winobjs.module_cur_hwnd
538  else:
539  # sandox path
540  sb_fname = windows_to_sbpath(fname)
541  if args.access & 0x80000000 or args.access == 1:
542  # read
543  if args.dwcreationdisposition == 2:
544  # create_always
545  if os.access(sb_fname, os.R_OK):
546  # but file exist
547  pass
548  else:
549  raise NotImplementedError("Untested case") # to test
550  # h = open(sb_fname, 'rb+')
551  elif args.dwcreationdisposition == 3:
552  # open_existing
553  if os.access(sb_fname, os.R_OK):
554  s = os.stat(sb_fname)
555  if stat.S_ISDIR(s.st_mode):
556  ret = winobjs.handle_pool.add(sb_fname, 0x1337)
557  else:
558  h = open(sb_fname, 'r+b')
559  ret = winobjs.handle_pool.add(sb_fname, h)
560  else:
561  log.warning("FILE %r DOES NOT EXIST!", fname)
562  elif args.dwcreationdisposition == 1:
563  # create new
564  if os.access(sb_fname, os.R_OK):
565  # file exist
566  # ret = 80
567  winobjs.lastwin32error = 80
568  else:
569  # first create an empty file
570  open(sb_fname, 'w').close()
571  # then open
572  h = open(sb_fname, 'r+b')
573  ret = winobjs.handle_pool.add(sb_fname, h)
574  elif args.dwcreationdisposition == 4:
575  # open_always
576  if os.access(sb_fname, os.R_OK):
577  s = os.stat(sb_fname)
578  if stat.S_ISDIR(s.st_mode):
579  ret = winobjs.handle_pool.add(sb_fname, 0x1337)
580  else:
581  h = open(sb_fname, 'r+b')
582  ret = winobjs.handle_pool.add(sb_fname, h)
583  else:
584  raise NotImplementedError("Untested case")
585  else:
586  raise NotImplementedError("Untested case")
587  elif args.access & 0x40000000:
588  # write
589  if args.dwcreationdisposition == 3:
590  # open existing
591  if is_original_file:
592  # cannot open self in write mode!
593  pass
594  elif os.access(sb_fname, os.R_OK):
595  s = os.stat(sb_fname)
596  if stat.S_ISDIR(s.st_mode):
597  # open dir
598  ret = winobjs.handle_pool.add(sb_fname, 0x1337)
599  else:
600  h = open(sb_fname, 'r+b')
601  ret = winobjs.handle_pool.add(sb_fname, h)
602  else:
603  raise NotImplementedError("Untested case") # to test
604  elif args.dwcreationdisposition == 5:
605  # truncate_existing
606  if is_original_file:
607  pass
608  else:
609  raise NotImplementedError("Untested case") # to test
610  else:
611  # raise NotImplementedError("Untested case") # to test
612  h = open(sb_fname, 'w')
613  ret = winobjs.handle_pool.add(sb_fname, h)
614  else:
615  raise NotImplementedError("Untested case")
616 
617  # h = open(sb_fname, 'rb+')
618  # ret = winobjs.handle_pool.add(sb_fname, h)
619  log.debug('ret %x', ret)
620  jitter.func_ret_stdcall(ret_ad, ret)
621 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFileA (   jitter)

Definition at line 622 of file win_api_x86_32.py.

623 def kernel32_CreateFileA(jitter):
624  kernel32_CreateFile(jitter, whoami(), get_str_ansi)
625 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFileMapping (   jitter,
  funcname,
  get_str 
)

Definition at line 2171 of file win_api_x86_32.py.

2172 def kernel32_CreateFileMapping(jitter, funcname, get_str):
2173  ret_ad, args = jitter.func_args_stdcall(["hfile", "lpattr", "flprotect",
2174  "dwmaximumsizehigh",
2175  "dwmaximumsizelow", "lpname"])
2176  # f = get_str(jitter, args.lpname) if args.lpname else None
2177 
2178  if args.hfile == 0xffffffff:
2179  # Create null mapping
2180  if args.dwmaximumsizehigh:
2181  raise NotImplementedError("Untested case")
2182  hmap = StringIO("\x00"*args.dwmaximumsizelow)
2183  hmap_handle = winobjs.handle_pool.add('filemem', hmap)
2184 
2185  ret = winobjs.handle_pool.add('filemapping', hmap_handle)
2186  else:
2187  if not args.hfile in winobjs.handle_pool:
2188  raise ValueError('unknown handle')
2189  ret = winobjs.handle_pool.add('filemapping', args.hfile)
2190  jitter.func_ret_stdcall(ret_ad, ret)
2191 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFileMappingA (   jitter)

Definition at line 2192 of file win_api_x86_32.py.

2193 def kernel32_CreateFileMappingA(jitter):
2194  kernel32_CreateFileMapping(jitter, whoami(), get_str_ansi)
2195 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFileMappingW (   jitter)

Definition at line 2196 of file win_api_x86_32.py.

2197 def kernel32_CreateFileMappingW(jitter):
2198  kernel32_CreateFileMapping(jitter, whoami(), get_str_unic)
2199 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateFileW (   jitter)

Definition at line 626 of file win_api_x86_32.py.

627 def kernel32_CreateFileW(jitter):
628  kernel32_CreateFile(jitter, whoami(), lambda x, y: get_str_unic(jitter, y))
629 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateMutex (   jitter,
  funcname,
  get_str 
)

Definition at line 807 of file win_api_x86_32.py.

808 def kernel32_CreateMutex(jitter, funcname, get_str):
809  ret_ad, args = jitter.func_args_stdcall(["mutexattr", "initowner",
810  "lpname"])
811 
812  if args.lpname:
813  name = get_str(jitter, args.lpname)
814  log.debug(name)
815  else:
816  name = None
817  if args.initowner:
818  if name in winobjs.mutex:
819  raise NotImplementedError("Untested case")
820  # ret = 0
821  else:
822  winobjs.mutex[name] = id(name)
823  ret = winobjs.mutex[name]
824  else:
825  if name in winobjs.mutex:
826  raise NotImplementedError("Untested case")
827  # ret = 0
828  else:
829  winobjs.mutex[name] = id(name)
830  ret = winobjs.mutex[name]
831  jitter.func_ret_stdcall(ret_ad, ret)
832 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateMutexA (   jitter)

Definition at line 833 of file win_api_x86_32.py.

834 def kernel32_CreateMutexA(jitter):
835  kernel32_CreateMutex(jitter, whoami(), get_str_ansi)
836 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateMutexW (   jitter)

Definition at line 837 of file win_api_x86_32.py.

838 def kernel32_CreateMutexW(jitter):
839  kernel32_CreateMutex(jitter, whoami(), get_str_unic)
840 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_CreateToolhelp32Snapshot (   jitter)

Definition at line 290 of file win_api_x86_32.py.

292  ret_ad, _ = jitter.func_args_stdcall(["dwflags", "th32processid"])
293  jitter.func_ret_stdcall(ret_ad, winobjs.handle_toolhelpsnapshot)
294 
def miasm2.os_dep.win_api_x86_32.kernel32_FindFirstFileA (   jitter)

Definition at line 2651 of file win_api_x86_32.py.

2652 def kernel32_FindFirstFileA(jitter):
2653  ret_ad, args = jitter.func_args_stdcall(["pfilepattern", "pfindfiledata"])
2654 
2655  filepattern = get_str_ansi(jitter, args.pfilepattern)
2656  h = winobjs.find_data.findfirst(filepattern)
2657 
2658  fname = winobjs.find_data.findnext(h)
2659  fdata = win32_find_data(cfilename=fname)
2660 
2661  jitter.vm.set_mem(args.pfindfiledata, fdata.toStruct())
2662  jitter.func_ret_stdcall(ret_ad, h)
2663 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_FindNextFileA (   jitter)

Definition at line 2664 of file win_api_x86_32.py.

2665 def kernel32_FindNextFileA(jitter):
2666  ret_ad, args = jitter.func_args_stdcall(["handle", "pfindfiledata"])
2667 
2668  fname = winobjs.find_data.findnext(args.handle)
2669  if fname is None:
2670  ret = 0
2671  else:
2672  ret = 1
2673  fdata = win32_find_data(cfilename=fname)
2674  jitter.vm.set_mem(args.pfindfiledata, fdata.toStruct())
2675 
2676  jitter.func_ret_stdcall(ret_ad, ret)
2677 
def miasm2.os_dep.win_api_x86_32.kernel32_FlushFileBuffers (   jitter)

Definition at line 2416 of file win_api_x86_32.py.

2417 def kernel32_FlushFileBuffers(jitter):
2418  ret_ad, args = jitter.func_args_stdcall(['hwnd'])
2419  if args.hwnd in winobjs.handle_pool:
2420  pass
2421  else:
2422  raise ValueError('unknown filename')
2423  jitter.func_ret_stdcall(ret_ad, 1)
2424 
def miasm2.os_dep.win_api_x86_32.kernel32_FlushInstructionCache (   jitter)

Definition at line 694 of file win_api_x86_32.py.

696  ret_ad, _ = jitter.func_args_stdcall(["hprocess", "lpbasead", "dwsize"])
697  jitter.func_ret_stdcall(ret_ad, 0x1337)
698 
def miasm2.os_dep.win_api_x86_32.kernel32_GetCommandLineA (   jitter)

Definition at line 1008 of file win_api_x86_32.py.

1009 def kernel32_GetCommandLineA(jitter):
1010  ret_ad, _ = jitter.func_args_stdcall(0)
1011  s = winobjs.module_path + '\x00'
1012  s = '"%s"' % s
1013  alloc_addr = winobjs.heap.alloc(jitter, 0x1000)
1014  jitter.vm.set_mem(alloc_addr, s)
1015  jitter.func_ret_stdcall(ret_ad, alloc_addr)
1016 
def miasm2.os_dep.win_api_x86_32.kernel32_GetCommandLineW (   jitter)

Definition at line 1017 of file win_api_x86_32.py.

1018 def kernel32_GetCommandLineW(jitter):
1019  ret_ad, _ = jitter.func_args_stdcall(0)
1020  s = winobjs.module_path + '\x00'
1021  s = set_str_unic('"%s"' % s)
1022  alloc_addr = winobjs.heap.alloc(jitter, 0x1000)
1023  jitter.vm.set_mem(alloc_addr, s)
1024  jitter.func_ret_stdcall(ret_ad, alloc_addr)
1025 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetCurrentProcess (   jitter)

Definition at line 295 of file win_api_x86_32.py.

296 def kernel32_GetCurrentProcess(jitter):
297  ret_ad, _ = jitter.func_args_stdcall(0)
298  jitter.func_ret_stdcall(ret_ad, winobjs.handle_curprocess)
299 
def miasm2.os_dep.win_api_x86_32.kernel32_GetCurrentProcessId (   jitter)

Definition at line 300 of file win_api_x86_32.py.

301 def kernel32_GetCurrentProcessId(jitter):
302  ret_ad, _ = jitter.func_args_stdcall(0)
303  jitter.func_ret_stdcall(ret_ad, winobjs.dw_pid_cur)
304 
def miasm2.os_dep.win_api_x86_32.kernel32_GetCurrentThreadId (   jitter)

Definition at line 2110 of file win_api_x86_32.py.

2111 def kernel32_GetCurrentThreadId(jitter):
2112  ret_ad, _ = jitter.func_args_stdcall(0)
2113  jitter.func_ret_stdcall(ret_ad, 0x113377)
2114 
def miasm2.os_dep.win_api_x86_32.kernel32_GetDiskFreeSpace (   jitter,
  funcname,
  get_str 
)

Definition at line 2280 of file win_api_x86_32.py.

2281 def kernel32_GetDiskFreeSpace(jitter, funcname, get_str):
2282  ret_ad, args = jitter.func_args_stdcall(["lprootpathname",
2283  "lpsectorpercluster",
2284  "lpbytespersector",
2285  "lpnumberoffreeclusters",
2286  "lptotalnumberofclusters"])
2287  # rootpath = (get_str(jitter, args.lprootpathname)
2288  # if args.lprootpathname else "")
2289  jitter.vm.set_mem(args.lpsectorpercluster, pck32(8))
2290  jitter.vm.set_mem(args.lpbytespersector, pck32(0x200))
2291  jitter.vm.set_mem(args.lpnumberoffreeclusters, pck32(0x222222))
2292  jitter.vm.set_mem(args.lptotalnumberofclusters, pck32(0x333333))
2293  jitter.func_ret_stdcall(ret_ad, 1)
2294 
tuple pck32
Definition: utils.py:12

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetDiskFreeSpaceA (   jitter)

Definition at line 2295 of file win_api_x86_32.py.

2296 def kernel32_GetDiskFreeSpaceA(jitter):
2297  kernel32_GetDiskFreeSpace(jitter, whoami(), get_str_ansi)
2298 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetDiskFreeSpaceW (   jitter)

Definition at line 2299 of file win_api_x86_32.py.

2300 def kernel32_GetDiskFreeSpaceW(jitter):
2301  kernel32_GetDiskFreeSpace(jitter, whoami(), get_str_unic)
2302 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetDriveType (   jitter,
  funcname,
  get_str 
)

Definition at line 2259 of file win_api_x86_32.py.

2260 def kernel32_GetDriveType(jitter, funcname, get_str):
2261  ret_ad, args = jitter.func_args_stdcall(['pathname'])
2262 
2263  p = get_str(jitter, args.pathname)
2264  p = p.upper()
2265 
2266  ret = 0
2267  if p[0] == "C":
2268  ret = 3
2269 
2270  jitter.func_ret_stdcall(ret_ad, ret)
2271 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetDriveTypeA (   jitter)

Definition at line 2272 of file win_api_x86_32.py.

2273 def kernel32_GetDriveTypeA(jitter):
2274  kernel32_GetDriveType(jitter, whoami(), get_str_ansi)
2275 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetDriveTypeW (   jitter)

Definition at line 2276 of file win_api_x86_32.py.

2277 def kernel32_GetDriveTypeW(jitter):
2278  kernel32_GetDriveType(jitter, whoami(), get_str_unic)
2279 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetEnvironmentVariableA (   jitter)

Definition at line 1564 of file win_api_x86_32.py.

1567  get_str_ansi,
1568  lambda x: x + "\x00",
1569  len)
1570 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetEnvironmentVariableW (   jitter)

Definition at line 1571 of file win_api_x86_32.py.

1574  get_str_unic,
1575  lambda x: "\x00".join(list(x + "\x00")),
1576  len)
1577 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetFileSize (   jitter)

Definition at line 660 of file win_api_x86_32.py.

661 def kernel32_GetFileSize(jitter):
662  ret_ad, args = jitter.func_args_stdcall(["hwnd", "lpfilesizehight"])
663 
664  if args.hwnd == winobjs.module_cur_hwnd:
665  ret = len(open(winobjs.module_fname_nux).read())
666  elif args.hwnd in winobjs.handle_pool:
667  wh = winobjs.handle_pool[args.hwnd]
668  ret = len(open(wh.name).read())
669  else:
670  raise ValueError('unknown hwnd!')
671 
672  if args.lpfilesizehight != 0:
673  jitter.vm.set_mem(args.lpfilesizehight, pck32(ret))
674  jitter.func_ret_stdcall(ret_ad, ret)
675 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_GetFileSizeEx (   jitter)

Definition at line 676 of file win_api_x86_32.py.

677 def kernel32_GetFileSizeEx(jitter):
678  ret_ad, args = jitter.func_args_stdcall(["hwnd", "lpfilesizehight"])
679 
680  if args.hwnd == winobjs.module_cur_hwnd:
681  l = len(open(winobjs.module_fname_nux).read())
682  elif args.hwnd in winobjs.handle_pool:
683  wh = winobjs.handle_pool[args.hwnd]
684  l = len(open(wh.name).read())
685  else:
686  raise ValueError('unknown hwnd!')
687 
688  if args.lpfilesizehight == 0:
689  raise NotImplementedError("Untested case")
690  jitter.vm.set_mem(args.lpfilesizehight, pck32(
691  l & 0xffffffff) + pck32((l >> 32) & 0xffffffff))
692  jitter.func_ret_stdcall(ret_ad, 1)
693 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_GetLastError (   jitter)

Definition at line 867 of file win_api_x86_32.py.

868 def kernel32_GetLastError(jitter):
869  ret_ad, _ = jitter.func_args_stdcall(0)
870  jitter.func_ret_stdcall(ret_ad, winobjs.lastwin32error)
871 
def miasm2.os_dep.win_api_x86_32.kernel32_GetLocaleInfo (   jitter,
  funcname,
  set_str 
)

Definition at line 2031 of file win_api_x86_32.py.

2032 def kernel32_GetLocaleInfo(jitter, funcname, set_str):
2033  ret_ad, args = jitter.func_args_stdcall(["localeid", "lctype",
2034  "lplcdata", "cchdata"])
2035 
2036  buf = None
2037  ret = 0
2038  if args.localeid == 0x40c:
2039  if args.lctype == 0x3:
2040  buf = "ENGLISH"
2041  buf = buf[:args.cchdata - 1]
2042  jitter.vm.set_mem(args.lplcdata, set_str(buf))
2043  ret = len(buf)
2044  else:
2045  raise ValueError('unimpl localeid')
2046 
2047  jitter.func_ret_stdcall(ret_ad, ret)
2048 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetLocaleInfoA (   jitter)

Definition at line 2049 of file win_api_x86_32.py.

2050 def kernel32_GetLocaleInfoA(jitter):
2051  kernel32_GetLocaleInfo(jitter, whoami(), set_str_ansi)
2052 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetLocaleInfoW (   jitter)

Definition at line 2053 of file win_api_x86_32.py.

2054 def kernel32_GetLocaleInfoW(jitter):
2055  kernel32_GetLocaleInfo(jitter, whoami(), set_str_unic)
2056 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetLocalTime (   jitter)

Definition at line 2137 of file win_api_x86_32.py.

2138 def kernel32_GetLocalTime(jitter):
2139  ret_ad, args = jitter.func_args_stdcall(["lpsystemtime"])
2140 
2141  s = struct.pack('HHHHHHHH',
2142  2011, # year
2143  10, # month
2144  5, # dayofweek
2145  7, # day
2146  13, # hour
2147  37, # minutes
2148  00, # seconds
2149  999, # millisec
2150  )
2151  jitter.vm.set_mem(args.lpsystemtime, s)
2152  jitter.func_ret_stdcall(ret_ad, args.lpsystemtime)
2153 
def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleFileName (   jitter,
  funcname,
  set_str 
)

Definition at line 770 of file win_api_x86_32.py.

771 def kernel32_GetModuleFileName(jitter, funcname, set_str):
772  ret_ad, args = jitter.func_args_stdcall(["hmodule", "lpfilename", "nsize"])
773 
774  if args.hmodule in [0, winobjs.hcurmodule]:
775  p = winobjs.module_path[:]
776  elif (winobjs.runtime_dll and
777  args.hmodule in winobjs.runtime_dll.name2off.values()):
778  name_inv = dict([(x[1], x[0])
779  for x in winobjs.runtime_dll.name2off.items()])
780  p = name_inv[args.hmodule]
781  else:
782  log.warning(('Unknown module 0x%x.' +
783  'Set winobjs.hcurmodule and retry'), args.hmodule)
784  p = None
785 
786  if p is None:
787  l = 0
788  elif args.nsize < len(p):
789  p = p[:args.nsize]
790  l = len(p)
791  else:
792  l = len(p)
793 
794  if p:
795  jitter.vm.set_mem(args.lpfilename, set_str(p))
796 
797  jitter.func_ret_stdcall(ret_ad, l)
798 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleFileNameA (   jitter)

Definition at line 799 of file win_api_x86_32.py.

800 def kernel32_GetModuleFileNameA(jitter):
801  kernel32_GetModuleFileName(jitter, whoami(), set_str_ansi)
802 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleFileNameW (   jitter)

Definition at line 803 of file win_api_x86_32.py.

804 def kernel32_GetModuleFileNameW(jitter):
805  kernel32_GetModuleFileName(jitter, whoami(), set_str_unic)
806 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleHandle (   jitter,
  funcname,
  get_str 
)

Definition at line 939 of file win_api_x86_32.py.

940 def kernel32_GetModuleHandle(jitter, funcname, get_str):
941  ret_ad, args = jitter.func_args_stdcall(["dllname"])
942 
943  if args.dllname:
944  libname = get_str(jitter, args.dllname)
945  log.info(libname)
946  if libname:
947  ret = winobjs.runtime_dll.lib_get_add_base(libname)
948  else:
949  log.warning('unknown module!')
950  ret = 0
951  else:
952  ret = winobjs.current_pe.NThdr.ImageBase
953  log.debug("default img base %x", ret)
954  jitter.func_ret_stdcall(ret_ad, ret)
955 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleHandleA (   jitter)

Definition at line 956 of file win_api_x86_32.py.

957 def kernel32_GetModuleHandleA(jitter):
958  kernel32_GetModuleHandle(jitter, whoami(), get_str_ansi)
959 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetModuleHandleW (   jitter)

Definition at line 960 of file win_api_x86_32.py.

961 def kernel32_GetModuleHandleW(jitter):
962  kernel32_GetModuleHandle(jitter, whoami(), get_str_unic)
963 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetNativeSystemInfo (   jitter)

Definition at line 2678 of file win_api_x86_32.py.

2679 def kernel32_GetNativeSystemInfo(jitter):
2680  ret_ad, args = jitter.func_args_stdcall(["sys_ptr"])
2681  sysinfo = systeminfo()
2682  jitter.vm.set_mem(args.sys_ptr, sysinfo.pack())
2683  jitter.func_ret_stdcall(ret_ad, 0)
2684 
def miasm2.os_dep.win_api_x86_32.kernel32_GetPriorityClass (   jitter)

Definition at line 366 of file win_api_x86_32.py.

367 def kernel32_GetPriorityClass(jitter):
368  ret_ad, _ = jitter.func_args_stdcall(["hwnd"])
369  jitter.func_ret_stdcall(ret_ad, 0)
370 
def miasm2.os_dep.win_api_x86_32.kernel32_GetProcAddress (   jitter)

Definition at line 909 of file win_api_x86_32.py.

910 def kernel32_GetProcAddress(jitter):
911  ret_ad, args = jitter.func_args_stdcall(["libbase", "fname"])
912  fname = args.fname
913  if fname < 0x10000:
914  fname = fname
915  else:
916  fname = get_str_ansi(jitter, fname, 0x100)
917  if not fname:
918  fname = None
919  log.info(fname)
920  if fname is not None:
921  ad = winobjs.runtime_dll.lib_get_add_func(args.libbase, fname)
922  else:
923  ad = 0
924  ad = winobjs.runtime_dll.lib_get_add_func(args.libbase, fname)
925  jitter.add_breakpoint(ad, jitter.handle_lib)
926  jitter.func_ret_stdcall(ret_ad, ad)
927 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetProcessAffinityMask (   jitter)

Definition at line 2341 of file win_api_x86_32.py.

2343  ret_ad, args = jitter.func_args_stdcall(["hprocess",
2344  "procaffmask",
2345  "systemaffmask"])
2346  jitter.vm.set_mem(args.procaffmask, pck32(1))
2347  jitter.vm.set_mem(args.systemaffmask, pck32(1))
2348  jitter.func_ret_stdcall(ret_ad, 1)
2349 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_GetStartupInfo (   jitter,
  funcname,
  set_str 
)

Definition at line 2093 of file win_api_x86_32.py.

2094 def kernel32_GetStartupInfo(jitter, funcname, set_str):
2095  ret_ad, args = jitter.func_args_stdcall(["ptr"])
2096 
2097  s = "\x00" * 0x2c + "\x81\x00\x00\x00" + "\x0a"
2098 
2099  jitter.vm.set_mem(args.ptr, s)
2100  jitter.func_ret_stdcall(ret_ad, args.ptr)
2101 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetStartupInfoA (   jitter)

Definition at line 2102 of file win_api_x86_32.py.

2103 def kernel32_GetStartupInfoA(jitter):
2104  kernel32_GetStartupInfo(jitter, whoami(), set_str_ansi)
2105 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetStartupInfoW (   jitter)

Definition at line 2106 of file win_api_x86_32.py.

2107 def kernel32_GetStartupInfoW(jitter):
2108  kernel32_GetStartupInfo(jitter, whoami(), set_str_unic)
2109 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetSystemDefaultLangID (   jitter)

Definition at line 2465 of file win_api_x86_32.py.

2467  ret_ad, _ = jitter.func_args_stdcall(0)
2468  jitter.func_ret_stdcall(ret_ad, 0x409) # encglish
2469 
def miasm2.os_dep.win_api_x86_32.kernel32_GetSystemDirectoryA (   jitter)

Definition at line 1542 of file win_api_x86_32.py.

1543 def kernel32_GetSystemDirectoryA(jitter):
1544  my_GetSystemDirectory(jitter, whoami(), set_str_ansi)
1545 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetSystemDirectoryW (   jitter)

Definition at line 1546 of file win_api_x86_32.py.

1547 def kernel32_GetSystemDirectoryW(jitter):
1548  my_GetSystemDirectory(jitter, whoami(), set_str_unic)
1549 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetSystemInfo (   jitter)

Definition at line 995 of file win_api_x86_32.py.

996 def kernel32_GetSystemInfo(jitter):
997  ret_ad, args = jitter.func_args_stdcall(["sys_ptr"])
998  sysinfo = systeminfo()
999  jitter.vm.set_mem(args.sys_ptr, sysinfo.pack())
1000  jitter.func_ret_stdcall(ret_ad, 0)
1001 
def miasm2.os_dep.win_api_x86_32.kernel32_GetSystemTime (   jitter)

Definition at line 2154 of file win_api_x86_32.py.

2155 def kernel32_GetSystemTime(jitter):
2156  ret_ad, args = jitter.func_args_stdcall(["lpsystemtime"])
2157 
2158  s = struct.pack('HHHHHHHH',
2159  2011, # year
2160  10, # month
2161  5, # dayofweek
2162  7, # day
2163  13, # hour
2164  37, # minutes
2165  00, # seconds
2166  999, # millisec
2167  )
2168  jitter.vm.set_mem(args.lpsystemtime, s)
2169  jitter.func_ret_stdcall(ret_ad, args.lpsystemtime)
2170 
def miasm2.os_dep.win_api_x86_32.kernel32_GetTempFileNameA (   jitter)

Definition at line 2571 of file win_api_x86_32.py.

2572 def kernel32_GetTempFileNameA(jitter):
2573  global temp_num
2574  ret_ad, args = jitter.func_args_stdcall(["path", "ext", "unique", "buf"])
2575 
2576  temp_num += 1
2577  ext = get_str_ansi(jitter, args.ext) if args.ext else 'tmp'
2578  path = get_str_ansi(jitter, args.path) if args.path else "xxx"
2579  fname = path + "\\" + "temp%.4d" % temp_num + "." + ext
2580  jitter.vm.set_mem(args.buf, fname)
2581 
2582  jitter.func_ret_stdcall(ret_ad, 0)
2583 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetTempPathA (   jitter)

Definition at line 2560 of file win_api_x86_32.py.

2561 def kernel32_GetTempPathA(jitter):
2562  kernel32_myGetTempPath(jitter, set_str_ansi)
2563 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetTempPathW (   jitter)

Definition at line 2564 of file win_api_x86_32.py.

2565 def kernel32_GetTempPathW(jitter):
2566  kernel32_myGetTempPath(jitter, set_str_unic)
2567 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetThreadLocale (   jitter)

Definition at line 2026 of file win_api_x86_32.py.

2027 def kernel32_GetThreadLocale(jitter):
2028  ret_ad, _ = jitter.func_args_stdcall(0)
2029  jitter.func_ret_stdcall(ret_ad, 0x40c)
2030 
def miasm2.os_dep.win_api_x86_32.kernel32_GetTickCount (   jitter)

Definition at line 331 of file win_api_x86_32.py.

332 def kernel32_GetTickCount(jitter):
333  ret_ad, _ = jitter.func_args_stdcall(0)
334  winobjs.tickcount += 1
335  jitter.func_ret_stdcall(ret_ad, winobjs.tickcount)
336 
def miasm2.os_dep.win_api_x86_32.kernel32_GetUserGeoID (   jitter)

Definition at line 1450 of file win_api_x86_32.py.

1451 def kernel32_GetUserGeoID(jitter):
1452  ret_ad, args = jitter.func_args_stdcall(["geoclass"])
1453  if args.geoclass == 14:
1454  ret = 12345678
1455  elif args.geoclass == 16:
1456  ret = 55667788
1457  else:
1458  raise ValueError('unknown geolcass')
1459  jitter.func_ret_stdcall(ret_ad, ret)
1460 
def miasm2.os_dep.win_api_x86_32.kernel32_GetVersion (   jitter)

Definition at line 337 of file win_api_x86_32.py.

338 def kernel32_GetVersion(jitter):
339  ret_ad, _ = jitter.func_args_stdcall(0)
340  jitter.func_ret_stdcall(ret_ad, winobjs.getversion)
341 
def miasm2.os_dep.win_api_x86_32.kernel32_GetVersionEx (   jitter,
  set_str = set_str_unic 
)

Definition at line 342 of file win_api_x86_32.py.

343 def kernel32_GetVersionEx(jitter, set_str=set_str_unic):
344  ret_ad, args = jitter.func_args_stdcall(["ptr_struct"])
345 
346  s = struct.pack("IIIII",
347  0x114, # struct size
348  0x5, # maj vers
349  0x2, # min vers
350  0xa28, # build nbr
351  0x2, # platform id
352  )
353  t = set_str("Service pack 4")
354  t = s + (t + '\x00' * 128 * 2)[:128 * 2]
355  t += struct.pack('HHHBB', 3, 0, 0x100, 1, 0)
356  s = t
357  jitter.vm.set_mem(args.ptr_struct, s)
358  jitter.func_ret_stdcall(ret_ad, 1)
359 
def miasm2.os_dep.win_api_x86_32.kernel32_GetVolumeInformationA (   jitter)

Definition at line 1493 of file win_api_x86_32.py.

1494 def kernel32_GetVolumeInformationA(jitter):
1496  jitter, whoami(), get_str_ansi, lambda x: x + "\x00")
1497 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GetVolumeInformationW (   jitter)

Definition at line 1498 of file win_api_x86_32.py.

1499 def kernel32_GetVolumeInformationW(jitter):
1500  my_GetVolumeInformation(jitter, whoami(), get_str_unic, set_str_unic)
1501 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_GlobalAlloc (   jitter)

Definition at line 263 of file win_api_x86_32.py.

264 def kernel32_GlobalAlloc(jitter):
265  ret_ad, args = jitter.func_args_stdcall(["uflags", "msize"])
266  alloc_addr = winobjs.heap.alloc(jitter, args.msize)
267  jitter.func_ret_stdcall(ret_ad, alloc_addr)
268 
def miasm2.os_dep.win_api_x86_32.kernel32_GlobalFree (   jitter)

Definition at line 280 of file win_api_x86_32.py.

281 def kernel32_GlobalFree(jitter):
282  ret_ad, _ = jitter.func_args_stdcall(["addr"])
283  jitter.func_ret_stdcall(ret_ad, 0)
284 
def miasm2.os_dep.win_api_x86_32.kernel32_HeapAlloc (   jitter)

Definition at line 252 of file win_api_x86_32.py.

253 def kernel32_HeapAlloc(jitter):
254  ret_ad, args = jitter.func_args_stdcall(["heap", "flags", "size"])
255  alloc_addr = winobjs.heap.alloc(jitter, args.size)
256  jitter.func_ret_stdcall(ret_ad, alloc_addr)
257 
def miasm2.os_dep.win_api_x86_32.kernel32_HeapFree (   jitter)

Definition at line 258 of file win_api_x86_32.py.

259 def kernel32_HeapFree(jitter):
260  ret_ad, _ = jitter.func_args_stdcall(["heap", "flags", "pmem"])
261  jitter.func_ret_stdcall(ret_ad, 1)
262 
def miasm2.os_dep.win_api_x86_32.kernel32_InitializeCriticalSection (   jitter)

Definition at line 2115 of file win_api_x86_32.py.

2117  ret_ad, _ = jitter.func_args_stdcall(["lpcritic"])
2118  jitter.func_ret_stdcall(ret_ad, 0)
2119 
def miasm2.os_dep.win_api_x86_32.kernel32_IsBadReadPtr (   jitter)

Definition at line 1230 of file win_api_x86_32.py.

1231 def kernel32_IsBadReadPtr(jitter):
1232  ret_ad, _ = jitter.func_args_stdcall(['lp', 'ucb'])
1233  jitter.func_ret_stdcall(ret_ad, 0)
1234 
def miasm2.os_dep.win_api_x86_32.kernel32_IsDebuggerPresent (   jitter)

Definition at line 285 of file win_api_x86_32.py.

286 def kernel32_IsDebuggerPresent(jitter):
287  ret_ad, _ = jitter.func_args_stdcall(0)
288  jitter.func_ret_stdcall(ret_ad, winobjs.dbg_present)
289 
def miasm2.os_dep.win_api_x86_32.kernel32_IsWow64Process (   jitter)

Definition at line 1002 of file win_api_x86_32.py.

1003 def kernel32_IsWow64Process(jitter):
1004  ret_ad, args = jitter.func_args_stdcall(["process", "bool_ptr"])
1005  jitter.vm.set_mem(args.bool_ptr, pck32(0))
1006  jitter.func_ret_stdcall(ret_ad, 1)
1007 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_LoadLibraryA (   jitter)

Definition at line 885 of file win_api_x86_32.py.

886 def kernel32_LoadLibraryA(jitter):
887  ret_ad, args = jitter.func_args_stdcall(["dllname"])
888 
889  libname = get_str_ansi(jitter, args.dllname, 0x100)
890  log.info(libname)
891 
892  ret = winobjs.runtime_dll.lib_get_add_base(libname)
893  log.info("ret %x", ret)
894  jitter.func_ret_stdcall(ret_ad, ret)
895 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_LoadLibraryExA (   jitter)

Definition at line 896 of file win_api_x86_32.py.

897 def kernel32_LoadLibraryExA(jitter):
898  ret_ad, args = jitter.func_args_stdcall(["dllname", "hfile", "flags"])
899 
900  if args.hfile != 0:
901  raise NotImplementedError("Untested case")
902  libname = get_str_ansi(jitter, args.dllname, 0x100)
903  log.info(libname)
904 
905  ret = winobjs.runtime_dll.lib_get_add_base(libname)
906  log.info("ret %x", ret)
907  jitter.func_ret_stdcall(ret_ad, ret)
908 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_LoadLibraryW (   jitter)

Definition at line 928 of file win_api_x86_32.py.

929 def kernel32_LoadLibraryW(jitter):
930  ret_ad, args = jitter.func_args_stdcall(["dllname"])
931 
932  libname = get_str_unic(jitter, args.dllname, 0x100)
933  log.info(libname)
934 
935  ret = winobjs.runtime_dll.lib_get_add_base(libname)
936  log.info("ret %x", ret)
937  jitter.func_ret_stdcall(ret_ad, ret)
938 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_LocalAlloc (   jitter)

Definition at line 274 of file win_api_x86_32.py.

275 def kernel32_LocalAlloc(jitter):
276  ret_ad, args = jitter.func_args_stdcall(["uflags", "msize"])
277  alloc_addr = winobjs.heap.alloc(jitter, args.msize)
278  jitter.func_ret_stdcall(ret_ad, alloc_addr)
279 
def miasm2.os_dep.win_api_x86_32.kernel32_LocalFree (   jitter)

Definition at line 269 of file win_api_x86_32.py.

270 def kernel32_LocalFree(jitter):
271  ret_ad, _ = jitter.func_args_stdcall(["lpvoid"])
272  jitter.func_ret_stdcall(ret_ad, 0)
273 
def miasm2.os_dep.win_api_x86_32.kernel32_lstrcatA (   jitter)

Definition at line 1442 of file win_api_x86_32.py.

1443 def kernel32_lstrcatA(jitter):
1444  my_lstrcat(jitter, whoami(), get_str_ansi)
1445 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcatW (   jitter)

Definition at line 1446 of file win_api_x86_32.py.

1447 def kernel32_lstrcatW(jitter):
1448  my_lstrcat(jitter, whoami(), get_str_unic)
1449 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcmpA (   jitter)

Definition at line 1367 of file win_api_x86_32.py.

1368 def kernel32_lstrcmpA(jitter):
1369  my_lstrcmp(jitter, whoami(), lambda x: get_str_ansi(jitter, x))
1370 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcmpi (   jitter)

Definition at line 1383 of file win_api_x86_32.py.

1384 def kernel32_lstrcmpi(jitter):
1385  my_lstrcmp(jitter, whoami(), lambda x: get_str_ansi(jitter, x).lower())
1386 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcmpiA (   jitter)

Definition at line 1371 of file win_api_x86_32.py.

1372 def kernel32_lstrcmpiA(jitter):
1373  my_lstrcmp(jitter, whoami(), lambda x: get_str_ansi(jitter, x).lower())
1374 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcmpiW (   jitter)

Definition at line 1379 of file win_api_x86_32.py.

1380 def kernel32_lstrcmpiW(jitter):
1381  my_lstrcmp(jitter, whoami(), lambda x: get_str_unic(jitter, x).lower())
1382 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcmpW (   jitter)

Definition at line 1375 of file win_api_x86_32.py.

1376 def kernel32_lstrcmpW(jitter):
1377  my_lstrcmp(jitter, whoami(), lambda x: get_str_unic(jitter, x))
1378 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcpy (   jitter)

Definition at line 1403 of file win_api_x86_32.py.

1404 def kernel32_lstrcpy(jitter):
1405  my_strcpy(jitter, whoami(), get_str_ansi, lambda x: x + "\x00")
1406 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcpyA (   jitter)

Definition at line 1399 of file win_api_x86_32.py.

1400 def kernel32_lstrcpyA(jitter):
1401  my_strcpy(jitter, whoami(), get_str_ansi, lambda x: x + "\x00")
1402 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcpyn (   jitter)

Definition at line 1407 of file win_api_x86_32.py.

1408 def kernel32_lstrcpyn(jitter):
1409  ret_ad, args = jitter.func_args_stdcall(["ptr_str1", "ptr_str2",
1410  "mlen"])
1411  s2 = get_str_ansi(jitter, args.ptr_str2)
1412  s2 = s2[:args.mlen]
1413  jitter.vm.set_mem(args.ptr_str1, s2)
1414  jitter.func_ret_stdcall(ret_ad, args.ptr_str1)
1415 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrcpyW (   jitter)

Definition at line 1394 of file win_api_x86_32.py.

1395 def kernel32_lstrcpyW(jitter):
1396  my_strcpy(jitter, whoami(), get_str_unic,
1397  lambda x: set_str_unic(x) + "\x00\x00")
1398 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrlen (   jitter)

Definition at line 1430 of file win_api_x86_32.py.

1431 def kernel32_lstrlen(jitter):
1432  my_strlen(jitter, whoami(), get_str_ansi, len)
1433 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrlenA (   jitter)

Definition at line 1422 of file win_api_x86_32.py.

1423 def kernel32_lstrlenA(jitter):
1424  my_strlen(jitter, whoami(), get_str_ansi, len)
1425 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_lstrlenW (   jitter)

Definition at line 1426 of file win_api_x86_32.py.

1427 def kernel32_lstrlenW(jitter):
1428  my_strlen(jitter, whoami(), get_str_unic, len)
1429 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_MapViewOfFile (   jitter)

Definition at line 2200 of file win_api_x86_32.py.

2201 def kernel32_MapViewOfFile(jitter):
2202  ret_ad, args = jitter.func_args_stdcall(["hfile", "flprotect",
2203  "dwfileoffsethigh",
2204  "dwfileoffsetlow",
2205  "length"])
2206 
2207  if not args.hfile in winobjs.handle_pool:
2208  raise ValueError('unknown handle')
2209  hmap = winobjs.handle_pool[args.hfile]
2210  if not hmap.info in winobjs.handle_pool:
2211  raise ValueError('unknown file handle')
2212 
2213  hfile_o = winobjs.handle_pool[hmap.info]
2214  fd = hfile_o.info
2215  fd.seek((args.dwfileoffsethigh << 32) | args.dwfileoffsetlow)
2216  data = fd.read(args.length) if args.length else fd.read()
2217  length = len(data)
2218 
2219  log.debug('mapp total: %x', len(data))
2220  access_dict = {
2221  0x0: 0,
2222  0x1: 0,
2223  0x2: PAGE_READ,
2224  0x4: PAGE_READ | PAGE_WRITE,
2225  0x10: PAGE_EXEC,
2226  0x20: PAGE_EXEC | PAGE_READ,
2227  0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
2228  0x100: 0,
2229  }
2230  # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
2231 
2232  if not args.flprotect in access_dict:
2233  raise ValueError('unknown access dw!')
2234 
2235  alloc_addr = winobjs.heap.alloc(jitter, len(data))
2236  jitter.vm.set_mem(alloc_addr, data)
2237 
2238  winobjs.handle_mapped[alloc_addr] = (hfile_o, args.dwfileoffsethigh,
2239  args.dwfileoffsetlow, length)
2240 
2241  jitter.func_ret_stdcall(ret_ad, alloc_addr)
2242 
def miasm2.os_dep.win_api_x86_32.kernel32_MultiByteToWideChar (   jitter)

Definition at line 1502 of file win_api_x86_32.py.

1503 def kernel32_MultiByteToWideChar(jitter):
1504  ret_ad, args = jitter.func_args_stdcall(["codepage", "dwflags",
1505  "lpmultibytestr",
1506  "cbmultibyte",
1507  "lpwidecharstr",
1508  "cchwidechar"])
1509  src = get_str_ansi(jitter, args.lpmultibytestr) + '\x00'
1510  l = len(src)
1511 
1512  src = "\x00".join(list(src))
1513  jitter.vm.set_mem(args.lpwidecharstr, src)
1514  jitter.func_ret_stdcall(ret_ad, l)
1515 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_myGetTempPath (   jitter,
  func 
)

Definition at line 2552 of file win_api_x86_32.py.

2553 def kernel32_myGetTempPath(jitter, func):
2554  ret_ad, args = jitter.func_args_stdcall(["l", "buf"])
2555  l = 'c:\\temp\\'
2556  if len(l) < args.l:
2557  jitter.vm.set_mem(args.buf, func(l + '\x00'))
2558  jitter.func_ret_stdcall(ret_ad, len(l))
2559 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_Process32First (   jitter)

Definition at line 305 of file win_api_x86_32.py.

306 def kernel32_Process32First(jitter):
307  ret_ad, args = jitter.func_args_stdcall(["s_handle", "ad_pentry"])
308 
309  pentry = struct.pack(
310  'IIIIIIIII', *process_list[0][:-1]) + process_list[0][-1]
311  jitter.vm.set_mem(args.ad_pentry, pentry)
312  winobjs.toolhelpsnapshot_info[args.s_handle] = 0
313 
314  jitter.func_ret_stdcall(ret_ad, 1)
315 
def miasm2.os_dep.win_api_x86_32.kernel32_Process32Next (   jitter)

Definition at line 316 of file win_api_x86_32.py.

317 def kernel32_Process32Next(jitter):
318  ret_ad, args = jitter.func_args_stdcall(["s_handle", "ad_pentry"])
319 
320  winobjs.toolhelpsnapshot_info[args.s_handle] += 1
321  if winobjs.toolhelpsnapshot_info[args.s_handle] >= len(process_list):
322  ret = 0
323  else:
324  ret = 1
325  n = winobjs.toolhelpsnapshot_info[args.s_handle]
326  pentry = struct.pack(
327  'IIIIIIIII', *process_list[n][:-1]) + process_list[n][-1]
328  jitter.vm.set_mem(args.ad_pentry, pentry)
329  jitter.func_ret_stdcall(ret_ad, ret)
330 
def miasm2.os_dep.win_api_x86_32.kernel32_ReadFile (   jitter)

Definition at line 630 of file win_api_x86_32.py.

631 def kernel32_ReadFile(jitter):
632  ret_ad, args = jitter.func_args_stdcall(["hwnd", "lpbuffer",
633  "nnumberofbytestoread",
634  "lpnumberofbytesread",
635  "lpoverlapped"])
636  if args.hwnd == winobjs.module_cur_hwnd:
637  pass
638  elif args.hwnd in winobjs.handle_pool:
639  pass
640  else:
641  raise ValueError('unknown hwnd!')
642 
643  data = None
644  if args.hwnd in winobjs.files_hwnd:
645  data = winobjs.files_hwnd[
646  winobjs.module_cur_hwnd].read(args.nnumberofbytestoread)
647  elif args.hwnd in winobjs.handle_pool:
648  wh = winobjs.handle_pool[args.hwnd]
649  data = wh.info.read(args.nnumberofbytestoread)
650  else:
651  raise ValueError('unknown filename')
652 
653  if data is not None:
654  if (args.lpnumberofbytesread):
655  jitter.vm.set_mem(args.lpnumberofbytesread, pck32(len(data)))
656  jitter.vm.set_mem(args.lpbuffer, data)
657 
658  jitter.func_ret_stdcall(ret_ad, 1)
659 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_RestoreLastError (   jitter)

Definition at line 881 of file win_api_x86_32.py.

882 def kernel32_RestoreLastError(jitter):
883  kernel32_SetLastError(jitter)
884 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_RtlMoveMemory (   jitter)

Definition at line 1112 of file win_api_x86_32.py.

1113 def kernel32_RtlMoveMemory(jitter):
1114  ret_ad, args = jitter.func_args_stdcall(["ad_dst", "ad_src", "m_len"])
1115  data = jitter.vm.get_mem(args.ad_src, args.m_len)
1116  jitter.vm.set_mem(args.ad_dst, data)
1117  jitter.func_ret_stdcall(ret_ad, 0)
1118 
def miasm2.os_dep.win_api_x86_32.kernel32_SetEndOfFile (   jitter)

Definition at line 2406 of file win_api_x86_32.py.

2407 def kernel32_SetEndOfFile(jitter):
2408  ret_ad, args = jitter.func_args_stdcall(['hwnd'])
2409  if args.hwnd in winobjs.handle_pool:
2410  wh = winobjs.handle_pool[args.hwnd]
2411  wh.info.seek(0, 2)
2412  else:
2413  raise ValueError('unknown filename')
2414  jitter.func_ret_stdcall(ret_ad, 1)
2415 
def miasm2.os_dep.win_api_x86_32.kernel32_SetFileAttributesA (   jitter)

Definition at line 1623 of file win_api_x86_32.py.

1624 def kernel32_SetFileAttributesA(jitter):
1625  ret_ad, args = jitter.func_args_stdcall(["lpfilename",
1626  "dwfileattributes"])
1627  if args.lpfilename:
1628  # fname = get_str_ansi(jitter, args.lpfilename)
1629  ret = 1
1630  else:
1631  ret = 0
1632  jitter.vm.set_mem(FS_0_AD + 0x34, pck32(3))
1633 
1634  jitter.func_ret_stdcall(ret_ad, ret)
1635 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_SetFilePointer (   jitter)

Definition at line 2355 of file win_api_x86_32.py.

2356 def kernel32_SetFilePointer(jitter):
2357  ret_ad, args = jitter.func_args_stdcall(["hwnd", "distance",
2358  "p_distance_high",
2359  "movemethod"])
2360 
2361  if args.hwnd == winobjs.module_cur_hwnd:
2362  pass
2363  elif args.hwnd in winobjs.handle_pool:
2364  pass
2365  else:
2366  raise ValueError('unknown hwnd!')
2367 
2368  # data = None
2369  if args.hwnd in winobjs.files_hwnd:
2370  winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(args.distance)
2371  elif args.hwnd in winobjs.handle_pool:
2372  wh = winobjs.handle_pool[args.hwnd]
2373  # data = wh.info.seek(args.distance)
2374  else:
2375  raise ValueError('unknown filename')
2376  jitter.func_ret_stdcall(ret_ad, args.distance)
2377 
def miasm2.os_dep.win_api_x86_32.kernel32_SetFilePointerEx (   jitter)

Definition at line 2378 of file win_api_x86_32.py.

2379 def kernel32_SetFilePointerEx(jitter):
2380  ret_ad, args = jitter.func_args_stdcall(["hwnd", "distance_l",
2381  "distance_h",
2382  "pnewfileptr",
2383  "movemethod"])
2384  distance = args.distance_l | (args.distance_h << 32)
2385  if distance:
2386  raise ValueError('Not implemented')
2387  if args.pnewfileptr:
2388  raise ValueError('Not implemented')
2389  if args.hwnd == winobjs.module_cur_hwnd:
2390  pass
2391  elif args.hwnd in winobjs.handle_pool:
2392  pass
2393  else:
2394  raise ValueError('unknown hwnd!')
2395 
2396  # data = None
2397  if args.hwnd in winobjs.files_hwnd:
2398  winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(distance)
2399  elif args.hwnd in winobjs.handle_pool:
2400  wh = winobjs.handle_pool[args.hwnd]
2401  # data = wh.info.seek(distance)
2402  else:
2403  raise ValueError('unknown filename')
2404  jitter.func_ret_stdcall(ret_ad, 1)
2405 
def miasm2.os_dep.win_api_x86_32.kernel32_SetLastError (   jitter)

Definition at line 872 of file win_api_x86_32.py.

873 def kernel32_SetLastError(jitter):
874  ret_ad, args = jitter.func_args_stdcall(["errcode"])
875  # lasterr addr
876  # ad = FS_0_AD + 0x34
877  # jitter.vm.set_mem(ad, pck32(args.errcode))
878  winobjs.lastwin32error = args.errcode
879  jitter.func_ret_stdcall(ret_ad, 0)
880 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_SetPriorityClass (   jitter)

Definition at line 371 of file win_api_x86_32.py.

372 def kernel32_SetPriorityClass(jitter):
373  ret_ad, _ = jitter.func_args_stdcall(["hwnd", "dwpclass"])
374  jitter.func_ret_stdcall(ret_ad, 0)
375 
def miasm2.os_dep.win_api_x86_32.kernel32_SHGetPathFromIDList (   jitter,
  funcname,
  set_str 
)

Definition at line 847 of file win_api_x86_32.py.

848 def kernel32_SHGetPathFromIDList(jitter, funcname, set_str):
849  ret_ad, args = jitter.func_args_stdcall(["pidl", "ppath"])
850 
851  if args.pidl == 7: # CSIDL_STARTUP:
852  s = "c:\\doc\\user\\startmenu\\programs\\startup"
853  s = set_str(s)
854  else:
855  raise ValueError('pidl not implemented', args.pidl)
856  jitter.vm.set_mem(args.ppath, s)
857  jitter.func_ret_stdcall(ret_ad, 1)
858 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.kernel32_Sleep (   jitter)

Definition at line 1220 of file win_api_x86_32.py.

1221 def kernel32_Sleep(jitter):
1222  ret_ad, _ = jitter.func_args_stdcall(['t'])
1223  jitter.func_ret_stdcall(ret_ad, 0)
1224 
def miasm2.os_dep.win_api_x86_32.kernel32_TlsAlloc (   jitter)

Definition at line 2057 of file win_api_x86_32.py.

2058 def kernel32_TlsAlloc(jitter):
2059  ret_ad, _ = jitter.func_args_stdcall(0)
2060  winobjs.tls_index += 1
2061  jitter.func_ret_stdcall(ret_ad, winobjs.tls_index)
2062 
def miasm2.os_dep.win_api_x86_32.kernel32_TlsFree (   jitter)

Definition at line 2063 of file win_api_x86_32.py.

2064 def kernel32_TlsFree(jitter):
2065  ret_ad, _ = jitter.func_args_stdcall(["tlsindex"])
2066  jitter.func_ret_stdcall(ret_ad, 0)
2067 
def miasm2.os_dep.win_api_x86_32.kernel32_TlsGetValue (   jitter)

Definition at line 2074 of file win_api_x86_32.py.

2075 def kernel32_TlsGetValue(jitter):
2076  ret_ad, args = jitter.func_args_stdcall(["tlsindex"])
2077  if not args.tlsindex in winobjs.tls_values:
2078  raise ValueError("unknown tls val", repr(args.tlsindex))
2079  jitter.func_ret_stdcall(ret_ad, winobjs.tls_values[args.tlsindex])
2080 
def miasm2.os_dep.win_api_x86_32.kernel32_TlsSetValue (   jitter)

Definition at line 2068 of file win_api_x86_32.py.

2069 def kernel32_TlsSetValue(jitter):
2070  ret_ad, args = jitter.func_args_stdcall(["tlsindex", "tlsvalue"])
2071  winobjs.tls_values[args.tlsindex] = args.tlsvalue
2072  jitter.func_ret_stdcall(ret_ad, 1)
2073 
def miasm2.os_dep.win_api_x86_32.kernel32_UnmapViewOfFile (   jitter)

Definition at line 2243 of file win_api_x86_32.py.

2244 def kernel32_UnmapViewOfFile(jitter):
2245  ret_ad, args = jitter.func_args_stdcall(['ad'])
2246 
2247  if not args.ad in winobjs.handle_mapped:
2248  raise NotImplementedError("Untested case")
2249  """
2250  hfile_o, dwfileoffsethigh, dwfileoffsetlow, length = winobjs.handle_mapped[ad]
2251  off = (dwfileoffsethigh<<32) | dwfileoffsetlow
2252  s = jitter.vm.get_mem(ad, length)
2253  hfile_o.info.seek(off)
2254  hfile_o.info.write(s)
2255  hfile_o.info.close()
2256  """
2257  jitter.func_ret_stdcall(ret_ad, 1)
2258 
def miasm2.os_dep.win_api_x86_32.kernel32_VirtualAlloc (   jitter)

Definition at line 716 of file win_api_x86_32.py.

717 def kernel32_VirtualAlloc(jitter):
718  ret_ad, args = jitter.func_args_stdcall(['lpvoid', 'dwsize',
719  'alloc_type', 'flprotect'])
720 
721  access_dict = {
722  0x0: 0,
723  0x1: 0,
724  0x2: PAGE_READ,
725  0x4: PAGE_READ | PAGE_WRITE,
726  0x10: PAGE_EXEC,
727  0x20: PAGE_EXEC | PAGE_READ,
728  0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
729  0x100: 0,
730  }
731 
732  # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
733 
734  if not args.flprotect in access_dict:
735  raise ValueError('unknown access dw!')
736 
737  if args.lpvoid == 0:
738  alloc_addr = winobjs.heap.next_addr(args.dwsize)
739  jitter.vm.add_memory_page(
740  alloc_addr, access_dict[args.flprotect], "\x00" * args.dwsize)
741  else:
742  all_mem = jitter.vm.get_all_memory()
743  if args.lpvoid in all_mem:
744  alloc_addr = args.lpvoid
745  jitter.vm.set_mem_access(args.lpvoid, access_dict[args.flprotect])
746  else:
747  alloc_addr = winobjs.heap.next_addr(args.dwsize)
748  # alloc_addr = args.lpvoid
749  jitter.vm.add_memory_page(
750  alloc_addr, access_dict[args.flprotect], "\x00" * args.dwsize)
751 
752  log.debug('Memory addr: %x', alloc_addr)
753  jitter.func_ret_stdcall(ret_ad, alloc_addr)
754 
def miasm2.os_dep.win_api_x86_32.kernel32_VirtualFree (   jitter)

Definition at line 755 of file win_api_x86_32.py.

756 def kernel32_VirtualFree(jitter):
757  ret_ad, _ = jitter.func_args_stdcall(["lpvoid", "dwsize", "alloc_type"])
758  jitter.func_ret_stdcall(ret_ad, 0)
759 
def miasm2.os_dep.win_api_x86_32.kernel32_VirtualLock (   jitter)

Definition at line 964 of file win_api_x86_32.py.

965 def kernel32_VirtualLock(jitter):
966  ret_ad, _ = jitter.func_args_stdcall(["lpaddress", "dwsize"])
967  jitter.func_ret_stdcall(ret_ad, 1)
968 
def miasm2.os_dep.win_api_x86_32.kernel32_VirtualProtect (   jitter)

Definition at line 699 of file win_api_x86_32.py.

700 def kernel32_VirtualProtect(jitter):
701  ret_ad, args = jitter.func_args_stdcall(['lpvoid', 'dwsize',
702  'flnewprotect',
703  'lpfloldprotect'])
704  # XXX mask hpart
705  flnewprotect = args.flnewprotect & 0xFFF
706  if not flnewprotect in access_dict:
707  raise ValueError('unknown access dw!')
708  jitter.vm.set_mem_access(args.lpvoid, access_dict[flnewprotect])
709 
710  # XXX todo real old protect
711  if args.lpfloldprotect:
712  jitter.vm.set_mem(args.lpfloldprotect, pck32(0x40))
713 
714  jitter.func_ret_stdcall(ret_ad, 1)
715 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.kernel32_VirtualQuery (   jitter)

Definition at line 2303 of file win_api_x86_32.py.

2304 def kernel32_VirtualQuery(jitter):
2305  ret_ad, args = jitter.func_args_stdcall(["ad", "lpbuffer", "dwl"])
2306 
2307  access_dict = {
2308  0x0: 0,
2309  0x1: 0,
2310  0x2: PAGE_READ,
2311  0x4: PAGE_READ | PAGE_WRITE,
2312  0x10: PAGE_EXEC,
2313  0x20: PAGE_EXEC | PAGE_READ,
2314  0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
2315  0x100: 0,
2316  }
2317  access_dict_inv = dict([(x[1], x[0]) for x in access_dict.iteritems()])
2318 
2319  all_mem = jitter.vm.get_all_memory()
2320  found = None
2321  for basead, m in all_mem.iteritems():
2322  if basead <= args.ad < basead + m['size']:
2323  found = args.ad, m
2324  break
2325  if not found:
2326  raise ValueError('cannot find mem', hex(args.ad))
2327 
2328  if args.dwl != 0x1c:
2329  raise ValueError('strange mem len', hex(args.dwl))
2330  s = struct.pack('IIIIIII',
2331  args.ad,
2332  basead,
2333  access_dict_inv[m['access']],
2334  m['size'],
2335  0x1000,
2336  access_dict_inv[m['access']],
2337  0x01000000)
2338  jitter.vm.set_mem(args.lpbuffer, s)
2339  jitter.func_ret_stdcall(ret_ad, args.dwl)
2340 
def miasm2.os_dep.win_api_x86_32.kernel32_WaitForSingleObject (   jitter)

Definition at line 1599 of file win_api_x86_32.py.

1600 def kernel32_WaitForSingleObject(jitter):
1601  ret_ad, args = jitter.func_args_stdcall(['handle', 'dwms'])
1602 
1603  t_start = time.time() * 1000
1604  found = False
1605  while True:
1606  if args.dwms and args.dwms + t_start > time.time() * 1000:
1607  ret = 0x102
1608  break
1609  for key, value in winobjs.events_pool.iteritems():
1610  if key != args.handle:
1611  continue
1612  found = True
1613  if value[1] == 1:
1614  ret = 0
1615  break
1616  if not found:
1617  log.warning('unknown handle')
1618  ret = 0xffffffff
1619  break
1620  time.sleep(0.1)
1621  jitter.func_ret_stdcall(ret_ad, ret)
1622 
def miasm2.os_dep.win_api_x86_32.kernel32_WriteFile (   jitter)

Definition at line 2425 of file win_api_x86_32.py.

2426 def kernel32_WriteFile(jitter):
2427  ret_ad, args = jitter.func_args_stdcall(["hwnd", "lpbuffer",
2428  "nnumberofbytestowrite",
2429  "lpnumberofbyteswrite",
2430  "lpoverlapped"])
2431  data = jitter.vm.get_mem(args.lpbuffer, args.nnumberofbytestowrite)
2432 
2433  if args.hwnd == winobjs.module_cur_hwnd:
2434  pass
2435  elif args.hwnd in winobjs.handle_pool:
2436  pass
2437  else:
2438  raise ValueError('unknown hwnd!')
2439 
2440  if args.hwnd in winobjs.files_hwnd:
2441  winobjs.files_hwnd[winobjs.module_cur_hwnd].write(data)
2442  elif args.hwnd in winobjs.handle_pool:
2443  wh = winobjs.handle_pool[args.hwnd]
2444  wh.info.write(data)
2445  else:
2446  raise ValueError('unknown filename')
2447 
2448  if (args.lpnumberofbyteswrite):
2449  jitter.vm.set_mem(args.lpnumberofbyteswrite, pck32(len(data)))
2450 
2451  jitter.func_ret_stdcall(ret_ad, 1)
2452 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.mdl2ad (   n)

Definition at line 1274 of file win_api_x86_32.py.

1275 def mdl2ad(n):
1276  return winobjs.nt_mdl_ad + 0x10 * n
1277 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt__ultow (   jitter)

Definition at line 2711 of file win_api_x86_32.py.

2712 def msvcrt__ultow(jitter):
2713  ret_ad, args = jitter.func_args_cdecl(["value", "p", "radix"])
2714 
2715  value = args.value & 0xFFFFFFFF
2716  if not args.radix in [10, 16, 20]:
2717  raise ValueError("Not tested")
2718  s = int2base(value, args.radix)
2719  jitter.vm.set_mem(args.p, set_str_unic(s + "\x00"))
2720  jitter.func_ret_cdecl(ret_ad, args.p)
2721 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt__wfopen (   jitter)

Definition at line 2746 of file win_api_x86_32.py.

2747 def msvcrt__wfopen(jitter):
2748  msvcrt_myfopen(jitter, get_str_unic)
2749 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt_atexit (   jitter)

Definition at line 2535 of file win_api_x86_32.py.

2536 def msvcrt_atexit(jitter):
2537  ret_ad, _ = jitter.func_args_cdecl(["func"])
2538  jitter.func_ret_cdecl(ret_ad, 0)
2539 
def miasm2.os_dep.win_api_x86_32.msvcrt_fclose (   jitter)

Definition at line 2524 of file win_api_x86_32.py.

2525 def msvcrt_fclose(jitter):
2526  ret_ad, args = jitter.func_args_cdecl(['stream'])
2527  fd = upck32(jitter.vm.get_mem(args.stream + 0x10, 4))
2528 
2529  if not fd in winobjs.handle_pool:
2530  raise NotImplementedError("Untested case")
2531  o = winobjs.handle_pool[fd]
2532  # off = o.info.close()
2533  jitter.func_ret_cdecl(ret_ad, 0)
2534 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.msvcrt_fopen (   jitter)

Definition at line 2750 of file win_api_x86_32.py.

2751 def msvcrt_fopen(jitter):
2752  msvcrt_myfopen(jitter, get_str_ansi)
2753 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt_fread (   jitter)

Definition at line 2513 of file win_api_x86_32.py.

2514 def msvcrt_fread(jitter):
2515  ret_ad, args = jitter.func_args_cdecl(["buf", "size", "nmemb", "stream"])
2516  fd = upck32(jitter.vm.get_mem(args.stream + 0x10, 4))
2517  if not fd in winobjs.handle_pool:
2518  raise NotImplementedError("Untested case")
2519 
2520  data = winobjs.handle_pool[fd].info.read(args.size * args.nmemb)
2521  jitter.vm.set_mem(args.buf, data)
2522  jitter.func_ret_cdecl(ret_ad, args.nmemb)
2523 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.msvcrt_free (   jitter)

Definition at line 2476 of file win_api_x86_32.py.

2477 def msvcrt_free(jitter):
2478  ret_ad, _ = jitter.func_args_cdecl(["ptr"])
2479  jitter.func_ret_cdecl(ret_ad, 0)
2480 
def miasm2.os_dep.win_api_x86_32.msvcrt_fseek (   jitter)

Definition at line 2481 of file win_api_x86_32.py.

2482 def msvcrt_fseek(jitter):
2483  ret_ad, args = jitter.func_args_cdecl(['stream', 'offset', 'orig'])
2484  fd = upck32(jitter.vm.get_mem(args.stream + 0x10, 4))
2485 
2486  if not fd in winobjs.handle_pool:
2487  raise NotImplementedError("Untested case")
2488  o = winobjs.handle_pool[fd]
2489  o.info.seek(args.offset, args.orig)
2490  jitter.func_ret_cdecl(ret_ad, 0)
2491 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.msvcrt_ftell (   jitter)

Definition at line 2492 of file win_api_x86_32.py.

2493 def msvcrt_ftell(jitter):
2494  ret_ad, args = jitter.func_args_cdecl(["stream"])
2495  fd = upck32(jitter.vm.get_mem(args.stream + 0x10, 4))
2496 
2497  if not fd in winobjs.handle_pool:
2498  raise NotImplementedError("Untested case")
2499  o = winobjs.handle_pool[fd]
2500  off = o.info.tell()
2501  jitter.func_ret_cdecl(ret_ad, off)
2502 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.msvcrt_malloc (   jitter)

Definition at line 2470 of file win_api_x86_32.py.

2471 def msvcrt_malloc(jitter):
2472  ret_ad, args = jitter.func_args_cdecl(["msize"])
2473  addr = winobjs.heap.alloc(jitter, args.msize)
2474  jitter.func_ret_cdecl(ret_ad, addr)
2475 
def miasm2.os_dep.win_api_x86_32.msvcrt_memcmp (   jitter)

Definition at line 1805 of file win_api_x86_32.py.

1806 def msvcrt_memcmp(jitter):
1807  ret_ad, args = jitter.func_args_cdecl(['ps1', 'ps2', 'size'])
1808  s1 = jitter.vm.get_mem(args.ps1, args.size)
1809  s2 = jitter.vm.get_mem(args.ps2, args.size)
1810  ret = cmp(s1, s2)
1811  jitter.func_ret_cdecl(ret_ad, ret)
1812 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt_memcpy (   jitter)

Definition at line 1798 of file win_api_x86_32.py.

1799 def msvcrt_memcpy(jitter):
1800  ret_ad, args = jitter.func_args_cdecl(['dst', 'src', 'size'])
1801  s = jitter.vm.get_mem(args.src, args.size)
1802  jitter.vm.set_mem(args.dst, s)
1803  jitter.func_ret_cdecl(ret_ad, args.dst)
1804 
def miasm2.os_dep.win_api_x86_32.msvcrt_memset (   jitter)

Definition at line 1792 of file win_api_x86_32.py.

1793 def msvcrt_memset(jitter):
1794  ret_ad, args = jitter.func_args_cdecl(['addr', 'c', 'size'])
1795  jitter.vm.set_mem(args.addr, chr(args.c) * args.size)
1796  jitter.func_ret_cdecl(ret_ad, args.addr)
1797 
def miasm2.os_dep.win_api_x86_32.msvcrt_myfopen (   jitter,
  func 
)

Definition at line 2722 of file win_api_x86_32.py.

2723 def msvcrt_myfopen(jitter, func):
2724  ret_ad, args = jitter.func_args_cdecl(["pfname", "pmode"])
2725 
2726  fname = func(jitter, args.pfname)
2727  rw = func(jitter, args.pmode)
2728  log.debug(fname)
2729  log.debug(rw)
2730 
2731  if rw in ['r', 'rb', 'wb+']:
2732  sb_fname = windows_to_sbpath(fname)
2733  h = open(sb_fname, rw)
2734  eax = winobjs.handle_pool.add(sb_fname, h)
2735  dwsize = 0x20
2736  alloc_addr = winobjs.heap.alloc(jitter, dwsize)
2737  pp = pck32(0x11112222) + pck32(0) + pck32(0) + pck32(0) + pck32(eax)
2738  #pdw(0x11112222)
2739  jitter.vm.set_mem(alloc_addr, pp)
2740 
2741  else:
2742  raise ValueError('unknown access mode %s' % rw)
2743 
2744  jitter.func_ret_cdecl(ret_ad, alloc_addr)
2745 
tuple pck32
Definition: utils.py:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.msvcrt_rand (   jitter)

Definition at line 2350 of file win_api_x86_32.py.

2351 def msvcrt_rand(jitter):
2352  ret_ad, _ = jitter.func_args_cdecl(0)
2353  jitter.func_ret_stdcall(ret_ad, 0x666)
2354 
def miasm2.os_dep.win_api_x86_32.msvcrt_rewind (   jitter)

Definition at line 2503 of file win_api_x86_32.py.

2504 def msvcrt_rewind(jitter):
2505  ret_ad, args = jitter.func_args_cdecl(["stream"])
2506  fd = upck32(jitter.vm.get_mem(args.stream + 0x10, 4))
2507  if not fd in winobjs.handle_pool:
2508  raise NotImplementedError("Untested case")
2509  o = winobjs.handle_pool[fd]
2510  # off = o.info.seek(0, 0)
2511  jitter.func_ret_cdecl(ret_ad, 0)
2512 
tuple upck32
Definition: utils.py:8
def miasm2.os_dep.win_api_x86_32.msvcrt_strlen (   jitter)

Definition at line 2754 of file win_api_x86_32.py.

2755 def msvcrt_strlen(jitter):
2756  ret_ad, args = jitter.func_args_cdecl(["src"])
2757 
2758  s = get_str_ansi(jitter, args.src)
2759  jitter.func_ret_cdecl(ret_ad, len(s))

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.my_CreateDirectory (   jitter,
  funcname,
  get_str 
)

Definition at line 1550 of file win_api_x86_32.py.

1551 def my_CreateDirectory(jitter, funcname, get_str):
1552  ret_ad, args = jitter.func_args_stdcall(['lppath', 'secattrib'])
1553  # path = get_str(jitter, args.lppath)
1554  jitter.func_ret_stdcall(ret_ad, 0x1337)
1555 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_CreateEvent (   jitter,
  funcname,
  get_str 
)

Definition at line 1578 of file win_api_x86_32.py.

1579 def my_CreateEvent(jitter, funcname, get_str):
1580  ret_ad, args = jitter.func_args_stdcall(["lpeventattributes",
1581  "bmanualreset",
1582  "binitialstate",
1583  "lpname"])
1584  s = get_str(jitter, args.lpname) if args.lpname else None
1585  if not s in winobjs.events_pool:
1586  winobjs.events_pool[s] = (args.bmanualreset, args.binitialstate)
1587  else:
1588  log.warning('WARNING: known event')
1589  jitter.func_ret_stdcall(ret_ad, id(s))
1590 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_GetEnvironmentVariable (   jitter,
  funcname,
  get_str,
  set_str,
  mylen 
)

Definition at line 1516 of file win_api_x86_32.py.

1517 def my_GetEnvironmentVariable(jitter, funcname, get_str, set_str, mylen):
1518  ret_ad, args = jitter.func_args_stdcall(["lpname", "lpbuffer",
1519  "nsize"])
1520 
1521  s = get_str(jitter, args.lpname)
1522  if get_str == get_str_unic:
1523  s = s
1524  log.debug('variable %r', s)
1525  if s in winobjs.env_variables:
1526  v = set_str(winobjs.env_variables[s])
1527  else:
1528  log.warning('WARNING unknown env variable %r', s)
1529  v = ""
1530  jitter.vm.set_mem(args.lpbuffer, v)
1531  jitter.func_ret_stdcall(ret_ad, mylen(v))
1532 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_GetSystemDirectory (   jitter,
  funcname,
  set_str 
)

Definition at line 1533 of file win_api_x86_32.py.

1534 def my_GetSystemDirectory(jitter, funcname, set_str):
1535  ret_ad, args = jitter.func_args_stdcall(["lpbuffer", "usize"])
1536  s = "c:\\windows\\system32"
1537  l = len(s)
1538  s = set_str(s)
1539  jitter.vm.set_mem(args.lpbuffer, s)
1540  jitter.func_ret_stdcall(ret_ad, l)
1541 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_GetVolumeInformation (   jitter,
  funcname,
  get_str,
  set_str 
)

Definition at line 1461 of file win_api_x86_32.py.

1462 def my_GetVolumeInformation(jitter, funcname, get_str, set_str):
1463  ret_ad, args = jitter.func_args_stdcall(["lprootpathname",
1464  "lpvolumenamebuffer",
1465  "nvolumenamesize",
1466  "lpvolumeserialnumber",
1467  "lpmaximumcomponentlength",
1468  "lpfilesystemflags",
1469  "lpfilesystemnamebuffer",
1470  "nfilesystemnamesize"])
1471  if args.lprootpathname:
1472  s = get_str(jitter, args.lprootpathname)
1473 
1474  if args.lpvolumenamebuffer:
1475  s = "volumename"
1476  s = s[:args.nvolumenamesize]
1477  jitter.vm.set_mem(args.lpvolumenamebuffer, set_str(s))
1478 
1479  if args.lpvolumeserialnumber:
1480  jitter.vm.set_mem(args.lpvolumeserialnumber, pck32(11111111))
1481  if args.lpmaximumcomponentlength:
1482  jitter.vm.set_mem(args.lpmaximumcomponentlength, pck32(0xff))
1483  if args.lpfilesystemflags:
1484  jitter.vm.set_mem(args.lpfilesystemflags, pck32(22222222))
1485 
1486  if args.lpfilesystemnamebuffer:
1487  s = "filesystemname"
1488  s = s[:args.nfilesystemnamesize]
1489  jitter.vm.set_mem(args.lpfilesystemnamebuffer, set_str(s))
1490 
1491  jitter.func_ret_stdcall(ret_ad, 1)
1492 
tuple pck32
Definition: utils.py:12

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_lstrcat (   jitter,
  funcname,
  get_str 
)

Definition at line 1434 of file win_api_x86_32.py.

1435 def my_lstrcat(jitter, funcname, get_str):
1436  ret_ad, args = jitter.func_args_stdcall(['ptr_str1', 'ptr_str2'])
1437  s1 = get_str(jitter, args.ptr_str1)
1438  s2 = get_str(jitter, args.ptr_str2)
1439  jitter.vm.set_mem(args.ptr_str1, s1 + s2)
1440  jitter.func_ret_stdcall(ret_ad, args.ptr_str1)
1441 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_lstrcmp (   jitter,
  funcname,
  get_str 
)

Definition at line 1360 of file win_api_x86_32.py.

1361 def my_lstrcmp(jitter, funcname, get_str):
1362  ret_ad, args = jitter.func_args_stdcall(["ptr_str1", "ptr_str2"])
1363  s1 = get_str(args.ptr_str1)
1364  s2 = get_str(args.ptr_str2)
1365  jitter.func_ret_stdcall(ret_ad, cmp(s1, s2))
1366 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_strcpy (   jitter,
  funcname,
  get_str,
  set_str 
)

Definition at line 1387 of file win_api_x86_32.py.

1388 def my_strcpy(jitter, funcname, get_str, set_str):
1389  ret_ad, args = jitter.func_args_stdcall(["ptr_str1", "ptr_str2"])
1390  s2 = get_str(jitter, args.ptr_str2)
1391  jitter.vm.set_mem(args.ptr_str1, set_str(s2))
1392  jitter.func_ret_stdcall(ret_ad, args.ptr_str1)
1393 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.my_strlen (   jitter,
  funcname,
  get_str,
  mylen 
)

Definition at line 1416 of file win_api_x86_32.py.

1417 def my_strlen(jitter, funcname, get_str, mylen):
1418  ret_ad, args = jitter.func_args_stdcall(["src"])
1419  src = get_str(jitter, args.src)
1420  jitter.func_ret_stdcall(ret_ad, mylen(src))
1421 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_LdrGetProcedureAddress (   jitter)

Definition at line 1772 of file win_api_x86_32.py.

1773 def ntdll_LdrGetProcedureAddress(jitter):
1774  ret_ad, args = jitter.func_args_stdcall(["libbase", "pfname",
1775  "opt", "p_ad"])
1776 
1777  l1, l2, p_src = struct.unpack('HHI', jitter.vm.get_mem(args.pfname, 0x8))
1778  fname = get_str_ansi(jitter, p_src)
1779 
1780  ad = winobjs.runtime_dll.lib_get_add_func(args.libbase, fname)
1781 
1782  jitter.vm.set_mem(args.p_ad, pck32(ad))
1783 
1784  jitter.func_ret_stdcall(ret_ad, 0)
1785 
tuple pck32
Definition: utils.py:12

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_LdrLoadDll (   jitter)

Definition at line 1750 of file win_api_x86_32.py.

1751 def ntdll_LdrLoadDll(jitter):
1752  ret_ad, args = jitter.func_args_stdcall(["path", "flags",
1753  "modname", "modhandle"])
1754 
1755  l1, l2, p_src = struct.unpack('HHI',
1756  jitter.vm.get_mem(args.modname, 0x8))
1757  s = get_str_unic(jitter, p_src)
1758  libname = s.lower()
1759 
1760  ad = winobjs.runtime_dll.lib_get_add_base(libname)
1761  jitter.vm.set_mem(args.modhandle, pck32(ad))
1762 
1763  jitter.func_ret_stdcall(ret_ad, 0)
1764 
tuple pck32
Definition: utils.py:12

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_memset (   jitter)

Definition at line 1786 of file win_api_x86_32.py.

1787 def ntdll_memset(jitter):
1788  ret_ad, args = jitter.func_args_stdcall(['addr', 'c', 'size'])
1789  jitter.vm.set_mem(args.addr, chr(args.c) * args.size)
1790  jitter.func_ret_stdcall(ret_ad, args.addr)
1791 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlAnsiCharToUnicodeChar (   jitter)

Definition at line 1119 of file win_api_x86_32.py.

1120 def ntdll_RtlAnsiCharToUnicodeChar(jitter):
1121  ret_ad, args = jitter.func_args_stdcall(['ad_ad_ch'])
1122  ad_ch = upck32(jitter.vm.get_mem(args.ad_ad_ch, 4))
1123  ch = ord(jitter.vm.get_mem(ad_ch, 1))
1124  jitter.vm.set_mem(args.ad_ad_ch, pck32(ad_ch + 1))
1125  jitter.func_ret_stdcall(ret_ad, ch)
1126 
tuple upck32
Definition: utils.py:8
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntdll_RtlAnsiStringToUnicodeString (   jitter)

Definition at line 1731 of file win_api_x86_32.py.

1733  ret_ad, args = jitter.func_args_stdcall(["dst", "src", "alloc_str"])
1734 
1735  l1, l2, p_src = struct.unpack('HHI', jitter.vm.get_mem(args.src, 0x8))
1736  s = get_str_ansi(jitter, p_src)
1737  s = ("\x00".join(s + "\x00"))
1738  l = len(s) + 1
1739  if args.alloc_str:
1740  alloc_addr = winobjs.heap.next_addr(l)
1741  jitter.vm.add_memory_page(
1742  alloc_addr, PAGE_READ | PAGE_WRITE, "\x00" * l)
1743  else:
1744  alloc_addr = p_src
1745  jitter.vm.set_mem(alloc_addr, s)
1746  o = struct.pack('HHI', l, l, alloc_addr)
1747  jitter.vm.set_mem(args.dst, o)
1748  jitter.func_ret_stdcall(ret_ad, 0)
1749 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_RtlCompareMemory (   jitter)

Definition at line 1201 of file win_api_x86_32.py.

1202 def ntdll_RtlCompareMemory(jitter):
1203  ret_ad, args = jitter.func_args_stdcall(['ad1', 'ad2', 'm_len'])
1204  data1 = jitter.vm.get_mem(args.ad1, args.m_len)
1205  data2 = jitter.vm.get_mem(args.ad2, args.m_len)
1206 
1207  i = 0
1208  while data1[i] == data2[i]:
1209  i += 1
1210  if i >= args.m_len:
1211  break
1212 
1213  jitter.func_ret_stdcall(ret_ad, i)
1214 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlComputeCrc32 (   jitter)

Definition at line 1159 of file win_api_x86_32.py.

1160 def ntdll_RtlComputeCrc32(jitter):
1161  ret_ad, args = jitter.func_args_stdcall(["dwinit", "pdata", "ilen"])
1162  data = jitter.vm.get_mem(args.pdata, args.ilen)
1163  crc_r = crc32(data, args.dwinit)
1164  jitter.func_ret_stdcall(ret_ad, crc_r)
1165 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlEnlargedUnsignedMultiply (   jitter)

Definition at line 1188 of file win_api_x86_32.py.

1190  ret_ad, args = jitter.func_args_stdcall(['a', 'b'])
1191  a = args.a * args.b
1192  jitter.func_ret_stdcall(ret_ad, a & 0xffffffff, (a >> 32) & 0xffffffff)
1193 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlExtendedIntegerMultiply (   jitter)

Definition at line 1166 of file win_api_x86_32.py.

1168  ret_ad, args = jitter.func_args_stdcall(['multiplicand_low',
1169  'multiplicand_high',
1170  'multiplier'])
1171  a = (args.multiplicand_high << 32) + args.multiplicand_low
1172  a = a * args.multiplier
1173  jitter.func_ret_stdcall(ret_ad, a & 0xffffffff, (a >> 32) & 0xffffffff)
1174 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlFindCharInUnicodeString (   jitter)

Definition at line 1127 of file win_api_x86_32.py.

1129  ret_ad, args = jitter.func_args_stdcall(["flags", "main_str_ad",
1130  "search_chars_ad", "pos_ad"])
1131 
1132  if args.flags != 0:
1133  raise ValueError('unk flags')
1134 
1135  ml1, ml2, mptra = struct.unpack('HHL',
1136  jitter.vm.get_mem(args.main_str_ad, 8))
1137  sl1, sl2, sptra = struct.unpack(
1138  'HHL', jitter.vm.get_mem(args.search_chars_ad, 8))
1139  main_data = jitter.vm.get_mem(mptra, ml1)[:-1]
1140  search_data = jitter.vm.get_mem(sptra, sl1)[:-1]
1141 
1142  pos = None
1143  for i, c in enumerate(main_data):
1144  for s in search_data:
1145  if s == c:
1146  pos = i
1147  break
1148  if pos:
1149  break
1150  if pos is None:
1151  ret = 0xC0000225
1152  jitter.vm.set_mem(args.pos_ad, pck32(0))
1153  else:
1154  ret = 0
1155  jitter.vm.set_mem(args.pos_ad, pck32(pos))
1156 
1157  jitter.func_ret_stdcall(ret_ad, ret)
1158 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntdll_RtlFreeUnicodeString (   jitter)

Definition at line 1765 of file win_api_x86_32.py.

1766 def ntdll_RtlFreeUnicodeString(jitter):
1767  ret_ad, args = jitter.func_args_stdcall(['src'])
1768  # l1, l2, p_src = struct.unpack('HHI', jitter.vm.get_mem(args.src, 0x8))
1769  # s = get_str_unic(jitter, p_src)
1770  jitter.func_ret_stdcall(ret_ad, 0)
1771 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlHashUnicodeString (   jitter)

Definition at line 1092 of file win_api_x86_32.py.

1093 def ntdll_RtlHashUnicodeString(jitter):
1094  ret_ad, args = jitter.func_args_stdcall(["ad_ctxu", "case_i", "h_id",
1095  "phout"])
1096 
1097  if args.h_id != 1:
1098  raise ValueError('unk hash unicode', args.h_id)
1099 
1100  l1, l2, ptra = struct.unpack('HHL', jitter.vm.get_mem(args.ad_ctxu, 8))
1101  s = jitter.vm.get_mem(ptra, l1)
1102  s = s[:-1]
1103  hv = 0
1104 
1105  if args.case_i:
1106  s = s.lower()
1107  for c in s:
1108  hv = ((65599 * hv) + ord(c)) & 0xffffffff
1109  jitter.vm.set_mem(args.phout, pck32(hv))
1110  jitter.func_ret_stdcall(ret_ad, 0)
1111 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntdll_RtlInitAnsiString (   jitter)

Definition at line 1082 of file win_api_x86_32.py.

1083 def ntdll_RtlInitAnsiString(jitter):
1084  ret_ad, args = jitter.func_args_stdcall(["ad_ctx", "ad_str"])
1085 
1086  s = get_str_ansi(jitter, args.ad_str)
1087  l = len(s)
1088  jitter.vm.set_mem(args.ad_ctx,
1089  pck16(l) + pck16(l + 1) + pck32(args.ad_str))
1090  jitter.func_ret_stdcall(ret_ad, 0)
1091 
tuple pck16
Definition: utils.py:11
tuple pck32
Definition: utils.py:12

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_RtlInitString (   jitter)

Definition at line 1722 of file win_api_x86_32.py.

1723 def ntdll_RtlInitString(jitter):
1724  ret_ad, args = jitter.func_args_stdcall(["pstring", "source"])
1725  s = get_str_ansi(jitter, args.source)
1726  l = len(s) + 1
1727  o = struct.pack('HHI', l, l, args.source)
1728  jitter.vm.set_mem(args.pstring, o)
1729  jitter.func_ret_stdcall(ret_ad, 0)
1730 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntdll_RtlLargeIntegerAdd (   jitter)

Definition at line 1175 of file win_api_x86_32.py.

1176 def ntdll_RtlLargeIntegerAdd(jitter):
1177  ret_ad, args = jitter.func_args_stdcall(['a_low', 'a_high',
1178  'b_low', 'b_high'])
1179  a = (args.a_high << 32) + args.a_low + (args.b_high << 32) + args.b_low
1180  jitter.func_ret_stdcall(ret_ad, a & 0xffffffff, (a >> 32) & 0xffffffff)
1181 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlLargeIntegerShiftRight (   jitter)

Definition at line 1182 of file win_api_x86_32.py.

1184  ret_ad, args = jitter.func_args_stdcall(['a_low', 'a_high', 's_count'])
1185  a = ((args.a_high << 32) + args.a_low) >> args.s_count
1186  jitter.func_ret_stdcall(ret_ad, a & 0xffffffff, (a >> 32) & 0xffffffff)
1187 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlLargeIntegerSubtract (   jitter)

Definition at line 1194 of file win_api_x86_32.py.

1195 def ntdll_RtlLargeIntegerSubtract(jitter):
1196  ret_ad, args = jitter.func_args_stdcall(['a_low', 'a_high',
1197  'b_low', 'b_high'])
1198  a = (args.a_high << 32) + args.a_low - (args.b_high << 32) + args.b_low
1199  jitter.func_ret_stdcall(ret_ad, a & 0xffffffff, (a >> 32) & 0xffffffff)
1200 
def miasm2.os_dep.win_api_x86_32.ntdll_RtlMoveMemory (   jitter)

Definition at line 1636 of file win_api_x86_32.py.

1637 def ntdll_RtlMoveMemory(jitter):
1638  ret_ad, args = jitter.func_args_stdcall(["dst", "src", "l"])
1639  s = jitter.vm.get_mem(args.src, args.l)
1640  jitter.vm.set_mem(args.dst, s)
1641  jitter.func_ret_stdcall(ret_ad, 1)
1642 
def miasm2.os_dep.win_api_x86_32.ntdll_ZwAllocateVirtualMemory (   jitter)

Definition at line 1681 of file win_api_x86_32.py.

1682 def ntdll_ZwAllocateVirtualMemory(jitter):
1683  ret_ad, args = jitter.func_args_stdcall(["handle", "lppvoid",
1684  "zerobits", "pdwsize",
1685  "alloc_type",
1686  "flprotect"])
1687 
1688  # ad = upck32(jitter.vm.get_mem(args.lppvoid, 4))
1689  dwsize = upck32(jitter.vm.get_mem(args.pdwsize, 4))
1690 
1691  access_dict = {
1692  0x0: 0,
1693  0x1: 0,
1694  0x2: PAGE_READ,
1695  0x4: PAGE_READ | PAGE_WRITE,
1696  0x10: PAGE_EXEC,
1697  0x20: PAGE_EXEC | PAGE_READ,
1698  0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
1699  0x100: 0,
1700  }
1701 
1702  # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
1703 
1704  if not args.flprotect in access_dict:
1705  raise ValueError('unknown access dw!')
1706 
1707  alloc_addr = winobjs.heap.next_addr(dwsize)
1708  jitter.vm.add_memory_page(
1709  alloc_addr, access_dict[args.flprotect], "\x00" * dwsize)
1710  jitter.vm.set_mem(args.lppvoid, pck32(alloc_addr))
1711 
1712  jitter.func_ret_stdcall(ret_ad, 0)
1713 
tuple upck32
Definition: utils.py:8
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntdll_ZwFreeVirtualMemory (   jitter)

Definition at line 1714 of file win_api_x86_32.py.

1715 def ntdll_ZwFreeVirtualMemory(jitter):
1716  ret_ad, args = jitter.func_args_stdcall(["handle", "lppvoid",
1717  "pdwsize", "alloc_type"])
1718  # ad = upck32(jitter.vm.get_mem(args.lppvoid, 4))
1719  # dwsize = upck32(jitter.vm.get_mem(args.pdwsize, 4))
1720  jitter.func_ret_stdcall(ret_ad, 0)
1721 
def miasm2.os_dep.win_api_x86_32.ntdll_ZwProtectVirtualMemory (   jitter)

Definition at line 1660 of file win_api_x86_32.py.

1661 def ntdll_ZwProtectVirtualMemory(jitter):
1662  ret_ad, args = jitter.func_args_stdcall(["handle", "lppvoid",
1663  "pdwsize",
1664  "flnewprotect",
1665  "lpfloldprotect"])
1666 
1667  ad = upck32(jitter.vm.get_mem(args.lppvoid, 4))
1668  # dwsize = upck32(jitter.vm.get_mem(args.pdwsize, 4))
1669  # XXX mask hpart
1670  flnewprotect = args.flnewprotect & 0xFFF
1671 
1672  if not flnewprotect in access_dict:
1673  raise ValueError('unknown access dw!')
1674  jitter.vm.set_mem_access(ad, access_dict[flnewprotect])
1675 
1676  # XXX todo real old protect
1677  jitter.vm.set_mem(args.lpfloldprotect, pck32(0x40))
1678 
1679  jitter.func_ret_stdcall(ret_ad, 1)
1680 
tuple upck32
Definition: utils.py:8
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntdll_ZwQuerySystemInformation (   jitter)

Definition at line 1643 of file win_api_x86_32.py.

1644 def ntdll_ZwQuerySystemInformation(jitter):
1645  ret_ad, args = jitter.func_args_stdcall(["systeminformationclass",
1646  "systeminformation",
1647  "systeminformationl",
1648  "returnl"])
1649  if args.systeminformationclass == 2:
1650  # SYSTEM_PERFORMANCE_INFORMATION
1651  o = struct.pack('II', 0x22222222, 0x33333333)
1652  o += "\x00" * args.systeminformationl
1653  o = o[:args.systeminformationl]
1654  jitter.vm.set_mem(args.systeminformation, o)
1655  else:
1656  raise ValueError('unknown sysinfo class',
1657  args.systeminformationclass)
1658  jitter.func_ret_stdcall(ret_ad, 0)
1659 
def miasm2.os_dep.win_api_x86_32.ntdll_ZwUnmapViewOfSection (   jitter)

Definition at line 1225 of file win_api_x86_32.py.

1226 def ntdll_ZwUnmapViewOfSection(jitter):
1227  ret_ad, _ = jitter.func_args_stdcall(['h', 'ad'])
1228  jitter.func_ret_stdcall(ret_ad, 0)
1229 
def miasm2.os_dep.win_api_x86_32.ntoskrnl_ExAllocatePoolWithTagPriority (   jitter)

Definition at line 1349 of file win_api_x86_32.py.

1351  ret_ad, args = jitter.func_args_stdcall(["pool_type",
1352  "nbr_of_bytes",
1353  "tag", "priority"])
1354  alloc_addr = winobjs.heap.next_addr(args.nbr_of_bytes)
1355  jitter.vm.add_memory_page(
1356  alloc_addr, PAGE_READ | PAGE_WRITE, "\x00" * args.nbr_of_bytes)
1357 
1358  jitter.func_ret_stdcall(ret_ad, alloc_addr)
1359 
def miasm2.os_dep.win_api_x86_32.ntoskrnl_IoAllocateMdl (   jitter)

Definition at line 1282 of file win_api_x86_32.py.

1283 def ntoskrnl_IoAllocateMdl(jitter):
1284  ret_ad, args = jitter.func_args_stdcall(["v_addr", "l", "second_buf",
1285  "chargequota", "pirp"])
1286  m = mdl(args.v_addr, args.l)
1287  winobjs.nt_mdl[winobjs.nt_mdl_cur] = m
1288  jitter.vm.set_mem(mdl2ad(winobjs.nt_mdl_cur), str(m))
1289  jitter.func_ret_stdcall(ret_ad, mdl2ad(winobjs.nt_mdl_cur))
1290  winobjs.nt_mdl_cur += 1
1291 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_IoFreeMdl (   jitter)

Definition at line 1327 of file win_api_x86_32.py.

1328 def ntoskrnl_IoFreeMdl(jitter):
1329  ret_ad, args = jitter.func_args_stdcall(['p_mdl'])
1330  if not ad2mdl(args.p_mdl) in winobjs.nt_mdl:
1331  raise ValueError('unk mdl', hex(args.p_mdl))
1332  del(winobjs.nt_mdl[ad2mdl(args.p_mdl)])
1333  jitter.func_ret_stdcall(ret_ad, 0)
1334 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_KeInitializeEvent (   jitter)

Definition at line 1235 of file win_api_x86_32.py.

1236 def ntoskrnl_KeInitializeEvent(jitter):
1237  ret_ad, args = jitter.func_args_stdcall(['my_event', 'my_type',
1238  'my_state'])
1239  jitter.vm.set_mem(args.my_event, pck32(winobjs.win_event_num))
1240  winobjs.win_event_num += 1
1241 
1242  jitter.func_ret_stdcall(ret_ad, 0)
1243 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.ntoskrnl_MmMapLockedPagesSpecifyCache (   jitter)

Definition at line 1300 of file win_api_x86_32.py.

1302  ret_ad, args = jitter.func_args_stdcall(["p_mdl", "access_mode",
1303  "cache_type", "base_ad",
1304  "bugcheckonfailure",
1305  "priority"])
1306  if not ad2mdl(args.p_mdl) in winobjs.nt_mdl:
1307  raise ValueError('unk mdl', hex(args.p_mdl))
1308 
1309  jitter.func_ret_stdcall(ret_ad, winobjs.nt_mdl[ad2mdl(args.p_mdl)].ad)
1310 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_MmProbeAndLockPages (   jitter)

Definition at line 1292 of file win_api_x86_32.py.

1293 def ntoskrnl_MmProbeAndLockPages(jitter):
1294  ret_ad, args = jitter.func_args_stdcall(["p_mdl", "access_mode", "op"])
1295 
1296  if not ad2mdl(args.p_mdl) in winobjs.nt_mdl:
1297  raise ValueError('unk mdl', hex(args.p_mdl))
1298  jitter.func_ret_stdcall(ret_ad, 0)
1299 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_MmProtectMdlSystemAddress (   jitter)

Definition at line 1311 of file win_api_x86_32.py.

1313  ret_ad, args = jitter.func_args_stdcall(["p_mdl", "prot"])
1314  if not ad2mdl(args.p_mdl) in winobjs.nt_mdl:
1315  raise ValueError('unk mdl', hex(args.p_mdl))
1316 
1317  jitter.func_ret_stdcall(ret_ad, 0)
1318 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_MmUnlockPages (   jitter)

Definition at line 1319 of file win_api_x86_32.py.

1320 def ntoskrnl_MmUnlockPages(jitter):
1321  ret_ad, args = jitter.func_args_stdcall(['p_mdl'])
1322  if not ad2mdl(args.p_mdl) in winobjs.nt_mdl:
1323  raise ValueError('unk mdl', hex(args.p_mdl))
1324 
1325  jitter.func_ret_stdcall(ret_ad, 0)
1326 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_RtlGetVersion (   jitter)

Definition at line 1244 of file win_api_x86_32.py.

1245 def ntoskrnl_RtlGetVersion(jitter):
1246  ret_ad, args = jitter.func_args_stdcall(['ptr_version'])
1247 
1248  s = struct.pack("IIIII",
1249  0x114, # struct size
1250  0x5, # maj vers
1251  0x2, # min vers
1252  0x666, # build nbr
1253  0x2, # platform id
1254  ) + set_str_unic("Service pack 4")
1255 
1256  jitter.vm.set_mem(args.ptr_version, s)
1257  jitter.func_ret_stdcall(ret_ad, 0)
1258 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.ntoskrnl_RtlQueryRegistryValues (   jitter)

Definition at line 1340 of file win_api_x86_32.py.

1342  ret_ad, args = jitter.func_args_stdcall(["relativeto", "path",
1343  "querytable",
1344  "context",
1345  "environ"])
1346  # path = get_str_unic(jitter, args.path)
1347  jitter.func_ret_stdcall(ret_ad, 0)
1348 
def miasm2.os_dep.win_api_x86_32.ntoskrnl_RtlVerifyVersionInfo (   jitter)

Definition at line 1259 of file win_api_x86_32.py.

1260 def ntoskrnl_RtlVerifyVersionInfo(jitter):
1261  ret_ad, args = jitter.func_args_stdcall(['ptr_version'])
1262 
1263  s = jitter.vm.get_mem(args.ptr_version, 0x5 * 4)
1264  s_size, s_majv, s_minv, s_buildn, s_platform = struct.unpack('IIIII', s)
1265  raise NotImplementedError("Untested case")
1266  # jitter.vm.set_mem(args.ptr_version, s)
1267  # jitter.func_ret_stdcall(ret_ad, 0)
1268 
def miasm2.os_dep.win_api_x86_32.raw2guid (   r)

Definition at line 2685 of file win_api_x86_32.py.

2686 def raw2guid(r):
2687  o = struct.unpack('IHHHBBBBBB', r)
2688  return '{%.8X-%.4X-%.4X-%.4X-%.2X%.2X%.2X%.2X%.2X%.2X}' % o
2689 
def miasm2.os_dep.win_api_x86_32.shell32_CommandLineToArgvW (   jitter)

Definition at line 1026 of file win_api_x86_32.py.

1027 def shell32_CommandLineToArgvW(jitter):
1028  ret_ad, args = jitter.func_args_stdcall(["pcmd", "pnumargs"])
1029  cmd = get_str_unic(jitter, args.pcmd)
1030  log.debug(cmd)
1031  tks = cmd.split(' ')
1032  addr = winobjs.heap.alloc(jitter, len(cmd) * 2 + 4 * len(tks))
1033  addr_ret = winobjs.heap.alloc(jitter, 4 * (len(tks) + 1))
1034  o = 0
1035  for i, t in enumerate(tks):
1036  x = set_str_unic(t) + "\x00\x00"
1037  jitter.vm.set_mem(addr_ret + 4 * i, pck32(addr + o))
1038  jitter.vm.set_mem(addr + o, x)
1039  o += len(x) + 2
1040 
1041  jitter.vm.set_mem(addr_ret + 4 * i, pck32(0))
1042  jitter.vm.set_mem(args.pnumargs, pck32(len(tks)))
1043  jitter.func_ret_stdcall(ret_ad, addr_ret)
1044 
tuple pck32
Definition: utils.py:12

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shell32_SHGetPathFromIDListA (   jitter)

Definition at line 863 of file win_api_x86_32.py.

864 def shell32_SHGetPathFromIDListA(jitter):
865  kernel32_SHGetPathFromIDList(jitter, whoami(), set_str_ansi)
866 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shell32_SHGetPathFromIDListW (   jitter)

Definition at line 859 of file win_api_x86_32.py.

860 def shell32_SHGetPathFromIDListW(jitter):
861  kernel32_SHGetPathFromIDList(jitter, whoami(), set_str_unic)
862 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shell32_SHGetSpecialFolderLocation (   jitter)

Definition at line 841 of file win_api_x86_32.py.

843  ret_ad, args = jitter.func_args_stdcall(["hwndowner", "nfolder", "ppidl"])
844  jitter.vm.set_mem(args.ppidl, pck32(args.nfolder))
845  jitter.func_ret_stdcall(ret_ad, 0)
846 
tuple pck32
Definition: utils.py:12
def miasm2.os_dep.win_api_x86_32.shlwapi_PathFindExtensionA (   jitter)

Definition at line 1813 of file win_api_x86_32.py.

1814 def shlwapi_PathFindExtensionA(jitter):
1815  ret_ad, args = jitter.func_args_stdcall(['path_ad'])
1816  path = get_str_ansi(jitter, args.path_ad)
1817  i = path.rfind('.')
1818  if i == -1:
1819  i = args.path_ad + len(path)
1820  else:
1821  i = args.path_ad + i
1822  jitter.func_ret_stdcall(ret_ad, i)
1823 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathGetDriveNumber (   jitter,
  funcname,
  get_str 
)

Definition at line 1872 of file win_api_x86_32.py.

1873 def shlwapi_PathGetDriveNumber(jitter, funcname, get_str):
1874  ret_ad, args = jitter.func_args_stdcall(['path_ad'])
1875  path = get_str(jitter, args.path_ad)
1876  l = ord(path[0].upper()) - ord('A')
1877  if 0 <= l <= 25:
1878  ret = l
1879  else:
1880  ret = -1
1881 
1882  jitter.func_ret_stdcall(ret_ad, ret)
1883 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathGetDriveNumberA (   jitter)

Definition at line 1884 of file win_api_x86_32.py.

1885 def shlwapi_PathGetDriveNumberA(jitter):
1886  shlwapi_PathGetDriveNumber(jitter, whoami(), get_str_ansi)
1887 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathGetDriveNumberW (   jitter)

Definition at line 1888 of file win_api_x86_32.py.

1889 def shlwapi_PathGetDriveNumberW(jitter):
1890  shlwapi_PathGetDriveNumber(jitter, whoami(), get_str_unic)
1891 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathIsDirectoryW (   jitter)

Definition at line 1847 of file win_api_x86_32.py.

1848 def shlwapi_PathIsDirectoryW(jitter):
1849  ret_ad, args = jitter.func_args_stdcall(['ptr_path'])
1850  fname = get_str_unic(jitter, args.ptr_path)
1851 
1852  sb_fname = windows_to_sbpath(fname)
1853 
1854  s = os.stat(sb_fname)
1855  ret = 0
1856  if stat.S_ISDIR(s.st_mode):
1857  ret = 1
1858 
1859  jitter.func_ret_cdecl(ret_ad, ret)
1860 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathIsFileSpec (   jitter,
  funcname,
  get_str 
)

Definition at line 1861 of file win_api_x86_32.py.

1862 def shlwapi_PathIsFileSpec(jitter, funcname, get_str):
1863  ret_ad, args = jitter.func_args_stdcall(['path_ad'])
1864  path = get_str(jitter, args.path_ad)
1865  if path.find(':') != -1 and path.find('\\') != -1:
1866  ret = 0
1867  else:
1868  ret = 1
1869 
1870  jitter.func_ret_stdcall(ret_ad, ret)
1871 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathIsFileSpecA (   jitter)

Definition at line 1892 of file win_api_x86_32.py.

1893 def shlwapi_PathIsFileSpecA(jitter):
1894  shlwapi_PathIsFileSpec(jitter, whoami(), get_str_ansi)
1895 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathIsFileSpecW (   jitter)

Definition at line 1896 of file win_api_x86_32.py.

1897 def shlwapi_PathIsFileSpecW(jitter):
1898  shlwapi_PathIsFileSpec(jitter, whoami(), get_str_unic)
1899 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathIsPrefixW (   jitter)

Definition at line 1835 of file win_api_x86_32.py.

1836 def shlwapi_PathIsPrefixW(jitter):
1837  ret_ad, args = jitter.func_args_stdcall(['ptr_prefix', 'ptr_path'])
1838  prefix = get_str_unic(jitter, args.ptr_prefix)
1839  path = get_str_unic(jitter, args.ptr_path)
1840 
1841  if path.startswith(prefix):
1842  ret = 1
1843  else:
1844  ret = 0
1845  jitter.func_ret_stdcall(ret_ad, ret)
1846 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_PathRemoveFileSpecW (   jitter)

Definition at line 1824 of file win_api_x86_32.py.

1825 def shlwapi_PathRemoveFileSpecW(jitter):
1826  ret_ad, args = jitter.func_args_stdcall(['path_ad'])
1827  path = get_str_unic(jitter, args.path_ad)
1828  i = path.rfind('\\')
1829  if i == -1:
1830  i = 0
1831  jitter.vm.set_mem(args.path_ad + i * 2, "\x00\x00")
1832  path = get_str_unic(jitter, args.path_ad)
1833  jitter.func_ret_stdcall(ret_ad, 1)
1834 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_StrCmpNIA (   jitter)

Definition at line 1969 of file win_api_x86_32.py.

1970 def shlwapi_StrCmpNIA(jitter):
1971  ret_ad, args = jitter.func_args_stdcall(["ptr_str1", "ptr_str2",
1972  "nchar"])
1973  s1 = get_str_ansi(jitter, args.ptr_str1).lower()
1974  s2 = get_str_ansi(jitter, args.ptr_str2).lower()
1975  s1 = s1[:args.nchar]
1976  s2 = s2[:args.nchar]
1977  jitter.func_ret_stdcall(ret_ad, cmp(s1, s2))
1978 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_StrToInt64Ex (   jitter,
  funcname,
  get_str 
)

Definition at line 1912 of file win_api_x86_32.py.

1913 def shlwapi_StrToInt64Ex(jitter, funcname, get_str):
1914  ret_ad, args = jitter.func_args_stdcall(['pstr', 'flags', 'pret'])
1915  i_str = get_str(jitter, args.pstr)
1916  if get_str is get_str_unic:
1917  i_str = i_str
1918 
1919  if args.flags == 0:
1920  r = int(i_str)
1921  elif args.flags == 1:
1922  r = int(i_str, 16)
1923  else:
1924  raise ValueError('cannot decode int')
1925 
1926  jitter.vm.set_mem(args.pret, struct.pack('q', r))
1927  jitter.func_ret_stdcall(ret_ad, 1)
1928 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_StrToInt64ExA (   jitter)

Definition at line 1929 of file win_api_x86_32.py.

1930 def shlwapi_StrToInt64ExA(jitter):
1931  shlwapi_StrToInt64Ex(jitter, whoami(), get_str_ansi)
1932 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_StrToInt64ExW (   jitter)

Definition at line 1933 of file win_api_x86_32.py.

1934 def shlwapi_StrToInt64ExW(jitter):
1935  shlwapi_StrToInt64Ex(jitter, whoami(), get_str_unic)
1936 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.shlwapi_StrToIntA (   jitter)

Definition at line 1900 of file win_api_x86_32.py.

1901 def shlwapi_StrToIntA(jitter):
1902  ret_ad, args = jitter.func_args_stdcall(['i_str_ad'])
1903  i_str = get_str_ansi(jitter, args.i_str_ad)
1904  try:
1905  i = int(i_str)
1906  except:
1907  log.warning('WARNING cannot convert int')
1908  i = 0
1909 
1910  jitter.func_ret_stdcall(ret_ad, i)
1911 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.user32_BlockInput (   jitter)

Definition at line 396 of file win_api_x86_32.py.

397 def user32_BlockInput(jitter):
398  ret_ad, _ = jitter.func_args_stdcall(["blockit"])
399  jitter.func_ret_stdcall(ret_ad, 1)
400 
def miasm2.os_dep.win_api_x86_32.user32_FindWindowA (   jitter)

Definition at line 386 of file win_api_x86_32.py.

387 def user32_FindWindowA(jitter):
388  ret_ad, _ = jitter.func_args_stdcall(["pclassname", "pwindowname"])
389  jitter.func_ret_stdcall(ret_ad, 0)
390 
def miasm2.os_dep.win_api_x86_32.user32_GetForegroundWindow (   jitter)

Definition at line 381 of file win_api_x86_32.py.

382 def user32_GetForegroundWindow(jitter):
383  ret_ad, _ = jitter.func_args_stdcall(0)
384  jitter.func_ret_stdcall(ret_ad, winobjs.getforegroundwindow)
385 
def miasm2.os_dep.win_api_x86_32.user32_GetKeyboardType (   jitter)

Definition at line 2081 of file win_api_x86_32.py.

2082 def user32_GetKeyboardType(jitter):
2083  ret_ad, args = jitter.func_args_stdcall(["typeflag"])
2084 
2085  ret = 0
2086  if args.typeflag == 0:
2087  ret = 4
2088  else:
2089  raise ValueError('unimpl keyboard type')
2090 
2091  jitter.func_ret_stdcall(ret_ad, ret)
2092 
def miasm2.os_dep.win_api_x86_32.user32_GetMessagePos (   jitter)

Definition at line 1215 of file win_api_x86_32.py.

1216 def user32_GetMessagePos(jitter):
1217  ret_ad, _ = jitter.func_args_stdcall(0)
1218  jitter.func_ret_stdcall(ret_ad, 0x00110022)
1219 
def miasm2.os_dep.win_api_x86_32.user32_GetSystemMetrics (   jitter)

Definition at line 2120 of file win_api_x86_32.py.

2121 def user32_GetSystemMetrics(jitter):
2122  ret_ad, args = jitter.func_args_stdcall(["nindex"])
2123 
2124  ret = 0
2125  if args.nindex in [0x2a, 0x4a]:
2126  ret = 0
2127  else:
2128  raise ValueError('unimpl index')
2129  jitter.func_ret_stdcall(ret_ad, ret)
2130 
def miasm2.os_dep.win_api_x86_32.user32_GetTopWindow (   jitter)

Definition at line 391 of file win_api_x86_32.py.

392 def user32_GetTopWindow(jitter):
393  ret_ad, _ = jitter.func_args_stdcall(["hwnd"])
394  jitter.func_ret_stdcall(ret_ad, 0)
395 
def miasm2.os_dep.win_api_x86_32.user32_GetWindowLongA (   jitter)

Definition at line 760 of file win_api_x86_32.py.

761 def user32_GetWindowLongA(jitter):
762  ret_ad, _ = jitter.func_args_stdcall(["hwnd", "nindex"])
763  jitter.func_ret_stdcall(ret_ad, winobjs.windowlong_dw)
764 
def miasm2.os_dep.win_api_x86_32.user32_IsCharAlpha (   jitter,
  funcname,
  get_str 
)

Definition at line 1937 of file win_api_x86_32.py.

1938 def user32_IsCharAlpha(jitter, funcname, get_str):
1939  ret_ad, args = jitter.func_args_stdcall(["c"])
1940  try:
1941  c = chr(args.c)
1942  except:
1943  log.error('bad char %r', args.c)
1944  c = "\x00"
1945  if c.isalpha(jitter):
1946  ret = 1
1947  else:
1948  ret = 0
1949  jitter.func_ret_stdcall(ret_ad, ret)
1950 

+ Here is the caller graph for this function:

def miasm2.os_dep.win_api_x86_32.user32_IsCharAlphaA (   jitter)

Definition at line 1951 of file win_api_x86_32.py.

1952 def user32_IsCharAlphaA(jitter):
1953  user32_IsCharAlpha(jitter, whoami(), get_str_ansi)
1954 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.user32_IsCharAlphaNumericA (   jitter)

Definition at line 1959 of file win_api_x86_32.py.

1960 def user32_IsCharAlphaNumericA(jitter):
1961  ret_ad, args = jitter.func_args_stdcall(["c"])
1962  c = chr(args.c)
1963  if c.isalnum(jitter):
1964  ret = 1
1965  else:
1966  ret = 0
1967  jitter.func_ret_stdcall(ret_ad, ret)
1968 
def miasm2.os_dep.win_api_x86_32.user32_IsCharAlphaW (   jitter)

Definition at line 1955 of file win_api_x86_32.py.

1956 def user32_IsCharAlphaW(jitter):
1957  user32_IsCharAlpha(jitter, whoami(), get_str_unic)
1958 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.user32_IsCharLowerA (   jitter)

Definition at line 2459 of file win_api_x86_32.py.

2460 def user32_IsCharLowerA(jitter):
2461  ret_ad, args = jitter.func_args_stdcall(["c"])
2462  ret = 1 if args.c & 0x20 else 0
2463  jitter.func_ret_stdcall(ret_ad, ret)
2464 
def miasm2.os_dep.win_api_x86_32.user32_IsCharUpperA (   jitter)

Definition at line 2453 of file win_api_x86_32.py.

2454 def user32_IsCharUpperA(jitter):
2455  ret_ad, args = jitter.func_args_stdcall(["c"])
2456  ret = 0 if args.c & 0x20 else 1
2457  jitter.func_ret_stdcall(ret_ad, ret)
2458 
def miasm2.os_dep.win_api_x86_32.user32_MessageBoxA (   jitter)

Definition at line 2540 of file win_api_x86_32.py.

2541 def user32_MessageBoxA(jitter):
2542  ret_ad, args = jitter.func_args_stdcall(["hwnd", "lptext",
2543  "lpcaption", "utype"])
2544 
2545  text = get_str_ansi(jitter, args.lptext)
2546  caption = get_str_ansi(jitter, args.lpcaption)
2547 
2548  log.info('Caption: %r Text: %r', caption, text)
2549 
2550  jitter.func_ret_stdcall(ret_ad, 0)
2551 

+ Here is the call graph for this function:

def miasm2.os_dep.win_api_x86_32.user32_SetWindowLongA (   jitter)

Definition at line 765 of file win_api_x86_32.py.

766 def user32_SetWindowLongA(jitter):
767  ret_ad, _ = jitter.func_args_stdcall(["hwnd", "nindex", "newlong"])
768  jitter.func_ret_stdcall(ret_ad, winobjs.windowlong_dw)
769 
def miasm2.os_dep.win_api_x86_32.whoami ( )

Definition at line 234 of file win_api_x86_32.py.

235 def whoami():
236  return inspect.stack()[1][3]
237 
def miasm2.os_dep.win_api_x86_32.wsock32_WSAStartup (   jitter)

Definition at line 2131 of file win_api_x86_32.py.

2132 def wsock32_WSAStartup(jitter):
2133  ret_ad, args = jitter.func_args_stdcall(["version, pwsadata"])
2134  jitter.vm.set_mem(args.pwsadata, "\x01\x01\x02\x02WinSock 2.0\x00")
2135  jitter.func_ret_stdcall(ret_ad, 0)
2136 

Variable Documentation

dictionary miasm2.os_dep.win_api_x86_32.access_dict
Initial value:
1 = {0x0: 0,
2  0x1: 0,
3  0x2: PAGE_READ,
4  0x4: PAGE_READ | PAGE_WRITE,
5  0x10: PAGE_EXEC,
6  0x20: PAGE_EXEC | PAGE_READ,
7  0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
8  0x80: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
9  # 0x80: PAGE_EXECUTE_WRITECOPY
10  0x100: 0
11  }

Definition at line 66 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])

Definition at line 78 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.console_handler = logging.StreamHandler()

Definition at line 41 of file win_api_x86_32.py.

miasm2.os_dep.win_api_x86_32.digs = string.digits+string.lowercase

Definition at line 2690 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.kernel32_GetVersionExA
Initial value:
1 = lambdajitter:kernel32_GetVersionEx(jitter,
2  set_str_ansi)

Definition at line 360 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.kernel32_GetVersionExW
Initial value:
1 = lambdajitter:kernel32_GetVersionEx(jitter,
2  set_str_unic)

Definition at line 362 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.log = logging.getLogger("win_api_x86_32")

Definition at line 40 of file win_api_x86_32.py.

int miasm2.os_dep.win_api_x86_32.MAX_PATH = 260

Definition at line 47 of file win_api_x86_32.py.

list miasm2.os_dep.win_api_x86_32.process_list

Definition at line 178 of file win_api_x86_32.py.

int miasm2.os_dep.win_api_x86_32.temp_num = 0

Definition at line 2568 of file win_api_x86_32.py.

tuple miasm2.os_dep.win_api_x86_32.winobjs = c_winobjs()

Definition at line 175 of file win_api_x86_32.py.