summaryrefslogtreecommitdiffhomepage
path: root/src/guid/ntapi_tt_guid.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
committermidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
commitdd89bb8ad4fe184a34b5dbdda237e640fc82121b (patch)
tree5e80d2da35f5892f92be29f57982b2708e6bd99b /src/guid/ntapi_tt_guid.c
parentdcdadc2702712fa750ed255ed1dfa354522797a0 (diff)
downloadntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.bz2
ntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.xz
entered advanced internal development stage.
Diffstat (limited to 'src/guid/ntapi_tt_guid.c')
-rw-r--r--src/guid/ntapi_tt_guid.c182
1 files changed, 182 insertions, 0 deletions
diff --git a/src/guid/ntapi_tt_guid.c b/src/guid/ntapi_tt_guid.c
new file mode 100644
index 0000000..07cd938
--- /dev/null
+++ b/src/guid/ntapi_tt_guid.c
@@ -0,0 +1,182 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013,2014,2015 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_time.h>
+#include <ntapi/nt_guid.h>
+#include "ntapi_impl.h"
+
+
+void __fastcall __ntapi_tt_guid_copy(
+ __out nt_guid * pguid_dst,
+ __in const nt_guid * pguid_src)
+{
+ uint64_t * dst;
+ uint64_t * src;
+
+ dst = (uint64_t *)pguid_dst;
+ src = (uint64_t *)pguid_src;
+
+ *dst = *src;
+ src++; dst++;
+ *dst = *src;
+}
+
+
+void __fastcall __ntapi_tt_guid_to_utf16_string(
+ __in const nt_guid * guid,
+ __out nt_guid_str_utf16 * guid_str)
+{
+ uint16_t key;
+ wchar16_t * wch;
+
+ wch = &(guid_str->group5[0]);
+
+ __ntapi_tt_uint32_to_hex_utf16(
+ guid->data1,
+ &guid_str->group1[0]);
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ guid->data2,
+ &guid_str->group2[0]);
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ guid->data3,
+ &guid_str->group3[0]);
+
+ key = guid->data4[0] * 0x100 + guid->data4[1];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,
+ &guid_str->group4[0]);
+
+ key = guid->data4[2] * 0x100 + guid->data4[3];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,
+ &guid_str->group5[0]);
+
+ key = guid->data4[4] * 0x100 + guid->data4[5];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,
+ &(wch[4]));
+
+ key = guid->data4[6] * 0x100 + guid->data4[7];
+
+ __ntapi_tt_uint16_to_hex_utf16(
+ key,
+ &(wch[8]));
+
+ guid_str->lbrace = '{';
+ guid_str->rbrace = '}';
+ guid_str->dash1 = '-';
+ guid_str->dash2 = '-';
+ guid_str->dash3 = '-';
+ guid_str->dash4 = '-';
+
+ return;
+}
+
+
+int32_t __fastcall __ntapi_tt_guid_compare(
+ __in const nt_guid * pguid_dst,
+ __in const nt_guid * pguid_src)
+{
+ uint64_t * dst;
+ uint64_t * src;
+
+ dst = (uint64_t *)pguid_dst;
+ src = (uint64_t *)pguid_src;
+
+ if ((*dst != *src) || (*(++dst) != *(++src)))
+ return NT_STATUS_OBJECT_TYPE_MISMATCH;
+
+ return NT_STATUS_SUCCESS;
+}
+
+
+int32_t __fastcall __ntapi_tt_utf16_string_to_guid(
+ __out nt_guid_str_utf16 * guid_str,
+ __in nt_guid * guid)
+{
+ int32_t status;
+ wchar16_t * wch;
+ uint16_t key;
+
+ if ((guid_str->lbrace != '{')
+ || (guid_str->rbrace != '}')
+ || (guid_str->dash1 != '-')
+ || (guid_str->dash2 != '-')
+ || (guid_str->dash3 != '-')
+ || (guid_str->dash4 != '-'))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ wch = &(guid_str->group5[0]);
+
+ status = __ntapi_tt_hex_utf16_to_uint32(
+ guid_str->group1,
+ &guid->data1);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ guid_str->group2,
+ &guid->data2);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ guid_str->group3,
+ &guid->data3);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ guid_str->group4,
+ &key);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ guid->data4[0] = key / 0x100;
+ guid->data4[1] = key % 0x100;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ &(wch[0]),
+ &key);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ guid->data4[2] = key / 0x100;
+ guid->data4[3] = key % 0x100;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ &(wch[4]),
+ &key);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ guid->data4[4] = key / 0x100;
+ guid->data4[5] = key % 0x100;
+
+ status = __ntapi_tt_hex_utf16_to_uint16(
+ &(wch[8]),
+ &key);
+
+ if (status != NT_STATUS_SUCCESS)
+ return status;
+
+ guid->data4[6] = key / 0x100;
+ guid->data4[7] = key % 0x100;
+
+ return NT_STATUS_SUCCESS;
+}