parse_samr.c

来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,438 行 · 第 1/5 页

C
2,438
字号
		return False;	if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout){	u_3->logout.low = nt_logout.low;	u_3->logout.high = nt_logout.high;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,			     prs_struct *ps, int depth){	if (u_3 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info3");	depth++;	if(!smb_io_time("logout", &u_3->logout, ps, depth))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info6(SAM_UNK_INFO_6 * u_6){	u_6->unknown_0 = 0x00000000;	u_6->ptr_0 = 1;	memset(u_6->padding, 0, sizeof(u_6->padding));	/* 12 bytes zeros */}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,			     prs_struct *ps, int depth){	if (u_6 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info6");	depth++;	if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */		return False;	if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */		return False;	if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding)))	/* 12 bytes zeros */		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role){	u_7->server_role = server_role;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,			     prs_struct *ps, int depth){	if (u_7 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info7");	depth++;	if(!prs_uint16("server_role", ps, depth, &u_7->server_role))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num){	unix_to_nt_time(&u_8->domain_create_time, 0);	u_8->seq_num.low = seq_num;	u_8->seq_num.high = 0x0000;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,			     prs_struct *ps, int depth){	if (u_8 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info8");	depth++;	if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))		return False;	if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout){	u_12->duration.low = nt_lock_duration.low;	u_12->duration.high = nt_lock_duration.high;	u_12->reset_count.low = nt_reset_time.low;	u_12->reset_count.high = nt_reset_time.high;	u_12->bad_attempt_lockout = lockout;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,			      prs_struct *ps, int depth){	if (u_12 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info12");	depth++;	if(!smb_io_time("duration", &u_12->duration, ps, depth))		return False;	if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))		return False;	if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server){	init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);	init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,			     prs_struct *ps, int depth){	if (u_5 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info5");	depth++;	if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))		return False;	if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info2(SAM_UNK_INFO_2 * u_2,			const char *comment, const char *domain, const char *server,			uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role){	u_2->logout.low = nt_logout.low;	u_2->logout.high = nt_logout.high;	u_2->seq_num.low = seq_num;	u_2->seq_num.high = 0x00000000;	u_2->unknown_4 = 0x00000001;	u_2->server_role = server_role;	u_2->unknown_6 = 0x00000001;	u_2->num_domain_usrs = num_users;	u_2->num_domain_grps = num_groups;	u_2->num_local_grps = num_alias;	memset(u_2->padding, 0, sizeof(u_2->padding));	/* 12 bytes zeros */	init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);	init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);	init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);	init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);	init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);	init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,			     prs_struct *ps, int depth){	if (u_2 == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_unk_info2");	depth++;	if(!smb_io_time("logout", &u_2->logout, ps, depth))		return False;	if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))		return False;	if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))		return False;	if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))		return False;	/* put all the data in here, at the moment, including what the above	   pointer is referring to	 */	if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))		return False;	if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */		return False;	if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))		return False;	if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */		return False;	if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))		return False;	if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))		return False;	if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))		return False;	if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))		return False;	if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))		return False;	if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))		return False;	return True;}/*******************************************************************inits a structure.********************************************************************/void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist, 		    uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age){	u_1->min_length_password = min_pass_len;	u_1->password_history = pass_hist;	u_1->password_properties = password_properties;		/* password never expire */	u_1->expire.high = nt_expire.high;	u_1->expire.low = nt_expire.low;		/* can change the password now */	u_1->min_passwordage.high = nt_min_age.high;	u_1->min_passwordage.low = nt_min_age.low;	}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,			     prs_struct *ps, int depth){	if (u_1 == NULL)	  return False;	prs_debug(ps, depth, desc, "sam_io_unk_info1");	depth++;	if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))		return False;	if(!prs_uint16("password_history", ps, depth, &u_1->password_history))		return False;	if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))		return False;	if(!smb_io_time("expire", &u_1->expire, ps, depth))		return False;	if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))		return False;	return True;}/*******************************************************************inits a SAMR_R_QUERY_DOMAIN_INFO structure.********************************************************************/void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,				uint16 switch_value, SAM_UNK_CTR * ctr,				NTSTATUS status){	DEBUG(5, ("init_samr_r_query_dom_info\n"));	r_u->ptr_0 = 0;	r_u->switch_value = 0;	r_u->status = status;	/* return status */	if (NT_STATUS_IS_OK(status)) {		r_u->switch_value = switch_value;		r_u->ptr_0 = 1;		r_u->ctr = ctr;	}}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,			      prs_struct *ps, int depth){        if (r_u == NULL)		return False;	prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))		return False;	if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {		if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))			return False;		if(!prs_align(ps))			return False;		switch (r_u->switch_value) {		case 0x0c:			if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))				return False;			break;		case 0x08:			if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))				return False;			break;		case 0x07:			if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))				return False;			break;		case 0x06:			if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))				return False;			break;		case 0x05:			if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))				return False;			break;		case 0x03:			if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))				return False;			break;		case 0x02:			if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))				return False;			break;		case 0x01:			if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))				return False;			break;		default:			DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",				r_u->switch_value));			r_u->status = NT_STATUS_INVALID_INFO_CLASS;			return False;		}	}		if(!prs_align(ps))		return False;	if(!prs_ntstatus("status", ps, depth, &r_u->status))		return False;		return True;}/*******************************************************************reads or writes a SAMR_R_SET_SEC_OBJ structure.********************************************************************/BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,			     prs_struct *ps, int depth){	if (r_u == NULL)		return False;  	prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");	depth++;	if(!prs_align(ps))		return False;	if(!prs_ntstatus("status", ps, depth, &r_u->status))		return False;	return True;}/*******************************************************************reads or writes a SAMR_R_QUERY_SEC_OBJ structure.********************************************************************/BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,			     prs_struct *ps, int depth){	if (r_u == NULL)		return False;  	prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr", ps, depth, &r_u->ptr))		return False;	if (r_u->ptr != 0) {		if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))			return False;	}	if(!prs_ntstatus("status", ps, depth, &r_u->status))		return False;	return True;}/*******************************************************************reads or writes a SAM_STR1 structure.********************************************************************/static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,			    uint32 name_buf, uint32 desc_buf,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?