Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSharedMemory between local process and Windows Service
Forum Updated to NodeBB v4.3 + New Features

QSharedMemory between local process and Windows Service

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AccWhid
    wrote on 30 Mar 2020, 22:36 last edited by
    #1

    We have been successfully using shared memory to communicate between several Windows processes. However, we've recently run into an issue with sharing memory between a Windows service and a local user process.

    Whenever the local process or the service attempts to attach to shared memory created by the other process we get the error "QSharedMemory::handle: doesn't exist".

    When running the service as a command line application everything works fine.

    I'm assuming this has something to do with how Windows handles services, but can't find any good information on the subject. Does anyone have any potential insight or is this an invalid workflow?

    Thanks!

    J 1 Reply Last reply 31 Mar 2020, 07:40
    0
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 30 Mar 2020, 23:09 last edited by
      #2

      It's a security feature. windoze services run in a different context to prevent exactly what you are trying to do.

      1 Reply Last reply
      2
      • A AccWhid
        30 Mar 2020, 22:36

        We have been successfully using shared memory to communicate between several Windows processes. However, we've recently run into an issue with sharing memory between a Windows service and a local user process.

        Whenever the local process or the service attempts to attach to shared memory created by the other process we get the error "QSharedMemory::handle: doesn't exist".

        When running the service as a command line application everything works fine.

        I'm assuming this has something to do with how Windows handles services, but can't find any good information on the subject. Does anyone have any potential insight or is this an invalid workflow?

        Thanks!

        J Offline
        J Offline
        JonB
        wrote on 31 Mar 2020, 07:40 last edited by JonB
        #3

        @AccWhid
        As @Kent-Dorfman says, Windoze is precisely preventing you from trying to do something as naughty as this! :) You certainly don't want to be sharing memory between elevated and user processes. It's "an invalid workflow" in that you shouldn't be sharing memory like this!

        I think you're going to really have to rethink your mode of operation. What do you use it for? You would normally be expected to share data via socket/file, which is a quite different architecture. Otherwise, I don't know, you might find that you can use "named" shared memory/memory mapped files to achieve this, e.g. read https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory.

        1 Reply Last reply
        2

        1/3

        30 Mar 2020, 22:36

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved