How do I convert this to VB.net
[DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
static unsafe extern IntPtr memcpy(byte* dest, byte* src, uint count);
static unsafe void ProfileEvent(byte* data, uint uiSize, uint uiUserData)
{
if (uiSize > 0)
{
if (uiReceivedProfileCount < uiNeededProfileCount)
{
uiProfileDataSize = uiSize;
fixed (byte* dst = &abyProfileBuffer[uiReceivedProfileCount * uiSize])
{
memcpy(dst, data, uiSize);
}
uiReceivedProfileCount++;
}
if (uiReceivedProfileCount >= uiNeededProfileCount)
{
hProfileEvent.Set();
}
}
}
What I have tried:
Using
CodeTranslator: Code Translation From VB.NET <-> C# <-> TypeScript <-> Java[
^]
Comes up with:
Private Declare Function memcpy Lib "msvcrt.dll" Alias "memcpy" (ByVal dest As Byte, ByVal src As Byte, ByVal count As UInteger) As IntPtr
Private Shared Sub ProfileEvent(ByVal data As Byte, ByVal uiSize As UInteger, ByVal uiUserData As UInteger)
If (uiSize > 0) Then
If (bProfileReceived < uiNeededProfileCount) Then
uiProfileDataSize = uiSize
abyProfileBuffer((bProfileReceived * uiSize))
memcpy(dst, data, uiSize)
bProfileReceived = (bProfileReceived + 1)
End If
If (bProfileReceived >= uiNeededProfileCount) Then
'If the needed profile count is arrived: set the event
hProfileEvent.Set
End If
End If
End Sub
Honestly, it didn't do so well.
It missed the byte* array all together.
In reality I think I'm just stuck on:
fixed (byte* dst = &abyProfileBuffer[uiReceivedProfileCount * uiSize])
{
memcpy(dst, data, uiSize);
}
I googled
"fixed (byte*" vb.net
And found:
Convert fixed and byte* from c# to vb.net - Stack Overflow[
^]
and I eventually found:
https://social.technet.microsoft.com/wiki/contents/articles/24254.moving-memory-in-net-using-vb-and-the-cil.aspx[
^]
Not sure how to use that.
Any help to fill in the puzzle pieces?