Comments (2)
Hi Tom,
This is more of discussion or feature request. But is there any interest in implementing the winsrv.h stuff like
StartServiceCtrlDispatcher
and associalted api's?
Yes, I think it would be a nice addition to the library.
I find I am trying to implement wrappers around the winsrv api's from windows crate
That's pretty much how winsafe
itself started: as safe wrapper to the good ol' winapi
โ the windows
crate didn't even exist back in those days. Eventually winsafe
evolved to completely remove winapi
as a dependency, which made a lot of things easier and also boosted the compilation time (winsafe
has zero dependencies).
and thought perhaps forking winsafe and implementing them in here.
Seems like a good idea. I would be glad to help you with your fork, until it's stable enough to be merged into the master branch.
the winsrv api's use a lot of types in the winuser.h. So I'm guessing all the consts and structs could be added to the
user/co/consts
anduser/structs
types and maybe add a new feature folder forservice
apis inwinsrv.h
?
The Cargo features of winsafe
are based on the DLLs (kernel32, user32, etc.), and not on the C headers. But there is a very complicated story besides that...
My first attempt was very rigid about the Cargo features, with each item correctly placed according to its DLL. It was beautiful, a super organized library. But I quickly got a lot of headaches with the Windows API C headers. For example: the base of everything is kernel32; advapi32 is built on top of it. SECURITY_DESCRIPTOR
is a struct which is used by many kernel32 calls, however, it is initialized via InitializeSecurityDescriptor
which belongs to... advapi32. Yes, a circular dependency. And just one of many. I had no choice other than aglutinate advapi32 into kernel32 โ you can read this note in the project README. And there are circular dependencies all over the place... it's unbelievable how careless those people were.
That said, let's dive onto your case.
As far as I could see, the winsrv.h
functions belong to advapi32, which would place them into the kernel
Cargo feature within winsafe
. But you're telling me that they use constants and structs from user
, which seems to be... another case of circular dependency. We would have to carefully evaluate each case, to see if we should downgrade the item from user
to kernel
, or upgrade the function from kernel
to user
.
Dealing with stuff like this can be pretty overwhelming, so I suggest you to start simple. Start with the first function call you need, then perform a Cargo check in isolation:
cargo check --features kernel
The proceed to the next function, until something weird appears.
And let me know of your progress, we can work together on this.
from winsafe.
Hello @rodrigocfd
I sent a very preliminary PR here: #100 which is not ready to merge at all but thought it would be useful so you can view it a bit.
After your helpful response and studying the Windows API more I see that the API's for working with Windows Services are similar to working with regular Windows. There is a lot of messaging and the messages are implemented in the user
feature, and the API's for managing services are in the kernel
feature. So I dont know if there is a circular dependency yet however I thought for first attemp I would just implement the service messaging types first. And then later add the kernel stuff.
The winsafe crate has a precedent for everything I needed to do so far, and so I tried my best to follow existing patterns. Let me know what you think and I'll finish adding the messaging types and service api's and comment again if stuck.
from winsafe.
Related Issues (20)
- validate_retrieved_reg_val always fails
- [Question] - Calling windows APIs twice best practice HOT 3
- RegQueryValueEx returning TRANSACTION_REQUEST_NOT_VALID for valid data HOT 6
- nm_custom_draw should provide a mutable reference? HOT 6
- How do you envision WM_USER being used? HOT 1
- `WC::NoValue`? HOT 1
- I don't think `MultiByteToWideChar` and `WideCharToMultiByte` need to add 1 to `num_bytes` HOT 4
- resizable_layout not work as expect HOT 8
- When the new_dlg function is used to create a window, the wm_create event does not work HOT 6
- Async IO should be marked as "unsafe" HOT 1
- CreateToolhelp32Snapshot error when compiling for x86
- Panic in wstring/ QueryFullProcessImageName HOT 3
- How to set up a transparent window๏ผ HOT 1
- please font settings HOT 7
- Add missing API to open app in foreground? HOT 3
- Possible ShellExecuteEx implementation HOT 8
- Linker errors in Windows 7
- Add support for raw-window-handle HOT 3
- Can't run library tests on 0.0.21 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winsafe.