471,344 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

ServiceController.ExecuteCommand() throws Exception,...

Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...

TIA,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Jun 27 '08 #1
6 4154
On May 28, 8:25*am, "Kerem Gümrükcü" <kareem...@hotmail.comwrote:
Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...
What error are you getting?
are you sure you have permission?
I do not think that your problem is with the command, but in any case
use a bigger number, like in the 1000
Jun 27 '08 #2
Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!

Thanks for your answer,...

Regards

K.

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comschrieb im
Newsbeitrag
news:76**********************************@q24g2000 prf.googlegroups.com...
On May 28, 8:25 am, "Kerem Gümrükcü" <kareem...@hotmail.comwrote:
Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...
What error are you getting?
are you sure you have permission?
I do not think that your problem is with the command, but in any case
use a bigger number, like in the 1000
Jun 27 '08 #3
Kerem Gümrükcü wrote:
Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!
I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument from
-2147483648 to 2147483647.

HTH,
-rick-
Jun 27 '08 #4
Hi Ricks,
>I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument
from -2147483648 to 2147483647.
http://msdn.microsoft.com/en-us/libr...08(VS.85).aspx

See section "Control Code",...

Obviously the .NET Function calls this or the Ex Function, i didnt check it,
but the case is that it can raise a Win32Exception and it does in my case.
So the Parameter for ExecuteCommand does not rely on its DataType, but
rather on the value. But i see now, that the OS is restricting and reserving
Control Codes below 128 to its private usage and does not accept codes
from an externall application sending them,...

I was looking for some way of doing this to support the complete range of
control codes in my application, but this is AFAIK not possible and i cant
see any bypassing methdo,..and there is no need for anymore,...

Thanks for your reply,...
Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Rick Lones" <Wr******@YcharterZ.netschrieb im Newsbeitrag
news:wG****************@newsfe05.lga...
Kerem Gümrükcü wrote:
>Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!
I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument
from -2147483648 to 2147483647.

HTH,
-rick-

Jun 27 '08 #5
Kerem Gümrükcü wrote:
Hi Rick,

you can bypass this by extending the servicecontroller
and implementing some IPC mechanism to share large
amounts of real data structures between any application
and even any operating system as far your ipc technique
allows this. I solved it with a three way implementation:
sockets, named pipes and shared memory in a single
service. The service can handle sockt connections from
any IPv4 and IPv6 Connections, uses a OutputDebugString
like memory mapped mechanism and also can handle
named pipe connections. This way i can send any data
to the service as a endpoint. You also can use any
communication method like WCF or newer things, it
depends on you,...
Yes, I was thinking that if more data needed to be transferred (not an excessive
amount, just parameters and switch settings and like that) then the custom
command could be used to kick off a message dialog via remoting or some such
mechanism. Looked into it a bit this afternoon - kind of attractive simply
because I haven't done remoting before. As you say, there are a lot of ways . . .

Regards,
-rick-
Jun 27 '08 #6
Hi Rick,

i liked the Memmory Mappped approach if
it will run on the local machine. There will be
no Firewall to configure and it is really fast,
as long it is local and a point to point
communication and you wont serve to more
clients but just one,...

That maybe will give you an insight view:
http://www.codeproject.com/KB/threads/csthreadmsg.aspx

If you want to serve .NET only clients stay at .NET
only technologies. If you want to serve any type
of client, then stay at a mechanism that will be at
Operating System Level and can be "created"
with Windows API Exports, due to the fact that
neraly any modern language can use the windows
API today,...

Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Rick Lones" <Wr******@YcharterZ.netschrieb im Newsbeitrag
news:hB***************@newsfe02.lga...
Kerem Gümrükcü wrote:
>Hi Rick,

you can bypass this by extending the servicecontroller
and implementing some IPC mechanism to share large
amounts of real data structures between any application
and even any operating system as far your ipc technique
allows this. I solved it with a three way implementation:
sockets, named pipes and shared memory in a single
service. The service can handle sockt connections from
any IPv4 and IPv6 Connections, uses a OutputDebugString
like memory mapped mechanism and also can handle
named pipe connections. This way i can send any data
to the service as a endpoint. You also can use any
communication method like WCF or newer things, it
depends on you,...
Yes, I was thinking that if more data needed to be transferred (not an
excessive amount, just parameters and switch settings and like that) then
the custom command could be used to kick off a message dialog via remoting
or some such mechanism. Looked into it a bit this afternoon - kind of
attractive simply because I haven't done remoting before. As you say,
there are a lot of ways . . .

Regards,
-rick-

Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ucasesoftware | last post: by
10 posts views Thread by Bill Burris | last post: by
3 posts views Thread by Bram Hoefnagel | last post: by
1 post views Thread by Martin Arvidsson, Visual Systems AB | last post: by
7 posts views Thread by =?Utf-8?B?YXVsZGg=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.