microsoft / microsoft/win32metadata

CreateRemoteThread(Ex) is not really usable

Open
#2,014 3 comments 0 reactions 1 assignee Claimed by @AArnott View on GitHub
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

When trying to use the CreateRemoteThread(Ex) function, I found that the generated signatures are not really usable as the lpStartAddress is of a delegate type:

```cs
internal static extern unsafe winmdroot.Foundation.HANDLE CreateRemoteThread(winmdroot.Foundation.HANDLE hProcess, [Optional] winmdroot.Security.SECURITY_ATTRIBUTES* lpThreadAttributes, nuint dwStackSize, winmdroot.System.Threading.LPTHREAD_START_ROUTINE lpStartAddress, [Optional] void* lpParameter, uint dwCreationFlags, [Optional] uint* lpThreadId);
```

The problem is that the remote function address is almost certainly invalid in the context of the calling process and creating a delegate to such an address (by using, for example, `Marshal.GetDelegateForFunctionPointer`) will fail. If there is a way to create this delegate, please let me know. Otherwise, could you please change the lpStartAddress type to either `void *` or `nint`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.