Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <Windows.h>
- #include <Psapi.h>
- #include <tchar.h>
- int main(void)
- {
- FILE* programLog;
- fopen_s(&programLog, "C:\\Users\\xblac\\Desktop\\program_log.txt", "w");
- WinExec("C:\\Users\\xblac\\AppData\\Roaming\\Spotify\\Spotify.exe", SW_MAXIMIZE);
- DWORD allProcesessArray[1024] = {0};
- DWORD sizeOfAllProcesessArrayInBytes = 0;
- EnumProcesses(allProcesessArray, sizeof(allProcesessArray), &sizeOfAllProcesessArrayInBytes);
- DWORD numberOfProcesess = sizeOfAllProcesessArrayInBytes / sizeof(DWORD);
- DWORD myProcessId = allProcesessArray[numberOfProcesess - 1];
- HANDLE myProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, myProcessId);
- HMODULE allModulesArray;
- DWORD sizeOfAllModulesArray;
- EnumProcessModules(myProcessHandle, &allModulesArray, sizeof(allModulesArray), &sizeOfAllModulesArray);
- TCHAR myProcessName[MAX_PATH] = TEXT("<no access>");
- GetModuleBaseName(myProcessHandle, allModulesArray, myProcessName, sizeof(myProcessName) / sizeof(TCHAR));
- char myProcessNameCharStr[MAX_PATH];
- for (int i = 0; i < sizeof(myProcessName) / sizeof(TCHAR); i++)
- {
- myProcessNameCharStr[i] = myProcessName[i];
- }
- fprintf_s(programLog, "Process Name: %s | PID: %ld \n\n", myProcessNameCharStr, myProcessId);
- PROCESS_MEMORY_COUNTERS sMemoryCounters;
- if (GetProcessMemoryInfo(myProcessHandle, &sMemoryCounters, sizeof(sMemoryCounters)))
- {
- fprintf_s(programLog, "MEMORY USAGE INFO: \n");
- fprintf_s(programLog, "×Page Fault Control: %ld \n", sMemoryCounters.PageFaultCount);
- fprintf_s(programLog, "×Peak Working Seat Size: %zd \n", sMemoryCounters.PeakWorkingSetSize);
- fprintf_s(programLog, "×Working Set Size: %zd \n", sMemoryCounters.WorkingSetSize);
- fprintf_s(programLog, "×Quota Peak Paged Pool Usage: %zd \n", sMemoryCounters.QuotaPeakPagedPoolUsage);
- fprintf_s(programLog, "×Quota Page Pool Usage: %zd\n", sMemoryCounters.QuotaPagedPoolUsage);
- fprintf_s(programLog, "×Quota Peak Non Paged Pool Usage: %zd \n", sMemoryCounters.QuotaPeakNonPagedPoolUsage);
- fprintf_s(programLog, "×Quota Non Paged Pool Usage: %zd \n", sMemoryCounters.QuotaNonPagedPoolUsage);
- fprintf_s(programLog, "×Pagefile Usage: %zd \n", sMemoryCounters.PagefileUsage);
- fprintf_s(programLog, "×Peak Pagefile Usage: %zd \n\n", sMemoryCounters.PeakPagefileUsage);
- }
- FILETIME startTime;
- FILETIME closeTime;
- FILETIME kernelTime;
- FILETIME userTime;
- if (GetProcessTimes(myProcessHandle, &startTime, &closeTime, &kernelTime, &userTime))
- {
- fprintf_s(programLog, "PROCES TIMING'S INFO:\n");
- fprintf_s(programLog, "×Start Time:\n LOW TIME: %ld HIGH TIME: %ld \n",startTime.dwLowDateTime,startTime.dwHighDateTime);
- fprintf_s(programLog, "×Close Time:\n LOW TIME: %ld HIGH TIME: %ld \n", closeTime.dwLowDateTime, closeTime.dwHighDateTime);
- fprintf_s(programLog, "×KernelMod Time:\n LOW TIME: %ld HIGH TIME: %ld \n", kernelTime.dwLowDateTime, kernelTime.dwHighDateTime);
- fprintf_s(programLog, "×UserMod Time:\n LOW TIME: %ld HIGH TIME: %ld \n\n", userTime.dwLowDateTime, userTime.dwHighDateTime);
- }
- PERFORMANCE_INFORMATION sPerformanceInfo;
- if (GetPerformanceInfo(&sPerformanceInfo, sizeof(sPerformanceInfo)))
- {
- fprintf_s(programLog, "MY PROGRAM PERFORMANCE:\n");
- fprintf_s(programLog, "×Commit Total: %zd \n", sPerformanceInfo.CommitTotal);
- fprintf_s(programLog, "×Commit Limit: %zd \n", sPerformanceInfo.CommitLimit);
- fprintf_s(programLog, "×Commit Peak: %zd \n", sPerformanceInfo.CommitPeak);
- fprintf_s(programLog, "×Physical Total: %zd \n", sPerformanceInfo.PhysicalTotal);
- fprintf_s(programLog, "×Physical Available: %zd \n", sPerformanceInfo.PhysicalAvailable);
- fprintf_s(programLog, "×System Cache: %zd \n", sPerformanceInfo.SystemCache);
- fprintf_s(programLog, "×Kernel Total: %zd \n", sPerformanceInfo.KernelTotal);
- fprintf_s(programLog, "×Kernel Paged: %zd \n", sPerformanceInfo.KernelPaged);
- fprintf_s(programLog, "×Kernel Non Paged: %zd \n", sPerformanceInfo.KernelNonpaged);
- fprintf_s(programLog, "×Page Size: %zd \n", sPerformanceInfo.PageSize);
- fprintf_s(programLog, "×Handle Count: %ld \n", sPerformanceInfo.HandleCount);
- fprintf_s(programLog, "×Process Count: %ld \n", sPerformanceInfo.ProcessCount);
- fprintf_s(programLog, "×Thread Count: %ld \n", sPerformanceInfo.ThreadCount);
- }
- fclose(programLog);
- DWORD exitCode;
- GetExitCodeProcess(myProcessHandle, &exitCode);
- Sleep(5000);
- TerminateProcess(myProcessHandle, exitCode);
- CloseHandle(myProcessHandle);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment