[APPHELP] Various cleanup tasks
[reactos.git] / reactos / dll / appcompat / apphelp / layer.c
index 5ae7405..d4d69e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Mark Jansen
+ * Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -159,7 +159,7 @@ BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
             FindClose(FindHandle);
             SdbpResizeTempStr(LongPath, (LongPath->Str.Length >> 1) + 20);
             StringCbPrintfW(LongPath->Str.Buffer, LongPath->Str.MaximumLength, SIGN_MEDIA_FMT, SignMedia, Scratch.Str.Buffer + 3);
-            LongPath->Str.Length = (USHORT)wcslen(LongPath->Str.Buffer) * sizeof(WCHAR);
+            LongPath->Str.Length = (USHORT)SdbpStrlen(LongPath->Str.Buffer) * sizeof(WCHAR);
             SdbpFreeTempStr(&Scratch);
             return TRUE;
         }
@@ -217,7 +217,7 @@ NTSTATUS SdbpOpenKey(PUNICODE_STRING FullPath, BOOL bMachine, ACCESS_MASK Access
             return Status;
         }
     }
-    FullPath->MaximumLength = (USHORT)(BasePath.Length + (wcslen(LayersKey) + 1) * sizeof(WCHAR));
+    FullPath->MaximumLength = (USHORT)(BasePath.Length + SdbpStrsize(LayersKey));
     FullPath->Buffer = SdbAlloc(FullPath->MaximumLength);
     FullPath->Length = 0;
     RtlAppendUnicodeStringToString(FullPath, &BasePath);
@@ -447,7 +447,7 @@ BOOL WINAPI SdbSetPermLayerKeys(PCWSTR wszPath, PCWSTR wszLayers, BOOL bMachine)
     Status = SdbpOpenKey(&FullKey, bMachine, KEY_SET_VALUE, &KeyHandle);
     if (NT_SUCCESS(Status))
     {
-        Status = NtSetValueKey(KeyHandle, &LongPath.Str, 0, REG_SZ, (PVOID)wszLayers, (wcslen(wszLayers)+1) * sizeof(WCHAR));
+        Status = NtSetValueKey(KeyHandle, &LongPath.Str, 0, REG_SZ, (PVOID)wszLayers, SdbpStrsize(wszLayers));
         if (!NT_SUCCESS(Status))
         {
             SHIM_INFO("Failed to write a value to Key \"%wZ\" Status 0x%lx\n", &FullKey, Status);