Results 1 to 9 of 9

Thread: Open an in-memory file with the default system application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open an in-memory file with the default system application

    Quote Originally Posted by wysota View Post
    That's not exactly what I meant. If you're on Windows, you can use WinAPI to ask for the default app registered to handle a particular file type and if it is in a list of solutions known to work, then call it.
    Still would be a no generic and no guaranteed solution, because nothing assures that the default application will be able to read the data buffer. In that case would be impossible to open the file stored in the BLOB and would have to create a temporary file anyway.

    The combination of trying to get the default app to open the in-memory file + creating a temporary file as a fallback method would be the safest, but honestly I can't see the difference between creating a temporary file now and then and creating it every time: creating the file only when strictly needed is safer than creating it every time, but both are unsafe anyway.

    Quote Originally Posted by wysota View Post
    A possible solution would be to use an encrypted ramdisk filesystem to store those temporary files.
    I'm confused; the default system app ought to have read access to that encrypted ramdisk filesystem, and (correct me if I'm wrong) that would only be possible if the whole system has access to such ramdisk. I mean, the app (and the OS) would see the ramdisk as any other filesystem present in the computer, encrypted or not. As I said to Rhayader, the temporary files wouldn't survive a reboot, but besides that I can't see the benefit in using a ramdisk.

    Maybe I'm not getting the point. If so, please tell me.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Open an in-memory file with the default system application

    Quote Originally Posted by berzasnon View Post
    Still would be a no generic and no guaranteed solution, because nothing assures that the default application will be able to read the data buffer.
    Going this way, there is never a generic and guaranteed solution because there might be no default application for a particular file type installed at all and creating a temporary file wouldn't have helped either.

    I'm confused; the default system app ought to have read access to that encrypted ramdisk filesystem, and (correct me if I'm wrong) that would only be possible if the whole system has access to such ramdisk.
    No, not really. It should be possible to execute the program with special privileges that allow it access to a particular directory, disallowing anyone else.

    besides that I can't see the benefit in using a ramdisk.
    The 'ramdisk' part is not important here. The 'encrypted' is.

    If you're expecting to thwack a magic wand and have a ready solution then that's probably not going to happen. I'm sure your requirement can be fulfilled but you need to get your hands dirty in the low-level system behaviour. You would be much better asking your question on some geek Windows forum than here.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open an in-memory file with the default system application

    Quote Originally Posted by wysota View Post
    No, not really. It should be possible to execute the program with special privileges that allow it access to a particular directory, disallowing anyone else.

    The 'ramdisk' part is not important here. The 'encrypted' is.

    If you're expecting to thwack a magic wand and have a ready solution then that's probably not going to happen. I'm sure your requirement can be fulfilled but you need to get your hands dirty in the low-level system behaviour. You would be much better asking your question on some geek Windows forum than here.
    Don't get me wrong, I'm not expecting a magic wand solution, I'm just concerned about the effort/benefit ratio. I can get my hands dirty and finally have to create a temporary file anyway in some situations, so I think it's not worth the effort. Since the use of temporary files is not strictly forbidden, I think in this case is justified to use them.

    Funny thing: I have been testing, and if I create a .pdf temporary file and open it with the default application (Sumatra PDF, can't tell if the result would be the same with Adobe Reader), I can delete the file inmediately after being opened (a really temporary file, a few seconds of life span) and Sumatra PDF will keep showing the file and won't complain. Obviously it doesn't lock the files it opens. That makes sense, since it opens the file for read-only access.

    Maybe getting every application to open the temporary file as read-only...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Open an in-memory file with the default system application

    Quote Originally Posted by berzasnon View Post
    Funny thing: I have been testing, and if I create a .pdf temporary file and open it with the default application (Sumatra PDF, can't tell if the result would be the same with Adobe Reader), I can delete the file inmediately after being opened (a really temporary file, a few seconds of life span) and Sumatra PDF will keep showing the file and won't complain. Obviously it doesn't lock the files it opens. That makes sense, since it opens the file for read-only access.
    Firstly, on Windows, most apps usually open files in exclusive mode so you won't be able to delete the file. Secondly, deleting the file does not delete it from disk, it can still be accessed using freely available tools. Thirdly, even if there is no file, if an app keeps the data in memory, a clever attacker can access it directly from the process memory. If you don't have a secure application that prevents all these (and regular apps don't) your system will not be safe.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 19th October 2010, 06:33
  2. Replies: 4
    Last Post: 16th February 2010, 17:42
  3. Open pdf file in the standard app system
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2008, 15:34
  4. How to open a HTML-file with the default webbrowser?
    By Teuniz in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2007, 11:58
  5. How to open a document with the default application?
    By SkripT in forum Qt Programming
    Replies: 7
    Last Post: 30th April 2006, 08:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.