-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSystemTools.cs
35 lines (30 loc) · 1.12 KB
/
SystemTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace AForge
{
using System;
using System.Runtime.InteropServices;
public static class SystemTools
{
public static unsafe IntPtr CopyUnmanagedMemory(IntPtr dst, IntPtr src, int count)
{
CopyUnmanagedMemory((byte*) dst.ToPointer(), (byte*) src.ToPointer(), count);
return dst;
}
public static unsafe byte* CopyUnmanagedMemory(byte* dst, byte* src, int count)
{
return memcpy(dst, src, count);
}
[DllImport("ntdll.dll")]
private static extern unsafe byte* memcpy(byte* dst, byte* src, int count);
[DllImport("ntdll.dll")]
private static extern unsafe byte* memset(byte* dst, int filler, int count);
public static unsafe byte* SetUnmanagedMemory(byte* dst, int filler, int count)
{
return memset(dst, filler, count);
}
public static unsafe IntPtr SetUnmanagedMemory(IntPtr dst, int filler, int count)
{
SetUnmanagedMemory((byte*) dst.ToPointer(), filler, count);
return dst;
}
}
}