From 26c3809d6f6f8a0491b51acc03a418baff7a389e Mon Sep 17 00:00:00 2001 From: cod Date: Tue, 27 Aug 2024 17:35:21 +0200 Subject: [PATCH 1/2] removed GetThreadId and replaced with optional CLIENTID argument --- c/meterpreter/source/metsrv/remote_thread.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/c/meterpreter/source/metsrv/remote_thread.c b/c/meterpreter/source/metsrv/remote_thread.c index 76ea4423..fc71be86 100644 --- a/c/meterpreter/source/metsrv/remote_thread.c +++ b/c/meterpreter/source/metsrv/remote_thread.c @@ -39,7 +39,8 @@ HANDLE create_remote_thread(HANDLE hProcess, SIZE_T sStackSize, LPVOID pvStartAd BOOL bCreateSuspended; DWORD dwThreadId; HANDLE hThread; - + CLIENTID ClientId; + if (pdwThreadId == NULL) { pdwThreadId = &dwThreadId; @@ -74,12 +75,12 @@ HANDLE create_remote_thread(HANDLE hProcess, SIZE_T sStackSize, LPVOID pvStartAd { dprintf("[REMOTETHREAD] Attempting thread creation with RtlCreateUserThread"); bCreateSuspended = (dwCreateFlags & CREATE_SUSPENDED) == CREATE_SUSPENDED; - ntResult = pRtlCreateUserThread(hProcess, NULL, bCreateSuspended, 0, 0, 0, (PTHREAD_START_ROUTINE)pvStartAddress, pvStartParam, &hThread, NULL); + ntResult = pRtlCreateUserThread(hProcess, NULL, bCreateSuspended, 0, 0, 0, (PTHREAD_START_ROUTINE)pvStartAddress, pvStartParam, &hThread, &ClientId); SetLastError(ntResult); if (ntResult == 0 && pdwThreadId) { - *pdwThreadId = GetThreadId(hThread); + *pdwThreadId = (DWORD) ClientId.UniqueThread; } } else From a5c18499a7b65a4c01c1e962853d5aa48ebe8bca Mon Sep 17 00:00:00 2001 From: cod Date: Sat, 14 Sep 2024 19:21:11 +0200 Subject: [PATCH 2/2] C4311: Compiler Warning treated as errors in msvc --- c/meterpreter/source/metsrv/remote_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/meterpreter/source/metsrv/remote_thread.c b/c/meterpreter/source/metsrv/remote_thread.c index fc71be86..0384927d 100644 --- a/c/meterpreter/source/metsrv/remote_thread.c +++ b/c/meterpreter/source/metsrv/remote_thread.c @@ -80,7 +80,7 @@ HANDLE create_remote_thread(HANDLE hProcess, SIZE_T sStackSize, LPVOID pvStartAd if (ntResult == 0 && pdwThreadId) { - *pdwThreadId = (DWORD) ClientId.UniqueThread; + *pdwThreadId = PtrToUint(ClientId.UniqueThread); } } else