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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
/*
* Unix SMB/Netbios implementation.
* Version 1.9.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
* Copyright (C) Paul Ashton 1997.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
extern int DEBUGLEVEL;
/*******************************************************************
make_svc_q_open_sc_man
********************************************************************/
void make_svc_q_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u,
char *server, char *database,
uint32 des_access)
{
DEBUG(5,("make_svc_q_open_sc_man\n"));
make_buf_unistr2(&(q_u->uni_srv_name), &(q_u->ptr_srv_name), server);
make_buf_unistr2(&(q_u->uni_db_name ), &(q_u->ptr_db_name), database);
q_u->des_access = des_access;
}
/*******************************************************************
reads or writes a SVC_Q_OPEN_SC_MAN structure.
********************************************************************/
void svc_io_q_open_sc_man(char *desc, SVC_Q_OPEN_SC_MAN *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return;
prs_debug(ps, depth, desc, "svc_io_q_open_sc_man");
depth++;
prs_align(ps);
prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name));
smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth);
prs_align(ps);
prs_uint32("ptr_db_name", ps, depth, &(q_u->ptr_db_name));
smb_io_unistr2("", &(q_u->uni_db_name), q_u->ptr_db_name, ps, depth);
prs_align(ps);
prs_uint32("des_access", ps, depth, &(q_u->des_access));
prs_align(ps);
}
/*******************************************************************
make_svc_r_open_sc_man
********************************************************************/
void make_svc_r_open_sc_man(SVC_R_OPEN_SC_MAN *r_u, POLICY_HND *hnd,
uint32 status)
{
DEBUG(5,("make_svc_r_unknown_0: %d\n", __LINE__));
memcpy(&(r_u->pol), hnd, sizeof(r_u->pol));
r_u->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
void svc_io_r_open_sc_man(char *desc, SVC_R_OPEN_SC_MAN *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL) return;
prs_debug(ps, depth, desc, "svc_io_r_open_sc_man");
depth++;
prs_align(ps);
smb_io_pol_hnd("", &(r_u->pol), ps, depth);
prs_uint32("status ", ps, depth, &(r_u->status));
}
/*******************************************************************
makes an SVC_Q_ENUM_SVCS_STATUS structure.
********************************************************************/
void make_svc_q_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_c, POLICY_HND *hnd,
uint32 service_type, uint32 service_state,
uint32 buf_size, uint32 resume_hnd )
{
if (q_c == NULL || hnd == NULL) return;
DEBUG(5,("make_svc_q_enum_svcs_status\n"));
memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
q_c->service_type = service_type;
q_c->service_state = service_state;
q_c->buf_size = buf_size;
make_enum_hnd(&q_c->resume_hnd, resume_hnd);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
void svc_io_q_enum_svcs_status(char *desc, SVC_Q_ENUM_SVCS_STATUS *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return;
prs_debug(ps, depth, desc, "svc_io_q_enum_svcs_status");
depth++;
prs_align(ps);
smb_io_pol_hnd("", &(q_u->pol), ps, depth);
prs_align(ps);
prs_uint32("service_type ", ps, depth, &(q_u->service_type ));
prs_uint32("service_state", ps, depth, &(q_u->service_state));
prs_uint32("buf_size ", ps, depth, &(q_u->buf_size ));
smb_io_enum_hnd("resume_hnd", &(q_u->resume_hnd), ps, depth);
}
/*******************************************************************
makes an SVC_R_ENUM_SVCS_STATUS structure.
********************************************************************/
void make_svc_r_enum_svcs_status(SVC_R_ENUM_SVCS_STATUS *r_c,
ENUM_SRVC_STATUS *svcs, uint32 more_buf_size,
uint32 num_svcs, uint32 resume_hnd,
uint32 dos_status)
{
if (r_c == NULL) return;
DEBUG(5,("make_svc_r_enum_svcs_status\n"));
r_c->svcs = svcs;
r_c->more_buf_size = more_buf_size;
r_c->num_svcs = num_svcs;
make_enum_hnd(&r_c->resume_hnd, resume_hnd);
r_c->dos_status = dos_status;
}
/*******************************************************************
reads or writes a SVC_R_ENUM_SVCS_STATUS structure.
this is another wierd structure. WHY oh WHY can the microsoft teams
not COMMUNICATE and get some CONSISTENCY TO THEIR DATA STRUCTURES!
ARGH!
********************************************************************/
void svc_io_r_enum_svcs_status(char *desc, SVC_R_ENUM_SVCS_STATUS *svc, prs_struct *ps, int depth)
{
int i;
if (svc == NULL) return;
prs_debug(ps, depth, desc, "svc_io_r_enum_svcs_status");
depth++;
prs_align(ps);
/*
* format is actually as laid out in SVC_R_ENUM_SVCS_STATUS.
* the reason for all the jumping about, which is horrible
* and can be avoided, is due to the use of offsets instead
* of pointers.
*
* if i ever find out that these offsets are in fact non-zero
* tokens just like pointer-tokens, i am going to go MAD.
*/
if (ps->io)
{
/* reading */
uint32 buf_offset;
uint32 new_offset;
prs_uint32("buf_size", ps, depth, &(svc->buf_size));
buf_offset = ps->offset;
ps->offset = buf_offset + svc->buf_size;
prs_uint32("more_buf_size", ps, depth, &(svc->more_buf_size));
prs_uint32("num_svcs", ps, depth, &(svc->num_svcs));
smb_io_enum_hnd("resume_hnd", &(svc->resume_hnd), ps, depth);
prs_uint32("dos_status", ps, depth, &(svc->dos_status));
new_offset = ps->offset;
ps->offset = buf_offset;
svc->svcs = Realloc(NULL, svc->num_svcs * sizeof(ENUM_SRVC_STATUS));
if (svc->svcs == NULL)
{
DEBUG(0,("svc_io_r_enum_svcs_status: Realloc failed\n"));
ps->offset = 0x7fffffff;
return;
}
bzero(svc->svcs, svc->num_svcs * sizeof(ENUM_SRVC_STATUS));
for (i = 0; i < svc->num_svcs; i++)
{
fstring name;
uint32 old_offset;
uint32 srvc_offset;
uint32 disp_offset;
prs_uint32("srvc_offset", ps, depth, &srvc_offset);
prs_uint32("disp_offset", ps, depth, &disp_offset);
svc_io_svc_status("status", &svc->svcs[i].status, ps, depth);
old_offset = ps->offset;
ps->offset = buf_offset + srvc_offset;
slprintf(name, sizeof(name)-1, "srvc[%02d]", i);
smb_io_unistr(name, &svc->svcs[i].uni_srvc_name, ps, depth);
ps->offset = buf_offset + disp_offset;
slprintf(name, sizeof(name)-1, "disp[%02d]", i);
smb_io_unistr(name, &svc->svcs[i].uni_disp_name, ps, depth);
ps->offset = old_offset;
}
ps->offset = new_offset;
}
else
{
/* writing */
uint32 buf_offset;
uint32 old_buf_offset;
uint32 srvc_offset = 9 * sizeof(uint32) * svc->num_svcs;
prs_uint32_pre("buf_size", ps, depth, &svc->buf_size, &buf_offset);
old_buf_offset = ps->offset;
srvc_offset += old_buf_offset;
if (svc->svcs == NULL)
{
return;
}
for (i = 0; i < svc->num_svcs; i++)
{
fstring name;
uint32 old_offset;
/*
* store unicode string offset and unicode string
*/
srvc_offset -= old_buf_offset;
prs_uint32("srvc_offset", ps, depth, &srvc_offset);
srvc_offset += old_buf_offset;
slprintf(name, sizeof(name)-1, "srvc[%02d]", i);
old_offset = ps->offset;
ps->offset = srvc_offset;
smb_io_unistr(name, &svc->svcs[i].uni_srvc_name, ps, depth);
srvc_offset = ps->offset;
ps->offset = old_offset;
/*
* store unicode string offset and unicode string
*/
srvc_offset -= old_buf_offset;
prs_uint32("disp_offset", ps, depth, &srvc_offset);
srvc_offset += old_buf_offset;
slprintf(name, sizeof(name)-1, "disp[%02d]", i);
old_offset = ps->offset;
ps->offset = srvc_offset;
smb_io_unistr(name, &svc->svcs[i].uni_disp_name, ps, depth);
srvc_offset = ps->offset;
ps->offset = old_offset;
/*
* store status info
*/
svc_io_svc_status("status", &svc->svcs[i].status, ps, depth);
}
prs_uint32_post("buf_size", ps, depth, &svc->buf_size, buf_offset, srvc_offset - buf_offset - sizeof(uint32));
ps->offset = srvc_offset;
prs_uint32("more_buf_size", ps, depth, &(svc->more_buf_size));
prs_uint32("num_svcs", ps, depth, &(svc->num_svcs));
smb_io_enum_hnd("resume_hnd", &(svc->resume_hnd), ps, depth);
prs_uint32("dos_status", ps, depth, &(svc->dos_status));
}
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
void svc_io_svc_status(char *desc, SVC_STATUS *svc, prs_struct *ps, int depth)
{
if (svc == NULL) return;
prs_debug(ps, depth, desc, "svc_io_svc_status");
depth++;
prs_align(ps);
prs_uint32("svc_type", ps, depth, &(svc->svc_type));
prs_uint32("current_state", ps, depth, &(svc->current_state));
prs_uint32("controls_accepted", ps, depth, &(svc->controls_accepted));
prs_uint32("win32_exit_code", ps, depth, &(svc->win32_exit_code));
prs_uint32("svc_specific_exit_code", ps, depth, &(svc->svc_specific_exit_code));
prs_uint32("check_point", ps, depth, &(svc->check_point));
prs_uint32("wait_hint", ps, depth, &(svc->wait_hint));
}
/*******************************************************************
makes an SVC_Q_CLOSE structure.
********************************************************************/
void make_svc_q_close(SVC_Q_CLOSE *q_c, POLICY_HND *hnd)
{
if (q_c == NULL || hnd == NULL) return;
DEBUG(5,("make_svc_q_close\n"));
memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
void svc_io_q_close(char *desc, SVC_Q_CLOSE *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return;
prs_debug(ps, depth, desc, "svc_io_q_close");
depth++;
prs_align(ps);
smb_io_pol_hnd("", &(q_u->pol), ps, depth);
prs_align(ps);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
void svc_io_r_close(char *desc, SVC_R_CLOSE *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL) return;
prs_debug(ps, depth, desc, "svc_io_r_close");
depth++;
prs_align(ps);
smb_io_pol_hnd("", &(r_u->pol), ps, depth);
prs_align(ps);
prs_uint32("status", ps, depth, &(r_u->status));
}
|