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. Inject .dll into Qt and call functions

Inject .dll into Qt and call functions

Scheduled Pinned Locked Moved Unsolved General and Desktop
dll
36 Posts 9 Posters 15.2k 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.
  • Johannes SJ Johannes S

    @kshegunov said:

    Does the window resize itself though, the clipping aside?

    So yeah, the window is smaller/bigger than before. Only the client area doesn't adjust properly.
    I've tried sending QResizeEvents, but that didnt really help.

    Isn't there a way to monitor the functions that are being called? If I could do that, I could resize the window by mouse and watch which functions are being used to resize..

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #19

    @Johannes-S said:

    Isn't there a way to monitor the functions that are being called?

    In an optimized compiled code (like Qt that's used in this case), no, not really. The compiler have probably inlined whatever it could and stripped many of the call instructions (you'd expect such when a function is called). And even if it hadn't it would take ages to sift through the assembly, and all that for a dubious result. The stack frame won't have any references to function names, only to addresses, so it's simply not worth even trying.

    One thing you could attempt is to inspect the properties of the main window or the central widget. It may be set to not resize through the size policy and/or minimum/maximum size, or in some other fashion. Currently, I don't have any better ideas.

    Although I haven't done this, as a last resort you could in principle try to overwrite the virtual table, if in fact the resizeEvent function was overriden ...

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JulienMaille
      wrote on last edited by
      #20

      Isn't it the purpose of GammaRay?
      https://github.com/KDAB/GammaRay

      kshegunovK 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #21

        Hi, just a thought
        Maybe try to use findChildren and dump all ClassNames to see
        how its structured.
        That might give hints on what we need to target to resize.
        also as @kshegunov, dump sizepol, min,max and geometry
        for all Widgets owned by mainwin and childs.

        1 Reply Last reply
        0
        • J JulienMaille

          Isn't it the purpose of GammaRay?
          https://github.com/KDAB/GammaRay

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #22

          @JulienMaille
          Possibly, but I don't know if it'll work without the debug information. Worth a try though.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • Johannes SJ Offline
            Johannes SJ Offline
            Johannes S
            wrote on last edited by
            #23

            Thanks a million guys, didn't have time to look into it today, but I'll try everything out tomorrow and let you know how it worked!

            1 Reply Last reply
            0
            • Johannes SJ Offline
              Johannes SJ Offline
              Johannes S
              wrote on last edited by Johannes S
              #24

              Okay, I've tried to dump some info on the window. This is what I got:

              Dumping window info:
              Class name: TableMainWidget
              Horizontal size policy: 5 Vertical size policy: 5
              Minimum size: 480/340
              Maximum size: 2560/1815
              44 children found:
              
              Class name: QRubberBand
              
              Class name: QWidget
              Form
              Class name: TableLayoutWidget
              
              Class name: QGraphicsView
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              Form
              Class name: CMinigamesTitleWidget
              
              Class name: QWidget
              
              Class name: QGraphicsView
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QGraphicsView
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QScrollArea
              
              Class name: QWidget
              Form
              Class name: CMinigamesPanelWidget
              
              Class name: QWidget
              
              Class name: QWebView
              Betfair
              Class name: QWebView
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QScrollBar
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              
              Class name: QWidget
              

              Not that helpful so far...I'm trying to get GammaRay to work.

              EDIT: So, I've cloned the git repo and cmake. I've used the cmake gui to build GammaRay with the visual studio 12 compiler. Then I've opened the solution file and built it with Qt5.
              For two files, I'm getting this error:

              qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in main.obj
              

              The other 70 succeed. I then tried to start the gammaray.exe, but I'm getting:
              error1
              error2

              What am I doing wrong here? Sorry that I seem to be so incompetent, I'm always struggling with this sh*t..

              J kshegunovK 2 Replies Last reply
              0
              • Johannes SJ Johannes S

                Okay, I've tried to dump some info on the window. This is what I got:

                Dumping window info:
                Class name: TableMainWidget
                Horizontal size policy: 5 Vertical size policy: 5
                Minimum size: 480/340
                Maximum size: 2560/1815
                44 children found:
                
                Class name: QRubberBand
                
                Class name: QWidget
                Form
                Class name: TableLayoutWidget
                
                Class name: QGraphicsView
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                Form
                Class name: CMinigamesTitleWidget
                
                Class name: QWidget
                
                Class name: QGraphicsView
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QGraphicsView
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QScrollArea
                
                Class name: QWidget
                Form
                Class name: CMinigamesPanelWidget
                
                Class name: QWidget
                
                Class name: QWebView
                Betfair
                Class name: QWebView
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QScrollBar
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                
                Class name: QWidget
                

                Not that helpful so far...I'm trying to get GammaRay to work.

                EDIT: So, I've cloned the git repo and cmake. I've used the cmake gui to build GammaRay with the visual studio 12 compiler. Then I've opened the solution file and built it with Qt5.
                For two files, I'm getting this error:

                qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in main.obj
                

                The other 70 succeed. I then tried to start the gammaray.exe, but I'm getting:
                error1
                error2

                What am I doing wrong here? Sorry that I seem to be so incompetent, I'm always struggling with this sh*t..

                J Offline
                J Offline
                JulienMaille
                wrote on last edited by JulienMaille
                #25

                @Johannes-S GammaRay needs to be compiled for exactly the Qt version you are using in the application you are debugging (and on most platforms even with the same compiler and compiler settings)

                https://github.com/KDAB/GammaRay/wiki/Getting-GammaRay

                Johannes SJ 1 Reply Last reply
                0
                • Johannes SJ Johannes S

                  Okay, I've tried to dump some info on the window. This is what I got:

                  Dumping window info:
                  Class name: TableMainWidget
                  Horizontal size policy: 5 Vertical size policy: 5
                  Minimum size: 480/340
                  Maximum size: 2560/1815
                  44 children found:
                  
                  Class name: QRubberBand
                  
                  Class name: QWidget
                  Form
                  Class name: TableLayoutWidget
                  
                  Class name: QGraphicsView
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  Form
                  Class name: CMinigamesTitleWidget
                  
                  Class name: QWidget
                  
                  Class name: QGraphicsView
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QGraphicsView
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QScrollArea
                  
                  Class name: QWidget
                  Form
                  Class name: CMinigamesPanelWidget
                  
                  Class name: QWidget
                  
                  Class name: QWebView
                  Betfair
                  Class name: QWebView
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QScrollBar
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  
                  Class name: QWidget
                  

                  Not that helpful so far...I'm trying to get GammaRay to work.

                  EDIT: So, I've cloned the git repo and cmake. I've used the cmake gui to build GammaRay with the visual studio 12 compiler. Then I've opened the solution file and built it with Qt5.
                  For two files, I'm getting this error:

                  qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in main.obj
                  

                  The other 70 succeed. I then tried to start the gammaray.exe, but I'm getting:
                  error1
                  error2

                  What am I doing wrong here? Sorry that I seem to be so incompetent, I'm always struggling with this sh*t..

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #26

                  @Johannes-S
                  Besides Gamma ray, i'd suggest focusing your investigations on CMinigamesPanelWidget subclass (possibly on Betfair as well).

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • J JulienMaille

                    @Johannes-S GammaRay needs to be compiled for exactly the Qt version you are using in the application you are debugging (and on most platforms even with the same compiler and compiler settings)

                    https://github.com/KDAB/GammaRay/wiki/Getting-GammaRay

                    Johannes SJ Offline
                    Johannes SJ Offline
                    Johannes S
                    wrote on last edited by
                    #27

                    @JulienMaille Yeah I figured that out, but I wasn't even able to start GammaRay without attaching it to anything...

                    1 Reply Last reply
                    0
                    • Johannes SJ Offline
                      Johannes SJ Offline
                      Johannes S
                      wrote on last edited by Johannes S
                      #28

                      Thank you very much, all of you who helped me here!
                      I finally got it to work today. It was the TableLayoutWidget, which I had tried to resize before, but I made a stupid mistake...I checked if the className was equal to "TableLayoutWidget" and resized only if it was. However, since I received the classname as a const char* the comparison to a string always failed and nothing happened...

                      So now all thats left to do is to find a way to easily communicate with the process to resize windows without reinjecting a .dll every time.

                      Thanks again!

                      EDIT: Do you know if there's a way to automatically subclass (SetWindowLong with a new WndProc) all windows of a process?

                      kshegunovK 1 Reply Last reply
                      1
                      • Johannes SJ Johannes S

                        Thank you very much, all of you who helped me here!
                        I finally got it to work today. It was the TableLayoutWidget, which I had tried to resize before, but I made a stupid mistake...I checked if the className was equal to "TableLayoutWidget" and resized only if it was. However, since I received the classname as a const char* the comparison to a string always failed and nothing happened...

                        So now all thats left to do is to find a way to easily communicate with the process to resize windows without reinjecting a .dll every time.

                        Thanks again!

                        EDIT: Do you know if there's a way to automatically subclass (SetWindowLong with a new WndProc) all windows of a process?

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by kshegunov
                        #29

                        @Johannes-S
                        I'm glad it worked.

                        So now all thats left to do is to find a way to easily communicate with the process to resize windows without reinjecting a .dll every time.

                        This may not be possible, although don't hold me to that statement.

                        Do you know if there's a way to automatically subclass (SetWindowLong with a new WndProc) all windows of a process?

                        I have no clue what you're talking about, but it's probably just me. I haven't developed for Windows for quite a lot of years.

                        Kind regards.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          patxi
                          wrote on last edited by patxi
                          #30

                          Hi, sorry for the bump. I am upping this because I'd like to share some more thoughts about this topic with @Johannes-S. I hope I didn't break any rules.

                          mrjjM 1 Reply Last reply
                          0
                          • P patxi

                            Hi, sorry for the bump. I am upping this because I'd like to share some more thoughts about this topic with @Johannes-S. I hope I didn't break any rules.

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #31

                            @patxi
                            Its quite ok
                            but the poster has not been online for 10 month so you might have better luck just posting a new question
                            regarding GammaRay and see what happens :)

                            1 Reply Last reply
                            0
                            • Y Offline
                              Y Offline
                              yue.feng
                              wrote on last edited by
                              #32

                              @Johannes-S
                              hi , i use CreateRemoteThread to inject a dll into a qt application ,after QCoreApplication::instance()->installEventFilter (this);
                              eventFilter doesnt work... i dont know why...please help

                              jsulmJ 1 Reply Last reply
                              0
                              • Y yue.feng

                                @Johannes-S
                                hi , i use CreateRemoteThread to inject a dll into a qt application ,after QCoreApplication::instance()->installEventFilter (this);
                                eventFilter doesnt work... i dont know why...please help

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #33

                                @yue-feng said in Inject .dll into Qt and call functions:

                                please help

                                How? You don't provide much information.
                                Did you verify that QCoreApplication::instance()->installEventFilter (this) is called?
                                If it is called did you do any debugging to see whether you event filter is called?

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                Y 1 Reply Last reply
                                1
                                • jsulmJ jsulm

                                  @yue-feng said in Inject .dll into Qt and call functions:

                                  please help

                                  How? You don't provide much information.
                                  Did you verify that QCoreApplication::instance()->installEventFilter (this) is called?
                                  If it is called did you do any debugging to see whether you event filter is called?

                                  Y Offline
                                  Y Offline
                                  yue.feng
                                  wrote on last edited by yue.feng
                                  #34

                                  @jsulm
                                  i tested yesterday, the reason why eventFilter doesnt work is that the ptr get from QCoreApplication::instance() is nullptr.....
                                  i think i use QCoreApplication::instance() in a wrong place...

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • Y yue.feng

                                    @jsulm
                                    i tested yesterday, the reason why eventFilter doesnt work is that the ptr get from QCoreApplication::instance() is nullptr.....
                                    i think i use QCoreApplication::instance() in a wrong place...

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #35

                                    @yue-feng said in Inject .dll into Qt and call functions:

                                    i think i use QCoreApplication::instance() in a wrong place

                                    Yes, looks like you use it before QCoreApplication instance is created.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    Y 1 Reply Last reply
                                    1
                                    • jsulmJ jsulm

                                      @yue-feng said in Inject .dll into Qt and call functions:

                                      i think i use QCoreApplication::instance() in a wrong place

                                      Yes, looks like you use it before QCoreApplication instance is created.

                                      Y Offline
                                      Y Offline
                                      yue.feng
                                      wrote on last edited by yue.feng
                                      #36

                                      @jsulm
                                      the question is solved,Thank you very much

                                      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