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. Why WINAPI works differently in Qt
Forum Updated to NodeBB v4.3 + New Features

Why WINAPI works differently in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 4 Posters 6.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.
  • jsulmJ jsulm

    @JonB It is LPSTR according to https://docs.microsoft.com/en-us/windows/desktop/api/psapi/nf-psapi-getmodulebasenamea which in turn is char* according to https://msdn.microsoft.com/en-us/library/cc230353.aspx

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #15

    @jsulm
    This isn't my area, so you C++-ers must sort it out! But that doc link says stuff like:

    nSize
    The size of the lpBaseName buffer, in characters.

    That's characters, not bytes. And sizeof() returns, bytes, right? And he might be compiling UNICODE, right? Can I leave this all to you guys, if you're happy that's fine, it was just an observation....

    1 Reply Last reply
    0
    • EngelardE Engelard

      @JonB No, all that stuff with char's does'nt matter because 'tital' number is wrong, and displaying of all that stuff after with simple char array works well.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #16

      @Engelard

      because 'tital' number is wrong

      As I said above, I think you should print out the relevant sizeof()s used to calculate that....

      EngelardE 1 Reply Last reply
      0
      • JonBJ JonB

        @Engelard

        because 'tital' number is wrong

        As I said above, I think you should print out the relevant sizeof()s used to calculate that....

        EngelardE Offline
        EngelardE Offline
        Engelard
        wrote on last edited by
        #17

        @JonB Well, i found different cbNeeded (which inititally DWORD 0). Vs print that is 28(for my test app), when qt print 40.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #18

          @Engelard said in Why WINAPI works differently in Qt:

          Vs print that is 28(for my test app), when qt print 40.

          That's what one would expect since when you link against Qt your app needs more modules.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          JonBJ 1 Reply Last reply
          2
          • EngelardE Offline
            EngelardE Offline
            Engelard
            wrote on last edited by
            #19

            Damn i found it!

            There is one more function in WinApi with postfix Ex: EnumProcessModulesEx. As it said in documentation of first function(which in my example):

            To control whether a 64-bit application enumerates 32-bit modules, 64-bit modules, or both types of modules, use the EnumProcessModulesEx function.

            All was needed is add Ex to that function and one more parameter at the end LIST_MODULES_ALL

            JonBJ 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @Engelard said in Why WINAPI works differently in Qt:

              Vs print that is 28(for my test app), when qt print 40.

              That's what one would expect since when you link against Qt your app needs more modules.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #20

              @Christian-Ehrlicher
              From OP's

              how to print all modules of the selected program
              void MWindow::printModules(DWORD id)

              I assumed he was passing the id of another program's modules, not the one he is running! Just shows...

              EngelardE 1 Reply Last reply
              0
              • EngelardE Engelard

                Damn i found it!

                There is one more function in WinApi with postfix Ex: EnumProcessModulesEx. As it said in documentation of first function(which in my example):

                To control whether a 64-bit application enumerates 32-bit modules, 64-bit modules, or both types of modules, use the EnumProcessModulesEx function.

                All was needed is add Ex to that function and one more parameter at the end LIST_MODULES_ALL

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #21

                @Engelard
                I did think it would be some 64-/32-bit issue...!!!
                Yes, these days you must always look to see if a Windows function has a ...Ex() variant, there are so many of them now!

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Christian-Ehrlicher
                  From OP's

                  how to print all modules of the selected program
                  void MWindow::printModules(DWORD id)

                  I assumed he was passing the id of another program's modules, not the one he is running! Just shows...

                  EngelardE Offline
                  EngelardE Offline
                  Engelard
                  wrote on last edited by Engelard
                  #22

                  @JonB said in Why WINAPI works differently in Qt:

                  I assumed he was passing the id of another program's modules, not the one he is running! Just shows...

                  What :DD

                  ProcessID was100% correct.

                  JonBJ 1 Reply Last reply
                  0
                  • EngelardE Engelard

                    @JonB said in Why WINAPI works differently in Qt:

                    I assumed he was passing the id of another program's modules, not the one he is running! Just shows...

                    What :DD

                    ProcessID was100% correct.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #23

                    @Engelard

                    What :DD

                    ?

                    If you are saying you always pass the current process as id I would have expected you to use GetCurrentProcessId(). And in that case anyway, https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openprocess

                    If you are using GetCurrentProcessId as an argument to this function, consider using GetCurrentProcess instead of OpenProcess, for improved performance.

                    So you might know you're opening the current process, but I don't see anything in your post which indicated that, I assumed it was the id of another process you wanted to examine. Just saying....

                    EngelardE 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Engelard

                      What :DD

                      ?

                      If you are saying you always pass the current process as id I would have expected you to use GetCurrentProcessId(). And in that case anyway, https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openprocess

                      If you are using GetCurrentProcessId as an argument to this function, consider using GetCurrentProcess instead of OpenProcess, for improved performance.

                      So you might know you're opening the current process, but I don't see anything in your post which indicated that, I assumed it was the id of another process you wanted to examine. Just saying....

                      EngelardE Offline
                      EngelardE Offline
                      Engelard
                      wrote on last edited by
                      #24

                      @JonB said in Why WINAPI works differently in Qt:

                      ?

                      Sorry. From my view it seemed like you said that my input of ID was incorrect so function gives "wrong" result.

                      JonBJ 1 Reply Last reply
                      0
                      • EngelardE Engelard

                        @JonB said in Why WINAPI works differently in Qt:

                        ?

                        Sorry. From my view it seemed like you said that my input of ID was incorrect so function gives "wrong" result.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #25

                        @Engelard OIC! NP :)

                        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