summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ntapi/nt_string.h20
-rw-r--r--include/ntapi/ntapi.h4
-rw-r--r--project/common.mk1
-rw-r--r--src/internal/ntapi.c4
-rw-r--r--src/internal/ntapi_fnapi.h4
-rw-r--r--src/string/ntapi_tt_dec_utf16_to_uintptr.c126
6 files changed, 159 insertions, 0 deletions
diff --git a/include/ntapi/nt_string.h b/include/ntapi/nt_string.h
index b24de3d..f85887d 100644
--- a/include/ntapi/nt_string.h
+++ b/include/ntapi/nt_string.h
@@ -205,4 +205,24 @@ typedef int32_t __stdcall ntapi_tt_uintptr_to_dec_null_utf8(
__in size_t buflen,
__out ssize_t * length);
+typedef int32_t __stdcall ntapi_tt_dec_utf16_to_uint16(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint16_t * key);
+
+typedef int32_t __stdcall ntapi_tt_dec_utf16_to_uint32(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint32_t * key);
+
+typedef int32_t __stdcall ntapi_tt_dec_utf16_to_uint64(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint64_t * key);
+
+typedef int32_t __stdcall ntapi_tt_dec_utf16_to_uintptr(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uintptr_t * key);
+
#endif
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index 2f073aa..a78d8f1 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -480,6 +480,10 @@ typedef struct _ntapi_vtbl {
ntapi_tt_uintptr_to_dec_utf8 * tt_uintptr_to_dec_utf8;
ntapi_tt_uintptr_to_dec_null_utf16 * tt_uintptr_to_dec_null_utf16;
ntapi_tt_uintptr_to_dec_null_utf8 * tt_uintptr_to_dec_null_utf8;
+ ntapi_tt_dec_utf16_to_uint16 * tt_dec_utf16_to_uint16;
+ ntapi_tt_dec_utf16_to_uint32 * tt_dec_utf16_to_uint32;
+ ntapi_tt_dec_utf16_to_uint64 * tt_dec_utf16_to_uint64;
+ ntapi_tt_dec_utf16_to_uintptr * tt_dec_utf16_to_uintptr;
ntapi_tt_init_unicode_string_from_utf16* tt_init_unicode_string_from_utf16;
/* nt_guid.h */
diff --git a/project/common.mk b/project/common.mk
index e993277..eb876f9 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -100,6 +100,7 @@ COMMON_SRCS = \
src/string/ntapi_tt_aligned_block_memlock.c \
src/string/ntapi_tt_aligned_block_memset.c \
src/string/ntapi_tt_aligned_memcpy_utf16.c \
+ src/string/ntapi_tt_dec_utf16_to_uintptr.c \
src/string/ntapi_tt_hex_utf16_to_uintptr.c \
src/string/ntapi_tt_init_unicode_string_from_utf16.c \
src/string/ntapi_tt_memcpy_utf16.c \
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 78075b6..f29fa69 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -276,6 +276,10 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_uintptr_to_dec_utf8 = __ntapi_tt_uintptr_to_dec_utf8;
__ntapi->tt_uintptr_to_dec_null_utf16 = __ntapi_tt_uintptr_to_dec_null_utf16;
__ntapi->tt_uintptr_to_dec_null_utf8 = __ntapi_tt_uintptr_to_dec_null_utf8;
+ __ntapi->tt_dec_utf16_to_uint16 = __ntapi_tt_dec_utf16_to_uint16;
+ __ntapi->tt_dec_utf16_to_uint32 = __ntapi_tt_dec_utf16_to_uint32;
+ __ntapi->tt_dec_utf16_to_uint64 = __ntapi_tt_dec_utf16_to_uint64;
+ __ntapi->tt_dec_utf16_to_uintptr = __ntapi_tt_dec_utf16_to_uintptr;
/* nt_guid.h */
__ntapi->tt_guid_copy = __ntapi_tt_guid_copy;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 5cea58f..37237de 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -138,6 +138,10 @@ ntapi_tt_uintptr_to_dec_utf16 __ntapi_tt_uintptr_to_dec_utf16;
ntapi_tt_uintptr_to_dec_utf8 __ntapi_tt_uintptr_to_dec_utf8;
ntapi_tt_uintptr_to_dec_null_utf16 __ntapi_tt_uintptr_to_dec_null_utf16;
ntapi_tt_uintptr_to_dec_null_utf8 __ntapi_tt_uintptr_to_dec_null_utf8;
+ntapi_tt_dec_utf16_to_uint16 __ntapi_tt_dec_utf16_to_uint16;
+ntapi_tt_dec_utf16_to_uint32 __ntapi_tt_dec_utf16_to_uint32;
+ntapi_tt_dec_utf16_to_uint64 __ntapi_tt_dec_utf16_to_uint64;
+ntapi_tt_dec_utf16_to_uintptr __ntapi_tt_dec_utf16_to_uintptr;
ntapi_wcslen __ntapi_tt_wcslen;
/* nt_guid.h */
diff --git a/src/string/ntapi_tt_dec_utf16_to_uintptr.c b/src/string/ntapi_tt_dec_utf16_to_uintptr.c
new file mode 100644
index 0000000..93f0967
--- /dev/null
+++ b/src/string/ntapi_tt_dec_utf16_to_uintptr.c
@@ -0,0 +1,126 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_status.h>
+
+static int32_t __tt_dec_utf16_to_uint64(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint64_t * key)
+{
+ int32_t status;
+ uint64_t lkey;
+ uint64_t hkey;
+ const wchar16_t * wch;
+
+ if (wch_cap <= wch_arg)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ else if (wch_cap - wch_arg > 20)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ lkey = 0;
+ hkey = 0;
+
+ if (wch_cap - wch_arg == 20) {
+ if ((status = __tt_dec_utf16_to_uint64(
+ &wch_arg[6],wch_cap,
+ &hkey)))
+ return status;
+
+ if (hkey > 18446744073709)
+ return NT_STATUS_INTEGER_OVERFLOW;
+
+ hkey *= 1000000;
+ wch_cap = &wch_arg[6];
+ }
+
+ for (wch=wch_arg; wch<wch_cap; wch++) {
+ if ((*wch < '0') || (*wch > '9'))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ lkey *= 10;
+ lkey += *wch - '0';
+ }
+
+ *key = lkey + hkey;
+
+ return NT_STATUS_SUCCESS;
+}
+
+int32_t __stdcall __ntapi_tt_dec_utf16_to_uint16(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint16_t * key)
+{
+ int32_t status;
+ uint64_t skey;
+ uint16_t rkey;
+
+ if ((status = __tt_dec_utf16_to_uint64(wch_arg,wch_cap,&skey)))
+ return status;
+
+ if ((rkey = skey) < skey)
+ return NT_STATUS_INTEGER_OVERFLOW;
+
+ *key = rkey;
+
+ return NT_STATUS_SUCCESS;
+}
+
+int32_t __stdcall __ntapi_tt_dec_utf16_to_uint32(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint32_t * key)
+{
+ int32_t status;
+ uint64_t skey;
+ uint32_t rkey;
+
+ if ((status = __tt_dec_utf16_to_uint64(wch_arg,wch_cap,&skey)))
+ return status;
+
+ if ((rkey = skey) < skey)
+ return NT_STATUS_INTEGER_OVERFLOW;
+
+ *key = rkey;
+
+ return NT_STATUS_SUCCESS;
+}
+
+
+
+int32_t __stdcall __ntapi_tt_dec_utf16_to_uint64(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uint64_t * key)
+{
+ return __tt_dec_utf16_to_uint64(
+ wch_arg,wch_cap,key);
+}
+
+#ifdef __NT32
+int32_t __stdcall __ntapi_tt_dec_utf16_to_uintptr(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uintptr_t * key)
+{
+ return __tt_dec_utf16_to_uint32(
+ wch_arg,wch_cap,key);
+}
+#endif
+
+#ifdef __NT64
+int32_t __stdcall __ntapi_tt_dec_utf16_to_uintptr(
+ __in const wchar16_t * wch_arg,
+ __in const wchar16_t * wch_cap,
+ __out uintptr_t * key)
+{
+ return __tt_dec_utf16_to_uint64(
+ wch_arg,wch_cap,key);
+}
+#endif