Add Win32 service support (closes #2) #3

Merged
luca0N merged 5 commits from dev_svc into dev 2026-05-30 23:57:17 +00:00
Owner

Add code to allow the resulting executable to be installed as a Win32 service.

Add code to allow the resulting executable to be installed as a Win32 service.
luca0N self-assigned this 2026-05-24 18:18:13 +00:00
Add Win32 service support
All checks were successful
/ Test (push) Successful in 15s
e37ab56454
Add code to allow the resulting executable to be installed as a Win32
service.
luca0N force-pushed dev_svc from e37ab56454
All checks were successful
/ Test (push) Successful in 15s
to ddb3fb4b23
All checks were successful
/ Test (push) Successful in 12s
2026-05-24 18:19:46 +00:00
Compare
luca0N force-pushed dev_svc from ddb3fb4b23
All checks were successful
/ Test (push) Successful in 12s
to 151ec1c2af
All checks were successful
/ Test (push) Successful in 14s
2026-05-24 18:20:55 +00:00
Compare
Author
Owner

The previous force-push operations were made to correct leftover commented code and the license in the source header, respectively.

The previous force-push operations were made to correct leftover commented code and the license in the source header, respectively.
luca0N left a comment

Some things to iron out before merging this pull request.

Some things to iron out before merging this pull request.
src/main.asm Outdated
@ -95,4 +116,0 @@
CALL printStdDev
MOV EAX, 02h
JMP .exit
Author
Owner

An unintended side effect from these changes was that this helpful message (although vague) was removed.

An unintended side effect from these changes was that this helpful message (although vague) was removed.
src/main.asm Outdated
@ -46,0 +67,4 @@
POP EBP
RET
runStandalone:
Author
Owner

This name is misleading, as this routine is called from both _start and svc.asm.

This name is misleading, as this routine is called from both `_start` and `svc.asm`.
@ -0,0 +26,4 @@
GLOBAL svcCtrlHandler
SECTION .rdata
STR_SVC_NAME: DB "Sticky", 00h
Author
Owner

STR_SVC_NAME is redeclared here (from main.asm). It'd be nice if it was declared on a single source file.

`STR_SVC_NAME` is redeclared here (from `main.asm`). It'd be nice if it was declared on a single source file.
src/svc.asm Outdated
@ -0,0 +41,4 @@
MOV DWORD [ESP+1Ch], EAX
CMP EAX, 00h
JNE .exit
INT 03h ; TODO: add proper err handling
Author
Owner

As the TODO comment suggests, better error handling should be added here.

As the `TODO` comment suggests, better error handling should be added here.
@ -0,0 +52,4 @@
MOV DWORD [ESP+0Ch], 00h ; dwWin32ExitCode
MOV DWORD [ESP+10h], 00h ; dwServiceSpecificExitCode
MOV DWORD [ESP+14h], 00h ; dwCheckPoint
MOV DWORD [ESP+18h], 00h ; dwWaitHint
Author
Owner

This struct can be moved to the rdata section.

This struct can be moved to the `rdata` section.
luca0N marked this conversation as resolved
src/svc.asm Outdated
@ -0,0 +68,4 @@
MOV EBP, ESP
NOP ; this program runs too quickly
; for any signals to be handled
Author
Owner

Comment indentation is all over the place.

Comment indentation is all over the place.
Refactor Win32 service code
All checks were successful
/ Test (push) Successful in 16s
ec4e0acd07
Move struct to read-only data section instead of manually setting bytes
in the stack, and relocate the position of the service control handle
variable in the stack.  The relocation was made to avoid potential
issues when moving code to subroutines.
Author
Owner

@luca0N wrote in #3 (comment):

Add code to allow the resulting executable to be installed as a Win32 service.

* [x] Allow manual installation as a Win32 service

* [ ] Prompt service installation[1](#fn:user-content-a)


1. This is a CLI/Win32 service hybrid program.  Installing Sticky as a service involves manually doing so via a combination of `sc.exe` and messing with the system registry (as command line arguments are required for specifying which images are to be attached).  To enhance UX, have a way to install Sticky as a service with the command line arguments directly from the program. [↩︎](#fnref:user-content-a)

Item no. 2 in the checklist has been removed as it is outside the scope of this pull request. It will be moved to an issue so that it can be evaluated for a potential future pull request.

@luca0N wrote in https://git.luca0n.com/luca0N/Sticky/pulls/3#issue-249: > Add code to allow the resulting executable to be installed as a Win32 service. > > * [x] Allow manual installation as a Win32 service > > * [ ] Prompt service installation[1](#fn:user-content-a) > > > 1. This is a CLI/Win32 service hybrid program. Installing Sticky as a service involves manually doing so via a combination of `sc.exe` and messing with the system registry (as command line arguments are required for specifying which images are to be attached). To enhance UX, have a way to install Sticky as a service with the command line arguments directly from the program. [↩︎](#fnref:user-content-a) Item no. 2 in the checklist has been removed as it is outside the scope of this pull request. It will be moved to an issue so that it can be evaluated for a potential future pull request.
Author
Owner

Ready to merge once all review comments are resolved.

Ready to merge once all review comments are resolved.
Refactor Win32 service code
All checks were successful
/ Test (push) Successful in 16s
4f65ce1b00
Perform some minor code refactoring in the Win32 service-related code.
This commit also moves Win32 functions to separate include files, and
introduces some other new include files for project source files.  As
new include files have been introduced, the Makefile has been updated
accordingly.
Move service name label and refactor comments
All checks were successful
/ Test (push) Successful in 14s
556bd5360b
Move the service name contents and label to the `svc.asm' source file
and make it a global symbol, and have all comments aligned at character
57 with 8-space tabs.
Add error handling during service initialization
Some checks failed
/ Test (push) Failing after 15s
c1cc5897a3
During Win32 service initialization, call RaiseException with a custom
exception code to indicate that an unrecoverable error occurred.

The newly created file `src/exceptions.inc' shall be used for defining
all program-defined exception codes via preprocessor macros, from now
on.
luca0N force-pushed dev_svc from c1cc5897a3
Some checks failed
/ Test (push) Failing after 15s
to c4973af852
Some checks failed
/ Test (push) Failing after 12s
2026-05-29 11:27:16 +00:00
Compare
luca0N force-pushed dev_svc from c4973af852
Some checks failed
/ Test (push) Failing after 12s
to 1bef15eaad
All checks were successful
/ Test (push) Successful in 16s
2026-05-30 23:55:40 +00:00
Compare
Author
Owner

The two previous force-push operations were made to fix build errors.

The two previous force-push operations were made to fix build errors.
luca0N deleted branch dev_svc 2026-05-30 23:57:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
luca0N/Sticky!3
No description provided.