Home > Software engineering >  Be urgent! I want to use in service program findwindow (namely session0 and session1) to communicate
Be urgent! I want to use in service program findwindow (namely session0 and session1) to communicate

Time:09-24

My demand is that
I have two procedures, one is service program, is a user program
As I now understand, service program in session0 user program in session1 layer
In normal service programs use findwindow and sendmessage is invalid,
I want to achieve now is in a service program to the user program sends the message

Below is the code I find on the Internet, the principle is to modify the window, can make the service routine messages to the window procedure, test
Service program in the service state run this code can be effective communication with the user program, once the Settings for the service procedures, would be invalid,
And set up the "allow the service and desktop interaction" also not make

Also please help to solve the great god, stuck here for two days the


 void the Run () 
{
HWND hWndQQ=NULL;
HWINSTA hstaSave;
LPCWSTR lpStation=L "WinSta0";
LPCWSTR lpDesk=L "default";
HWINSTA hstaUser;

HDESK hdeskSave;
HDESK hdeskUser;

HstaSave=GetProcessWindowStation ();

HstaUser=OpenWindowStation (lpStation, 0, WINSTA_ALL_ACCESS);

SetProcessWindowStation (hstaUser);

HdeskSave=GetThreadDesktop (GetCurrentThreadId ());

HdeskUser=OpenDesktop (lpDesk, 0, FALSE, DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS);
If (hdeskUser==NULL)
{
OutputDebugStringA (" @ xiaohuihui: Open the desktop Failed!" );

}
If (SetThreadDesktop (hdeskUser)==NULL)
{
OutputDebugStringA (" @ xiaohuihui: SetThreadDesktop Failed!" );
}

////////////////////////code here add interactive with the window///////////////////////////
HWndQQ=FindWindow (NULL, L "DiscernPicture");
If (hWndQQ!=NULL)
{
OutputDebugStringA (" @ xiaohuihui: Find the Window Success!" );
}
The else
{
OutputDebugStringA (" @ xiaohuihui: Find the Window Falied!" );
}

SetThreadDesktop (hdeskSave);
SetProcessWindowStation (hstaSave);
CloseDesktop (hdeskUser);
CloseWindowStation (hstaUser);
}

CodePudding user response:

Baidu search "Session0 penetration"?

CodePudding user response:

Search, but can't meet my needs, the current progress is
Interaction services must run in the context of the LocalSystem account, configure interactively run after,
DwServeceType parameters as specified in the CreateService function called when SERVICE_INTERACTIVE_PROCESS flag, services can be configured to run interactively,
However, the following registry entries contain a value NoInteractiveServices, used to control the influence of the SERVICE_INTERACTIVE_PROCESS marks:
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Windows
NoInteractiveServices default value is 0, which means service with SERVICE_INTERACTIVE_PROCESS logo can run interactively, when NoInteractiveServices value is set to a non-zero value, after the start of service, whether or not it set the SERVICE_INTERACTIVE_PROCESS, cannot in interactive mode;


Article 3 above have been realized, but still won't do

CodePudding user response:

Pipe, simple good ~

CodePudding user response:

Shared memory, pipes, dcom, the sock can realize communication
  • Related