//private bool _IsDisposed = false; //public bool IsDisposed { // get { return _IsDisposed; } //} public SmbScanner(int nMaxTask) { m_dic_netbios.Add(1, "NetBIOS computer name "); m_dic_netbios.Add(2, "NetBIOS domain name "); m_dic_netbios.Add(3, "DNS computer name "); m_dic_netbios.Add(4, "DNS domain name "); m_dic_netbios.Add(6, "Flags "); m_dic_netbios.Add(7, "Timestamp "); m_se = new Semaphore(nMaxTask, nMaxTask); m_que_sae = new Queue <SocketAsyncEventArgs>(); m_que_task = new Queue <SmbScanTaskInfo>(); m_hs_task_running = new HashSet <SmbScanTaskInfo>(); for (int i = 0; i < nMaxTask; i++) { SmbScanTaskInfo ti = new SmbScanTaskInfo(); SocketAsyncEventArgs sae = new SocketAsyncEventArgs(); sae.Completed += new EventHandler <SocketAsyncEventArgs>(IO_Completed); sae.SetBuffer(new byte[1500], 0, 1500); ti.RecvSAE = sae; sae.UserToken = ti; m_que_task.Enqueue(ti); } m_byNTLMSSP = Encoding.UTF8.GetBytes("NTLMSSP\0"); m_byNext = SmbScanner.GetNextVal(m_byNTLMSSP); new Thread(this.CheckTimeout) { IsBackground = true }.Start(); }
private static int KmpIndexOf(int nIndex, byte[] byParent, byte[] bySub, int[] nextVal) { int i = nIndex, j = -1; if (nextVal == null) { nextVal = SmbScanner.GetNextVal(bySub); } while (i < byParent.Length && j < bySub.Length) { if (j == -1 || byParent[i] == bySub[j]) { i++; j++; } else { j = nextVal[j]; } } return(j >= bySub.Length ? i - bySub.Length : -1); }