Blame src/fs/ntapi_tt_open_volume_by_guid.c

0e25b0
/********************************************************/
0e25b0
/*  ntapi: Native API core library                      */
0e25b0
/*  Copyright (C) 2013--2018  Z. Gilboa                 */
0e25b0
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
0e25b0
/********************************************************/
0e25b0
0e25b0
#include <ntapi/ntapi.h>
0e25b0
#include <ntapi/nt_file.h>
0e25b0
#include "ntapi_impl.h"
0e25b0
0e25b0
struct __ntapi_volume_name {
0e25b0
	wchar16_t		global[4];
0e25b0
	wchar16_t		volume[6];
0e25b0
	nt_guid_str_utf16	guid;
0e25b0
};
0e25b0
0e25b0
int32_t	__stdcall __ntapi_tt_open_volume_by_guid(
0e25b0
	__out	void **			hfile,
0e25b0
	__in	const nt_guid *		guid,
0e25b0
	__in	uint32_t		access,
0e25b0
	__in	nt_object_attributes *	oaarg,
0e25b0
	__out	nt_io_status_block *	iosb,
0e25b0
	__in	uint32_t		share,
0e25b0
	__in	uint32_t		options)
0e25b0
{
0e25b0
	struct __ntapi_volume_name	name;
0e25b0
	nt_unicode_string		path;
0e25b0
	nt_object_attributes		oa;
0e25b0
0e25b0
	if (!oaarg)
0e25b0
		oaarg = &(nt_object_attributes){sizeof(*oaarg),0,0,0,0,0};
0e25b0
0e25b0
	else if (oaarg->obj_name)
0e25b0
		return NT_STATUS_INVALID_PARAMETER;
0e25b0
0e25b0
	name.global[0] = '\\';
0e25b0
	name.global[1] = '?';
0e25b0
	name.global[2] = '?';
0e25b0
	name.global[3] = '\\';
0e25b0
0e25b0
	name.volume[0] = 'V';
0e25b0
	name.volume[1] = 'o';
0e25b0
	name.volume[2] = 'l';
0e25b0
	name.volume[3] = 'u';
0e25b0
	name.volume[4] = 'm';
0e25b0
	name.volume[5] = 'e';
0e25b0
0e25b0
	__ntapi->tt_guid_to_string_utf16(
0e25b0
		guid,&name.guid);
0e25b0
0e25b0
	path.strlen = sizeof(name);
0e25b0
	path.maxlen = 0;
0e25b0
	path.buffer = &name.global[0];
0e25b0
0e25b0
	oa.len      = oaarg->len;
0e25b0
	oa.root_dir = oaarg->root_dir;
0e25b0
	oa.obj_name = &pat;;
0e25b0
	oa.obj_attr = oaarg->obj_attr;
0e25b0
	oa.sec_desc = oaarg->sec_desc;
0e25b0
	oa.sec_qos  = oaarg->sec_qos;
0e25b0
0e25b0
	return __ntapi->zw_open_file(
0e25b0
		hfile,access,&oa,iosb,
0e25b0
		share,options);
0e25b0
}