Content filter on C# (wwwcensor)

Home Forums Discussions Support Content filter on C# (wwwcensor)

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5217
    zaitcev85
    Participant

      I use this code from examples (wwwcensor).
      I try to convert it in C# language in VS.NET.
      yet it does not work( please help me!!!

      source C++ code:

      DWORD dwDataLength = PacketBuffer.m_Length - (sizeof(ether_header) + pIpHeader->ip_hl*4 + pTcpHeader->th_off*4);
      PCHAR pData = (PCHAR)pEthHeader + (sizeof(ether_header) + pIpHeader->ip_hl*4 + pTcpHeader->th_off*4);
      // If packet contains any data - process it
      if (dwDataLength)
      {
      memcpy (szTempString, pData, dwDataLength);
      for (unsigned t = 0; t < dwDataLength; ++t)
      {
      if (szTempString[t] == 0)
      szTempString[t] = 0x20;
      if (isalpha((UCHAR)szTempString[t]))
      szTempString[t] = (char)toupper((UCHAR)szTempString[t]);
      }
      szTempString[dwDataLength] = 0;
      }

      it’s my C# variant:

      int size_ip = pIpHeader->IPLenVer * 4;
      int size_tcp = pTcpHeader->Off * 4;
      long dwDataLength = PacketBuffer.m_Length - sizeof(ETHER_HEADER) + size_ip + size_tcp;
      char* pData = (char*)pEthHeader + sizeof(ETHER_HEADER) + size_ip + size_tcp;
      string szTempString="";
      if (dwDataLength>0)
      {
      for (int i = 0; i < dwDataLength; i++)
      {
      if (pData == 0)
      szTempString += 0x20;
      if (IsAlpha((byte)pData
      ))
      szTempString += Convert.ToChar((byte)pData
      );
      }
      szTempString += 0x00;
      }

      my english bad. can answer me on Russian language.

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.