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. Qt bug with some WINapi
QtWS25 Last Chance

Qt bug with some WINapi

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.1k 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.
  • EngelardE Offline
    EngelardE Offline
    Engelard
    wrote on last edited by Engelard
    #1

    I did'nt found category with bugs on this forum, so i'm posting this bug here.

    Recently i've made topic about different work of code with WINapi EnumProcessModules ,in VS it returned 7 modules when totally the same code in Qt return only 5. Some processes return same modules, some differ so much like in VS 48 dll's and in Qt 10. So i'm suppose this topic about not just about one bug.

    Today i tried new function called VirtualQueryEx. With it i'm getting info about all memory process takes, here the code in my VS2017:

    #include "stdafx.h"
    #include <Windows.h>
    #include <Psapi.h>
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main()
    {
    	DWORD someID, address = 0, regions = 0, takenTotal = 0;
    	HWND someWindow = FindWindowA(NULL, "TESTs.exe");
    	GetWindowThreadProcessId(someWindow, &someID);
    	HANDLE someHandle = OpenProcess(PROCESS_ALL_ACCESS, false, someID);
    
    	MEMORY_BASIC_INFORMATION memInfo;
    
    	while(VirtualQueryEx(someHandle, (LPCVOID)address, &memInfo, sizeof(memInfo)))
    	{
    		address += memInfo.RegionSize;
    		
    		if(memInfo.State != MEM_FREE)
    		{
                            cout << "Base Address: " << memInfo.BaseAddress << endl;
    			cout << "Region Size: " << memInfo.RegionSize << endl << endl;
    			takenTotal += memInfo.RegionSize;
    			regions++;
    		}
    	}
    	cout << "total regions: " << regions << endl;
    	cout << "total MEM: " << takenTotal << endl;
    
    	cin.get();
    }
    

    It's works absolutely perfectly, scan goes like half second, and it displays me:

    total regions: 86
    total MEM: 48 000 000 or so

    But in Qt it working wrong, much worse then EnumModules about which i told previously, it scans like minutes and might hours i dont know why. I add it in second thread so my textBrowser append Base Address&Region Size each time it found valid. In VS it found 86, in qt it found thousands, and it never stops.

    I'm totally confident that it is a bug from Qt side. Or maybe i don't know something, so clarify me please.

    P.S. if you would try to test this stuff in Qt - do it in threads because whole window will freeze for minutes(or hours, i'm never reach the end of scan).
    P.P.S. the only difference i found in VS and Qt code examples(except simple "cout" stuff) is including "stdafx" in VS when in Qt not possible to include that.

    1 Reply Last reply
    0
    • 6thC6 Offline
      6thC6 Offline
      6thC
      wrote on last edited by
      #2

      I can't really help with your issue but if there is a bug, this is where they are tracked: https://bugreports.qt.io/secure/Dashboard.jspa

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

        I don't see why Qt should have a bug just because a WinAPI - only function does take ages...

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

        EngelardE 1 Reply Last reply
        2
        • Christian EhrlicherC Christian Ehrlicher

          I don't see why Qt should have a bug just because a WinAPI - only function does take ages...

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

          I noticed warning in Qt today, it compiles with it but i thought it might be that important thing:

          alt text
          How can i resolve this? i tried convert it to different VOIDs, but no effect..

          @Christian-Ehrlicher well, because simple code example works correct in first IDE when in Qt it does'nt?

          JonBJ 1 Reply Last reply
          0
          • EngelardE Engelard

            I noticed warning in Qt today, it compiles with it but i thought it might be that important thing:

            alt text
            How can i resolve this? i tried convert it to different VOIDs, but no effect..

            @Christian-Ehrlicher well, because simple code example works correct in first IDE when in Qt it does'nt?

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

            @Engelard
            Are you compiling for 64-bit? I assume DWORD is 32-bits but an address pointer like LPCVOID is 64-bits?
            If that is indeed the case, DWORD address is not a suitable type for passing to VirtualQueryEx()?

            EngelardE 1 Reply Last reply
            2
            • JonBJ JonB

              @Engelard
              Are you compiling for 64-bit? I assume DWORD is 32-bits but an address pointer like LPCVOID is 64-bits?
              If that is indeed the case, DWORD address is not a suitable type for passing to VirtualQueryEx()?

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

              @JonB OMG OMG OMG

              How would i know that...
              No mention about that in MSDN, in VS everything fine, so how would anybody know that.

              Tnx for trace, found solution, change DWORD to DWORD_PTR and everything fine now(but still results are different with modules but atleast no infinite loop).

              DWORD_PTR will be 32-bit on 32-bit Windows and 64-bit on 64-bit Windows

              JonBJ 1 Reply Last reply
              0
              • EngelardE Engelard

                @JonB OMG OMG OMG

                How would i know that...
                No mention about that in MSDN, in VS everything fine, so how would anybody know that.

                Tnx for trace, found solution, change DWORD to DWORD_PTR and everything fine now(but still results are different with modules but atleast no infinite loop).

                DWORD_PTR will be 32-bit on 32-bit Windows and 64-bit on 64-bit Windows

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

                @Engelard
                I don't know how you'd know that. I just thought about it :)

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved