Vadim Smirnov

Forum Replies Created

Viewing 15 posts - 826 through 840 (of 1,496 total)
  • Author
    Posts
  • in reply to: trouble modifying passthru sample #6840
    Vadim Smirnov
    Keymaster

      SendPacketToAdapter can send any packet on the network even if it is not in correct format. I think you just don’t form the correct INTERMEDIATE_BUFFER. I’m not sure I fully understand what you are doing in your C# code as I’m not really experienced in C#, but to my limited knowledge the code is incorrect.

      byte[] newPacket = new byte[sizeof(ETHER_HEADER) + sizeof(IPHeader) + sizeof(UdpHeader) +
      sizeof(PlatformHeader) + dataLength + sizeof(GPSHeader)];

      ...

      IntPtr outgoingPacket = Marshal.AllocHGlobal((IntPtr)(newPacket.Length));
      Marshal.Copy(newPacket, 0, outgoingPacket, newPacket.Length);

      ETH_REQUEST outgoingRequest = new ETH_REQUEST();
      outgoingRequest.hAdapterHandle = Request.hAdapterHandle;
      outgoingRequest.EthPacket.Buffer = outgoingPacket;

      In your code above you use newPacket as managed INTERMEDIATE_BUFFER and outgoingPacket as unmanaged INTERMEDIATE_BUFFER. However, the size for allocation for newPacket must be sizeof(INTERMEDIATE_BUFFER), not the size you have used above. As well when you copy managed INTERMEDIATE_BUFFER into unmanaged memory once again you should copy sizeof(INTERMEDIATE_BUFFER).

      Note that you have to initialize INTERMEDIATE_BUFFER fields (you can copy values from the original structure and adjust m_Length).

      Also note that the resulted packet must fit into MAX_ETHER_FRAME (more exactly it should not exceed network interface MTU value).

      in reply to: TDI Filter, hook ClientEventsReceive #6830
      Vadim Smirnov
      Keymaster

        I think you can just return STATUS_DATA_NOT_ACCEPTED

        in reply to: A BSOD problem of tdifw. #6833
        Vadim Smirnov
        Keymaster

          It looks like ctx->old_handler = NULL. You can inspect the code to check how could it happen, may be this is a sort of race condition.

          in reply to: VirtNet VLAN support ? #6828
          Vadim Smirnov
          Keymaster

            I think it is doable, but I can’t say how hard it could be 😉 You never know before you try…

            in reply to: Using WinpkFilter to make UDP DPI proxy… #6749
            Vadim Smirnov
            Keymaster

              1) According to the above scenario, can I use your WinpkFilter 3.x product to do it?

              Sure you can.

              2) Can I set a specific device adapter filter so that ONLY UDP packets going to a specific port are grabbed via a ReadPacket() call?

              Yes, you can use built-in WinpkFilter filters for this.

              3) Can I use the “listen” mode to grab the packets, and signal to DROP bad packets but let the good ones pass through? I really don’t want to have to re-send the good packets to the loopback address or use tunneling mode. I’d like to just drop the bad packets and let things be as normal for the good packets.

              No, if you suppose to drop packets you should be filtering in tunnel mode. Listen mode only gives you a copy of the packet while passing the original one.

              4) Can I open up multiple device adapter handles and set different filters for them so that simultaneous ReadPacket() calls return different packets based on the different filters?

              Yes, you can open multiply adapters and set adapter specific filters.

              5) Is there a way to not have to keep calling the ReadPacket() method inside of a loop? Like, set the adapter to execute a callback function when a new packet is on the buffer? This would support an event driven model which is much more efficient on the CPU.

              Driver code can’t callback user mode code. If to be precise, you can execute a code in user mode part of the memory, but it can’t be safe (as packets arrive from the network at IRQL_DISPATCH_LEVEL but user mode memory can be paged out) and it also would be a security hole (as user mode code is executed with kernel mode privilege).

              6) After reviewing your product documentation, I noticed there is no structure documentation for the Adapter structure that is used commonly throughout your product as an Integer Pointer Handle. You have all the other structures documented, why not this very important one? I figured it must be a common structure in NDIS, but after some research, I’m finding that driver developers start adding their custom fields to it. What is the WinpkFilter structure associated with individual Adapter handles, i.e “_ETH_REQUEST.hAdapterHandle” ?

              This is internal WinpkFilter structure and it is not accessible from user mode (it is allocated from kernel memory).Thats why it is opaque.

              in reply to: Capturing double copies in VirtNet Adapter #6608
              Vadim Smirnov
              Keymaster

                VirtNet has hardcoded MAC address in driver, however you can easily changed it through the network card properties. Driver tries to read MAC address from the registry during driver start.

                in reply to: Filter packets comming in/out #6837
                Vadim Smirnov
                Keymaster

                  You can use WinpkFilter built-in filters to intercept only packets destined to port 80. For the intercepted packet you can get a pointer to packet data and search for the “explorer” string. If you modify the packet you have to recalculate packets TCP and IP checksums. Also, if you modify packet length you also have to affect TCP header.

                  in reply to: trouble modifying passthru sample #6838
                  Vadim Smirnov
                  Keymaster

                    I’m not experienced in C# well enough to inspect your code for possible errors. However, I would recommend you to install network sniffer like Network Monitor or Wireshark and intercept your handcrafted packets from the network. Network sniffer will show if anything is wrong with checksum.

                    Also, I can’t see in the code fragment where do you check if you are working with UDP packet. Or do you treat every outgoing packet as UDP one?

                    in reply to: PPP & Dial-up Issue #6832
                    Vadim Smirnov
                    Keymaster

                      Try to run passthru sample on the same network interface for which you run wireshark and I think you will be able to get exactly the same capture.

                      in reply to: WinpkFilter news/updates. #5511
                      Vadim Smirnov
                      Keymaster

                        WinpkFilter 3.0.7 released. This service release includes the bugfix for WinpkFilter NDIS IM driver on power state changes.

                        If you are eligible for a free update, please send the following details to [email protected] tо receive an update instruction:

                        1) Your order ID.
                        2) An approximate date of purchasing.

                        in reply to: Virtual Network Adapter VirtNet 1.0 and Vista64 #6700
                        Vadim Smirnov
                        Keymaster
                          in reply to: Virtual Network Adapter VirtNet 1.0 and Vista64 #6698
                          Vadim Smirnov
                          Keymaster

                            The download link is the same. Archive contain both 32 bit and 64 bit drivers.

                            in reply to: Ссылки на сайте #6824
                            Vadim Smirnov
                            Keymaster

                              Спасибо за информацию. Меры приняты. 😯

                              in reply to: Virtual Network Adapter VirtNet in Windows Server 2008 #6823
                              Vadim Smirnov
                              Keymaster

                                Yes, you can install and use VirtNet on Windows 2008

                                in reply to: Virtual Network Adapter VirtNet 1.0 and Vista64 #6696
                                Vadim Smirnov
                                Keymaster

                                  You can use VirtNet under Windows x64 if disable driver signing requirement (press F8 during system boot and choose Disable Driver Signature Enforcement option) or you can use test signing for VirtNet driver.

                                Viewing 15 posts - 826 through 840 (of 1,496 total)