2013-10-08 5 views
0

내가 WFP (Windows 필터링 플랫폼)에 대한 내 C# 래퍼를 쓰기왔다, 내가 WinDivert 1.0.5, 이 수입 구문WinDivert 1.0.5 DivertRecv() 메소드 받기 마지막 오류 998

[DllImportAttribute("WinDivert.dll", EntryPoint = "DivertRecv",SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 
      [return: MarshalAsAttribute(UnmanagedType.Bool)] 
      public static extern bool DivertRecv([InAttribute()] System.IntPtr handle, 
                [OutAttribute()] System.IntPtr pPacket, 
                [InAttribute()] uint packetLen, 
             [ OutAttribute()] System.IntPtr pAddr, 
             [OutAttribute()] System.IntPtr readLen); 

사용이 함수 호출 구문

if(DivertRecv(handle, Ppacket, (uint)(8 * packet.Length-1), 
       Paddr, Ppacket_len) == false) 
       { 
        Console.ForegroundColor = ConsoleColor.Red; 
        Console.WriteLine("warning: failed to read packet {0} .", Marshal.GetLastWin32Error()); 
        Console.ResetColor(); 
        Console.WriteLine(" Press any key to Exit ..."); 
        Console.ReadKey(); 
        Environment.Exit(1); 
} 

하지만 기능은 모든 호출 false를 반환하고, GetLastWin32Error()는 오류 코드 998을 얻는다. PLZ 도와주세요.

+0

[이 질문] (http://stackoverflow.com/questions/23296106/windivert-in-c-sharp)을보고 도와주세요. 나는 당신이 해결 한 것과 같은 문제가있을 것이라고 생각합니다. – JohnTube

+0

@SecurityCrazy windivert에 대한 C# 래퍼를 공유하면 멋지다. 나는 하나를 함께 고투하는 과정에있다. ;) –

답변

0

998 = ERROR_NOACCESS (메모리 위치에 잘못된 액세스). 이 오류는 DivertRecv에 잘못된 포인터를 전달하여 발생했을 가능성이 큽니다.

pPacket 매개 변수는 미리 할당 된 크기의 packetLen 버퍼에 대한 포인터입니까?

+0

Basil 답장을 보내 주셔서 감사합니다 ... pPacket을 다음과 같이 선언합니다. - IntPtr Ppacket = new IntPtr (Marshal.SizeOf (typeof (PACKET)))); 그리고 PACKET은 내 프로젝트에서 선언 된 struct 유형입니다. –

+0

선언이 정확하다고 생각하지 않습니다. 단지 비트 값이 sizeof의 정수 결과 인 IntPtr을 생성합니다. 메모리를 할당하지 않습니다. – Basil

+0

친애하는 바질, 나는 당신에게 말할 필요가있다. .. 당신은 위대한 프로그래머이고, 나는 당신에게 어떻게 감사 할 수 있는지 모른다. .. 당신의 예에서이 문제에 나를 도울 수 있는가, TCP 1237 패킷을 보내라. .. –