[python-win32] how to use win32process.CreateRemoteThread

june y qwertyjune56 at gmail.com
Thu Sep 10 10:24:26 EDT 2020


<https://stackoverflow.com/posts/63814377/timeline>

i am studying win32process of pywin32.

but, i encounter a problem.

problem is I don't know win32process.CreateRemoteThread wants what arguments

I don't know what *TypeError: Unable to convert function to pointer-sized
value*, *TypeError: Unable to convert NoneType to pointer-sized
value*, *TypeError:
Unable to convert tuple to pointer-sized value* means,


import win32processimport win32conimport win32api

i=0
def cnt1():
    global i
    print("None")
    i+=1
def cnt2(a, b):
    global i
    print(f"args : {a} {b}")
    i+=1


pid = win32process.GetCurrentProcessId()print(f"pid : {pid}")
pHandle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, win32con.FALSE, pid)

a = None
b = (1, 2)

tHandle1, tid = win32process.CreateRemoteThread(pHandle, None, 0,
id(cnt1), id(a), 0)# when id(cnt1) argument is cnt1, error# TypeError:
Unable to convert function to pointer-sized value# when id(a) argument
is a, error# TypeError: Unable to convert NoneType to pointer-sized
value# So I tried to give the address through id(cnt1) and id(a) as
parameters of CreateRemoteThread.# but, python IDLE is
crashing...(Attachments)

tHandle2, tid = win32process.CreateRemoteThread(pHandle, None, 0,
id(cnt2), id(b), 0)# same as adove# when id(b) argument is b, error#
TypeError: Unable to convert tuple to pointer-sized value
print(f"i : {i}")

win32api.CloseHandle(tHandle1)
win32api.CloseHandle(tHandle2)
win32api.CloseHandle(pHandle)

it is my code
my enviroment is Windows 7 home 64bit, python 3.6.7, pywin32- 224

thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20200910/8a4978d7/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: errerIMG.png
Type: image/png
Size: 61076 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-win32/attachments/20200910/8a4978d7/attachment-0001.png>


More information about the python-win32 mailing list