mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +00:00
[SVCHOST]
Convert to Unicode. Fix buffer overruns and bad maths when UNICODE is defined. Patch by Samuel Serapion. svn path=/trunk/; revision=54893
This commit is contained in:
parent
cc92aa149f
commit
d788826576
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
add_executable(svchost svchost.c svchost.rc)
|
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_importlibs(svchost advapi32 msvcrt kernel32 ntdll)
|
||||||
add_cd_file(TARGET svchost DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET svchost DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -93,7 +93,7 @@ BOOL PrepareService(LPCTSTR ServiceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert possible %SystemRoot% to a real path */
|
/* Convert possible %SystemRoot% to a real path */
|
||||||
BufferSize = ExpandEnvironmentStrings(Buffer, DllPath, sizeof(DllPath));
|
BufferSize = ExpandEnvironmentStrings(Buffer, DllPath, _countof(DllPath));
|
||||||
if (0 == BufferSize)
|
if (0 == BufferSize)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid ServiceDll path: %s\n", Buffer);
|
DPRINT1("Invalid ServiceDll path: %s\n", Buffer);
|
||||||
|
@ -124,7 +124,7 @@ BOOL PrepareService(LPCTSTR ServiceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(Service, 0, sizeof(SERVICE));
|
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)
|
if (NULL == Service->Name)
|
||||||
{
|
{
|
||||||
DPRINT1("Not enough memory for service: %s\n", ServiceName);
|
DPRINT1("Not enough memory for service: %s\n", ServiceName);
|
||||||
|
@ -199,7 +199,7 @@ DWORD LoadServiceCategory(LPCTSTR ServiceCategory)
|
||||||
if (TRUE == PrepareService(ServiceName))
|
if (TRUE == PrepareService(ServiceName))
|
||||||
++NrOfServices;
|
++NrOfServices;
|
||||||
|
|
||||||
BufferIndex += (Length + 1) * sizeof(TCHAR);
|
BufferIndex += Length + 1;
|
||||||
|
|
||||||
ServiceName = &Buffer[BufferIndex];
|
ServiceName = &Buffer[BufferIndex];
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ int _tmain (int argc, LPTSTR argv [])
|
||||||
PSERVICE Service = FirstService;
|
PSERVICE Service = FirstService;
|
||||||
|
|
||||||
/* Fill the service table */
|
/* Fill the service table */
|
||||||
for (i = 0; i < NrOfServices; ++i)
|
for (i = 0; i < NrOfServices; i++)
|
||||||
{
|
{
|
||||||
DPRINT("Loading service: %s\n", Service->Name);
|
DPRINT("Loading service: %s\n", Service->Name);
|
||||||
ServiceTable[i].lpServiceName = Service->Name;
|
ServiceTable[i].lpServiceName = Service->Name;
|
||||||
|
@ -251,7 +251,7 @@ int _tmain (int argc, LPTSTR argv [])
|
||||||
ServiceTable[i].lpServiceProc = NULL;
|
ServiceTable[i].lpServiceProc = NULL;
|
||||||
|
|
||||||
if (FALSE == StartServiceCtrlDispatcher(ServiceTable))
|
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);
|
HeapFree(GetProcessHeap(), 0, ServiceTable);
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ int _tmain (int argc, LPTSTR argv [])
|
||||||
DPRINT1("Not enough memory for the service table, trying to allocate %u bytes\n", sizeof(SERVICE_TABLE_ENTRY) * (NrOfServices + 1));
|
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();
|
FreeServices();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
<!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>
|
<include base="svchost">.</include>
|
||||||
<library>advapi32</library>
|
<library>advapi32</library>
|
||||||
<file>svchost.c</file>
|
<file>svchost.c</file>
|
||||||
|
|
Loading…
Reference in a new issue