Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConquerOnline.Native
{
public unsafe class Msvcrt
{
[DllImport(NativeConfiguration.MSVCRT, EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
private static extern void* Memcpy(void* dest, void* src, uint count);
[DllImport(NativeConfiguration.MSVCRT, EntryPoint = "memset", CallingConvention = CallingConvention.Cdecl)]
private static extern void* Memset(void* dst, byte fill, int length);
[DllImport(NativeConfiguration.MSVCRT, EntryPoint = "srand", CallingConvention = CallingConvention.StdCall)]
public static extern short srand(int seed);
[DllImport(NativeConfiguration.MSVCRT, EntryPoint = "rand", CallingConvention = CallingConvention.StdCall)]
public static extern short rand();
#region memset
public static void MemorySet(byte[] Dest, byte Fill, int Length)
{
fixed (byte* dest = Dest)
Memset(dest, Fill, Length);
}
public static void MemorySet(byte[] Dest, byte Fill, uint Length)
{
fixed (byte* dest = Dest)
Memset(dest, Fill, (int)Length);
}
public static void MemorySet(byte* Dest, byte Fill, int Length)
{
Memset(Dest, Fill, Length);
}
public static void MemorySet(byte* Dest, byte Fill, uint Length)
{
Memset(Dest, Fill, (int)Length);
}
public static void MemorySet(void* Dest, byte Fill, int Length)
{
Memset(Dest, Fill, Length);
}
public static void MemorySet(void* Dest, byte Fill, uint Length)
{
Memset(Dest, Fill, (int)Length);
}
#endregion
#region memcpy
public static void MemoryCopy(byte* Dest, byte* Src, uint Count)
{
Memcpy(Dest, Src, Count);
}
public static void MemoryCopy(byte* Dest, byte* Src, int Count)
{
Memcpy(Dest, Src, (uint)Count);
}
public static void MemoryCopy(void* Dest, void* Src, uint Count)
{
Memcpy(Dest, Src, Count);
}
public static void MemoryCopy(void* Dest, void* Src, int Count)
{
Memcpy(Dest, Src, (uint)Count);
}
public static void MemoryCopy(byte[] Dest, byte[] Src, int Count)
{
fixed (byte* dest = Dest, src = Src)
Memcpy(dest, src, (uint)Count);
}
public static void MemoryCopy(byte[] Dest, byte[] Src, uint Count)
{
fixed (byte* dest = Dest, src = Src)
Memcpy(dest, src, Count);
}
#endregion
}
}