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
af27e215
Commit
af27e215
authored
Jul 18, 2007
by
Paul Vriens
Committed by
Alexandre Julliard
Jul 19, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32/service: Some tests for DeleteService.
parent
f8f6340a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
service.c
dlls/advapi32/service.c
+6
-0
service.c
dlls/advapi32/tests/service.c
+51
-1
No files found.
dlls/advapi32/service.c
View file @
af27e215
...
...
@@ -1558,6 +1558,12 @@ BOOL WINAPI DeleteService( SC_HANDLE hService )
return
FALSE
;
}
if
(
!
(
hsvc
->
dwAccess
&
DELETE
))
{
SetLastError
(
ERROR_ACCESS_DENIED
);
return
FALSE
;
}
/* Close the key to the service */
RegCloseKey
(
hsvc
->
hkey
);
...
...
dlls/advapi32/tests/service.c
View file @
af27e215
...
...
@@ -23,6 +23,7 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winreg.h"
#include "winsvc.h"
#include "lmcons.h"
...
...
@@ -323,9 +324,58 @@ static void test_create_delete_svc(void)
else
skip
(
"Could not retrieve a displayname (Spooler service doesn't exist)
\n
"
);
/* Windows doesn't care about the access rights for creation (which makes
* sense as there is no service yet) as long as there are sufficient
* rights to the manager.
*/
SetLastError
(
0xdeadbeef
);
svc_handle1
=
CreateServiceA
(
scm_handle
,
servicename
,
NULL
,
0
,
SERVICE_WIN32_OWN_PROCESS
|
SERVICE_INTERACTIVE_PROCESS
,
SERVICE_DISABLED
,
0
,
pathname
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
svc_handle1
!=
NULL
,
"Could not create the service : %d
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
ERROR_SUCCESS
/* W2K3, Vista */
||
GetLastError
()
==
0xdeadbeef
/* NT4, XP */
||
GetLastError
()
==
ERROR_IO_PENDING
/* W2K */
,
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d
\n
"
,
GetLastError
());
/* DeleteService however must have proper rights */
SetLastError
(
0xdeadbeef
);
ret
=
DeleteService
(
svc_handle1
);
ok
(
!
ret
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
/* Open the service with minimal rights for deletion.
* (Verified with 'SERVICE_ALL_ACCESS &~ DELETE')
*/
CloseServiceHandle
(
svc_handle1
);
svc_handle1
=
OpenServiceA
(
scm_handle
,
servicename
,
DELETE
);
/* Now that we have the proper rights, we should be able to delete */
SetLastError
(
0xdeadbeef
);
ret
=
DeleteService
(
svc_handle1
);
ok
(
ret
,
"Expected success
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
/* W2K3 */
||
GetLastError
()
==
0xdeadbeef
/* NT4, XP, Vista */
||
GetLastError
()
==
ERROR_IO_PENDING
/* W2K */
,
"Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d
\n
"
,
GetLastError
());
CloseServiceHandle
(
svc_handle1
);
CloseServiceHandle
(
scm_handle
);
}
/* Wait a while. One of the following tests also does a CreateService for the
* same servicename and this would result in an ERROR_SERVICE_MARKED_FOR_DELETE
* error if we do this to quick. Vista seems more picky then the others.
*/
Sleep
(
1000
);
/* And a final NULL check */
SetLastError
(
0xdeadbeef
);
ret
=
DeleteService
(
NULL
);
ok
(
!
ret
,
"Expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
static
void
test_close
(
void
)
{
...
...
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