mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-07 06:34:06 +00:00
sechost: Use CRT allocation functions.
This commit is contained in:
parent
faae2162b8
commit
fdc3e50634
|
@ -28,7 +28,6 @@
|
|||
#include "iads.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(security);
|
||||
|
||||
|
@ -1080,7 +1079,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO
|
|||
|
||||
*size = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
||||
|
||||
tok = heap_alloc( (wcslen(string) + 1) * sizeof(WCHAR) );
|
||||
tok = malloc( (wcslen(string) + 1) * sizeof(WCHAR) );
|
||||
if (!tok)
|
||||
{
|
||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||
|
@ -1208,7 +1207,7 @@ static BOOL parse_sd( const WCHAR *string, SECURITY_DESCRIPTOR_RELATIVE *sd, DWO
|
|||
ret = TRUE;
|
||||
|
||||
out:
|
||||
heap_free(tok);
|
||||
free(tok);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/heap.h"
|
||||
#include "wine/list.h"
|
||||
|
||||
#include "svcctl.h"
|
||||
|
@ -90,18 +89,18 @@ static unsigned int nb_services;
|
|||
static HANDLE service_event;
|
||||
static BOOL stop_service;
|
||||
|
||||
static WCHAR *heap_strdupAtoW( const char *src )
|
||||
static WCHAR *strdupAtoW( const char *src )
|
||||
{
|
||||
WCHAR *dst = NULL;
|
||||
if (src)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static WCHAR *heap_strdup_multi_AtoW( const char *src )
|
||||
static WCHAR *strdup_multi_AtoW( const char *src )
|
||||
{
|
||||
WCHAR *dst = NULL;
|
||||
const char *p = src;
|
||||
|
@ -113,7 +112,7 @@ static WCHAR *heap_strdup_multi_AtoW( const char *src )
|
|||
for (p = src; *p; p += strlen(p) + 1);
|
||||
p++; /* final null */
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -129,12 +128,12 @@ static inline DWORD multisz_size( const WCHAR *str )
|
|||
|
||||
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 )
|
||||
{
|
||||
heap_free(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static LONG WINAPI rpc_filter( EXCEPTION_POINTERS *eptr )
|
||||
|
@ -257,11 +256,11 @@ SC_HANDLE WINAPI DECLSPEC_HOTPATCH OpenSCManagerA( const char *machine, const ch
|
|||
WCHAR *machineW, *databaseW;
|
||||
SC_HANDLE ret;
|
||||
|
||||
machineW = heap_strdupAtoW( machine );
|
||||
databaseW = heap_strdupAtoW( database );
|
||||
machineW = strdupAtoW( machine );
|
||||
databaseW = strdupAtoW( database );
|
||||
ret = OpenSCManagerW( machineW, databaseW, access );
|
||||
heap_free( databaseW );
|
||||
heap_free( machineW );
|
||||
free( databaseW );
|
||||
free( machineW );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
nameW = heap_strdupAtoW( name );
|
||||
nameW = strdupAtoW( name );
|
||||
ret = OpenServiceW( manager, nameW, access );
|
||||
heap_free( nameW );
|
||||
free( nameW );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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) );
|
||||
|
||||
nameW = heap_strdupAtoW( name );
|
||||
display_nameW = heap_strdupAtoW( display_name );
|
||||
pathW = heap_strdupAtoW( path );
|
||||
groupW = heap_strdupAtoW( group );
|
||||
dependenciesW = heap_strdup_multi_AtoW( dependencies );
|
||||
usernameW = heap_strdupAtoW( username );
|
||||
passwordW = heap_strdupAtoW( password );
|
||||
nameW = strdupAtoW( name );
|
||||
display_nameW = strdupAtoW( display_name );
|
||||
pathW = strdupAtoW( path );
|
||||
groupW = strdupAtoW( group );
|
||||
dependenciesW = strdup_multi_AtoW( dependencies );
|
||||
usernameW = strdupAtoW( username );
|
||||
passwordW = strdupAtoW( password );
|
||||
|
||||
handle = CreateServiceW( manager, nameW, display_nameW, access, service_type, start_type, error_control,
|
||||
pathW, groupW, tag, dependenciesW, usernameW, passwordW );
|
||||
|
||||
heap_free( nameW );
|
||||
heap_free( display_nameW );
|
||||
heap_free( pathW );
|
||||
heap_free( groupW );
|
||||
heap_free( dependenciesW );
|
||||
heap_free( usernameW );
|
||||
heap_free( passwordW );
|
||||
free( nameW );
|
||||
free( display_nameW );
|
||||
free( pathW );
|
||||
free( groupW );
|
||||
free( dependenciesW );
|
||||
free( usernameW );
|
||||
free( passwordW );
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -480,11 +479,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le
|
|||
SERVICE_DESCRIPTIONA *sd = info;
|
||||
SERVICE_DESCRIPTIONW sdw;
|
||||
|
||||
sdw.lpDescription = heap_strdupAtoW( sd->lpDescription );
|
||||
sdw.lpDescription = strdupAtoW( sd->lpDescription );
|
||||
|
||||
r = ChangeServiceConfig2W( service, level, &sdw );
|
||||
|
||||
heap_free( sdw.lpDescription );
|
||||
free( sdw.lpDescription );
|
||||
}
|
||||
else if (level == SERVICE_CONFIG_FAILURE_ACTIONS)
|
||||
{
|
||||
|
@ -492,15 +491,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfig2A( SC_HANDLE service, DWORD le
|
|||
SERVICE_FAILURE_ACTIONSW faw;
|
||||
|
||||
faw.dwResetPeriod = fa->dwResetPeriod;
|
||||
faw.lpRebootMsg = heap_strdupAtoW( fa->lpRebootMsg );
|
||||
faw.lpCommand = heap_strdupAtoW( fa->lpCommand );
|
||||
faw.lpRebootMsg = strdupAtoW( fa->lpRebootMsg );
|
||||
faw.lpCommand = strdupAtoW( fa->lpCommand );
|
||||
faw.cActions = fa->cActions;
|
||||
faw.lpsaActions = fa->lpsaActions;
|
||||
|
||||
r = ChangeServiceConfig2W( service, level, &faw );
|
||||
|
||||
heap_free( faw.lpRebootMsg );
|
||||
heap_free( faw.lpCommand );
|
||||
free( faw.lpRebootMsg );
|
||||
free( faw.lpCommand );
|
||||
}
|
||||
else if (level == SERVICE_CONFIG_PRESHUTDOWN_INFO)
|
||||
{
|
||||
|
@ -561,22 +560,22 @@ BOOL WINAPI DECLSPEC_HOTPATCH ChangeServiceConfigA( SC_HANDLE service, DWORD ser
|
|||
error_control, debugstr_a(path), debugstr_a(group), tag, dependencies,
|
||||
debugstr_a(username), debugstr_a(password), debugstr_a(display_name) );
|
||||
|
||||
pathW = heap_strdupAtoW( path );
|
||||
groupW = heap_strdupAtoW( group );
|
||||
dependenciesW = heap_strdup_multi_AtoW( dependencies );
|
||||
usernameW = heap_strdupAtoW( username );
|
||||
passwordW = heap_strdupAtoW( password );
|
||||
display_nameW = heap_strdupAtoW( display_name );
|
||||
pathW = strdupAtoW( path );
|
||||
groupW = strdupAtoW( group );
|
||||
dependenciesW = strdup_multi_AtoW( dependencies );
|
||||
usernameW = strdupAtoW( username );
|
||||
passwordW = strdupAtoW( password );
|
||||
display_nameW = strdupAtoW( display_name );
|
||||
|
||||
r = ChangeServiceConfigW( service, service_type, start_type, error_control, pathW,
|
||||
groupW, tag, dependenciesW, usernameW, passwordW, display_nameW );
|
||||
|
||||
heap_free( pathW );
|
||||
heap_free( groupW );
|
||||
heap_free( dependenciesW );
|
||||
heap_free( usernameW );
|
||||
heap_free( passwordW );
|
||||
heap_free( display_nameW );
|
||||
free( pathW );
|
||||
free( groupW );
|
||||
free( dependenciesW );
|
||||
free( usernameW );
|
||||
free( passwordW );
|
||||
free( display_nameW );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -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 );
|
||||
|
||||
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;
|
||||
ret = QueryServiceConfigW( service, configW, 2 * size, ret_size );
|
||||
if (!ret) goto done;
|
||||
|
@ -668,7 +667,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfigA( SC_HANDLE service, QUERY_SERV
|
|||
ret = TRUE;
|
||||
|
||||
done:
|
||||
heap_free( buffer );
|
||||
free( buffer );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
if (buffer && size)
|
||||
bufferW = heap_alloc( size );
|
||||
bufferW = malloc( size );
|
||||
|
||||
if (!QueryServiceConfig2W( service, level, bufferW, size, ret_size ))
|
||||
{
|
||||
heap_free( bufferW );
|
||||
free( bufferW );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -805,11 +804,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2A( SC_HANDLE service, DWORD lev
|
|||
break;
|
||||
default:
|
||||
FIXME("conversion W->A not implemented for level %ld\n", level);
|
||||
heap_free( bufferW );
|
||||
free( bufferW );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
heap_free( bufferW );
|
||||
free( bufferW );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -833,7 +832,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
|
|||
switch (level)
|
||||
{
|
||||
case SERVICE_CONFIG_DESCRIPTION:
|
||||
if (!(bufptr = heap_alloc( size )))
|
||||
if (!(bufptr = malloc( size )))
|
||||
{
|
||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||
return FALSE;
|
||||
|
@ -852,7 +851,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
|
|||
|
||||
if (!ret_size)
|
||||
{
|
||||
if (level == SERVICE_CONFIG_DESCRIPTION) heap_free( bufptr );
|
||||
if (level == SERVICE_CONFIG_DESCRIPTION) free( bufptr );
|
||||
SetLastError(ERROR_INVALID_ADDRESS);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -876,7 +875,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
|
|||
|
||||
if (err != ERROR_SUCCESS && err != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
heap_free( bufptr );
|
||||
free( bufptr );
|
||||
SetLastError( err );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -889,7 +888,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
|
|||
|
||||
if (size < *ret_size)
|
||||
{
|
||||
heap_free( bufptr );
|
||||
free( bufptr );
|
||||
SetLastError( ERROR_INSUFFICIENT_BUFFER );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -902,7 +901,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH QueryServiceConfig2W( SC_HANDLE service, DWORD lev
|
|||
memcpy( desc->lpDescription, s->description, s->size );
|
||||
}
|
||||
}
|
||||
heap_free( bufptr );
|
||||
free( bufptr );
|
||||
break;
|
||||
}
|
||||
case SERVICE_CONFIG_PRESHUTDOWN_INFO:
|
||||
|
@ -1020,16 +1019,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceA( SC_HANDLE service, DWORD argc, cons
|
|||
BOOL r;
|
||||
|
||||
if (argc)
|
||||
argvW = heap_alloc( argc * sizeof(*argvW) );
|
||||
argvW = malloc( argc * sizeof(*argvW) );
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
argvW[i] = heap_strdupAtoW( argv[i] );
|
||||
argvW[i] = strdupAtoW( argv[i] );
|
||||
|
||||
r = StartServiceW( service, argc, (const WCHAR **)argvW );
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
heap_free( argvW[i] );
|
||||
heap_free( argvW );
|
||||
free( argvW[i] );
|
||||
free( argvW );
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1151,7 +1150,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
|
|||
|
||||
/* make sure we pass a valid pointer */
|
||||
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
|
||||
{
|
||||
|
@ -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 */
|
||||
if (err == ERROR_MORE_DATA) *needed *= 2;
|
||||
heap_free( buf );
|
||||
free( buf );
|
||||
SetLastError( err );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1193,7 +1192,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
|
|||
|
||||
if (total_size > size)
|
||||
{
|
||||
heap_free( buf );
|
||||
free( buf );
|
||||
*needed = total_size;
|
||||
SetLastError( ERROR_MORE_DATA );
|
||||
return FALSE;
|
||||
|
@ -1223,7 +1222,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumServicesStatusExW( SC_HANDLE manager, SC_ENUM_
|
|||
entry++;
|
||||
}
|
||||
|
||||
heap_free( buf );
|
||||
free( buf );
|
||||
*needed = 0;
|
||||
*returned = count;
|
||||
return TRUE;
|
||||
|
@ -1358,7 +1357,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
|
|||
|
||||
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;
|
||||
|
||||
data->service = service;
|
||||
|
@ -1367,7 +1366,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
|
|||
&data->calling_thread, 0, FALSE, DUPLICATE_SAME_ACCESS ))
|
||||
{
|
||||
ERR("DuplicateHandle failed: %lu\n", GetLastError());
|
||||
heap_free( data );
|
||||
free( data );
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1394,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH NotifyServiceStatusChangeW( SC_HANDLE service, DW
|
|||
LeaveCriticalSection( &service_cs );
|
||||
CloseHandle( data->calling_thread );
|
||||
CloseHandle( data->ready_evt );
|
||||
heap_free( data );
|
||||
free( data );
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1444,9 +1443,9 @@ SERVICE_STATUS_HANDLE WINAPI DECLSPEC_HOTPATCH RegisterServiceCtrlHandlerExA(
|
|||
WCHAR *nameW;
|
||||
SERVICE_STATUS_HANDLE ret;
|
||||
|
||||
nameW = heap_strdupAtoW( name );
|
||||
nameW = strdupAtoW( name );
|
||||
ret = RegisterServiceCtrlHandlerExW( nameW, handler, context );
|
||||
heap_free( nameW );
|
||||
free( nameW );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1553,7 +1552,7 @@ static WCHAR *service_get_pipe_name(void)
|
|||
return NULL;
|
||||
|
||||
len = ARRAY_SIZE(format) + 10 /* strlenW("4294967295") */;
|
||||
name = heap_alloc(len * sizeof(WCHAR));
|
||||
name = malloc(len * sizeof(WCHAR));
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
@ -1575,7 +1574,7 @@ static HANDLE service_open_pipe(void)
|
|||
if (GetLastError() != ERROR_PIPE_BUSY)
|
||||
break;
|
||||
} while (WaitNamedPipeW( pipe_name, NMPWAIT_USE_DEFAULT_WAIT ));
|
||||
heap_free(pipe_name);
|
||||
free(pipe_name);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -1600,13 +1599,13 @@ static DWORD WINAPI service_thread( void *arg )
|
|||
{
|
||||
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)
|
||||
argv[argc++] = p;
|
||||
argv[argc] = NULL;
|
||||
|
||||
info->proc.w( argc, argv );
|
||||
heap_free( argv );
|
||||
free( argv );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1614,17 +1613,17 @@ static DWORD WINAPI service_thread( void *arg )
|
|||
DWORD lenA;
|
||||
|
||||
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);
|
||||
|
||||
argv = heap_alloc( (argc+1)*sizeof(*argv) );
|
||||
argv = malloc( (argc + 1) * sizeof(*argv) );
|
||||
for (argc = 0, p = strA; *p; p += strlen( p ) + 1)
|
||||
argv[argc++] = p;
|
||||
argv[argc] = NULL;
|
||||
|
||||
info->proc.a( argc, argv );
|
||||
heap_free( argv );
|
||||
heap_free( strA );
|
||||
free( argv );
|
||||
free( strA );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1639,8 +1638,8 @@ static DWORD service_handle_start( struct service_data *service, const void *dat
|
|||
return ERROR_SERVICE_ALREADY_RUNNING;
|
||||
}
|
||||
|
||||
heap_free( service->args );
|
||||
service->args = heap_alloc( (count + 2) * sizeof(WCHAR) );
|
||||
free( service->args );
|
||||
service->args = malloc( (count + 2) * sizeof(WCHAR) );
|
||||
if (count) memcpy( service->args, data, count * sizeof(WCHAR) );
|
||||
service->args[count++] = 0;
|
||||
service->args[count++] = 0;
|
||||
|
@ -1693,19 +1692,19 @@ static DWORD WINAPI service_control_dispatcher( void *arg )
|
|||
if (count < info.total_size)
|
||||
{
|
||||
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 );
|
||||
if (!r)
|
||||
{
|
||||
if (GetLastError() != ERROR_BROKEN_PIPE)
|
||||
ERR( "pipe read failed error %lu\n", GetLastError() );
|
||||
heap_free( data );
|
||||
free( data );
|
||||
break;
|
||||
}
|
||||
if (count != data_size)
|
||||
{
|
||||
ERR( "partial pipe read %lu/%lu\n", count, data_size );
|
||||
heap_free( data );
|
||||
free( data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1751,12 +1750,12 @@ static DWORD WINAPI service_control_dispatcher( void *arg )
|
|||
done:
|
||||
LeaveCriticalSection( &service_cs );
|
||||
WriteFile( disp->pipe, &result, sizeof(result), &count, NULL );
|
||||
heap_free( data );
|
||||
free( data );
|
||||
}
|
||||
|
||||
CloseHandle( disp->pipe );
|
||||
CloseServiceHandle( disp->manager );
|
||||
heap_free( disp );
|
||||
free( disp );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1768,7 +1767,7 @@ static void handle_shutdown_msg(DWORD msg, DWORD accept)
|
|||
DWORD i, n = 0, sz, timeout = 2000;
|
||||
ULONGLONG stop_time;
|
||||
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 );
|
||||
for (i = 0; i < nb_services; i++)
|
||||
|
@ -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)
|
||||
|
@ -1822,13 +1821,13 @@ static BOOL service_run_main_thread(void)
|
|||
DWORD i, n, ret;
|
||||
HANDLE wait_handles[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 );
|
||||
if (!disp->manager)
|
||||
{
|
||||
ERR("failed to open service manager error %lu\n", GetLastError());
|
||||
heap_free( disp );
|
||||
free( disp );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1836,7 @@ static BOOL service_run_main_thread(void)
|
|||
{
|
||||
WARN("failed to create control pipe error %lu\n", GetLastError());
|
||||
CloseServiceHandle( disp->manager );
|
||||
heap_free( disp );
|
||||
free( disp );
|
||||
SetLastError( ERROR_FAILED_SERVICE_CONTROLLER_CONNECT );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1919,13 +1918,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherA( const SERVICE_TABLE_E
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
services = heap_alloc( nb_services * sizeof(*services) );
|
||||
services = malloc( nb_services * sizeof(*services) );
|
||||
|
||||
for (i = 0; i < nb_services; i++)
|
||||
{
|
||||
DWORD len = MultiByteToWideChar( CP_ACP, 0, servent[i].lpServiceName, -1, NULL, 0 );
|
||||
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 );
|
||||
info->proc.a = servent[i].lpServiceProc;
|
||||
info->unicode = FALSE;
|
||||
|
@ -1957,13 +1956,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherW( const SERVICE_TABLE_E
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
services = heap_alloc( nb_services * sizeof(*services) );
|
||||
services = malloc( nb_services * sizeof(*services) );
|
||||
|
||||
for (i = 0; i < nb_services; i++)
|
||||
{
|
||||
DWORD len = wcslen( servent[i].lpServiceName ) + 1;
|
||||
DWORD sz = FIELD_OFFSET( struct service_data, name[len] );
|
||||
info = heap_alloc_zero( sz );
|
||||
info = calloc( 1, sz );
|
||||
wcscpy( info->name, servent[i].lpServiceName );
|
||||
info->proc.w = servent[i].lpServiceProc;
|
||||
info->unicode = TRUE;
|
||||
|
@ -2056,7 +2055,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
|
|||
}
|
||||
|
||||
details_copy_size = 8;
|
||||
details_copy = heap_alloc( details_copy_size * sizeof(*details_copy) );
|
||||
details_copy = malloc( details_copy_size * sizeof(*details_copy) );
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -2089,7 +2088,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
|
|||
if (i == details_copy_size)
|
||||
{
|
||||
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);
|
||||
|
@ -2102,8 +2101,6 @@ static DWORD WINAPI device_notify_proc( void *arg )
|
|||
MIDL_user_free(buf);
|
||||
}
|
||||
|
||||
heap_free( details_copy );
|
||||
|
||||
__TRY
|
||||
{
|
||||
plugplay_unregister_listener( handle );
|
||||
|
@ -2113,6 +2110,7 @@ static DWORD WINAPI device_notify_proc( void *arg )
|
|||
}
|
||||
__ENDTRY
|
||||
|
||||
free( details_copy );
|
||||
RpcBindingFree( &plugplay_binding_handle );
|
||||
return 0;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
if (!(registration = heap_alloc(sizeof(struct device_notify_registration))))
|
||||
if (!(registration = malloc( sizeof(struct device_notify_registration) )))
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
|
@ -2161,6 +2159,6 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle )
|
|||
EnterCriticalSection( &service_cs );
|
||||
list_remove( ®istration->entry );
|
||||
LeaveCriticalSection(&service_cs);
|
||||
heap_free( registration );
|
||||
free( registration );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue