summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ntapi/nt_string.h4
-rw-r--r--include/ntapi/ntapi.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/string/ntapi_tt_aligned_block_memlock.c23
6 files changed, 30 insertions, 1 deletions
diff --git a/include/ntapi/nt_string.h b/include/ntapi/nt_string.h
index 4fddf8f..059a7ee 100644
--- a/include/ntapi/nt_string.h
+++ b/include/ntapi/nt_string.h
@@ -9,7 +9,6 @@ typedef void * __cdecl ntapi_memset(
int c,
size_t count);
-
typedef int __cdecl ntapi_sprintf(
char * buffer,
const char * format,
@@ -93,6 +92,9 @@ typedef uintptr_t * __cdecl ntapi_tt_aligned_block_memcpy(
__in const uintptr_t * src,
__in size_t bytes);
+typedef void * __cdecl ntapi_tt_aligned_block_memlock(
+ __in void * block,
+ __in size_t bytes);
typedef wchar16_t * __cdecl ntapi_tt_memcpy_utf16(
__in wchar16_t * dst,
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index c04d10a..8de63d3 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -458,6 +458,7 @@ typedef struct _ntapi_vtbl {
ntapi_tt_strncmp_utf16 * tt_strncmp_utf16;
ntapi_tt_aligned_block_memset * tt_aligned_block_memset;
ntapi_tt_aligned_block_memcpy * tt_aligned_block_memcpy;
+ ntapi_tt_aligned_block_memlock * tt_aligned_block_memlock;
ntapi_tt_aligned_memcpy_utf16 * tt_aligned_memcpy_utf16;
ntapi_tt_memcpy_utf16 * tt_memcpy_utf16;
ntapi_tt_generic_memset * tt_generic_memset;
diff --git a/project/common.mk b/project/common.mk
index f30b611..7be6a79 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -97,6 +97,7 @@ COMMON_SRCS = \
src/socket/ntapi_sc_socket_v2.c \
src/socket/ntapi_sc_wait.c \
src/string/ntapi_tt_aligned_block_memcpy.c \
+ 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_hex_utf16_to_uintptr.c \
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 9361338..a53ca80 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -253,6 +253,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_strncmp_utf16 = __ntapi_tt_strncmp_utf16;
__ntapi->tt_aligned_block_memset = __ntapi_tt_aligned_block_memset;
__ntapi->tt_aligned_block_memcpy = __ntapi_tt_aligned_block_memcpy;
+ __ntapi->tt_aligned_block_memlock = __ntapi_tt_aligned_block_memlock;
__ntapi->tt_memcpy_utf16 = __ntapi_tt_memcpy_utf16;
__ntapi->tt_aligned_memcpy_utf16 = __ntapi_tt_aligned_memcpy_utf16;
__ntapi->tt_generic_memset = __ntapi_tt_generic_memset;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 7c744c9..8280f55 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -115,6 +115,7 @@ ntapi_tt_strncmp_multibyte __ntapi_tt_strncmp_multibyte;
ntapi_tt_strncmp_utf16 __ntapi_tt_strncmp_utf16;
ntapi_tt_aligned_block_memset __ntapi_tt_aligned_block_memset;
ntapi_tt_aligned_block_memcpy __ntapi_tt_aligned_block_memcpy;
+ntapi_tt_aligned_block_memlock __ntapi_tt_aligned_block_memlock;
ntapi_tt_init_unicode_string_from_utf16 __ntapi_tt_init_unicode_string_from_utf16;
ntapi_tt_memcpy_utf16 __ntapi_tt_memcpy_utf16;
ntapi_tt_aligned_memcpy_utf16 __ntapi_tt_aligned_memcpy_utf16;
diff --git a/src/string/ntapi_tt_aligned_block_memlock.c b/src/string/ntapi_tt_aligned_block_memlock.c
new file mode 100644
index 0000000..5aa3a7e
--- /dev/null
+++ b/src/string/ntapi_tt_aligned_block_memlock.c
@@ -0,0 +1,23 @@
+/********************************************************/
+/* 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_string.h>
+#include <ntapi/nt_sync.h>
+#include <ntapi/nt_atomic.h>
+
+uintptr_t * __cdecl __ntapi_tt_aligned_block_memlock(
+ __in uintptr_t * dst,
+ __in size_t bytes)
+{
+ size_t addr = (size_t)dst & ~(size_t)(NT_SYNC_BLOCK_SIZE);
+ size_t cap = addr + bytes;
+
+ for (; addr<cap; addr+=NT_SYNC_BLOCK_SIZE)
+ at_locked_xadd((intptr_t *)addr,0);
+
+ return dst;
+}