1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
WinPopup Protocol plugin for Miranda IM.
Copyright (C) 2004-2011 Nikolay Raspopov
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma once
#define SMB_ANY_NAME _T("* ")
#define FACILITY_NETBIOS (0x0f0f)
#define SMB_HEADER_SIZE (32)
#pragma pack (push, 1)
typedef struct SESSION_INFO_BLOCK
{
SESSION_HEADER sib_header;
SESSION_BUFFER sib_Names[ NCBNAMSZ ];
} SESSION_INFO_BLOCK, *PSESSION_INFO_BLOCK;
#pragma pack (pop)
class netbios_name
{
public:
netbios_name(LPCTSTR n = SMB_ANY_NAME /* ANSI */, UCHAR type = 0, bool group = false, UCHAR lana = 0);
netbios_name(const NAME_BUFFER& n, UCHAR lana);
netbios_name& operator=(const netbios_name& n);
netbios_name& operator=(const UCHAR* n);
// Ñðàâíåíèå (ïðîèçâîäèòüñÿ òîëüêî ïî èìåíè, íîìåðó èìåíè, òèïó èìåíè)
bool operator==(const NAME_BUFFER& n) const;
// Ñðàâíåíèå (ïðîèçâîäèòüñÿ òîëüêî ïî èìåíè, íîìåðó èìåíè, òèïó èìåíè)
bool operator!=(const NAME_BUFFER& n) const;
// Ñðàâíåíèå (ïðîèçâîäèòüñÿ òîëüêî ïî èìåíè, íîìåðó èìåíè, òèïó èìåíè, àäàïòåðó)
bool operator==(const netbios_name& n) const;
// Ñðàâíåíèå (ïðîèçâîäèòüñÿ òîëüêî ïî èìåíè, íîìåðó èìåíè, òèïó èìåíè, àäàïòåðó)
bool operator!=(const netbios_name& n) const;
// Ðåãèñòðàöèÿ èìåíè
bool Register();
// Äëÿ óñêîðåíèÿ
void AskForDestroy();
// Äåðåãèñòðàöèÿ èìåíè
void Destroy();
// Îáðàòíîå ïðåîáðàçîâàíèå NetBIOS-èìåíè èç OEM â ANSI â âèäå: NAME <TYPE>
CStringA GetANSIFullName() const;
CStringA original; // Ïîëíîå èìÿ (â ANSI êîäèðîâêå)
NAME_BUFFER netbiosed; // NetBIOS èìÿ (â OEM êîäèðîâêå):
// typedef struct _NAME_BUFFER {
// UCHAR name[NCBNAMSZ];
// UCHAR name_num;
// UCHAR name_flags;
// } NAME_BUFFER, *PNAME_BUFFER;
// Ïîëó÷åíèå àòðèáóòîâ èìåíè:
UCHAR GetType() const;
bool IsGroupName() const;
bool IsRegistered() const;
bool IsDuplicated() const;
bool IsError() const;
bool IsOwnName() const;
UCHAR GetLana() const;
size_t GetLength() const; // Äëèíà èìåíè NetBIOS
protected:
bool m_managed; // Ôëàã óïðàâëÿåìîãî èìåíè
bool m_registered; // Ôëàã óñïåøíîé ðåãèñòðàöèè èìåíè
bool m_duplicated; // Ôëàã ñóùåñòâîâàíèÿ èìåíè äî ðåãèñòðàöèè
bool m_error; // Ôëàã îøèáêè ïðîñëóøèâàíèÿ èìåíè
UCHAR m_lana; // Íîìåð àäàïòåðà
HANDLE m_listener; // Õýíäëåð ðàáî÷åãî ïîòîêà-ñëóøàòåëÿ ñåññèé
HANDLE m_dgreceiver; // Õýíäëåð ðàáî÷åãî ïîòîêà-ñëóøàòåëÿ äàòàãðàìì
HANDLE m_term; // Õýíäëåð ñîáûòèÿ îñòàíîâà ðàáî÷åãî ïîòîêà-ñëóøàòåëÿ
// Îáðàòíîå ïðåîáðàçîâàíèå NetBIOS-èìåíè èç OEM â ANSI
CStringA GetANSIName() const;
bool GetRealSender(UCHAR lsn, CStringA& sRealFrom) const;
UCHAR AddName();
UCHAR DeleteName();
// Îæèäàíèå íà÷àëà ñåññèè
void Listener();
static void ListenerThread(LPVOID param);
// Îæèäàíèå äàòàãðàììû
void DatagramReceiver();
static void DatagramReceiverThread(LPVOID param);
// Îáðàáîòêà ñåññèè (èç Listener)
void Receiver(UCHAR lsn);
static void ReceiverThread(LPVOID param);
};
typedef CAtlArray <netbios_name*> netbios_name_array;
typedef CAtlList <netbios_name> netbios_name_list;
/*
Name Number(h) Type Usage
--------------------------------------------------------------------------
<computername> 00 U Workstation Service
<computername> 01 U Messenger Service
<\\--__MSBROWSE__> 01 G Master Browser
<computername> 03 U Messenger Service
<computername> 06 U RAS Server Service
<computername> 1F U NetDDE Service
<computername> 20 U File Server Service
<computername> 21 U RAS Client Service
<computername> 22 U Microsoft Exchange Interchange(MSMail
Connector)
<computername> 23 U Microsoft Exchange Store
<computername> 24 U Microsoft Exchange Directory
<computername> 30 U Modem Sharing Server Service
<computername> 31 U Modem Sharing Client Service
<computername> 43 U SMS Clients Remote Control
<computername> 44 U SMS Administrators Remote Control
Tool
<computername> 45 U SMS Clients Remote Chat
<computername> 46 U SMS Clients Remote Transfer
<computername> 4C U DEC Pathworks TCPIP service on
Windows NT
<computername> 42 U mccaffee anti-virus
<computername> 52 U DEC Pathworks TCPIP service on
Windows NT
<computername> 87 U Microsoft Exchange MTA
<computername> 6A U Microsoft Exchange IMC
<computername> BE U Network Monitor Agent
<computername> BF U Network Monitor Application
<username> 03 U Messenger Service
<domain> 00 G Domain Name
<domain> 1B U Domain Master Browser
<domain> 1C G Domain Controllers
<domain> 1D U Master Browser
<domain> 1E G Browser Service Elections
<INet~Services> 1C G IIS
<IS~computer name> 00 U IIS
<computername> [2B] U Lotus Notes Server Service
IRISMULTICAST [2F] G Lotus Notes
IRISNAMESERVER [33] G Lotus Notes
Forte_$ND800ZA [20] U DCA IrmaLan Gateway Server Service
*/
|