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

Antariy

Hi to all!

Attached to this post is a fully-functional memory reporting utility. This is NOT a usual application; read further.

Program features:

o The Program is compatible and fully functional on Windows systems with any size of memory (RAM and Swap file (sometimes called a paging file)).
In short: The program is not limited to show info only under 4 GB of RAM. It shows the size of memory which is actually installed in the system and supported by the OS. For example, on 32-bit WinXP with PAE enabled, the program will show info about any size of memory, let's say 8 GB. Under old Win9x systems, the program will work and show the proper memory size as well.
o The information is displayed in a format that is comfortable for reading. There are no "crazy" big unreadable numbers, eliminating the need for manual conversion of values. Each size value (i.e. Total RAM size, Free RAM size, Total Paging File size, Free Paging File size) in the results is converted independently.
In short, you may see something like these results (this is an example):

RAM:
Size: 1.998 GB
Free: 987.654 MB
Swap:
Size: 4.998 GB
Free: 3.210 GB


o The program has a useful pseudo-3D "for first-sight" indicator of the free RAM. Indicator has high sensitivity, and graduating from orange color (low amount of free RAM) to green color (high amount of free RAM).
o The program has a shell icon. I'm pointing this out to make it clear that the program does have a Windows resources structure, which contains the icon itself. I.e., the program's file contains about 200 bytes of data which is not required to for functionality, in general; The icon is just "cool stuff" and is what you see as the pseudo-3D indicator from the point above in the program features list (i.e. this point in the features list is just a technical point on the file format and details of complication of implementation in general).
Some parts of the resource structure contains import name strings. Moreover, the control structure of the icon itself contains the imported dll name string (user32.dll).
The resource structure was also modified to be "truncated" a bit. In particular, part of the IAT and part of the resource data are "overheaded" - part of the IAT is actually contained in the start of the resource structure :lol
o The program supposedly works under all Windows versions. The word "supposedly" is not the case for laughing on the "strange_crazy_non-standard-format_etc_etc program", actually, it was tested and working properly on Win95, Win98, Win2000 32 bit (:lol), WinXP 32 bit, Win Vista 32 bit/64 bit, Win7 32 bit/64 bit, Win8 64 bit, and even on Wine 1.3.8. "Supposedly" refers to the fact that the program may not work under future Windows versions. But... any program has a chance to not work under future Windows versions due to some compatibility flaws (also called "revolutionary improvements in the OS").
o The program requires a minimum of a i386 CPU with FPU hardware. Recommended configuration is the i486DX and compatible or better (due to fwait omission) ::)
o The program does not require any runtime libraries (like msvcrt*.dll, crtdll.dll or similar) - it imports the kernel32.dll and user32.dll only.
Decimal fraction notation of FP numbers is supported via tricky "final-integer" code + just wsprintfA of user32.dll, including proper substitution of memory size units. Also, this part of the code (conversion of the binary size of the memory to the resulting formatted string) uses a self-modifying trick for supporting memory of any size, including the possibility of old Win9x.
o The programs size is under 1 KB. It is so small, and works because it has proper format. It works not because of curiousity, but because of the labour that I put into it. So, there is no place for comments about some "specifications", "standards" and "right way of doing things" - it is in compliance with them... This is a fancy remake of the program - stuff just for fun, and that's all.


Originally, the program was not assembled with MASM, it was not recompilable at all and had no textual source code. The program file was just built/edited/modified/developed_further, manually, in the HEX-editor.
The program uses a really crazy-modified PE file to be as small as possible, while maintaining functionality. For this reason, some crappy AVs could easily "proudly reveal" that the program is a virus. This is not true ::)

For now I will try to solve the source code omission problem, and will make the program recompilable. The only thing which will not be implemented in the "sources-mode" program tweak is the resource icon. Due to impossibility of resource modification in a straightforward manner.

Differencies between MemInfoMicro.exe (the original handmade program EXE) and MemInfoMicro25.exe (source-code tweak):
Source-code mode has no icon and thus, no graphical indicator with the code to make it change color; it has no initial code loader which builds startup code from the pieces placed in the header; it does not use self-modifing code; the programs file is a pure PE-file - it is compatible with any operating system, as much as possible, even the author's post-processed source-code compiled EXE, which is placed in the archive.

