summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ntapi/nt_file.h9
-rw-r--r--include/ntapi/ntapi.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/fs/ntapi_tt_open_volume_by_guid.c65
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
6 files changed, 78 insertions, 0 deletions
diff --git a/include/ntapi/nt_file.h b/include/ntapi/nt_file.h
index 177612b..885a7d8 100644
--- a/include/ntapi/nt_file.h
+++ b/include/ntapi/nt_file.h
@@ -1214,4 +1214,13 @@ typedef int32_t __stdcall ntapi_tt_open_physical_parent_directory(
__in uint32_t open_options,
__out int * reserved);
+typedef int32_t __stdcall ntapi_tt_open_volume_by_guid(
+ __out void ** hfile,
+ __in const nt_guid * guid,
+ __in uint32_t desired_access,
+ __in nt_object_attributes * obj_attr,
+ __out nt_io_status_block * io_status_block,
+ __in uint32_t share_access,
+ __in uint32_t open_options);
+
#endif
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index 79efeb9..3c2cfd6 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -392,6 +392,7 @@ typedef struct _ntapi_vtbl {
ntapi_tt_get_file_handle_type * tt_get_file_handle_type;
ntapi_tt_open_logical_parent_directory * tt_open_logical_parent_directory;
ntapi_tt_open_physical_parent_directory * tt_open_physical_parent_directory;
+ ntapi_tt_open_volume_by_guid * tt_open_volume_by_guid;
/* nt_ipc.h */
ntapi_ipc_connect_by_attr * ipc_connect_by_attr;
diff --git a/project/common.mk b/project/common.mk
index adafe4b..54c5629 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -14,6 +14,7 @@ COMMON_SRCS = \
src/fs/ntapi_tt_mount.c \
src/fs/ntapi_tt_open_logical_parent_directory.c \
src/fs/ntapi_tt_open_physical_parent_directory.c \
+ src/fs/ntapi_tt_open_volume_by_guid.c \
src/fs/ntapi_tt_stat.c \
src/fs/ntapi_tt_statfs.c \
src/guid/ntapi_tt_guid.c \
diff --git a/src/fs/ntapi_tt_open_volume_by_guid.c b/src/fs/ntapi_tt_open_volume_by_guid.c
new file mode 100644
index 0000000..4f6236c
--- /dev/null
+++ b/src/fs/ntapi_tt_open_volume_by_guid.c
@@ -0,0 +1,65 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <ntapi/ntapi.h>
+#include <ntapi/nt_file.h>
+#include "ntapi_impl.h"
+
+struct __ntapi_volume_name {
+ wchar16_t global[4];
+ wchar16_t volume[6];
+ nt_guid_str_utf16 guid;
+};
+
+int32_t __stdcall __ntapi_tt_open_volume_by_guid(
+ __out void ** hfile,
+ __in const nt_guid * guid,
+ __in uint32_t access,
+ __in nt_object_attributes * oaarg,
+ __out nt_io_status_block * iosb,
+ __in uint32_t share,
+ __in uint32_t options)
+{
+ struct __ntapi_volume_name name;
+ nt_unicode_string path;
+ nt_object_attributes oa;
+
+ if (!oaarg)
+ oaarg = &(nt_object_attributes){sizeof(*oaarg),0,0,0,0,0};
+
+ else if (oaarg->obj_name)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ name.global[0] = '\\';
+ name.global[1] = '?';
+ name.global[2] = '?';
+ name.global[3] = '\\';
+
+ name.volume[0] = 'V';
+ name.volume[1] = 'o';
+ name.volume[2] = 'l';
+ name.volume[3] = 'u';
+ name.volume[4] = 'm';
+ name.volume[5] = 'e';
+
+ __ntapi->tt_guid_to_string_utf16(
+ guid,&name.guid);
+
+ path.strlen = sizeof(name);
+ path.maxlen = 0;
+ path.buffer = &name.global[0];
+
+ oa.len = oaarg->len;
+ oa.root_dir = oaarg->root_dir;
+ oa.obj_name = &path;
+ oa.obj_attr = oaarg->obj_attr;
+ oa.sec_desc = oaarg->sec_desc;
+ oa.sec_qos = oaarg->sec_qos;
+
+ return __ntapi->zw_open_file(
+ hfile,access,&oa,iosb,
+ share,options);
+}
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index f22f2c4..d1540dd 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -187,6 +187,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_get_file_handle_type = __ntapi_tt_get_file_handle_type;
__ntapi->tt_open_logical_parent_directory = __ntapi_tt_open_logical_parent_directory;
__ntapi->tt_open_physical_parent_directory = __ntapi_tt_open_physical_parent_directory;
+ __ntapi->tt_open_volume_by_guid = __ntapi_tt_open_volume_by_guid;
/* nt_ipc.h */
__ntapi->ipc_connect_by_attr = __ntapi_ipc_connect_by_attr;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 3e309bd..5630fb7 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -47,6 +47,7 @@ ntapi_tt_crc64_table __ntapi_tt_crc64_table;
ntapi_tt_get_file_handle_type __ntapi_tt_get_file_handle_type;
ntapi_tt_open_logical_parent_directory __ntapi_tt_open_logical_parent_directory;
ntapi_tt_open_physical_parent_directory __ntapi_tt_open_physical_parent_directory;
+ntapi_tt_open_volume_by_guid __ntapi_tt_open_volume_by_guid;
/* nt_ipc.h */