News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MemInfoMicro : The Return

Started by Antariy, May 21, 2012, 11:30:16 AM

Previous topic - Next topic

Antariy

MemInfoMicro : The Return2


Hi to all!

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

Original thread on the Old MASM32 Forum.

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 :biggrin: 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 Gunther who have tested the program on Wine.
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.
Many thanks to John (sinsi) who have tested the programs on Windows 8 x64.


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 original program (handmade MemInfoMicro.exe) and the source code with Author's compiled EXE. Feedback and testing is welcome.

dedndave

well - Dave didn't do the edits, like he should have   :redface:

Antariy

Quote from: dedndave on May 21, 2012, 10:26:43 PM
well - Dave didn't do the edits, like he should have   :redface:

No-no-no, Dave, the main thread message (two messages above of this message) was massively fixed owing to you! Thanks again! :biggrin:

Antariy

The archive attached to this post contains the history of this thread on the Old MASM Forum.