From b51a6e180864e90f2a70ff50046dd4e20fd761a3 Mon Sep 17 00:00:00 2001 From: hakril Date: Fri, 7 Feb 2025 13:39:00 +0100 Subject: [PATCH] Adding CreateRemoteThreadEx definition --- ctypes_generation/definitions/functions/winfunc.txt | 11 +++++++++++ docs/source/winfuncs_generated.rst | 2 ++ windows/generated_def/meta.py | 1 + windows/generated_def/winfuncs.py | 5 +++++ windows/winproxy/apis/kernel32.py | 12 ++++++------ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ctypes_generation/definitions/functions/winfunc.txt b/ctypes_generation/definitions/functions/winfunc.txt index cc4d696..637c5ae 100644 --- a/ctypes_generation/definitions/functions/winfunc.txt +++ b/ctypes_generation/definitions/functions/winfunc.txt @@ -150,6 +150,17 @@ HANDLE WINAPI CreateRemoteThread( _Out_ LPDWORD lpThreadId ); +HANDLE CreateRemoteThreadEx( + [in] HANDLE hProcess, + [in, optional] LPSECURITY_ATTRIBUTES lpThreadAttributes, + [in] SIZE_T dwStackSize, + [in] LPTHREAD_START_ROUTINE lpStartAddress, + [in, optional] LPVOID lpParameter, + [in] DWORD dwCreationFlags, + [in, optional] LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, + [out, optional] LPDWORD lpThreadId +); + BOOL WINAPI CreateProcessA( __in_opt LPCSTR lpApplicationName, __inout_opt LPSTR lpCommandLine, diff --git a/docs/source/winfuncs_generated.rst b/docs/source/winfuncs_generated.rst index eef30e1..9005838 100644 --- a/docs/source/winfuncs_generated.rst +++ b/docs/source/winfuncs_generated.rst @@ -1390,6 +1390,8 @@ Functions .. function:: CreateRemoteThread(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId) +.. function:: CreateRemoteThreadEx(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpAttributeList, lpThreadId) + .. function:: CreateProcessA(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation) .. function:: CreateProcessW(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation) diff --git a/windows/generated_def/meta.py b/windows/generated_def/meta.py index 9c6cc78..9dea2ff 100644 --- a/windows/generated_def/meta.py +++ b/windows/generated_def/meta.py @@ -14680,6 +14680,7 @@ functions = {'AccessCheck', 'CreateProcessAsUserW', 'CreateProcessW', 'CreateRemoteThread', +'CreateRemoteThreadEx', 'CreateServiceA', 'CreateServiceW', 'CreateStreamOnHGlobal', diff --git a/windows/generated_def/winfuncs.py b/windows/generated_def/winfuncs.py index 9127a71..0f7f87d 100644 --- a/windows/generated_def/winfuncs.py +++ b/windows/generated_def/winfuncs.py @@ -3470,6 +3470,11 @@ CreateThreadParams = ((1, 'lpThreadAttributes'), (1, 'dwStackSize'), (1, 'lpStar CreateRemoteThreadPrototype = WINFUNCTYPE(HANDLE, HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD) CreateRemoteThreadParams = ((1, 'hProcess'), (1, 'lpThreadAttributes'), (1, 'dwStackSize'), (1, 'lpStartAddress'), (1, 'lpParameter'), (1, 'dwCreationFlags'), (1, 'lpThreadId')) +#def CreateRemoteThreadEx(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpAttributeList, lpThreadId): +# return CreateRemoteThreadEx.ctypes_function(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpAttributeList, lpThreadId) +CreateRemoteThreadExPrototype = WINFUNCTYPE(HANDLE, HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPPROC_THREAD_ATTRIBUTE_LIST, LPDWORD) +CreateRemoteThreadExParams = ((1, 'hProcess'), (1, 'lpThreadAttributes'), (1, 'dwStackSize'), (1, 'lpStartAddress'), (1, 'lpParameter'), (1, 'dwCreationFlags'), (1, 'lpAttributeList'), (1, 'lpThreadId')) + #def CreateProcessA(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation): # return CreateProcessA.ctypes_function(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation) CreateProcessAPrototype = WINFUNCTYPE(BOOL, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION) diff --git a/windows/winproxy/apis/kernel32.py b/windows/winproxy/apis/kernel32.py index de603fd..1340103 100644 --- a/windows/winproxy/apis/kernel32.py +++ b/windows/winproxy/apis/kernel32.py @@ -214,6 +214,11 @@ def CreateRemoteThread(hProcess=NeededParameter, lpThreadAttributes=None, dwStac lpStartAddress=NeededParameter, lpParameter=NeededParameter, dwCreationFlags=0, lpThreadId=None): return CreateRemoteThread.ctypes_function(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId) +@Kernel32Proxy() +def CreateRemoteThreadEx(hProcess, lpThreadAttributes=None, dwStackSize=0, lpStartAddress=NeededParameter, lpParameter=NeededParameter, dwCreationFlags=0, lpAttributeList=None, lpThreadId=None): + return CreateRemoteThreadEx.ctypes_function(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpAttributeList, lpThreadId) + + @Kernel32Proxy() def GetThreadContext(hThread, lpContext): # TODO: RM ME IF TEST PASS @@ -661,12 +666,7 @@ def FindNextChangeNotification(hChangeHandle): @Kernel32Proxy() def FindCloseChangeNotification(hChangeHandle): - return FindCloseChange - Notification.ctypes_function(hChangeHandle) - -@Kernel32Proxy() -def FindNextChangeNotification(hChangeHandle): - return FindNextChangeNotification.ctypes_function(hChangeHandle) + return FindCloseChangeNotification.ctypes_function(hChangeHandle) @Kernel32Proxy() def ReadDirectoryChangesW(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine):