News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MemInfoMicro : The Return

Started by Antariy, October 25, 2010, 09:07:43 PM

Previous topic - Next topic

Magnum

Quote from: ToutEnMasm on October 27, 2010, 07:11:37 AM

Here is the modify sample of masm32 with sources.
He use GlobalMemoryStatusEx instead of GlobalMemoryStatus and wait your futur machines.


ToutEnMasm,

On my machine which has a swapfile of 307,200 Mbs, your program is showing 820 Mbs.

Have a great day,
                         Andy

ToutEnMasm


Quote
On my machine which has a swapfile of 307,200 Mbs, your program is showing 820 Mbs
He can have a little difference with the value indicated by  the systeme.(config panel -- systeme)
The Unit used by the systeme panel is in GiB (power of 2 more near of  a GB )
Usually the disk capacity is given in GB instead of GiB (it is like that in my country).
But the difference couldn't be so big (*2)
Are you sure of your number ?.



Magnum

Have a great day,
                         Andy

jj2007

Magnum,
what do you get with Alex' new version?

Magnum

Quote from: ToutEnMasm on October 27, 2010, 07:11:37 AM

Here is the modify sample of masm32 with sources.
He use GlobalMemoryStatusEx instead of GlobalMemoryStatus and wait your futur machines.


meminfo is giving 648 for swapfile.

The actual value of my pagefile.sys is 384 MB (402,653,184 bytes)

This is the value on a system with XP Pro Sp3.

Error also occurs on my XP home Edition.

Have a great day,
                         Andy

Antariy

Quote from: jj2007 on October 28, 2010, 04:36:35 PM
Magnum,
what do you get with Alex' new version?

This is big quiet, probably  :bg

On Win9x, returned the really params of the *SWAP file* in the dwXXXPageFile. So, info returned by GlobalMemoryStatus is show really values of the things.
On WinNT, with no differency between GlobalMemoryStatus/Ex, returned the size of *available virtual memory*, not just size of swap file.
But this is not simpe sum of size of RAM + size of the swap file, this is sum with substraction of the some working size, which is differents from versions of system, moreover, it is dependent from total size of VM.

So, this is not a bug of any program - see results shown by *ANY* program which is used APIs to gets the sizes of memorys. They will show the same results.

This is just extension/changement in Windows NT - it show to program the real size of memory, which can be allocated in total, instead of showing simple size of the swap file.



Alex

Antariy

Quote from: ToutEnMasm on October 28, 2010, 04:39:00 AM
Quote
I wonder why you still post my *old* (even remaked) programs to thread
This allow useful comparisons between the versions,that all.

I hope I will not looks harming, but they just incomparable.



Alex

Antariy

Hi to all!

Due to some peopes was interested to know how program works, and due to some peoples does not understand main point of this thread :green2, I have written this text, which is explain work of program in general words - this is not require many text to be written, and this is gives easy opportunity to debug program, and understand which part do the explained things.

So.

Program, which is included to the examples of the MASM32 package, and located there: "\masm32\examples\exampl10\MemInfoMicro" just is simple example, written by me more than 2 years ago.
But that program inspire me to make the new one, which is something like the current program. But the history of that is too long, and current program is not similar to many previous versions, where I have implemented something new, in parallel with decreasing of size and testing across different Windows.

Anybody can see at this thread a remake of the my old MASM32 example, which in result:
Have the uncomfortable showing of results
Have not graphical indicator, which is useful enough
Have not contain an shell icon
Have size at 7168 bytes (7KB)
Uses one code path which is not compatible with Win9x, but appear in Windows 2000...
...And moreover - compiled executable is not runnable even under Windows 2000, due to required subsystem version in PE header is set to 5.1. This is subsystem version of Windows XP, and this is happened due to using default setting of LINK.EXE from MSVC v.10 package.

So, that is without comments... :green2



My work been much more harder, I guess.
So, in short.

Initially program has entry point which is been inside PE-header, because big part of code located at that place.
But on DEP-enabled systems that program not work - due to PE-header placed in first section of .EXE, which is not marked as executable.
The new one is use re-loader, or re-locator, which is copy pieces of the code from header to the end of the single section, which have read/write/execute attributes. So, old good DOS stuffs is still possible at Windows 7, and do a great job :bg

So, after start of program, it firtsly copy all code pieces to the not used place, after than it calls that code, which is already placed as monolithic stuff.
That code do preparations for right work of program on different Windows which is have different opportunities.
In short, that code searches for presence of GlobalMemoryStatusEx, which is present since Win2k, and uses QWORDs for results. If this functions is founded, then program change some variables, which is used further in the code, and have great meaning due to unification of the main algorightm - the *one* code path is works with DWORD or QWORDs.
Also some parts of the code is patched to have opcodes which is loads QWORDs, not DWORDs.

These things provide opportunity of using single unified algo which is works with totally different structures of the different APIs on Windows 9x and Windows 2000 +.

NOTE: under memory size/sizes I have understand any size with no difference between RAM or SWAP.
Main alorithm, which is parse sizes, based on FPU code, which is do conversion to the readable form of results, and to the integer values.
Anybody can see, what program does not use any RTL (like MSVCRT.DLL), so, I was needed in manual preparation of the results to showing them in compfortable fractional decimal format. The integer part of the each size is the one DWORD, passed onto stack, the fractional part is the other DWORD which is passed onto stack.
The memory size units, which is needed for comfortability reading of the fractional results, and further compatibility with greather memory, is changed at the parsing loop, for *each* reported size. So, for example, if your system have 2 GB of memory, but only  1023 MBs is free, then program show this at comfortable manner- "2 GB" and "1023 MB".

So, my current program would not confuse the user with incredible big or strange fractional values - it just change the unit of the memory size, and will show result in more readable form. The more is memory size - not bigger awesome number will be shown, but bigger stand the unit (currently supported units to the ExaBytes - i.e. greatest unit for 64bit integer). The less is memory size - the smaller is unit.


Further, the calculation of the color for indicator is made by code, which is calculates the green and red values of the bitmap channels. After that I have replace the corresponding pixels of the main (and single) icon of the executable.

Probably, anybody was wondered, how I put such high-gradient, up to 48x48 sized TrueColor icon to that file? The 48x48x24 icon will have size ~7 KB itself, but program with icon and all other things have size 7 times smaller? :bg

Maybe this is would be an discovery, maybe - not. This is big discuss itself. So, I have just point to this fact - program have no bad icon.

I hope, after explaining, the program would not appear as something uninteresting thing.


One note: if remove resources (a shell icon) and graphical indicator, then program will have size less than 800 bytes, with the same compatibility and algorithm of showing results. So, resources and icon still the one from the biggest things in the program's file.

And, of course, program's file have no place which is not used for placing of code and/or data. This is parts of control structures of the header, spare places, and places which is trimmed to be compactly. Used some parts of the resources structures also, moreover, the icon contain some parts of imports :bg



Alex

Gunther

Alex,

so we know what you've done. You are a really code Волшебник (kind of magician like Merlin). Thank you.

Gunther
Forgive your enemies, but never forget their names.

Magnum

Quote from: ToutEnMasm on October 27, 2010, 07:11:37 AM

Here is the modify sample of masm32 with sources.
He use GlobalMemoryStatusEx instead of GlobalMemoryStatus and wait your futur machines.


Sorry but...

This is the version I used and the total swapfile results are wrong for both XP Pro and XP Home Edition.

I will be glad to help with any info you need to fix it.



Have a great day,
                         Andy

GregL


Antariy

Anybody have a Windows 95, installed on real or virtual machine? Just curious about test on such great OS  :bg



Alex

MichaelW

Running under Windows 95 OSR2.1:

I forgot to add that the color is off because the monitor on that system has no red output.
eschew obfuscation

Antariy

Quote from: MichaelW on October 30, 2010, 09:54:40 PM
Running under Windows 95 OSR2.1:

Thank you very much, Michael !
Very nicely looks!
Windows 95 not use swap file at all, with 256 MBs of RAM.

So, now is proved that even Win95 can run MemInfoMicro!  :bg



Alex

Antariy

Quote from: MichaelW on October 30, 2010, 09:54:40 PM
I forgot to add that the color is off because the monitor on that system has no red output.

Your archive, which I downloaded at first time, contains the colored image. ???



Alex