Notes on source-code tweak: Even if it isn't straightforward, we can still do some tricks :bg We can put some strings in the stub field of the PE header. This is actually a proper method, in accordance with the spec. So, I've made the binary stub with the required strings, and 3 BATch files for program compilation - one is the standard, simple compilation without any tricks. The other two - for LINK and POLINK, which use a crafted stub as the "data section". When you use one of these two BATch files, you'll get an EXE file with a size of 1 KB, and this file will be straightforwardly compatible with the spec. So, still, this is the program with the size of 1 KB (author's post-processed EXE is under 1 KB, and it is still in full compliance with the specifications). Read comments in the BAT files.



Testing on any Windows systems is greatly appreciated, as well as reporting any flaws. Also very much appreciated are reports about successful tests on Windows operating systems not listed in the tested OS list in the program features list.


Many thanks to Frank (frktons) for patient testing of the program under Windows 7 x64!
Many thanks to MASM32 project, which inspired me to build these kinds of utilities!
Many thanks to all people who will test or have already tested this program and report(ed) results.
Many thanks to Alan (redskull) who found a non-exiting bug due to hanging on parasitive thread on some configurations of Win Vista.
Many thanks to Dave (dedndave) who was very kind to check and to properly edit the text you're reading, as well as comments in the sources.


You may use this program any way you want, so long as you preserve the copyright (it is MINE :)), and at your own risk.
This program is not a virus, but I have no responsibility for usage of the information provided or techniques used in this program.

The archive attached to this post contains the program. Feedback and testing is welcome.

Antariy

There is an screenshots under different Windows, to prove my text:



Thanks to Frank for making screenshot under Windows 7 x64!

Not needed to download file attached to *this* post - it is just image which is shown in this post.


Alex

Antariy

I cannot believe - no one download the program! Peoples, this is NOT a virus!!!



Alex

jj2007

Quote from: Antariy on October 25, 2010, 09:37:02 PM
I cannot believe - no one download the program! Peoples, this is NOT a virus!!!

Avira says it's a virus - but I trust you more than I trust Avira, of course :green2

Alex, you are a madman, but it works just fine!
:U

frktons

The first posted image is what my Win7/64 bit ultimate shows.

Great job. Nobody knows, except Alex, how he got this small size.

Frank
Mind is like a parachute. You know what to do in order to use it :-)

Antariy

Quote from: jj2007 on October 25, 2010, 09:48:57 PM
Quote from: Antariy on October 25, 2010, 09:37:02 PM
I cannot believe - no one download the program! Peoples, this is NOT a virus!!!

Avira says it's a virus - but I trust you more than I trust Avira, of course :green2

Alex, you are a madman, but it works just fine!
:U

Thank you, Jochen!
When I first time send program to Frank for testing, his mail served disallow him to download archive - server says what it found a virus  :green2



Alex
P.S why I'm madman?  :bg

Antariy

Quote from: frktons on October 25, 2010, 09:51:14 PM
The first posted image is what my Win7/64 bit ultimate shows.

Great job. Nobody knows, except Alex, how he got this small size.

Well, just documentation of this program is harder than writing it  :green2
Jokes apart - for documenting all things would be needed write text which will be bigger than program at 20 times, at least. With consideration of my English - this is not so simple thing to do.



Alex

Gunther

Alex,



rock solid and well done  :U. Do you plan to release the source?

Gunther
Forgive your enemies, but never forget their names.

jj2007

Quote from: Antariy on October 25, 2010, 09:52:14 PM
P.S why I'm madman?  :bg

Only a madman can squeeze so much functionality in 1008 bytes :U

Antariy

Quote from: Gunther on October 25, 2010, 10:37:43 PM
Alex,


rock solid and well done  :U. Do you plan to release the source?

Sources is not available - they just does not exist  :bg
This is handmade in hex editor.



Alex

Antariy

Quote from: Gunther on October 25, 2010, 10:37:43 PM


rock solid and well done  :U. Do you plan to release the source?

Old good WinXP - more than 75% of system resources serves to user, not to OS  :green2



Alex

dedndave

looks great here, Alex   :U



(XP Pro)

redskull

On Vista, the program does not exit properly (each instance of the process remains in task manager, and must be killed manually).  Otherwise, nice work. 

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Antariy

Quote from: dedndave on October 25, 2010, 11:14:48 PM
looks great here, Alex   :U



(XP Pro)

Thank you, Dave!

You have not only WinXP Pro, but WinXP Media Center Edition, as I see?  :bg



Alex

dedndave

yes - that's correct
for this, it is the same OS as XP Pro   :P

i need to buy some memory - lol