探测Win2K/XP/2003本机系统信息(11)


if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %dn",GetLastError());
__leave;
}
dwNumberBytes = MAX_INFO_BUF_LEN;
pBuffer = (LPVOID)malloc(dwNumberBytes);
Status; = NtQuerySystemInformation(SYSTEM_PAGE_INFO,
pBuffer,
dwNumberBytes,
&dwReturnLength);
if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation for Pagefile Error: %dn",GetLastError());
__leave;
}
pSystemPagefileInfo = (PSYSTEM_PAGEFILE_INFORMATION)pBuffer;
do
{
printf("CurrentPagefileSize:t%dn",pSystemPagefileInfo->CurrentSize);
printf("TotalPagefileUsed:t%dn",pSystemPagefileInfo->TotalUsed);
printf("PeakPagefileUsed:t%dn",pSystemPagefileInfo->PeakUsed);
wprintf(L"PagefileFileName:t%sn",pSystemPagefileInfo->FileName.Buffer);
pSystemPagefileInfo = (PSYSTEM_PAGEFILE_INFORMATION)((char *)pBufferpSystemPagefileInfo->NetxEntryOffset);
}while(pSystemPagefileInfo->NetxEntryOffset != 0);
}
__finally
{
if(pBuffer != NULL)
{
free(pBuffer);
}
if(hNtDll; != NULL)
{
FreeLibrary(hNtDll);
}
}
return 0;
}
DWORD CacheInfo()
{
SYSTEM_CACHE_INFORMATIONSystemCacheInfo;
HMODULEhNtDll = NULL;
DWORD; dwNumberBytes;
DWORD; dwReturnLength;
NTSTATUSStatus;
__try
{
hNtDll = LoadLibrary("NtDll.dll");
if(hNtDll == NULL)
{
printf("LoadLibrary Error: %dn",GetLastError());
__leave;
}
NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %dn",GetLastError());
__leave;
}
dwNumberBytes = sizeof(SYSTEM_CACHE_INFORMATION);
Status; = NtQuerySystemInformation(SYSTEM_CACHE_INFO,
;&SystemCacheInfo,
dwNumberBytes,
&dwReturnLength);
if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation for Cache Error: %dn",GetLastError());
__leave;
}
printf("CacheWorkingSetSize:tt%d(KB)n",SystemCacheInfo.SystemCacheWsSize/1024);
printf("CacheWorkingSetPeakSize:t%d(KB)n",SystemCacheInfo.SystemCacheWsPeakSize/1024);
printf("CacheWorkingSetFaults:tt%dn",SystemCacheInfo.SystemCacheWsFaults);
printf("CacheWorkingSetMinimum:tt%dn",SystemCacheInfo.SystemCacheWsMinimum);
printf("CacheWorkingSetMaximum:tt%dn",SystemCacheInfo.SystemCacheWsMaximum);
printf("TransitionSharedPages:tt%dn",SystemCacheInfo.TransitionSharedPages);
printf("TransitionSharedPagesPeak:t%dn",SystemCacheInfo.TransitionSharedPagesPeak);
}
__finally
{
if(hNtDll != NULL)
{
FreeLibrary(hNtDll);
}
}
return 0;
}
VOID Start()
{
printf("T-PMPerf, by TOo2yn");
printf("E-mail: TOo2y@safechina.netn");
printf("HomePage: www.safechina.netn");
printf("Date: 05-09-2003nn");
return ;
}
VOID Usage()
{
printf("Usage:tT-PMPerf

推荐阅读