Commit fdc3e506 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

sechost: Use CRT allocation functions.

parent faae2162
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "iads.h" #include "iads.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(security); WINE_DEFAULT_DEBUG_CHANNEL(security);
...@@ -1080,7 +1079,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO ...@@ -1080,7 +1079,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO
*size = sizeof(SECURITY_DESCRIPTOR_RELATIVE); *size = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
tok = heap_alloc( (wcslen(string) + 1) * sizeof(WCHAR) ); tok = malloc( (wcslen(string) + 1) * sizeof(WCHAR) );
if (!tok) if (!tok)
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
...@@ -1208,7 +1207,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO ...@@ -1208,7 +1207,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO
ret = TRUE; ret = TRUE;
out: out:
heap_free(tok); free(tok);
return ret; return ret;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
#include "svcctl.h" #include "svcctl.h"
...@@ -90,18 +89,18 @@ static unsigned int nb_services; ...@@ -90,18 +89,18 @@ static unsigned int nb_services;
static HANDLE service_event; static HANDLE service_event;
static BOOL stop_service; static BOOL stop_service;
static WCHAR *heap_strdupAtoW( const char *src ) static WCHAR *strdupAtoW( const char *src )
{ {
WCHAR *dst = NULL; WCHAR *dst = NULL;
if (src) if (src)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
if ((dst = heap_alloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len ); if ((dst = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
} }
return dst; return dst;
} }
static WCHAR *heap_strdup_multi_AtoW( const char *src ) static WCHAR *strdup_multi_AtoW( const char *src )
{ {
WCHAR *dst = NULL; WCHAR *dst = NULL;
const char *p = src; const char *p = src;
...@@ -113,7 +112,7 @@ static WCHAR *heap_strdup_multi_AtoW( const char *src ) ...@@ -113,7 +112,7 @@ static WCHAR *heap_strdup_multi_AtoW( const char *src )
for (p = src; *p; p += strlen(p) + 1); for (p = src; *p; p += strlen(p) + 1);
p++; /* final null */ p++; /* final null */
len = MultiByteToWideChar( CP_ACP, 0, src, p - src, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, src, p - src, NULL, 0 );
if ((dst = heap_alloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, p - src, dst, len ); if ((dst = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, p - src, dst, len );
return dst; return dst;
} }
...@@ -129,12 +128,12 @@ static inline DWORD multisz_size( const WCHAR *str ) ...@@ -129,12 +128,12 @@ static inline DWORD multisz_size( const WCHAR *str )
void __RPC_FAR * __RPC_USER MIDL_user_allocate( SIZE_T len ) void __RPC_FAR * __RPC_USER MIDL_user_allocate( SIZE_T len )
{ {
return heap_alloc(len); return malloc(len);
} }
void __RPC_USER MIDL_user_free( void __RPC_FAR *ptr ) void __RPC_USER MIDL_user_free( void __RPC_FAR *ptr )
{ {
heap_free(ptr); free(ptr);
} }
static LONG WINAPI rpc_filter( EXCEPTION_POINTERS *eptr ) static LONG WINAPI rpc_filter( EXCEPTION_POINTERS *eptr )
...@@ -257,11 +256,11 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH OpenSCManagerA( const char *machine, const ch ...@@ -257,11 +256,11 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH OpenSCManagerA( const char *machine, const ch
WCHAR *machineW, *databaseW; WCHAR *machineW, *databaseW;
SC_HANDLE ret; SC_HANDLE ret;
machineW = heap_strdupAtoW( machine ); machineW = strdupAtoW( machine );
databaseW = heap_strdupAtoW( database ); databaseW = strdupAtoW( database );
ret = OpenSCManagerW( machineW, databaseW, access ); ret = OpenSCManagerW( machineW, databaseW, access );
heap_free( databaseW ); free( databaseW );
heap_free( machineW ); free( machineW );
return ret; return ret;
} }
...@@ -300,9 +299,9 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH OpenServiceA( SC_HANDLE manager, const char * ...@@ -300,9 +299,9 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH OpenServiceA( SC_HANDLE manager, const char *
TRACE( "%p %s %#lx\n", manager, debugstr_a(name), access ); TRACE( "%p %s %#lx\n", manager, debugstr_a(name), access );
nameW = heap_strdupAtoW( name ); nameW = strdupAtoW( name );
ret = OpenServiceW( manager, nameW, access ); ret = OpenServiceW( manager, nameW, access );
heap_free( nameW ); free( nameW );
return ret; return ret;
} }
...@@ -351,24 +350,24 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH CreateServiceA( SC_HANDLE manager, const char ...@@ -351,24 +350,24 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH CreateServiceA( SC_HANDLE manager, const char
TRACE( "%p %s %s\n", manager, debugstr_a(name), debugstr_a(display_name) ); TRACE( "%p %s %s\n", manager, debugstr_a(name), debugstr_a(display_name) );
nameW = heap_strdupAtoW( name ); nameW = strdupAtoW( name );
display_nameW = heap_strdupAtoW( display_name ); display_nameW = strdupAtoW( display_name );
pathW = heap_strdupAtoW( path ); pathW = strdupAtoW( path );
groupW = heap_strdupAtoW( group ); groupW = strdupAtoW( group );
dependenciesW = heap_strdup_multi_AtoW( dependencies ); dependenciesW = strdup_multi_AtoW( dependencies );
usernameW = heap_strdupAtoW( username ); usernameW = strdupAtoW( username );
passwordW = heap_strdupAtoW( password ); passwordW = strdupAtoW( password );
handle = CreateServiceW( manager, nameW, display_nameW, access, service_type, start_type, error_control, handle = CreateServiceW( manager, nameW, display_nameW, access, service_type, start_type, error_control,
pathW, groupW, tag, dependenciesW, usernameW, passwordW ); pathW, groupW, tag, dependenciesW, usernameW, passwordW );
heap_free( nameW ); free( nameW );
heap_free( display_nameW ); free( display_nameW );
heap_free( pathW ); free( pathW );
heap_free( groupW ); free( groupW );
heap_free( dependenciesW ); free( dependenciesW );
heap_free( usernameW ); free( usernameW );
heap_free( passwordW ); free( passwordW );
return handle; return handle;
} }
...@@ -480,11 +479,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le ...@@ -480,11 +479,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le
SERVICE_DESCRIPTIONA *sd = info; SERVICE_DESCRIPTIONA *sd = info;
SERVICE_DESCRIPTIONW sdw; SERVICE_DESCRIPTIONW sdw;
sdw.lpDescription = heap_strdupAtoW( sd->lpDescription ); sdw.lpDescription = strdupAtoW( sd->lpDescription );
r = ChangeServiceConfig2W( service, level, &sdw ); r = ChangeServiceConfig2W( service, level, &sdw );
heap_free( sdw.lpDescription ); free( sdw.lpDescription );
} }
else if (level == SERVICE_CONFIG_FAILURE_ACTIONS) else if (level == SERVICE_CONFIG_FAILURE_ACTIONS)
{ {
...@@ -492,15 +491,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le ...@@ -492,15 +491,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le
SERVICE_FAILURE_ACTIONSW faw; SERVICE_FAILURE_ACTIONSW faw;
faw.dwResetPeriod = fa->dwResetPeriod; faw.dwResetPeriod = fa->dwResetPeriod;
faw.lpRebootMsg = heap_strdupAtoW( fa->lpRebootMsg ); faw.lpRebootMsg = strdupAtoW( fa->lpRebootMsg );
faw.lpCommand = heap_strdupAtoW( fa->lpCommand ); faw.lpCommand = strdupAtoW( fa->lpCommand );
faw.cActions = fa->cActions; faw.cActions = fa->cActions;
faw.lpsaActions = fa->lpsaActions; faw.lpsaActions = fa->lpsaActions;
r = ChangeServiceConfig2W( service, level, &faw ); r = ChangeServiceConfig2W( service, level, &faw );
heap_free( faw.lpRebootMsg ); free( faw.lpRebootMsg );
heap_free( faw.lpCommand ); free( faw.lpCommand );
} }
else if (level == SERVICE_CONFIG_PRESHUTDOWN_INFO) else if (level == SERVICE_CONFIG_PRESHUTDOWN_INFO)
{ {
...@@ -561,22 +560,22 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfigA( SC_HANDLE service, DWORD ser ...@@ -561,22 +560,22 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfigA( SC_HANDLE service, DWORD ser
error_control, debugstr_a(path), debugstr_a(group), tag, dependencies, error_control, debugstr_a(path), debugstr_a(group), tag, dependencies,
debugstr_a(username), debugstr_a(password), debugstr_a(display_name) ); debugstr_a(username), debugstr_a(password), debugstr_a(display_name) );
pathW = heap_strdupAtoW( path ); pathW = strdupAtoW( path );
groupW = heap_strdupAtoW( group ); groupW = strdupAtoW( group );
dependenciesW = heap_strdup_multi_AtoW( dependencies ); dependenciesW = strdup_multi_AtoW( dependencies );
usernameW = heap_strdupAtoW( username ); usernameW = strdupAtoW( username );
passwordW = heap_strdupAtoW( password ); passwordW = strdupAtoW( password );
display_nameW = heap_strdupAtoW( display_name ); display_nameW = strdupAtoW( display_name );
r = ChangeServiceConfigW( service, service_type, start_type, error_control, pathW, r = ChangeServiceConfigW( service, service_type, start_type, error_control, pathW,
groupW, tag, dependenciesW, usernameW, passwordW, display_nameW ); groupW, tag, dependenciesW, usernameW, passwordW, display_nameW );
heap_free( pathW ); free( pathW );
heap_free( groupW ); free( groupW );
heap_free( dependenciesW ); free( dependenciesW );
heap_free( usernameW ); free( usernameW );
heap_free( passwordW ); free( passwordW );
heap_free( display_nameW ); free( display_nameW );
return r; return r;
} }
...@@ -626,7 +625,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfigA( SC_HANDLE service, QUERY_SERV ...@@ -626,7 +625,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfigA( SC_HANDLE service, QUERY_SERV
TRACE( "%p %p %ld %p\n", service, config, size, ret_size ); TRACE( "%p %p %ld %p\n", service, config, size, ret_size );
if (!(buffer = heap_alloc( 2 * size ))) return set_error( ERROR_NOT_ENOUGH_MEMORY ); if (!(buffer = malloc( 2 * size ))) return set_error( ERROR_NOT_ENOUGH_MEMORY );
configW = (QUERY_SERVICE_CONFIGW *)buffer; configW = (QUERY_SERVICE_CONFIGW *)buffer;
ret = QueryServiceConfigW( service, configW, 2 * size, ret_size ); ret = QueryServiceConfigW( service, configW, 2 * size, ret_size );
if (!ret) goto done; if (!ret) goto done;
...@@ -668,7 +667,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfigA( SC_HANDLE service, QUERY_SERV ...@@ -668,7 +667,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfigA( SC_HANDLE service, QUERY_SERV
ret = TRUE; ret = TRUE;
done: done:
heap_free( buffer ); free( buffer );
return ret; return ret;
} }
...@@ -776,11 +775,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2A( SC_HANDLE service, DWORD lev ...@@ -776,11 +775,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2A( SC_HANDLE service, DWORD lev
TRACE( "%p %lu %p %lu %p\n", service, level, buffer, size, ret_size ); TRACE( "%p %lu %p %lu %p\n", service, level, buffer, size, ret_size );
if (buffer && size) if (buffer && size)
bufferW = heap_alloc( size ); bufferW = malloc( size );
if (!QueryServiceConfig2W( service, level, bufferW, size, ret_size )) if (!QueryServiceConfig2W( service, level, bufferW, size, ret_size ))
{ {
heap_free( bufferW ); free( bufferW );
return FALSE; return FALSE;
} }
...@@ -805,11 +804,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2A( SC_HANDLE service, DWORD lev ...@@ -805,11 +804,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2A( SC_HANDLE service, DWORD lev
break; break;
default: default:
FIXME("conversion W->A not implemented for level %ld\n", level); FIXME("conversion W->A not implemented for level %ld\n", level);
heap_free( bufferW ); free( bufferW );
return FALSE; return FALSE;
} }
heap_free( bufferW ); free( bufferW );
return TRUE; return TRUE;
} }
...@@ -833,7 +832,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev ...@@ -833,7 +832,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
switch (level) switch (level)
{ {
case SERVICE_CONFIG_DESCRIPTION: case SERVICE_CONFIG_DESCRIPTION:
if (!(bufptr = heap_alloc( size ))) if (!(bufptr = malloc( size )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
...@@ -852,7 +851,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev ...@@ -852,7 +851,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
if (!ret_size) if (!ret_size)
{ {
if (level == SERVICE_CONFIG_DESCRIPTION) heap_free( bufptr ); if (level == SERVICE_CONFIG_DESCRIPTION) free( bufptr );
SetLastError(ERROR_INVALID_ADDRESS); SetLastError(ERROR_INVALID_ADDRESS);
return FALSE; return FALSE;
} }
...@@ -876,7 +875,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev ...@@ -876,7 +875,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
if (err != ERROR_SUCCESS && err != ERROR_INSUFFICIENT_BUFFER) if (err != ERROR_SUCCESS && err != ERROR_INSUFFICIENT_BUFFER)
{ {
heap_free( bufptr ); free( bufptr );
SetLastError( err ); SetLastError( err );
return FALSE; return FALSE;
} }
...@@ -889,7 +888,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev ...@@ -889,7 +888,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
if (size < *ret_size) if (size < *ret_size)
{ {
heap_free( bufptr ); free( bufptr );
SetLastError( ERROR_INSUFFICIENT_BUFFER ); SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE; return FALSE;
} }
...@@ -902,7 +901,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev ...@@ -902,7 +901,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
memcpy( desc->lpDescription, s->description, s->size ); memcpy( desc->lpDescription, s->description, s->size );
} }
} }
heap_free( bufptr ); free( bufptr );
break; break;
} }
case SERVICE_CONFIG_PRESHUTDOWN_INFO: case SERVICE_CONFIG_PRESHUTDOWN_INFO:
...@@ -1020,16 +1019,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceA( SC_HANDLE service, DWORD argc, cons ...@@ -1020,16 +1019,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceA( SC_HANDLE service, DWORD argc, cons
BOOL r; BOOL r;
if (argc) if (argc)
argvW = heap_alloc( argc * sizeof(*argvW) ); argvW = malloc( argc * sizeof(*argvW) );
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
argvW[i] = heap_strdupAtoW( argv[i] ); argvW[i] = strdupAtoW( argv[i] );
r = StartServiceW( service, argc, (const WCHAR **)argvW ); r = StartServiceW( service, argc, (const WCHAR **)argvW );
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
heap_free( argvW[i] ); free( argvW[i] );
heap_free( argvW ); free( argvW );
return r; return r;
} }
...@@ -1151,7 +1150,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_ ...@@ -1151,7 +1150,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
/* make sure we pass a valid pointer */ /* make sure we pass a valid pointer */
buflen = max( size, sizeof(*services) ); buflen = max( size, sizeof(*services) );
if (!(buf = heap_alloc( buflen ))) return set_error( ERROR_NOT_ENOUGH_MEMORY ); if (!(buf = malloc( buflen ))) return set_error( ERROR_NOT_ENOUGH_MEMORY );
__TRY __TRY
{ {
...@@ -1169,7 +1168,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_ ...@@ -1169,7 +1168,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
{ {
/* double the needed size to fit the potentially larger ENUM_SERVICE_STATUS_PROCESSW */ /* double the needed size to fit the potentially larger ENUM_SERVICE_STATUS_PROCESSW */
if (err == ERROR_MORE_DATA) *needed *= 2; if (err == ERROR_MORE_DATA) *needed *= 2;
heap_free( buf ); free( buf );
SetLastError( err ); SetLastError( err );
return FALSE; return FALSE;
} }
...@@ -1193,7 +1192,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_ ...@@ -1193,7 +1192,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
if (total_size > size) if (total_size > size)
{ {
heap_free( buf ); free( buf );
*needed = total_size; *needed = total_size;
SetLastError( ERROR_MORE_DATA ); SetLastError( ERROR_MORE_DATA );
return FALSE; return FALSE;
...@@ -1223,7 +1222,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_ ...@@ -1223,7 +1222,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
entry++; entry++;
} }
heap_free( buf ); free( buf );
*needed = 0; *needed = 0;
*returned = count; *returned = count;
return TRUE; return TRUE;
...@@ -1358,7 +1357,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW ...@@ -1358,7 +1357,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
TRACE( "%p 0x%lx %p\n", service, mask, notify_buffer ); TRACE( "%p 0x%lx %p\n", service, mask, notify_buffer );
if (!(data = heap_alloc_zero( sizeof(*data) ))) if (!(data = calloc( 1, sizeof(*data) )))
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
data->service = service; data->service = service;
...@@ -1367,7 +1366,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW ...@@ -1367,7 +1366,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
&data->calling_thread, 0, FALSE, DUPLICATE_SAME_ACCESS )) &data->calling_thread, 0, FALSE, DUPLICATE_SAME_ACCESS ))
{ {
ERR("DuplicateHandle failed: %lu\n", GetLastError()); ERR("DuplicateHandle failed: %lu\n", GetLastError());
heap_free( data ); free( data );
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
} }
...@@ -1395,7 +1394,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW ...@@ -1395,7 +1394,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
LeaveCriticalSection( &service_cs ); LeaveCriticalSection( &service_cs );
CloseHandle( data->calling_thread ); CloseHandle( data->calling_thread );
CloseHandle( data->ready_evt ); CloseHandle( data->ready_evt );
heap_free( data ); free( data );
return err; return err;
} }
...@@ -1444,9 +1443,9 @@ SERVICE_STATUS_HANDLE WINAPI DECLSPEC_HOTPATCH RegisterServiceCtrlHandlerExA( ...@@ -1444,9 +1443,9 @@ SERVICE_STATUS_HANDLE WINAPI DECLSPEC_HOTPATCH RegisterServiceCtrlHandlerExA(
WCHAR *nameW; WCHAR *nameW;
SERVICE_STATUS_HANDLE ret; SERVICE_STATUS_HANDLE ret;
nameW = heap_strdupAtoW( name ); nameW = strdupAtoW( name );
ret = RegisterServiceCtrlHandlerExW( nameW, handler, context ); ret = RegisterServiceCtrlHandlerExW( nameW, handler, context );
heap_free( nameW ); free( nameW );
return ret; return ret;
} }
...@@ -1553,7 +1552,7 @@ static WCHAR *service_get_pipe_name(void) ...@@ -1553,7 +1552,7 @@ static WCHAR *service_get_pipe_name(void)
return NULL; return NULL;
len = ARRAY_SIZE(format) + 10 /* strlenW("4294967295") */; len = ARRAY_SIZE(format) + 10 /* strlenW("4294967295") */;
name = heap_alloc(len * sizeof(WCHAR)); name = malloc(len * sizeof(WCHAR));
if (!name) if (!name)
return NULL; return NULL;
...@@ -1575,7 +1574,7 @@ static HANDLE service_open_pipe(void) ...@@ -1575,7 +1574,7 @@ static HANDLE service_open_pipe(void)
if (GetLastError() != ERROR_PIPE_BUSY) if (GetLastError() != ERROR_PIPE_BUSY)
break; break;
} while (WaitNamedPipeW( pipe_name, NMPWAIT_USE_DEFAULT_WAIT )); } while (WaitNamedPipeW( pipe_name, NMPWAIT_USE_DEFAULT_WAIT ));
heap_free(pipe_name); free(pipe_name);
return handle; return handle;
} }
...@@ -1600,13 +1599,13 @@ static DWORD WINAPI service_thread( void *arg ) ...@@ -1600,13 +1599,13 @@ static DWORD WINAPI service_thread( void *arg )
{ {
WCHAR **argv, *p; WCHAR **argv, *p;
argv = heap_alloc( (argc+1)*sizeof(*argv) ); argv = malloc( (argc + 1) * sizeof(*argv) );
for (argc = 0, p = str; *p; p += wcslen( p ) + 1) for (argc = 0, p = str; *p; p += wcslen( p ) + 1)
argv[argc++] = p; argv[argc++] = p;
argv[argc] = NULL; argv[argc] = NULL;
info->proc.w( argc, argv ); info->proc.w( argc, argv );
heap_free( argv ); free( argv );
} }
else else
{ {
...@@ -1614,17 +1613,17 @@ static DWORD WINAPI service_thread( void *arg ) ...@@ -1614,17 +1613,17 @@ static DWORD WINAPI service_thread( void *arg )
DWORD lenA; DWORD lenA;
lenA = WideCharToMultiByte( CP_ACP,0, str, len, NULL, 0, NULL, NULL ); lenA = WideCharToMultiByte( CP_ACP,0, str, len, NULL, 0, NULL, NULL );
strA = heap_alloc(lenA); strA = malloc(lenA);
WideCharToMultiByte(CP_ACP,0, str, len, strA, lenA, NULL, NULL); WideCharToMultiByte(CP_ACP,0, str, len, strA, lenA, NULL, NULL);
argv = heap_alloc( (argc+1)*sizeof(*argv) ); argv = malloc( (argc + 1) * sizeof(*argv) );
for (argc = 0, p = strA; *p; p += strlen( p ) + 1) for (argc = 0, p = strA; *p; p += strlen( p ) + 1)
argv[argc++] = p; argv[argc++] = p;
argv[argc] = NULL; argv[argc] = NULL;
info->proc.a( argc, argv ); info->proc.a( argc, argv );
heap_free( argv ); free( argv );
heap_free( strA ); free( strA );
} }
return 0; return 0;
} }
...@@ -1639,8 +1638,8 @@ static DWORD service_handle_start( struct service_data *service, const void *dat ...@@ -1639,8 +1638,8 @@ static DWORD service_handle_start( struct service_data *service, const void *dat
return ERROR_SERVICE_ALREADY_RUNNING; return ERROR_SERVICE_ALREADY_RUNNING;
} }
heap_free( service->args ); free( service->args );
service->args = heap_alloc( (count + 2) * sizeof(WCHAR) ); service->args = malloc( (count + 2) * sizeof(WCHAR) );
if (count) memcpy( service->args, data, count * sizeof(WCHAR) ); if (count) memcpy( service->args, data, count * sizeof(WCHAR) );
service->args[count++] = 0; service->args[count++] = 0;
service->args[count++] = 0; service->args[count++] = 0;
...@@ -1693,19 +1692,19 @@ static DWORD WINAPI service_control_dispatcher( void *arg ) ...@@ -1693,19 +1692,19 @@ static DWORD WINAPI service_control_dispatcher( void *arg )
if (count < info.total_size) if (count < info.total_size)
{ {
data_size = info.total_size - FIELD_OFFSET(service_start_info,data); data_size = info.total_size - FIELD_OFFSET(service_start_info,data);
data = heap_alloc( data_size ); data = malloc( data_size );
r = ReadFile( disp->pipe, data, data_size, &count, NULL ); r = ReadFile( disp->pipe, data, data_size, &count, NULL );
if (!r) if (!r)
{ {
if (GetLastError() != ERROR_BROKEN_PIPE) if (GetLastError() != ERROR_BROKEN_PIPE)
ERR( "pipe read failed error %lu\n", GetLastError() ); ERR( "pipe read failed error %lu\n", GetLastError() );
heap_free( data ); free( data );
break; break;
} }
if (count != data_size) if (count != data_size)
{ {
ERR( "partial pipe read %lu/%lu\n", count, data_size ); ERR( "partial pipe read %lu/%lu\n", count, data_size );
heap_free( data ); free( data );
break; break;
} }
} }
...@@ -1751,12 +1750,12 @@ static DWORD WINAPI service_control_dispatcher( void *arg ) ...@@ -1751,12 +1750,12 @@ static DWORD WINAPI service_control_dispatcher( void *arg )
done: done:
LeaveCriticalSection( &service_cs ); LeaveCriticalSection( &service_cs );
WriteFile( disp->pipe, &result, sizeof(result), &count, NULL ); WriteFile( disp->pipe, &result, sizeof(result), &count, NULL );
heap_free( data ); free( data );
} }
CloseHandle( disp->pipe ); CloseHandle( disp->pipe );
CloseServiceHandle( disp->manager ); CloseServiceHandle( disp->manager );
heap_free( disp ); free( disp );
return 1; return 1;
} }
...@@ -1768,7 +1767,7 @@ static void handle_shutdown_msg(DWORD msg, DWORD accept) ...@@ -1768,7 +1767,7 @@ static void handle_shutdown_msg(DWORD msg, DWORD accept)
DWORD i, n = 0, sz, timeout = 2000; DWORD i, n = 0, sz, timeout = 2000;
ULONGLONG stop_time; ULONGLONG stop_time;
BOOL res, done = TRUE; BOOL res, done = TRUE;
SC_HANDLE *wait_handles = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SC_HANDLE) * nb_services ); SC_HANDLE *wait_handles = calloc( nb_services, sizeof(SC_HANDLE) );
EnterCriticalSection( &service_cs ); EnterCriticalSection( &service_cs );
for (i = 0; i < nb_services; i++) for (i = 0; i < nb_services; i++)
...@@ -1814,7 +1813,7 @@ static void handle_shutdown_msg(DWORD msg, DWORD accept) ...@@ -1814,7 +1813,7 @@ static void handle_shutdown_msg(DWORD msg, DWORD accept)
} }
} }
HeapFree( GetProcessHeap(), 0, wait_handles ); free( wait_handles );
} }
static BOOL service_run_main_thread(void) static BOOL service_run_main_thread(void)
...@@ -1822,13 +1821,13 @@ static BOOL service_run_main_thread(void) ...@@ -1822,13 +1821,13 @@ static BOOL service_run_main_thread(void)
DWORD i, n, ret; DWORD i, n, ret;
HANDLE wait_handles[MAXIMUM_WAIT_OBJECTS]; HANDLE wait_handles[MAXIMUM_WAIT_OBJECTS];
UINT wait_services[MAXIMUM_WAIT_OBJECTS]; UINT wait_services[MAXIMUM_WAIT_OBJECTS];
struct dispatcher_data *disp = heap_alloc( sizeof(*disp) ); struct dispatcher_data *disp = malloc( sizeof(*disp) );
disp->manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT ); disp->manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT );
if (!disp->manager) if (!disp->manager)
{ {
ERR("failed to open service manager error %lu\n", GetLastError()); ERR("failed to open service manager error %lu\n", GetLastError());
heap_free( disp ); free( disp );
return FALSE; return FALSE;
} }
...@@ -1837,7 +1836,7 @@ static BOOL service_run_main_thread(void) ...@@ -1837,7 +1836,7 @@ static BOOL service_run_main_thread(void)
{ {
WARN("failed to create control pipe error %lu\n", GetLastError()); WARN("failed to create control pipe error %lu\n", GetLastError());
CloseServiceHandle( disp->manager ); CloseServiceHandle( disp->manager );
heap_free( disp ); free( disp );
SetLastError( ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ); SetLastError( ERROR_FAILED_SERVICE_CONTROLLER_CONNECT );
return FALSE; return FALSE;
} }
...@@ -1919,13 +1918,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherA( const SERVICE_TABLE_E ...@@ -1919,13 +1918,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherA( const SERVICE_TABLE_E
return FALSE; return FALSE;
} }
services = heap_alloc( nb_services * sizeof(*services) ); services = malloc( nb_services * sizeof(*services) );
for (i = 0; i < nb_services; i++) for (i = 0; i < nb_services; i++)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, servent[i].lpServiceName, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, servent[i].lpServiceName, -1, NULL, 0 );
DWORD sz = FIELD_OFFSET( struct service_data, name[len] ); DWORD sz = FIELD_OFFSET( struct service_data, name[len] );
info = heap_alloc_zero( sz ); info = calloc( 1, sz );
MultiByteToWideChar( CP_ACP, 0, servent[i].lpServiceName, -1, info->name, len ); MultiByteToWideChar( CP_ACP, 0, servent[i].lpServiceName, -1, info->name, len );
info->proc.a = servent[i].lpServiceProc; info->proc.a = servent[i].lpServiceProc;
info->unicode = FALSE; info->unicode = FALSE;
...@@ -1957,13 +1956,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherW( const SERVICE_TABLE_E ...@@ -1957,13 +1956,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherW( const SERVICE_TABLE_E
return FALSE; return FALSE;
} }
services = heap_alloc( nb_services * sizeof(*services) ); services = malloc( nb_services * sizeof(*services) );
for (i = 0; i < nb_services; i++) for (i = 0; i < nb_services; i++)
{ {
DWORD len = wcslen( servent[i].lpServiceName ) + 1; DWORD len = wcslen( servent[i].lpServiceName ) + 1;
DWORD sz = FIELD_OFFSET( struct service_data, name[len] ); DWORD sz = FIELD_OFFSET( struct service_data, name[len] );
info = heap_alloc_zero( sz ); info = calloc( 1, sz );
wcscpy( info->name, servent[i].lpServiceName ); wcscpy( info->name, servent[i].lpServiceName );
info->proc.w = servent[i].lpServiceProc; info->proc.w = servent[i].lpServiceProc;
info->unicode = TRUE; info->unicode = TRUE;
...@@ -2056,7 +2055,7 @@ static DWORD WINAPI device_notify_proc( void *arg ) ...@@ -2056,7 +2055,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
} }
details_copy_size = 8; details_copy_size = 8;
details_copy = heap_alloc( details_copy_size * sizeof(*details_copy) ); details_copy = malloc( details_copy_size * sizeof(*details_copy) );
for (;;) for (;;)
{ {
...@@ -2089,7 +2088,7 @@ static DWORD WINAPI device_notify_proc( void *arg ) ...@@ -2089,7 +2088,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
if (i == details_copy_size) if (i == details_copy_size)
{ {
details_copy_size *= 2; details_copy_size *= 2;
details_copy = heap_realloc( details_copy, details_copy_size * sizeof(*details_copy) ); details_copy = realloc( details_copy, details_copy_size * sizeof(*details_copy) );
} }
} }
LeaveCriticalSection(&service_cs); LeaveCriticalSection(&service_cs);
...@@ -2102,8 +2101,6 @@ static DWORD WINAPI device_notify_proc( void *arg ) ...@@ -2102,8 +2101,6 @@ static DWORD WINAPI device_notify_proc( void *arg )
MIDL_user_free(buf); MIDL_user_free(buf);
} }
heap_free( details_copy );
__TRY __TRY
{ {
plugplay_unregister_listener( handle ); plugplay_unregister_listener( handle );
...@@ -2113,6 +2110,7 @@ static DWORD WINAPI device_notify_proc( void *arg ) ...@@ -2113,6 +2110,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
} }
__ENDTRY __ENDTRY
free( details_copy );
RpcBindingFree( &plugplay_binding_handle ); RpcBindingFree( &plugplay_binding_handle );
return 0; return 0;
} }
...@@ -2127,7 +2125,7 @@ HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_det ...@@ -2127,7 +2125,7 @@ HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_det
TRACE("callback %p, handle %p, filter %p, flags %#lx\n", details->cb, details->handle, filter, flags); TRACE("callback %p, handle %p, filter %p, flags %#lx\n", details->cb, details->handle, filter, flags);
if (!(registration = heap_alloc(sizeof(struct device_notify_registration)))) if (!(registration = malloc( sizeof(struct device_notify_registration) )))
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL; return NULL;
...@@ -2161,6 +2159,6 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle ) ...@@ -2161,6 +2159,6 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle )
EnterCriticalSection( &service_cs ); EnterCriticalSection( &service_cs );
list_remove( &registration->entry ); list_remove( &registration->entry );
LeaveCriticalSection(&service_cs); LeaveCriticalSection(&service_cs);
heap_free( registration ); free( registration );
return TRUE; return TRUE;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment