summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-06-13 13:06:05 +0000
committermidipix <writeonce@midipix.org>2018-06-13 12:14:17 -0400
commitd5e229619fb0d57da8ae79ea61b9ae72ed60216d (patch)
treee167cc0fea1d79dc323c96155f4799a725160c41 /src
parent5981d9f1e190e098c4fb151507e2a6d7ffac9dec (diff)
downloadntapi-d5e229619fb0d57da8ae79ea61b9ae72ed60216d.tar.bz2
ntapi-d5e229619fb0d57da8ae79ea61b9ae72ed60216d.tar.xz
keyed object directory: use a simplified naming scheme.
Diffstat (limited to 'src')
-rw-r--r--src/object/ntapi_tt_keyed_object_directory.c102
1 files changed, 57 insertions, 45 deletions
diff --git a/src/object/ntapi_tt_keyed_object_directory.c b/src/object/ntapi_tt_keyed_object_directory.c
index 77a6aff..705eec9 100644
--- a/src/object/ntapi_tt_keyed_object_directory.c
+++ b/src/object/ntapi_tt_keyed_object_directory.c
@@ -13,12 +13,46 @@
typedef ntapi_zw_open_directory_object objdir_open_fn;
-static nt_keyed_objdir_name __template_name = {__NT_BASED_NAMED_OBJECTS,
- 0,
- {0,0,0,0,0,0},
- {0,{0},0},
- {0}};
+static void __tt_guid_to_hex_utf16(
+ __in const nt_guid * guid,
+ __out wchar16_t * hex_str)
+{
+ uint16_t key;
+
+ __ntapi_tt_uint32_to_hex_utf16(
+ guid->data1,&hex_str[0]);
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ guid->data2,&hex_str[9]);
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ guid->data3,&hex_str[14]);
+
+ key = guid->data4[0] * 0x100 + guid->data4[1];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,&hex_str[19]);
+
+ key = guid->data4[2] * 0x100 + guid->data4[3];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,&hex_str[24]);
+
+ key = guid->data4[4] * 0x100 + guid->data4[5];
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,&hex_str[28]);
+
+ key = guid->data4[6] * 0x100 + guid->data4[7];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,&hex_str[32]);
+
+ hex_str[8] = '-';
+ hex_str[13] = '-';
+ hex_str[18] = '-';
+ hex_str[23] = '-';
+}
static nt_access_allowed_ace * __ipc_ace_init(
nt_access_allowed_ace * ace,
@@ -111,25 +145,24 @@ static int32_t __stdcall __tt_create_ipc_object_directory(
__ipc_sd_init(&sd,1);
__ntapi->tt_generic_memcpy(
- &objdir_name,
- &__template_name,
- sizeof(objdir_name));
+ objdir_name.base_named_objects,
+ (wchar16_t[])__NT_BASED_NAMED_OBJECTS,
+ sizeof(objdir_name.base_named_objects));
__ntapi->tt_memcpy_utf16(
objdir_name.prefix,
prefix,
sizeof(objdir_name.prefix));
- __ntapi->tt_guid_to_string_utf16(
- guid,
- (nt_guid_str_utf16 *)&objdir_name.objdir_guid);
+ __tt_guid_to_hex_utf16(
+ guid,objdir_name.guid);
objdir_name.backslash = '\\';
- objdir_name.objdir_guid.uscore_guid = '_';
+ objdir_name.uscore = '_';
name.strlen = sizeof(objdir_name);
name.maxlen = 0;
- name.buffer = (uint16_t *)&objdir_name;
+ name.buffer = objdir_name.base_named_objects;
oa.len = sizeof(oa);
oa.root_dir = 0;
@@ -152,12 +185,11 @@ static int32_t __stdcall __tt_create_ipc_object_directory(
static int32_t __stdcall __tt_create_keyed_object_directory(
__out void ** hdir,
__in uint32_t desired_access,
- __in const wchar16_t prefix[6],
- __in const nt_guid * guid,
+ __in void * hparent,
__in uint32_t key,
__in objdir_open_fn * openfn)
{
- nt_keyed_objdir_name objdir_name;
+ wchar16_t keystr[8];
nt_unicode_string name;
nt_sd_common_buffer sd;
nt_oa oa;
@@ -169,33 +201,15 @@ static int32_t __stdcall __tt_create_keyed_object_directory(
__ipc_sd_init(&sd,1);
- __ntapi->tt_generic_memcpy(
- &objdir_name,
- &__template_name,
- sizeof(__template_name));
-
- __ntapi->tt_memcpy_utf16(
- objdir_name.prefix,
- prefix,
- sizeof(objdir_name.prefix));
-
- __ntapi->tt_guid_to_string_utf16(
- guid,
- (nt_guid_str_utf16 *)&objdir_name.objdir_guid);
-
__ntapi->tt_uint32_to_hex_utf16(
- key,objdir_name.key);
-
- objdir_name.backslash = '\\';
- objdir_name.objdir_guid.uscore_guid = '_';
- objdir_name.objdir_guid.uscore_key = '_';
+ key,keystr);
- name.strlen = sizeof(objdir_name);
- name.maxlen = 0;
- name.buffer = (uint16_t *)&objdir_name;
+ name.strlen = sizeof(keystr);
+ name.maxlen = 0;
+ name.buffer = keystr;
oa.len = sizeof(oa);
- oa.root_dir = 0;
+ oa.root_dir = hparent;
oa.obj_name = &name;
oa.obj_attr = NT_OBJ_INHERIT;
oa.sec_desc = &sd.sd;
@@ -341,26 +355,24 @@ int32_t __stdcall __ntapi_tt_create_dev_object_directory_entry(
int32_t __stdcall __ntapi_tt_create_keyed_object_directory(
__out void ** hdir,
__in uint32_t desired_access,
- __in const wchar16_t prefix[6],
- __in const nt_guid * guid,
+ __in void * hparent,
__in uint32_t key)
{
return __tt_create_keyed_object_directory(
hdir,desired_access,
- prefix,guid,key,
+ hparent,key,
__ntapi->zw_create_directory_object);
}
int32_t __stdcall __ntapi_tt_open_keyed_object_directory(
__out void ** hdir,
__in uint32_t desired_access,
- __in const wchar16_t prefix[6],
- __in const nt_guid * guid,
+ __in void * hparent,
__in uint32_t key)
{
return __tt_create_keyed_object_directory(
hdir,desired_access,
- prefix,guid,key,
+ hparent,key,
__ntapi->zw_open_directory_object);
}