[SHIMLIB] Update helper functions, add ShimLib_StringNDuplicateA
authorMark Jansen <mark.jansen@reactos.org>
Sat, 24 Feb 2018 13:57:00 +0000 (14:57 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Sun, 22 Apr 2018 16:51:48 +0000 (18:51 +0200)
dll/appcompat/shims/shimlib/shimlib.c
dll/appcompat/shims/shimlib/shimlib.h

index 54d6479..b9c2652 100644 (file)
@@ -50,11 +50,16 @@ void ShimLib_ShimFree(PVOID pData)
     HeapFree(g_ShimLib_Heap, 0, pData);
 }
 
+PCSTR ShimLib_StringNDuplicateA(PCSTR szString, SIZE_T stringLengthIncludingNullTerm)
+{
+    PSTR NewString = ShimLib_ShimMalloc(stringLengthIncludingNullTerm);
+    StringCchCopyA(NewString, stringLengthIncludingNullTerm, szString);
+    return NewString;
+}
+
 PCSTR ShimLib_StringDuplicateA(PCSTR szString)
 {
-    SIZE_T Length = lstrlenA(szString);
-    PSTR NewString = ShimLib_ShimMalloc(Length+1);
-    return lstrcpyA(NewString, szString);
+    return ShimLib_StringNDuplicateA(szString, lstrlenA(szString) + 1);
 }
 
 BOOL ShimLib_StrAEqualsW(PCSTR szString, PCWSTR wszString)
index b6a6743..5eaf185 100644 (file)
@@ -2,7 +2,7 @@
  * PROJECT:     ReactOS Shim helper library
  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
  * PURPOSE:     ReactOS Shim Engine common functions / structures
- * COPYRIGHT:   Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org)
+ * COPYRIGHT:   Copyright 2016-2018 Mark Jansen (mark.jansen@reactos.org)
  */
 
 #pragma once
@@ -17,16 +17,17 @@ typedef struct tagHOOKAPI
 } HOOKAPI, *PHOOKAPI;
 
 
-PVOID ShimLib_ShimMalloc(SIZE_T);
-void ShimLib_ShimFree(PVOID);
-PCSTR ShimLib_StringDuplicateA(PCSTR);
-BOOL ShimLib_StrAEqualsW(PCSTR, PCWSTR);
+PVOID ShimLib_ShimMalloc(SIZE_T dwSize);
+VOID ShimLib_ShimFree(PVOID pData);
+PCSTR ShimLib_StringDuplicateA(PCSTR szString);
+PCSTR ShimLib_StringNDuplicateA(PCSTR szString, SIZE_T stringLength);
+BOOL ShimLib_StrAEqualsW(PCSTR szString, PCWSTR wszString);
 
 
 /* Forward events to generic handlers */
-void ShimLib_Init(HINSTANCE);
-void ShimLib_Deinit(void);
-PHOOKAPI WINAPI ShimLib_GetHookAPIs(LPCSTR,LPCWSTR,PDWORD);
+VOID ShimLib_Init(HINSTANCE hInstance);
+VOID ShimLib_Deinit(VOID);
+PHOOKAPI WINAPI ShimLib_GetHookAPIs(LPCSTR szCommandLine,LPCWSTR wszShimName,PDWORD pdwHookCount);
 BOOL WINAPI ShimLib_NotifyShims(DWORD fdwReason, PVOID ptr);