Thursday, August 7, 2008
Tuesday, June 24, 2008
Ended runners-up!! A good start.
Not bad! not bad at all, is what i will say for the result of the Infy tournament just ended.
My team ended up being the runners up!
As for me, I played some amazing tennis(my standards :)) against a really great oponent, guy was a senior national player. So i knew i dont stand a chance, so just went ahead and enjoyed playing, no fear, just hit my shots and was able to streach him in the first set till the last stages loosing 5-7.
But more than the game, the things i enjoyed most was meeting soo many good players, now friends...learnt a lot from them.....
Hope to continue ...the good start.
My team ended up being the runners up!
As for me, I played some amazing tennis(my standards :)) against a really great oponent, guy was a senior national player. So i knew i dont stand a chance, so just went ahead and enjoyed playing, no fear, just hit my shots and was able to streach him in the first set till the last stages loosing 5-7.
But more than the game, the things i enjoyed most was meeting soo many good players, now friends...learnt a lot from them.....
Hope to continue ...the good start.
Sunday, June 22, 2008
Played bad today :(
Gosh! Today i played in a tennis tournament after a very long gap, actually dont even remeber when did I last played, i think it was in my school days..
Its a totally different ball-game when you play in a tournament, but i am glad atleast i have started again .
When match started i felt the net was high :) :) funny ...then i was not moving well legs had gone heavy this happened for first few games :) happens i know..but my backhand ditched me totally, played too defensive....... but fought till end....
Never mind its over.
But the good news is that, we(my team) won, it is davis cup style team tournament...fellow players played an amazing doubles and a remarkable reverse singles....so we are in semi-finals...most probably i will be playing tommorow as well...:)
Lets c if my nervousness goes away......................................................................
Its a totally different ball-game when you play in a tournament, but i am glad atleast i have started again .
When match started i felt the net was high :) :) funny ...then i was not moving well legs had gone heavy this happened for first few games :) happens i know..but my backhand ditched me totally, played too defensive....... but fought till end....
Never mind its over.
But the good news is that, we(my team) won, it is davis cup style team tournament...fellow players played an amazing doubles and a remarkable reverse singles....so we are in semi-finals...most probably i will be playing tommorow as well...:)
Lets c if my nervousness goes away......................................................................
Thursday, June 12, 2008
PInvoke DhcpGetServerBindingInfo / DhcpSetServerBindingInfo C# ulong gotcha
Phew!! there is a thing always to remember while pinvoking. ulong is 64bit in c# while 32 bit in win32 world. Learned it hard way .. :)..
The error that you will get if you try to pinvoke if "null reference" .
Here is the signature and code snippet to be used.
[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern uint DhcpGetServerBindingInfo(
[MarshalAs(UnmanagedType.LPWStr)]
string ServerIpAddress,
uint Flags,
out IntPtr BindElementsInfo);
[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern uint DhcpSetServerBindingInfo(
[MarshalAs(UnmanagedType.LPWStr)]
string ServerIpAddress,
uint Flags,
IntPtr BindElementsInfo);
How to call:
IntPtr intptrBindElemArray = new IntPtr();
UInt32 ret;
ret = DhcpGetServerBindingInfo(localIP,
0,
out intptrBindElemArray);
if (ret != 0)
{
int code = 0;
code = (int)ret;
Win32Exception winex = new Win32Exception(code);
handleDHCPError(winex.NativeErrorCode + " : " + winex.Message);
}
Simple right.
Just that searched the hell lot but nobody in the world did it before ... :).
The error that you will get if you try to pinvoke if "null reference" .
Here is the signature and code snippet to be used.
[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern uint DhcpGetServerBindingInfo(
[MarshalAs(UnmanagedType.LPWStr)]
string ServerIpAddress,
uint Flags,
out IntPtr BindElementsInfo);
[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern uint DhcpSetServerBindingInfo(
[MarshalAs(UnmanagedType.LPWStr)]
string ServerIpAddress,
uint Flags,
IntPtr BindElementsInfo);
How to call:
IntPtr intptrBindElemArray = new IntPtr();
UInt32 ret;
ret = DhcpGetServerBindingInfo(localIP,
0,
out intptrBindElemArray);
if (ret != 0)
{
int code = 0;
code = (int)ret;
Win32Exception winex = new Win32Exception(code);
handleDHCPError(winex.NativeErrorCode + " : " + winex.Message);
}
Simple right.
Just that searched the hell lot but nobody in the world did it before ... :).
Sunday, April 27, 2008
Create process in another session.
So how do you create a process in another, different session than which you are logged on. (i am working on Windows Terminal Server 2008 although this can be done in earlier OSs as well)
In order to be able to do this you need to have "LOCAL_SYSTEM" credentials.
The api that will do this is CreateProcessAsUser(), and the most important parameter it will take is the hToken, which will the token of the user logged onto the other session, in which we are creating a process.
CreateProcessAsUser() creates process in the session of the token provided.
The api which will get you the token of that user is, WTSQueryUserToken(), which takes input a sessionid and outputs its token. It is this api which needs "LOCAL_SYSTEM" priveledge.
So i wrote a windows service, which runs as "LOCAL_SYSTEM" and here is very small skeleton code which does the work.
BOOL fSuccess;
HANDLE hToken;
fSuccess = WTSQueryUserToken(
SessionID,
&hToken);
if(!fSuccess){
return -1;
}
fSuccess = CreateProcessAsUser(
hToken,
AppName,
AppName,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartInfo,
&ProcInfo);
if(!fSuccess){
return -1;
}
In order to be able to do this you need to have "LOCAL_SYSTEM" credentials.
The api that will do this is CreateProcessAsUser(), and the most important parameter it will take is the hToken, which will the token of the user logged onto the other session, in which we are creating a process.
CreateProcessAsUser() creates process in the session of the token provided.
The api which will get you the token of that user is, WTSQueryUserToken(), which takes input a sessionid and outputs its token. It is this api which needs "LOCAL_SYSTEM" priveledge.
So i wrote a windows service, which runs as "LOCAL_SYSTEM" and here is very small skeleton code which does the work.
BOOL fSuccess;
HANDLE hToken;
fSuccess = WTSQueryUserToken(
SessionID,
&hToken);
if(!fSuccess){
return -1;
}
fSuccess = CreateProcessAsUser(
hToken,
AppName,
AppName,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartInfo,
&ProcInfo);
if(!fSuccess){
return -1;
}
Subscribe to:
Posts (Atom)