Results 1 to 20 of 63

Thread: DLL Injection with slots... ?!?!?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: DLL Injection with slots... ?!?!?

    Quote Originally Posted by gilamran View Post
    I'm unable to debug this... so where can I see the console?
    If you start your application on the command line and the slot can't be found a warning will be printed (or inside Qt Creator on the application output), but
    what do you need me to clarify?
    I get the "injecting" wrong (thought you would using QPluginLoader), so your slot should be found. So I am out of ideas right now.

  2. #2
    Join Date
    Oct 2010
    Posts
    48
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    Ok, I'll check the command line error.
    And I'll post a short code that do what I say, maybe it'll be clear than.

    Thanks again!

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DLL Injection with slots... ?!?!?

    I'm assuming you didn't create a plugin. This means a library exporting certain symbols that you use directly in the application you want to inject.

    I assume that you can not change the application code itself directly. If that's not the case, then see the examples and documentation of creating plugins or using libraries.

    Consider the following schema:
    Qt Code:
    1. +-----------------------------------------------------------------------------------------+
    2. | Application |
    3. | |
    4. | +---------------+ +-----------------------------------------+ |
    5. | +---------------+| | Application code, contains objects. | |
    6. | +---------------+|| | | |
    7. | +---------------+||| | mainWindow (a QMainWindow) | |
    8. | | Linked |||+ | | | |
    9. | | libraries ||+ | +-- button (a QPushButton) | |
    10. | | |+ | +-- label (a QLabel) | |
    11. | +---------------+ +-----------------------------------------+ |
    12. | | |
    13. | v |
    14. | +-------------------------------------------------------------------------------------+ |
    15. | | Your injected DLL | |
    16. | | | |
    17. | | +--------------------------+ | |
    18. | | | Class based on QObject | | |
    19. | | | inside DLL | | |
    20. | | | | | |
    21. | | | Contains signals and | | |
    22. | | | slots | | |
    23. | | +--------------------------+ | |
    24. | | | | |
    25. | | v | |
    26. | | +-------------------------------------------------------------------------+ | |
    27. | | | Create an object: | Do this from within a context | | |
    28. | | | | where the application event | | |
    29. | | | MyClass *myclass = new MyClass; | loop is running. | | |
    30. | | +-------------------------------------------------------------------------+ | |
    31. | | | | |
    32. | | v | |
    33. | | +------------------------------------------------+ | |
    34. | | | Example: | | |
    35. | | | Suppose you have installed an application | | |
    36. | | | event filter. | | |
    37. | | | | | |
    38. | | | Also, suppose you intercept the mainWindow | | |
    39. | | | show event. | | |
    40. | | | | | |
    41. | | | From this event, you have a pointer to | | |
    42. | | | mainWindow, let's call it pMainWindow | | |
    43. | | | | | |
    44. | | | Then you can write: | | |
    45. | | | | | |
    46. | | | connect(pMainWindow->button, SIGNAL(...), | | |
    47. | | | myclass, SLOT(...)); | | |
    48. | | | | | |
    49. | | | | | |
    50. | | | In pseudocode: | | |
    51. | | | ---------------------------------------------- | | |
    52. | | | when application started | | |
    53. | | | install eventfilter | | |
    54. | | | | | |
    55. | | | when eventfilter gets called | | |
    56. | | | check the event and the target object | | |
    57. | | | if event = show and object = mainWindow | | |
    58. | | | Create a new MyClass object if none | | |
    59. | | | already exists. | | |
    60. | | | Connect signals and slots | | |
    61. | | | | | |
    62. | | +------------------------------------------------+ | |
    63. | | | |
    64. | +-------------------------------------------------------------------------------------+ |
    65. | |
    66. +-----------------------------------------------------------------------------------------+
    To copy to clipboard, switch view to plain text mode 

    You create a dll that reimplements the application event function to install an event filter.
    In that event filter, you intercept the show event of a widget (for example). While intercepting that event, create a new QObject based object that contains signals and slots. Connect the slots of that object to the signals of the widget (or a member of that widget).

    Make sure that when you build your library, the definitions of all the classes are known (include the correct headers). Also make sure that your code is processed by MOC.

    Then inject the library in the program.

    How this is exactly done on Windows, I don't know. Maybe you don't need to reimplement the event function of the application in order to install an event filter. That would make it a little bit easier.

    EDIT: this is just a brainstorm from me. I do not assume that everything above is 100% correct.
    Last edited by tbscope; 17th October 2010 at 12:56.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    I think what he means is that the application doesn't know about the DLL and is not loading the DLL.

    Instead, he is using Winject to inject the DLL into the applications memory space, the application doesn't know the DLL has been injected. I assume it is being done this way because the source code of the original application isn't available and he wants to modify that application somehow. Maybe get some data from an existing Qt widget or manipulate the data somehow.

    Kinda similar to how flaab wanted to grab data from inside a Poker engine in his thread.

  5. #5
    Join Date
    Oct 2010
    Posts
    48
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    This is almost the same thing... and we're talking about the same software, FullTiltPoker!
    But flaab is asking how to intercept into internal function of QString or somthing like that...
    I want my DLL to get signals from this software, like dataChanged, etc.

    I'm not building a poker bot like flaab, I'm collecting players statistics.

    for this, I need my DLL to be able to "connect" to the software UI signals.
    Thanks for clearing me up.

    Gil.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    For best results in this case, you should use the same compiler as FTP. I'm going to guess that FTP uses something like Visual Studio 2008 rather than QtCreator (big companies don't like using free software)

  7. #7
    Join Date
    Oct 2010
    Posts
    48
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    yea I'm using Visual Studio 2008, How can I tell what's the FTP QT version?

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    Is it dynamically linked? (does it refuse to run if the DLLs are missing?)

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

    Default Re: DLL Injection with slots... ?!?!?

    Can you inject a dll into a statically linked app (which is probably packed or encrypted too) at all?
    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.


  10. #10
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DLL Injection with slots... ?!?!?

    Quote Originally Posted by wysota View Post
    Can you inject a dll into a statically linked app (which is probably packed or encrypted too) at all?
    Short answer: yes
    But: it is extremely difficult. It is done in software cracking. You need to alter the assembly source code.

  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    You can do it without altering the application code at all, if have something that easily identifies the 'target' application (such as the text for the window title or the process name) you can VirtualAllocEx and CreateRemoteThread, then your thread runs in the process space of the application and can do whatever it wishes.

  12. #12
    Join Date
    Oct 2010
    Posts
    48
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL Injection with slots... ?!?!?

    Quote Originally Posted by squidge View Post
    You can do it without altering the application code at all, if have something that easily identifies the 'target' application (such as the text for the window title or the process name) you can VirtualAllocEx and CreateRemoteThread, then your thread runs in the process space of the application and can do whatever it wishes.
    Hey guys, this is not the issue at all...
    It is possible, and this is the working part of my question.
    I'll post my code soon (And you can try it too)

    Back to the original question:
    Can I connect a slot function in my injected dll to the main app?

    Thanks

Similar Threads

  1. Signals & Slots!
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2010, 01:50
  2. Can you use dependency injection with Qt?
    By photo_tom in forum Qt Programming
    Replies: 0
    Last Post: 20th February 2010, 18:34
  3. How do you add slots?
    By rakkar in forum Newbie
    Replies: 10
    Last Post: 26th August 2009, 23:11
  4. Slots or new slots
    By Colx007 in forum Qt Programming
    Replies: 3
    Last Post: 21st January 2008, 17:38
  5. signal and slots
    By vermarajeev in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2007, 08:31

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.