[SETUPLIB][USETUP] Use NT RTL String Safe functions instead of Win32-oriented ones...
[reactos.git] / base / setup / lib / setuplib.c
index c5a8a6f..38d5b58 100644 (file)
@@ -16,9 +16,6 @@
 
 #include "setuplib.h"
 
-// HACK!
-#include <strsafe.h>
-
 #define NDEBUG
 #include <debug.h>
 
@@ -147,7 +144,11 @@ CheckUnattendedSetup(
             DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
             goto Quit;
         }
-        wcscpy(pSetupData->InstallationDirectory, Value);
+
+        RtlStringCchCopyW(pSetupData->InstallationDirectory,
+                          ARRAYSIZE(pSetupData->InstallationDirectory),
+                          Value);
+
         INF_FreeData(Value);
     }
 
@@ -189,7 +190,9 @@ CheckUnattendedSetup(
         if (INF_GetData(&Context, NULL, &Value))
         {
             LONG Id = wcstol(Value, NULL, 16);
-            swprintf(pSetupData->LocaleID, L"%08lx", Id);
+            RtlStringCchPrintfW(pSetupData->LocaleID,
+                                ARRAYSIZE(pSetupData->LocaleID),
+                                L"%08lx", Id);
             INF_FreeData(Value);
        }
     }
@@ -233,8 +236,8 @@ InstallSetupInfFile(
     if (IniSection)
     {
         /* Key "skipmissingfiles" */
-        // StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-                         // L"\"%s\"", L"WinNt5.2");
+        // RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                            // L"\"%s\"", L"WinNt5.2");
         // IniCacheInsertKey(IniSection, NULL, INSERT_LAST,
                           // L"Version", PathBuffer);
     }
@@ -242,20 +245,20 @@ InstallSetupInfFile(
     IniSection = IniCacheAppendSection(IniCache, L"Data");
     if (IniSection)
     {
-        StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-                         L"\"%s\"", IsUnattendedSetup ? L"yes" : L"no");
+        RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                            L"\"%s\"", IsUnattendedSetup ? L"yes" : L"no");
         IniCacheInsertKey(IniSection, NULL, INSERT_LAST,
                           L"UnattendedInstall", PathBuffer);
 
         // "floppylessbootpath" (yes/no)
 
-        StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-                         L"\"%s\"", L"winnt");
+        RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                            L"\"%s\"", L"winnt");
         IniCacheInsertKey(IniSection, NULL, INSERT_LAST,
                           L"ProductType", PathBuffer);
 
-        StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-                         L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
+        RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                            L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
         IniCacheInsertKey(IniSection, NULL, INSERT_LAST,
                           L"SourcePath", PathBuffer);
 
@@ -561,7 +564,10 @@ LoadSetupInf(
         if (!INF_GetData(&Context, NULL, &Value))
             return ERROR_CORRUPT_TXTSETUPSIF;
 
-        wcscpy(pSetupData->InstallationDirectory, Value);
+        RtlStringCchCopyW(pSetupData->InstallationDirectory,
+                          ARRAYSIZE(pSetupData->InstallationDirectory),
+                          Value);
+
         INF_FreeData(Value);
     }