Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
039e987b
Commit
039e987b
authored
2 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Assume Windows XP / Server 2003 or later
No need to use LoadLibrary() and GetProcAddress() here
parent
dfef8a98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/ntsvcs.c
+7
-22
7 additions, 22 deletions
src/sbbs3/ntsvcs.c
with
7 additions
and
22 deletions
src/sbbs3/ntsvcs.c
+
7
−
22
View file @
039e987b
...
...
@@ -488,24 +488,16 @@ static void WINAPI services_start(DWORD dwArgc, LPTSTR *lpszArgv)
}
/******************************************/
/* NT Ser
i
vce Install/Uninstall Functions */
/* NT Serv
i
ce Install/Uninstall Functions */
/******************************************/
/* ChangeServiceConfig2 is a Win2K+ API function, must call dynamically */
typedef
WINADVAPI
bool
(
WINAPI
*
ChangeServiceConfig2_t
)(
SC_HANDLE
,
DWORD
,
LPCVOID
);
static
void
describe_service
(
HANDLE
hSCMlib
,
SC_HANDLE
hService
,
char
*
description
)
static
void
describe_service
(
SC_HANDLE
hService
,
char
*
description
)
{
ChangeServiceConfig2_t
changeServiceConfig2
;
static
SERVICE_DESCRIPTION
service_desc
;
if
(
hSCMlib
==
NULL
)
return
;
static
SERVICE_DESCRIPTION
service_desc
=
{
0
};
service_desc
.
lpDescription
=
description
;
if
((
changeServiceConfig2
=
(
ChangeServiceConfig2_t
)
GetProcAddress
(
hSCMlib
,
"ChangeServiceConfig2A"
))
!=
NULL
)
changeServiceConfig2
(
hService
,
SERVICE_CONFIG_DESCRIPTION
,
&
service_desc
);
ChangeServiceConfig2
(
hService
,
SERVICE_CONFIG_DESCRIPTION
,
&
service_desc
);
}
static
bool
register_event_source
(
char
*
name
,
char
*
path
)
...
...
@@ -696,7 +688,7 @@ static DWORD get_service_info(SC_HANDLE hSCManager, char* name, DWORD* state)
/****************************************************************************/
/* Utility function to create a service with description (on Win2K+) */
/****************************************************************************/
static
void
create_service
(
HANDLE
hSCMlib
,
SC_HANDLE
hSCManager
static
void
create_service
(
SC_HANDLE
hSCManager
,
char
*
name
,
char
*
display_name
,
char
*
description
,
char
*
path
,
bool
autostart
)
{
...
...
@@ -728,7 +720,7 @@ static void create_service(HANDLE hSCMlib, SC_HANDLE hSCManager
printf
(
"!ERROR %d
\n
"
,
err
);
}
else
{
describe_service
(
hSCMlib
,
hService
,
description
);
describe_service
(
hService
,
description
);
CloseServiceHandle
(
hService
);
printf
(
"%s
\n
"
,
start_type_desc
(
start_type
));
...
...
@@ -743,7 +735,6 @@ static void create_service(HANDLE hSCMlib, SC_HANDLE hSCManager
static
int
install
(
const
char
*
svc_name
)
{
int
i
;
HANDLE
hSCMlib
;
SC_HANDLE
hSCManager
;
char
path
[
MAX_PATH
+
1
];
...
...
@@ -765,23 +756,17 @@ static int install(const char* svc_name)
return
-
1
;
}
hSCMlib
=
LoadLibrary
(
"ADVAPI32.DLL"
);
for
(
i
=
0
;
ntsvc_list
[
i
]
!=
NULL
;
i
++
)
if
(
svc_name
==
NULL
/* All? */
||
!
stricmp
(
ntsvc_list
[
i
]
->
name
,
svc_name
)
||
!
stricmp
(
ntsvc_list
[
i
]
->
name
+
STRLEN_SYNCHRONET
,
svc_name
))
create_service
(
hSCMlib
,
hSCManager
create_service
(
hSCManager
,
ntsvc_list
[
i
]
->
name
,
ntsvc_list
[
i
]
->
display_name
,
ntsvc_list
[
i
]
->
description
,
path
,
ntsvc_list
[
i
]
->
autostart
);
if
(
hSCMlib
!=
NULL
)
FreeLibrary
(
hSCMlib
);
CloseServiceHandle
(
hSCManager
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment