flat assembler
Message board for the users of flat assembler.

Index > Windows > MEMORYSTATUS definition is broken for x64

Author
Thread Post new topic Reply to topic
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
1. Wrong sizes of members of structure
2. Wrong names of members of structure
sample definition:
Code:
typedef struct _MEMORYSTATUS {
  DWORD  dwLength;
  DWORD  dwMemoryLoad;
  SIZE_T dwTotalPhys;
  SIZE_T dwAvailPhys;
  SIZE_T dwTotalPageFile;
  SIZE_T dwAvailPageFile;
  SIZE_T dwTotalVirtual;
  SIZE_T dwAvailVirtual;
}MEMORYSTATUS, *LPMEMORYSTATUS;    

http://msdn.microsoft.com/en-us/library/aa366772
Who knows how many more structures are broken this way.
Are they ported automatically from up-to-date header files?

_________________
Any offers?
Post 24 Jun 2009, 08:16
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
i think this errors can be in x86 structures too

ps. is anybody know what probability of such unknown errors in structure/compiler internals/etc?
Post 03 Jul 2009, 16:13
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3055
Location: vpcmipstrm
bitRAKE
Code:
struc MEMORYSTATUS {
        .:
        .dwLength               rd 1
        .dwMemoryLoad           rd 1
        .dwTotalPhys            rq 1    ; SIZE_T
        .dwAvailPhys            rq 1    ; SIZE_T
        .dwTotalPageFile        rq 1    ; SIZE_T
        .dwAvailPageFile        rq 1    ; SIZE_T
        .dwTotalVirtual         rq 1    ; SIZE_T
        .dwAvailVirtual         rq 1    ; SIZE_T
        .. = $ - .

 macro .GlobalMemoryStatus \{
          lea rcx,[.]
         call [GlobalMemoryStatus]
   \}
}

mstat MEMORYSTATUS

mstat.GlobalMemoryStatus
cmp [mstat.dwLength],mstat..
jnz .err    
Some Win32 stuff is missing, but the present stuff should be correct. The Win64 stuff is less accurate.
Post 04 Jul 2009, 07:03
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3055
Location: vpcmipstrm
bitRAKE
Code:
struc MSG {
      .:
      .hwnd           rq 1
        .message        rd 2
        .wParam         rq 1
        .lParam         rq 1
        .time           rd 2
        .pt             POINT
       .. = $ - .
}    
Post 09 Jul 2009, 16:23
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
I read further down and it says:
Quote:
On computers with more than 4 GB of memory, the MEMORYSTATUS structure can return incorrect information, reporting a value of –1 to indicate an overflow. If your application is at risk for this behavior, use the GlobalMemoryStatusEx function instead of the GlobalMemoryStatus function.

So I would guess that If your developing a 64bit program you would use 'GlobalMemoryStatusEX' only.
Post 21 Jul 2009, 01:19
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3055
Location: vpcmipstrm
bitRAKE
My interpretation was that that is only applicable to 32-bit programs on systems with more than 4GB of memory. Because there is sufficient space to report correct values in 64-bit programs. Which also matches my experience.
Post 21 Jul 2009, 02:29
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3055
Location: vpcmipstrm
bitRAKE
Maybe this should be moved to Windows sub-forum?
Post 23 Sep 2010, 04:12
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.