Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Saturday, December 16 2017 @ 10:17 AM CET

System Informations

   

CodingLevel : beginner

OS : windows
Language : C (VC6)

This is a code example on how to get some basic information about the system you are working on.It can also be extended , a real-time memory watcher can be added with just creating a thread.Enjoy.I hope the code talks for itself.



#include <windows.h> 
#include <stdio.h> 
HKEY key;
int ret;
char *Dir = "HARDWAREDESCRIPTIONSYSTEMCENTRALPROCESSOR";
char *string="ProcessorNameString";
unsigned char buffer[100];
unsigned long int t=1024;
double ram;
void main() 
{ 
 
   printf("CPU Informations: n");  
   ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,Dir,0,KEY_READ,&key);
   if( ret != ERROR_SUCCESS ) printf("ERROR!");
   ret = RegQueryValueEx(key,string,NULL,NULL,(unsigned char *)buffer,&t);
   if( ret != ERROR_SUCCESS ) printf("ERROR!");
   RegCloseKey(key);
   printf("  CPU Type:%sn",&buffer);

   SYSTEM_INFO SysInfo; 
   GetSystemInfo(&SysInfo);
   printf("  OEM ID: %un", SysInfo.dwOemId); 
   printf("  Number of processors: %un",SysInfo.dwNumberOfProcessors); 
   printf("  Page size: %un", SysInfo.dwPageSize); 
   printf("  Processor type: %un", SysInfo.dwProcessorType); 
   printf("  Minimum application address: %lxn",SysInfo.lpMinimumApplicationAddress); 
   printf("  Maximum application address: %lxn",SysInfo.lpMaximumApplicationAddress); 
   printf("  Active processor mask: %un",SysInfo.dwActiveProcessorMask); 
   printf("  Processor Level: %un",SysInfo.wProcessorLevel);
   printf("  Processor Revision: %un",SysInfo.wProcessorRevision);
   MEMORYSTATUS SysMem;
   GlobalMemoryStatus(&SysMem);
   printf("RAM Status:n");
   if( SysMem.dwAvailPhys >= 1000000)
   {
	 ram = (double)SysMem.dwAvailPhys/ (double)1024000000;
     printf("  Physical Memory Usage: %u%% ( free: %0.2lfGB )n",SysMem.dwMemoryLoad,ram);
   }
   else
   {
	ram = (double)SysMem.dwAvailPhys / (double)1024000;
    printf("  Physical Memory Usage: %u%% ( free: %.2lfMB )n",SysMem.dwMemoryLoad,ram);
   }
   if( SysMem.dwTotalPhys >= 1000000)
   {
	 ram = ((double)SysMem.dwTotalPhys / (double)1024000000);
     printf("  Total Physical System Memory: %.2fGBn",ram);
   }
   else
   {
	ram = ((double)SysMem.dwTotalPhys / (double)1024000);
    printf("  Total Physical System Memory: %uMBn",ram);
   }
   if( SysMem.dwTotalVirtual >= 1000000)
   {
	if( SysMem.dwAvailVirtual >= 1000000)
	{
     ram = ((double)SysMem.dwAvailVirtual / (double)1024000000);
	 double ram2 = ((double)SysMem.dwTotalVirtual / (double)1024000000);
     printf("  Virual Memory Usage: %0.2lfGB//%0.2lfGBn",ram,ram2);
	}
	else
	{
     ram = ((double)SysMem.dwAvailVirtual / (double)1024000);
	 double ram2 = ((double)SysMem.dwTotalVirtual / (double)1024000);
     printf("  Virual Memory Usage: %0.2lfMB//%0.2lfMBn",ram,ram2);
	}
   }
   else
   {
    ram = ((double)SysMem.dwAvailVirtual / (double)1024000);
	double ram2 = ((double)SysMem.dwTotalVirtual / (double)1024000);
    printf("  Virual Memory Usage: %0.2lfMB//%0.2lfMBn",ram,ram2);
   }
   system("pause");
   
} 
P.S. i also included a pre-compiled version to show how it works:D




What's Related

Story Options

System Informations | 1 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
System Informations
Authored by: detten on Tuesday, May 29 2007 @ 08:07 PM CEST
If you want to be able to retrieve just about every piece of hardware information in a windows system, and you know the very basics of SQL, try WMI (windows management Instrumentation). Its pretty easy to use and offers alot of info.
 Copyright © 2017 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.06 seconds