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
    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?)

  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: 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.


  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... ?!?!?

    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.

  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... ?!?!?

    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.

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

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


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

  8. #8
    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: 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.


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

  10. #10
    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: 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.


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

  12. #12
    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: 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.


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.