郁闷啦,我的是xp1,系统,在vc6.0下将北极星大哥的学习笔记本中的第一个程序编译成功后,不知道为什么没有任何输出?原文链接:http://bbs.pediy.com/showthread.php?threadid=15430
代码是:
#include <windows.h>
#include <fstream.h>
#include"stdio.h"
#include "psapi.h"
#pragma comment ( lib, "psapi.lib" )
int main( ){
ofstream fout ( "EnumProcessAndModule.txt" );
DWORD dwProcessId[1024], cbNeededProcess;
if ( !EnumProcesses( dwProcessId, sizeof(dwProcessId), &cbNeededProcess ) )
return 0;
for ( unsigned int i = 0; i < ( cbNeededProcess/sizeof(DWORD) ); i++ ){
char szProcessName[MAX_PATH] = "unknown";
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, dwProcessId[i] );
if ( NULL != hProcess )
{
HMODULE hMods[1024];
DWORD cbNeededModule ;
if ( EnumProcessModules( hProcess, hMods, sizeof(hMods), &cbNeededModule ) )
{
PROCESS_MEMORY_COUNTERS ProcessMemCounters ;
GetProcessMemoryInfo ( hProcess, &ProcessMemCounters, sizeof(ProcessMemCounters) ) ;
fout << "ProcessId : " << dwProcessId[i] << endl ;
fout << "Process Memory information:" << endl ;
fout << "PageFaultCount :" << hex << ProcessMemCounters.PageFaultCount << endl ;
fout << "PeakWorkingSetSize :" << hex << ProcessMemCounters.PeakWorkingSetSize << endl ;
fout << "WorkingSetSize :" << hex << ProcessMemCounters.WorkingSetSize << endl ;
fout << "QuotaPeakPagedPoolUsage :" << hex << ProcessMemCounters.QuotaPeakPagedPoolUsage << endl ;
fout << "QuotaPagedPoolUsage :" << hex << ProcessMemCounters.QuotaPagedPoolUsage << endl ;
fout << "QuotaPeakNonPagedPoolUsage :" << hex << ProcessMemCounters.QuotaPeakNonPagedPoolUsage << endl ;
fout << "QuotaNonPagedPoolUsage :" << hex << ProcessMemCounters.QuotaNonPagedPoolUsage << endl ;
fout << "PagefileUsage :" << hex << ProcessMemCounters.PagefileUsage << endl ;
fout << "PeakPagefileUsage :" << hex << ProcessMemCounters.PeakPagefileUsage << endl ;
for ( unsigned int j = 0; j < ( cbNeededModule/sizeof(DWORD) ); j++ )
{
char szModuleName[MAX_PATH];
if ( GetModuleFileNameEx ( hProcess, hMods[j], szModuleName, sizeof(szModuleName) ) )
{
fout << '\t' << szModuleName << hex << "(0x" << hMods[j] << ")" << endl ;
MODULEINFO ModuleInfo ;
if ( GetModuleInformation ( hProcess, hMods[j], &ModuleInfo, sizeof(ModuleInfo) ) )
{
fout << "\t\tBaseOfDll : " << ModuleInfo.lpBaseOfDll << endl ;
fout << "\t\tSizeOfImage : " << ModuleInfo.SizeOfImage << endl ;
fout << "\t\tEntryPoint : " << ModuleInfo.EntryPoint << endl ;
}
}
}
fout << endl << endl ;
}
CloseHandle( hProcess );
}
}
return 0 ;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课