Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 63

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

  1. #21
    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)

  2. #22
    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?

  3. #23
    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?)

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


  5. #25
    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.

  6. #26
    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.

  7. #27
    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

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

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

    Until you provide some code of yours (namely the header file for the class you wish to call a slot from) we're stuck so we might as well get a bit offtopic 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.


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

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

    Here are the files:
    Injected.cpp
    MyQWidget.h
    MyQWidget.cpp
    MyQWidgetMoc.cpp

    I'm injecting this DLL into the BasicLayout example (Comes with QT, run it to see where I'm going with this) , and do two connections:
    1. Line1 with Line2
    2. Line1 with mySlot function

    I than change Line1 text, and see that Line2 also changes, and any change that I do to Line1 are reflected in Line2 too -> The connection is working!
    And I did this connection from my DLL.

    In mySlot function I change the Line3 text (We know that I'm able to do it)
    so if the 2nd connection was successful we would have seen Line3 also change... but it doesn't... -> The connection didn't work!

    I've created MyQWidgetMoc.cpp with moc.exe that comes with QT...

    HELP HELP.
    Thanks

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

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

    So how do you know your slot was not called? And please don't reply that the text on lineEdit3 didn't change.
    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.


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

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

    Quote Originally Posted by wysota View Post
    So how do you know your slot was not called? And please don't reply that the text on lineEdit3 didn't change.
    sorry, but the text on lineEdit3 didn't change...
    If the 2nd connection was working, the lineEdit3 should have changed to "mySlot CALLED, yey"...
    What am I missing!?!?!?

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

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

    Quote Originally Posted by gilamran View Post
    sorry, but the text on lineEdit3 didn't change...
    If the 2nd connection was working, the lineEdit3 should have changed to "mySlot CALLED, yey"...
    What am I missing!?!?!?
    Debugging your application by changing values of lineedits is not a very professional way of doing things. What if you change the value but the change isn't reflected on the widget? Or if something rewrites the old value?

    1. Check the return value of connect()
    2. Use qDebug() or your debugger to see whether the slot is called.
    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.


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

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

    Check the return value of connect()
    The return value is TRUE for both connections

    Use qDebug() or your debugger to see whether the slot is called.
    I can't use a debugger, because this code is an injected dll, and don't know how to use the qDebug()... (Sorry)

    But just to make sure, inside mySlot function I disconnected the first connection, but it wasn't getting disconnected... man! this function is NOT being called!

    I've also tried
    Qt Code:
    1. this->metaObject()->indexOfSlot("mySlot()")
    To copy to clipboard, switch view to plain text mode 
    and got 4!! the information is there! but not being called... :-(

    I'm about to cry! anyone!?

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

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

    Quote Originally Posted by gilamran View Post
    The return value is TRUE for both connections
    So the connection is successfully made.

    I can't use a debugger, because this code is an injected dll,
    It doesn't change anything, you can still run the original application under the control of a debugger together with your dll.

    and don't know how to use the qDebug()... (Sorry)
    So learn to use it.

    But just to make sure, inside mySlot function I disconnected the first connection, but it wasn't getting disconnected... man! this function is NOT being called!

    I've also tried
    Qt Code:
    1. this->metaObject()->indexOfSlot("mySlot()")
    To copy to clipboard, switch view to plain text mode 
    and got 4!! the information is there! but not being called... :-(

    I'm about to cry! anyone!?
    Maybe the respective signal is not emitted
    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.


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

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

    for a better test I did this:
    I've opened the BasicLayout project in Visual Studio, added my MyQWidget.cpp/h and moc and connected the fields there...
    Inside mySlot function I did a qDebug out, and saw it!!! when I do the connection from inside the app it's working! meaning -> MyQWidget is good for receiving signals! the caller is having a problem! maybe it can't find me in some slots table!?

    When a signal is fired, how does QT "know" where to call to?

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

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

    Quote Originally Posted by gilamran View Post
    the caller is having a problem!
    The caller is not having a problem, it is you who has a problem while trying to break into the application.
    maybe it can't find me in some slots table!?
    Maybe the signal is not emitted (I hate to repeat myself)?

    When a signal is fired, how does QT "know" where to call to?
    It looks into the connection table for the object emitting the signal.
    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.


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

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

    Quote Originally Posted by wysota View Post
    It looks into the connection table for the object emitting the signal.
    Where can I see this code? I want to debug it.

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

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

    QMetaObject class, as far as I remember. If not, then it's in QObject. But trust me, you won't be able to debug it, it's complicated. If your connect() statement returned true, it means the connection is placed in the connection table. As long as both interested objects are alive, it will stay there (if you don't disconnect the signal manually).
    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.


  19. #39
    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... ?!?!?

    Post your solution (something loadable into VS or QtC) and we'll have a look at it.

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

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

    The solution is "Qt::DirectConnection"

    I did some deep debugging and found that the code is checking if the caller and the sender are from the same thread... OR Qt::AutoConnection! so I did DirectConnection and it's working!!!!!!!!!!!!!!!!!

    I want to thank all of you guys, for the time and effort! you are the best!

Similar Threads

  1. Signals & Slots!
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2010, 02:50
  2. Can you use dependency injection with Qt?
    By photo_tom in forum Qt Programming
    Replies: 0
    Last Post: 20th February 2010, 19:34
  3. How do you add slots?
    By rakkar in forum Newbie
    Replies: 10
    Last Post: 27th August 2009, 00:11
  4. Slots or new slots
    By Colx007 in forum Qt Programming
    Replies: 3
    Last Post: 21st January 2008, 18:38
  5. signal and slots
    By vermarajeev in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2007, 09: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.