Important: Please read the Qt Code of Conduct -

Qt bug with some WINapi

  • 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);
    	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;
    	cout << "total regions: " << regions << endl;
    	cout << "total MEM: " << takenTotal << endl;

    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.

  • I can't really help with your issue but if there is a bug, this is where they are tracked:

  • Lifetime Qt Champion

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

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

  • @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()?


    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

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

Log in to reply