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. Share data between applications
QtWS25 Last Chance

Share data between applications

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.1k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, I would like to know how to share data between two Qt applications... Lets say that application 1 have some strings which I want to access in application 2... Shared memory or any other way of doing it...

    I would also like to know how to access that data if I am not owner of the application... What I know is that two applications (which are not mine) are sharing data... How do I find out the way they are sharing it and access it?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      You can use a QSharedMemory for this purpose. Maybe in conjunction with a QSystemSemaphore, if you need to implemented something like a "producer vs. consumer" pattern. The "main" (server) application will create the shared memory under a pre-defined key, so the "client" (slave) application can attach to that shared memory. All programs connected to the shared memory will just get a pointer to the shared memory region. You need to make sure that all "well behaving" application synchronize their access to the shared memory properly, so no "evil" things will happen. Of course a "malicious" application could always mess up your shared memory, but there's no easy protection against that case.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks for the answer... If I am not owner of the application, how can I find that pre-defined key, so I can read data and show it in my application?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          You must know the key beforehand, it's as simple as that. If some application exposes data that is intended to be processed by another application via a shared memory, then that application must also define under which fixed key the data will be available. I'd suggest to generate a GUID for this purpose.

          (The application could also use a different key every time, but then the key must be made available at well-known location, e.g. at a specific registry path/key)

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Is there a way to get that key? Reading application memory, reverse engineering, anything else? I guess there must be some program that can find out that key...

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MuldeR
              wrote on last edited by
              #6

              Why should that be needed? If an application intended to share data through a QSharedMemory, it would have to properly document under which key the shared memory is available and - even more important - it would have to properly document the layout of the data that is exposed in its shared memory region.

              Of course, Qt uses underlying Operating System technologies to create the shared memory region. So, with some system tools, like Process Explorer on Windows, you can find the shared memory region - though the "native" key may be different than what you have specified in Qt, because Qt internally computes a Hash of your key! Anyway, all this is completely pointless, as long as you still don't know the data layout inside the shared memory region...


              See also here:
              http://i.imgur.com/17Fykbi.png

              My OpenSource software at: http://muldersoft.com/

              Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

              Go visit the coop: http://youtu.be/Jay...

              1 Reply Last reply
              0
              • W Offline
                W Offline
                wrosecrans
                wrote on last edited by
                #7

                [quote author="Anonymous" date="1416664815"]Is there a way to get that key? Reading application memory, reverse engineering, anything else? I guess there must be some program that can find out that key... [/quote]

                Not in general. There are many ways that applications can share data. So if you want to make your own client for some data source, you'll need to do some tinkering to figure out how the existing apps talk to each other. If it were me, and the apps were on Linux, I'd probably start with a tool like strace to see what system calls were being used. It will give you some idea of whether or not a file is being written somewhere with hint data. Also, lsof will list open files, and can also show information about socket connections.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  MuldeR you was right... Application is doing a lot of work with registry keys... Reading, querying, setting values into registry keys, mapping...

                  1 Reply Last reply
                  0

                  • Login

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