timus221

Untitled

Mar 2nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3. #include <Psapi.h>
  4. #include <tchar.h>
  5.  
  6. int main(void)
  7. {
  8. FILE* programLog;
  9. fopen_s(&programLog, "C:\\Users\\xblac\\Desktop\\program_log.txt", "w");
  10. WinExec("C:\\Users\\xblac\\AppData\\Roaming\\Spotify\\Spotify.exe", SW_MAXIMIZE);
  11.  
  12. DWORD allProcesessArray[1024] = {0};
  13. DWORD sizeOfAllProcesessArrayInBytes = 0;
  14.  
  15. EnumProcesses(allProcesessArray, sizeof(allProcesessArray), &sizeOfAllProcesessArrayInBytes);
  16.  
  17. DWORD numberOfProcesess = sizeOfAllProcesessArrayInBytes / sizeof(DWORD);
  18. DWORD myProcessId = allProcesessArray[numberOfProcesess - 1];
  19.  
  20. HANDLE myProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, myProcessId);
  21.  
  22. HMODULE allModulesArray;
  23. DWORD sizeOfAllModulesArray;
  24.  
  25. EnumProcessModules(myProcessHandle, &allModulesArray, sizeof(allModulesArray), &sizeOfAllModulesArray);
  26.  
  27. TCHAR myProcessName[MAX_PATH] = TEXT("<no access>");
  28. GetModuleBaseName(myProcessHandle, allModulesArray, myProcessName, sizeof(myProcessName) / sizeof(TCHAR));
  29.  
  30. char myProcessNameCharStr[MAX_PATH];
  31.  
  32. for (int i = 0; i < sizeof(myProcessName) / sizeof(TCHAR); i++)
  33. {
  34. myProcessNameCharStr[i] = myProcessName[i];
  35. }
  36.  
  37. fprintf_s(programLog, "Process Name: %s | PID: %ld \n\n", myProcessNameCharStr, myProcessId);
  38.  
  39. PROCESS_MEMORY_COUNTERS sMemoryCounters;
  40. if (GetProcessMemoryInfo(myProcessHandle, &sMemoryCounters, sizeof(sMemoryCounters)))
  41. {
  42. fprintf_s(programLog, "MEMORY USAGE INFO: \n");
  43. fprintf_s(programLog, "×Page Fault Control: %ld \n", sMemoryCounters.PageFaultCount);
  44. fprintf_s(programLog, "×Peak Working Seat Size: %zd \n", sMemoryCounters.PeakWorkingSetSize);
  45. fprintf_s(programLog, "×Working Set Size: %zd \n", sMemoryCounters.WorkingSetSize);
  46. fprintf_s(programLog, "×Quota Peak Paged Pool Usage: %zd \n", sMemoryCounters.QuotaPeakPagedPoolUsage);
  47. fprintf_s(programLog, "×Quota Page Pool Usage: %zd\n", sMemoryCounters.QuotaPagedPoolUsage);
  48. fprintf_s(programLog, "×Quota Peak Non Paged Pool Usage: %zd \n", sMemoryCounters.QuotaPeakNonPagedPoolUsage);
  49. fprintf_s(programLog, "×Quota Non Paged Pool Usage: %zd \n", sMemoryCounters.QuotaNonPagedPoolUsage);
  50. fprintf_s(programLog, "×Pagefile Usage: %zd \n", sMemoryCounters.PagefileUsage);
  51. fprintf_s(programLog, "×Peak Pagefile Usage: %zd \n\n", sMemoryCounters.PeakPagefileUsage);
  52. }
  53.  
  54. FILETIME startTime;
  55. FILETIME closeTime;
  56. FILETIME kernelTime;
  57. FILETIME userTime;
  58. if (GetProcessTimes(myProcessHandle, &startTime, &closeTime, &kernelTime, &userTime))
  59. {
  60. fprintf_s(programLog, "PROCES TIMING'S INFO:\n");
  61. fprintf_s(programLog, "×Start Time:\n LOW TIME: %ld HIGH TIME: %ld \n",startTime.dwLowDateTime,startTime.dwHighDateTime);
  62. fprintf_s(programLog, "×Close Time:\n LOW TIME: %ld HIGH TIME: %ld \n", closeTime.dwLowDateTime, closeTime.dwHighDateTime);
  63. fprintf_s(programLog, "×KernelMod Time:\n LOW TIME: %ld HIGH TIME: %ld \n", kernelTime.dwLowDateTime, kernelTime.dwHighDateTime);
  64. fprintf_s(programLog, "×UserMod Time:\n LOW TIME: %ld HIGH TIME: %ld \n\n", userTime.dwLowDateTime, userTime.dwHighDateTime);
  65. }
  66.  
  67. PERFORMANCE_INFORMATION sPerformanceInfo;
  68. if (GetPerformanceInfo(&sPerformanceInfo, sizeof(sPerformanceInfo)))
  69. {
  70. fprintf_s(programLog, "MY PROGRAM PERFORMANCE:\n");
  71. fprintf_s(programLog, "×Commit Total: %zd \n", sPerformanceInfo.CommitTotal);
  72. fprintf_s(programLog, "×Commit Limit: %zd \n", sPerformanceInfo.CommitLimit);
  73. fprintf_s(programLog, "×Commit Peak: %zd \n", sPerformanceInfo.CommitPeak);
  74. fprintf_s(programLog, "×Physical Total: %zd \n", sPerformanceInfo.PhysicalTotal);
  75. fprintf_s(programLog, "×Physical Available: %zd \n", sPerformanceInfo.PhysicalAvailable);
  76. fprintf_s(programLog, "×System Cache: %zd \n", sPerformanceInfo.SystemCache);
  77. fprintf_s(programLog, "×Kernel Total: %zd \n", sPerformanceInfo.KernelTotal);
  78. fprintf_s(programLog, "×Kernel Paged: %zd \n", sPerformanceInfo.KernelPaged);
  79. fprintf_s(programLog, "×Kernel Non Paged: %zd \n", sPerformanceInfo.KernelNonpaged);
  80. fprintf_s(programLog, "×Page Size: %zd \n", sPerformanceInfo.PageSize);
  81. fprintf_s(programLog, "×Handle Count: %ld \n", sPerformanceInfo.HandleCount);
  82. fprintf_s(programLog, "×Process Count: %ld \n", sPerformanceInfo.ProcessCount);
  83. fprintf_s(programLog, "×Thread Count: %ld \n", sPerformanceInfo.ThreadCount);
  84. }
  85.  
  86. fclose(programLog);
  87.  
  88. DWORD exitCode;
  89. GetExitCodeProcess(myProcessHandle, &exitCode);
  90.  
  91. Sleep(5000);
  92. TerminateProcess(myProcessHandle, exitCode);
  93. CloseHandle(myProcessHandle);
  94.  
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment