Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
5c51ad2c
Commit
5c51ad2c
authored
Feb 11, 2008
by
Roy Shea
Committed by
Alexandre Julliard
Feb 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qmgr: Add ServiceMain.
parent
313a903a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
2 deletions
+142
-2
Makefile.in
dlls/qmgr/Makefile.in
+3
-2
qmgr.spec
dlls/qmgr/qmgr.spec
+1
-0
service.c
dlls/qmgr/service.c
+138
-0
No files found.
dlls/qmgr/Makefile.in
View file @
5c51ad2c
...
...
@@ -3,13 +3,14 @@ TOPOBJDIR = ../..
SRCDIR
=
@srcdir@
VPATH
=
@srcdir@
MODULE
=
qmgr.dll
IMPORTS
=
advpack advapi32 kernel32
IMPORTS
=
advpack
ole32
advapi32 kernel32
EXTRALIBS
=
-luuid
C_SRCS
=
\
factory.c
\
qmgr.c
\
qmgr_main.c
qmgr_main.c
\
service.c
RC_SRCS
=
rsrc.rc
...
...
dlls/qmgr/qmgr.spec
View file @
5c51ad2c
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
@ stdcall -private ServiceMain(long ptr)
dlls/qmgr/service.c
0 → 100644
View file @
5c51ad2c
/*
* ServiceMain function for qmgr running within svchost
*
* Copyright 2007 (C) Google (Roy Shea)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "windef.h"
#include "objbase.h"
#include "winsvc.h"
#include "bits.h"
#include "qmgr.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
qmgr
);
static
WCHAR
qmgr_nameW
[]
=
{
'B'
,
'I'
,
'T'
,
'S'
,
0
};
static
SERVICE_STATUS_HANDLE
status_handle
;
static
SERVICE_STATUS
status
;
static
HANDLE
stop_event
=
NULL
;
static
VOID
UpdateStatus
(
DWORD
dwCurrentState
,
DWORD
dwWin32ExitCode
,
DWORD
dwWaitHint
)
{
status
.
dwServiceType
=
SERVICE_WIN32_OWN_PROCESS
;
status
.
dwCurrentState
=
dwCurrentState
;
if
(
dwCurrentState
==
SERVICE_START_PENDING
)
status
.
dwControlsAccepted
=
0
;
else
status
.
dwControlsAccepted
=
(
SERVICE_ACCEPT_STOP
|
SERVICE_ACCEPT_PAUSE_CONTINUE
|
SERVICE_ACCEPT_SHUTDOWN
);
status
.
dwWin32ExitCode
=
0
;
status
.
dwServiceSpecificExitCode
=
0
;
status
.
dwCheckPoint
=
0
;
status
.
dwWaitHint
=
dwWaitHint
;
if
(
!
SetServiceStatus
(
status_handle
,
&
status
))
{
ERR
(
"failed to set service status
\n
"
);
SetEvent
(
stop_event
);
}
}
/* Handle incoming ControlService signals */
static
DWORD
WINAPI
ServiceHandler
(
DWORD
ctrl
,
DWORD
event_type
,
LPVOID
event_data
,
LPVOID
context
)
{
switch
(
ctrl
)
{
case
SERVICE_CONTROL_STOP
:
case
SERVICE_CONTROL_SHUTDOWN
:
TRACE
(
"shutting down service
\n
"
);
UpdateStatus
(
SERVICE_STOP_PENDING
,
NO_ERROR
,
0
);
SetEvent
(
stop_event
);
break
;
default:
FIXME
(
"ignoring handle service ctrl %x
\n
"
,
ctrl
);
UpdateStatus
(
status
.
dwCurrentState
,
NO_ERROR
,
0
);
break
;
}
return
NO_ERROR
;
}
/* Main thread of the service */
static
BOOL
StartCount
(
void
)
{
HRESULT
hr
;
DWORD
dwReg
;
TRACE
(
"
\n
"
);
hr
=
CoInitializeEx
(
NULL
,
COINIT_MULTITHREADED
);
if
(
!
SUCCEEDED
(
hr
))
return
FALSE
;
hr
=
CoInitializeSecurity
(
NULL
,
-
1
,
NULL
,
NULL
,
RPC_C_AUTHN_LEVEL_NONE
,
RPC_C_IMP_LEVEL_IMPERSONATE
,
NULL
,
EOAC_NONE
,
NULL
);
if
(
!
SUCCEEDED
(
hr
))
return
FALSE
;
hr
=
CoRegisterClassObject
(
&
CLSID_BackgroundCopyManager
,
(
IUnknown
*
)
&
BITS_ClassFactory
,
CLSCTX_LOCAL_SERVER
,
REGCLS_MULTIPLEUSE
,
&
dwReg
);
if
(
!
SUCCEEDED
(
hr
))
return
FALSE
;
return
TRUE
;
}
/* Service entry point */
VOID
WINAPI
ServiceMain
(
DWORD
dwArgc
,
LPWSTR
*
lpszArgv
)
{
TRACE
(
"
\n
"
);
stop_event
=
CreateEventW
(
NULL
,
TRUE
,
FALSE
,
NULL
);
if
(
!
stop_event
)
{
ERR
(
"failed to create stop_event
\n
"
);
return
;
}
status_handle
=
RegisterServiceCtrlHandlerExW
(
qmgr_nameW
,
ServiceHandler
,
NULL
);
if
(
!
status_handle
)
{
ERR
(
"failed to register handler: %u
\n
"
,
GetLastError
());
return
;
}
UpdateStatus
(
SERVICE_START_PENDING
,
NO_ERROR
,
3000
);
if
(
!
StartCount
())
{
ERR
(
"failed starting service thread
\n
"
);
UpdateStatus
(
SERVICE_STOPPED
,
NO_ERROR
,
0
);
return
;
}
UpdateStatus
(
SERVICE_RUNNING
,
NO_ERROR
,
0
);
WaitForSingleObject
(
stop_event
,
INFINITE
);
UpdateStatus
(
SERVICE_STOPPED
,
NO_ERROR
,
0
);
CloseHandle
(
stop_event
);
TRACE
(
"service stoped
\n
"
);
}
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