Author: spetreolle
Date: Mon Jan  9 22:47:16 2012
New Revision: 54893

URL: http://svn.reactos.org/svn/reactos?rev=54893&view=rev
Log:
[SVCHOST]
Convert to Unicode.
Fix buffer overruns and bad maths when UNICODE is defined.

Patch by Samuel Serapion.

Modified:
    trunk/reactos/base/services/svchost/CMakeLists.txt
    trunk/reactos/base/services/svchost/svchost.c
    trunk/reactos/base/services/svchost/svchost.rbuild

Modified: trunk/reactos/base/services/svchost/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/svchost/CMakeLists.txt?rev=54893&r1=54892&r2=54893&view=diff
==============================================================================
--- trunk/reactos/base/services/svchost/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/services/svchost/CMakeLists.txt [iso-8859-1] Mon Jan  9 
22:47:16 2012
@@ -1,6 +1,6 @@
 
 add_executable(svchost svchost.c svchost.rc)
 
-set_module_type(svchost win32cui)
+set_module_type(svchost win32cui UNICODE)
 add_importlibs(svchost advapi32 msvcrt kernel32 ntdll)
 add_cd_file(TARGET svchost DESTINATION reactos/system32 FOR all)

Modified: trunk/reactos/base/services/svchost/svchost.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/svchost/svchost.c?rev=54893&r1=54892&r2=54893&view=diff
==============================================================================
--- trunk/reactos/base/services/svchost/svchost.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/svchost/svchost.c [iso-8859-1] Mon Jan  9 
22:47:16 2012
@@ -93,7 +93,7 @@
        }
 
        /* Convert possible %SystemRoot% to a real path */
-       BufferSize = ExpandEnvironmentStrings(Buffer, DllPath, sizeof(DllPath));
+       BufferSize = ExpandEnvironmentStrings(Buffer, DllPath, 
_countof(DllPath));
        if (0 == BufferSize)
        {
                DPRINT1("Invalid ServiceDll path: %s\n", Buffer);
@@ -124,7 +124,7 @@
        }
 
        memset(Service, 0, sizeof(SERVICE));
-       Service->Name = HeapAlloc(GetProcessHeap(), 0, _tcslen(ServiceName) + 
sizeof(TCHAR));
+       Service->Name = HeapAlloc(GetProcessHeap(), 0, (_tcslen(ServiceName)+1) 
* sizeof(TCHAR));
        if (NULL == Service->Name)
        {
                DPRINT1("Not enough memory for service: %s\n", ServiceName);
@@ -199,7 +199,7 @@
                if (TRUE == PrepareService(ServiceName))
                        ++NrOfServices;
 
-               BufferIndex += (Length + 1) * sizeof(TCHAR);
+               BufferIndex += Length + 1;
 
                ServiceName = &Buffer[BufferIndex];
        }
@@ -238,7 +238,7 @@
                PSERVICE Service = FirstService;
 
                /* Fill the service table */
-               for (i = 0; i < NrOfServices; ++i)
+               for (i = 0; i < NrOfServices; i++)
                {
                        DPRINT("Loading service: %s\n", Service->Name);
                        ServiceTable[i].lpServiceName = Service->Name;
@@ -251,7 +251,7 @@
                ServiceTable[i].lpServiceProc = NULL;
 
                if (FALSE == StartServiceCtrlDispatcher(ServiceTable))
-                       printf("Failed to start service control dispatcher, 
ErrorCode: %lu\n", GetLastError());
+                       DPRINT1("Failed to start service control dispatcher, 
ErrorCode: %lu\n", GetLastError());
 
                HeapFree(GetProcessHeap(), 0, ServiceTable);
        }
@@ -260,7 +260,7 @@
                DPRINT1("Not enough memory for the service table, trying to 
allocate %u bytes\n", sizeof(SERVICE_TABLE_ENTRY) * (NrOfServices + 1));
        }
 
-       DPRINT1("Freeing services...\n");
+       DPRINT("Freeing services...\n");
        FreeServices();
 
     return 0;

Modified: trunk/reactos/base/services/svchost/svchost.rbuild
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/svchost/svchost.rbuild?rev=54893&r1=54892&r2=54893&view=diff
==============================================================================
--- trunk/reactos/base/services/svchost/svchost.rbuild [iso-8859-1] (original)
+++ trunk/reactos/base/services/svchost/svchost.rbuild [iso-8859-1] Mon Jan  9 
22:47:16 2012
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="svchost" type="win32cui" installbase="system32" 
installname="svchost.exe">
+<module name="svchost" type="win32cui" installbase="system32" 
installname="svchost.exe" unicode="yes">
        <include base="svchost">.</include>
        <library>advapi32</library>
        <file>svchost.c</file>


Reply via email to