From 060eadf4e7f81c2d2da4f6c4b2f019186c47ec57 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 28 Jun 2016 15:33:11 -0400 Subject: string functions: added __ntapi_tt_strcmp_utf16(). --- include/ntapi/nt_string.h | 4 ++++ include/ntapi/ntapi.h | 1 + project/common.mk | 1 + src/internal/ntapi.c | 1 + src/internal/ntapi_fnapi.h | 1 + src/string/ntapi_tt_strcmp_utf16.c | 18 ++++++++++++++++++ 6 files changed, 26 insertions(+) create mode 100644 src/string/ntapi_tt_strcmp_utf16.c diff --git a/include/ntapi/nt_string.h b/include/ntapi/nt_string.h index a44e287..241bb37 100644 --- a/include/ntapi/nt_string.h +++ b/include/ntapi/nt_string.h @@ -47,6 +47,10 @@ typedef int __cdecl ntapi_tt_strcmp_multibyte( __in const char * a, __in const char * b); +typedef int __cdecl ntapi_tt_strcmp_utf16( + __in const wchar16_t * a, + __in const wchar16_t * b); + typedef void __cdecl ntapi_tt_init_unicode_string_from_utf16( __out nt_unicode_string * str_dest, __in wchar16_t * str_src); diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h index 1b618d5..723ee9c 100644 --- a/include/ntapi/ntapi.h +++ b/include/ntapi/ntapi.h @@ -401,6 +401,7 @@ typedef struct _ntapi_vtbl { ntapi_tt_string_null_offset_qword * tt_string_null_offset_qword; ntapi_tt_string_null_offset_ptrsize * tt_string_null_offset_ptrsize; ntapi_tt_strcmp_multibyte * tt_strcmp_multibyte; + ntapi_tt_strcmp_utf16 * tt_strcmp_utf16; ntapi_tt_aligned_block_memset * tt_aligned_block_memset; ntapi_tt_aligned_block_memcpy * tt_aligned_block_memcpy; ntapi_tt_aligned_memcpy_utf16 * tt_aligned_memcpy_utf16; diff --git a/project/common.mk b/project/common.mk index 52b1a18..7e2b832 100644 --- a/project/common.mk +++ b/project/common.mk @@ -74,6 +74,7 @@ COMMON_SRCS = \ src/string/ntapi_tt_init_unicode_string_from_utf16.c \ src/string/ntapi_tt_memcpy_utf16.c \ src/string/ntapi_tt_strcmp_multibyte.c \ + src/string/ntapi_tt_strcmp_utf16.c \ src/string/ntapi_tt_string_null_offset.c \ src/string/ntapi_tt_uintptr_to_hex_utf16.c \ src/string/ntapi_tt_uintptr_to_hex_utf8.c \ diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c index b01a52c..f053431 100644 --- a/src/internal/ntapi.c +++ b/src/internal/ntapi.c @@ -168,6 +168,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl) __ntapi->tt_string_null_offset_qword = __ntapi_tt_string_null_offset_qword; __ntapi->tt_string_null_offset_ptrsize = __ntapi_tt_string_null_offset_ptrsize; __ntapi->tt_strcmp_multibyte = __ntapi_tt_strcmp_multibyte; + __ntapi->tt_strcmp_utf16 = __ntapi_tt_strcmp_utf16; __ntapi->strlen = __ntapi_tt_string_null_offset_multibyte; __ntapi->wcslen = __ntapi_wcslen; __ntapi->tt_aligned_block_memset = __ntapi_tt_aligned_block_memset; diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h index ab74d85..d752e70 100644 --- a/src/internal/ntapi_fnapi.h +++ b/src/internal/ntapi_fnapi.h @@ -54,6 +54,7 @@ ntapi_tt_string_null_offset_dword __ntapi_tt_string_null_offset_dword; ntapi_tt_string_null_offset_qword __ntapi_tt_string_null_offset_qword; ntapi_tt_string_null_offset_ptrsize __ntapi_tt_string_null_offset_ptrsize; ntapi_tt_strcmp_multibyte __ntapi_tt_strcmp_multibyte; +ntapi_tt_strcmp_utf16 __ntapi_tt_strcmp_utf16; ntapi_wcslen __ntapi_wcslen; ntapi_tt_aligned_block_memset __ntapi_tt_aligned_block_memset; ntapi_tt_aligned_block_memcpy __ntapi_tt_aligned_block_memcpy; diff --git a/src/string/ntapi_tt_strcmp_utf16.c b/src/string/ntapi_tt_strcmp_utf16.c new file mode 100644 index 0000000..b083d12 --- /dev/null +++ b/src/string/ntapi_tt_strcmp_utf16.c @@ -0,0 +1,18 @@ +/********************************************************/ +/* ntapi: Native API core library */ +/* Copyright (C) 2013--2016 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */ +/********************************************************/ + +#include +#include + +int __cdecl __ntapi_tt_strcmp_utf16( + __in const wchar16_t * a, + __in const wchar16_t * b) +{ + for (; (*a == *b) && *a; a++, b++) + (void)0; + + return (int)*a - (int)*b; +} -- cgit v1.2.3