I would like to create a service which would be running with system privileges and I would like to be able to pass information from another script to the service in a secure manor meaning that information cannot easily come from another source for the service to act on, is this possible and if so can you give me an idea of where to start? Thanks.
Not a lot to go on so hard to offer specifics but in general you could pass some sort of encrypted key along with the data for verification. As long as you keep your key(s) secure that should do the job.
Jim
If you need learn about passing information between scripts running in different processes then consider:
- Named Pipe functions as documented in Consolidated WIL help.
- Using a file with a shared name.
- Using Snow++'s shared memory UDFs
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Process~UDFs+UDF~for~Using~Memory~Mapped~Files~for~Interprocess~Communication.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Process~UDFs+UDF~for~Using~Memory~Mapped~Files~for~Interprocess~Communication.txt)
The 'secure' part depends to a great extent to how secure you want the information to be and how you decide to pass the information between script process.
QuoteUsing Snow++'s shared memory UDFs...
Saw my name, had to comment...
I wish I could take credit, but I just found them somewhere in the Tech DB. As far as I can tell, original author unknown.
Also, as much as I would have liked to have used those routines somewhere along the way, as far as I know, I never have. The idea is cool (as it is under Unix), but the application just never seems to quite come up.
P.S. I mention Unix here, because the same thing applies there. Unix has had shared memory for decades now (since the early 80s), and I've always been fascinated by it, but have just never quite gotten around to actually using it in my day-to-day programming.
My apologies. I recalled your advocating of the idea in the past and assumed you were the author. I should know better than to assume...
Quote from: td on May 13, 2015, 09:19:20 PM
My apologies. I recalled your advocating of the idea in the past and assumed you were the author. I should know better than to assume...
No problem.
I have certainly advocated for it - it seems a nice solution to the eternal "So, I've created this thing, but how do I make sure that it gets deleted if my program crashes/exits unexpectedly" question. The fact that, in Windows, it just auto-magically disappears on the last close is nice. I think I have advocated for it as a way of implementing the "How do I check to see if my script is already running" problem, although the other way (the "WinTitle" way) is easier (less code/overhead). I suppose one might use the shared memory trick if for some reason you can't do the WinTitle trick.
We use memory mapped files in a couple of our extenders. It has the advantage of efficiency in that it requires minimal code to implement and a relatively small amount of system resources when executing.
Thanks for the suggestions.
I tried to implement the Shared memory routines which work great while running two scripts as different users however once I had one of the scripts running under the System account it seems to have partitioned memory space because the other script could not detect the shared memory and created a new memory space (which I verified by displaying the handle in both scripts).
Your service and the user script are running in different sessions on newer versions of Windows so try prepending "Global\" to the file name to create a cross session object in the kernel object space.