Skip to content

No ipc communication between gui(logged in user) and windows services(Local system account) #105

@sysdev-jay

Description

@sysdev-jay

I have used cpp-IPC between two processes running in a logged-in user session.
but when I try to use the same in GUI and Windows services running as a local system account then no communication happens. Simply client-side sending failed.

I know services run in different sessions (session 0) isolated from logged user sessions.

So I tried changing the Security SECURITY_ATTRIBUTES while creating CreateFileMapping to allow cross-session ipc communication but it still doesn't work.
I don't understand why it still not working.
There might be something that I am doing wrong here.

I have tried changing SECURITY_ATTRIBUTES this way:
File: cpp-ipc\src\libipc\platform\win\get_sa.h

inline LPSECURITY_ATTRIBUTES get_sa() { static struct initiator { //SECURITY_DESCRIPTOR sd_; SECURITY_ATTRIBUTES sa_; bool succ_ = false; initiator() { // Create a security descriptor that allows access to users in other sessions ZeroMemory(&sa_, sizeof(sa_)); sa_.nLength = sizeof(sa_); if(!ConvertStringSecurityDescriptorToSecurityDescriptor( L"D:P(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GWGR;;;IU)", SDDL_REVISION_1, &sa_.lpSecurityDescriptor, NULL)){ ipc::error("fail ConvertStringSecurityDescriptorToSecurityDescriptor[%d]\n", static_cast<int>(::GetLastError())); return; } sa_.nLength = sizeof(SECURITY_ATTRIBUTES); sa_.bInheritHandle = FALSE; succ_ = true; /* **THE OLD CODE IS BELOW** */ // if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) { // ipc::error("fail InitializeSecurityDescriptor[%d]\n", static_cast<int>(::GetLastError())); // return; // } // if (!::SetSecurityDescriptorDacl(&sd_, TRUE, NULL, FALSE)) { // ipc::error("fail SetSecurityDescriptorDacl[%d]\n", static_cast<int>(::GetLastError())); // return; // } // sa_.nLength = sizeof(SECURITY_ATTRIBUTES); // sa_.bInheritHandle = FALSE; // sa_.lpSecurityDescriptor = &sd_; // succ_ = true; } } handle; return handle.succ_ ? &handle.sa_ : nullptr; } 

Why is it not working between cross-session like GUI & service?

Please, please. @mutouyun
Thanks a lot :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions