Hello guys.
i'm working with TSAPI (alcatel) over C# (C/C++ works fine), but i'm having problem with access violation, see my code..
Windows PInvoke
[Flags()]
public enum AllocationType : uint
{
COMMIT = 0x1000,
RESERVE = 0x2000,
RESET = 0x80000,
LARGE_PAGES = 0x20000000,
PHYSICAL = 0x400000,
TOP_DOWN = 0x100000,
WRITE_WATCH = 0x200000
}
[Flags()]
public enum MemoryProtection : uint
{
EXECUTE = 0x10,
EXECUTE_READ = 0x20,
EXECUTE_READWRITE = 0x40,
EXECUTE_WRITECOPY = 0x80,
NOACCESS = 0x01,
READONLY = 0x02,
READWRITE = 0x04,
WRITECOPY = 0x08,
GUARD_Modifierflag = 0x100,
NOCACHE_Modifierflag = 0x200,
WRITECOMBINE_Modifierflag = 0x400
}
[DllImport("kernel32.dll", SetLastError = true)]
static extern unsafe UIntPtr VirtualAlloc(uint lpAddress, uint dwSize,
AllocationType flAllocationType, MemoryProtection flProtect);
TSAPI PInvoke
[DllImport("csta32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int acsGetEventPoll(uint acsHandle, void* eventBuf, void *eventBufSize, void* privData, void* numEvents);
MyCode C# unsafe code
byte* eventBuf = (byte*)VirtualAlloc(0, 1024, AllocationType.COMMIT | AllocationType.RESERVE, MemoryProtection.EXECUTE_READWRITE);
ushort* eventBufSize = (ushort*)VirtualAlloc(0, 2, AllocationType.COMMIT | AllocationType.RESERVE, MemoryProtection.EXECUTE_READWRITE); ;
*eventBufSize = 1024;
ushort* numEvents = (ushort*)VirtualAlloc(0, 2, AllocationType.COMMIT | AllocationType.RESERVE, MemoryProtection.EXECUTE_READWRITE); ;
*numEvents = 0;
void *privData = (byte*)VirtualAlloc(0, 1024, AllocationType.COMMIT | AllocationType.RESERVE, MemoryProtection.EXECUTE_READWRITE);
acsGetEventPoll(acsHandle, eventBuf, eventBufSize, privData, numEvents);
Some ideia????