Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
fdc3e506
Commit
fdc3e506
authored
Nov 01, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sechost: Use CRT allocation functions.
parent
faae2162
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
102 deletions
+99
-102
security.c
dlls/sechost/security.c
+2
-3
service.c
dlls/sechost/service.c
+97
-99
No files found.
dlls/sechost/security.c
View file @
fdc3e506
...
@@ -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
=
m
alloc
(
(
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
;
}
}
...
...
dlls/sechost/service.c
View file @
fdc3e506
...
@@ -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
=
m
alloc
(
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
=
m
alloc
(
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
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
=
m
alloc
(
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment