public int Find(char[] characterSet, int start, int end)
 {
     System.Windows.Forms.NativeMethods.CHARRANGE charrange;
     bool flag = true;
     bool negate = false;
     int textLength = this.TextLength;
     if (characterSet == null)
     {
         throw new ArgumentNullException("characterSet");
     }
     if ((start < 0) || (start > textLength))
     {
         throw new ArgumentOutOfRangeException("start", System.Windows.Forms.SR.GetString("InvalidBoundArgument", new object[] { "start", start, 0, textLength }));
     }
     if ((end < start) && (end != -1))
     {
         throw new ArgumentOutOfRangeException("end", System.Windows.Forms.SR.GetString("InvalidLowBoundArgumentEx", new object[] { "end", end, "start" }));
     }
     if (characterSet.Length == 0)
     {
         return -1;
     }
     int windowTextLength = System.Windows.Forms.SafeNativeMethods.GetWindowTextLength(new HandleRef(this, base.Handle));
     if (start == end)
     {
         start = 0;
         end = windowTextLength;
     }
     if (end == -1)
     {
         end = windowTextLength;
     }
     charrange = new System.Windows.Forms.NativeMethods.CHARRANGE {
         cpMax = charrange.cpMin = start
     };
     System.Windows.Forms.NativeMethods.TEXTRANGE lParam = new System.Windows.Forms.NativeMethods.TEXTRANGE {
         chrg = new System.Windows.Forms.NativeMethods.CHARRANGE()
     };
     lParam.chrg.cpMin = charrange.cpMin;
     lParam.chrg.cpMax = charrange.cpMax;
     System.Windows.Forms.UnsafeNativeMethods.CharBuffer buffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(0x201);
     lParam.lpstrText = buffer.AllocCoTaskMem();
     if (lParam.lpstrText == IntPtr.Zero)
     {
         throw new OutOfMemoryException();
     }
     try
     {
         bool flag3 = false;
         while (!flag3)
         {
             if (flag)
             {
                 lParam.chrg.cpMin = charrange.cpMax;
                 lParam.chrg.cpMax += 0x200;
             }
             else
             {
                 lParam.chrg.cpMax = charrange.cpMin;
                 lParam.chrg.cpMin -= 0x200;
                 if (lParam.chrg.cpMin < 0)
                 {
                     lParam.chrg.cpMin = 0;
                 }
             }
             if (end != -1)
             {
                 lParam.chrg.cpMax = Math.Min(lParam.chrg.cpMax, end);
             }
             int num3 = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x44b, 0, lParam);
             if (num3 == 0)
             {
                 charrange.cpMax = charrange.cpMin = -1;
                 goto Label_02F4;
             }
             buffer.PutCoTaskMem(lParam.lpstrText);
             string str = buffer.GetString();
             if (flag)
             {
                 for (int i = 0; i < num3; i++)
                 {
                     if (this.GetCharInCharSet(str[i], characterSet, negate))
                     {
                         flag3 = true;
                         continue;
                     }
                     charrange.cpMax++;
                 }
             }
             else
             {
                 int num5 = num3;
                 while (num5-- != 0)
                 {
                     if (this.GetCharInCharSet(str[num5], characterSet, negate))
                     {
                         flag3 = true;
                         continue;
                     }
                     charrange.cpMin--;
                 }
             }
         }
     }
     finally
     {
         if (lParam.lpstrText != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(lParam.lpstrText);
         }
     }
 Label_02F4:
     return (flag ? charrange.cpMax : charrange.cpMin);
 }
 private string CharRangeToString(System.Windows.Forms.NativeMethods.CHARRANGE c)
 {
     System.Windows.Forms.NativeMethods.TEXTRANGE lParam = new System.Windows.Forms.NativeMethods.TEXTRANGE {
         chrg = c
     };
     if ((c.cpMax > this.Text.Length) || ((c.cpMax - c.cpMin) <= 0))
     {
         return string.Empty;
     }
     int size = (c.cpMax - c.cpMin) + 1;
     System.Windows.Forms.UnsafeNativeMethods.CharBuffer buffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(size);
     IntPtr ptr = buffer.AllocCoTaskMem();
     if (ptr == IntPtr.Zero)
     {
         throw new OutOfMemoryException(System.Windows.Forms.SR.GetString("OutOfMemory"));
     }
     lParam.lpstrText = ptr;
     int num1 = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x44b, 0, lParam);
     buffer.PutCoTaskMem(ptr);
     if (lParam.lpstrText != IntPtr.Zero)
     {
         Marshal.FreeCoTaskMem(ptr);
     }
     return buffer.GetString();
 }