Posted By

breakerzhao on 04/19/12


Tagged

windows


Versions (?)

Kill Rising's popup window


 / Published in: C++
 

Terminate Rising anti-virus program's annoying ad. popup window process "popwndexe.exe", remove from its config file "RsMgrsvc.ini".

  1. // KillPopwnd.cpp
  2. // Description: Kill Rising's fucking popup window program "popwndexe.exe"
  3. //
  4.  
  5. #define _CRT_SECURE_NO_WARNINGS
  6.  
  7. #include <stdio.h>
  8. #include <tchar.h>
  9. #include <string.h>
  10.  
  11. #include <vector>
  12.  
  13. #include <Windows.h>
  14. #include <Psapi.h>
  15.  
  16. #define POPWND_NAME "popwndexe.exe"
  17. #define POPWND_INI "RsMgrsvc.ini"
  18. #define MAX_PROCESSES 1024
  19. #define BUF_SIZE 1024
  20.  
  21. int _tmain(int argc, _TCHAR* argv[])
  22. {
  23. DWORD pids[MAX_PROCESSES];
  24. DWORD bytes;
  25. DWORD procnum;
  26. DWORD i;
  27. HANDLE proc;
  28. TCHAR name[MAX_PATH];
  29.  
  30. if (!EnumProcesses(pids, sizeof(pids), &bytes))
  31. return -1;
  32. procnum = bytes / sizeof(DWORD);
  33.  
  34. // find popwndexe's process
  35. for (i = 0; i < procnum; i++) {
  36. proc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, pids[i]);
  37. if (proc == 0)
  38. continue;
  39. GetModuleBaseName(proc, 0, name, _countof(name));
  40. // _tprintf(_T("%lu: %s\n"), pids[i], name); // TEST
  41. if (_tcsicmp(name, _T(POPWND_NAME)) == 0)
  42. break;
  43. CloseHandle(proc);
  44. }
  45. if (i == procnum) {
  46. _tprintf(_T("process %s doesn't exist\n"), _T(POPWND_NAME));
  47. return 1;
  48. }
  49.  
  50. GetModuleFileNameEx(proc, 0, name, _countof(name));
  51. // kill popwndexe's process
  52. if (!TerminateProcess(proc, 0)) {
  53. _tprintf(_T("failed to terminate process %s\n"), _T(POPWND_NAME));
  54. return -1;
  55. }
  56. CloseHandle(proc);
  57.  
  58. // get popwndexe's ini full path
  59. _TCHAR* p = _tcsrchr(name, _T('\\'));
  60. if (p == 0)
  61. return -1;
  62. *(p + 1) = 0;
  63. if (_tcscat_s(name, _countof(name), _T(POPWND_INI)) != 0)
  64. return -1;
  65.  
  66. // open popwndexe's ini
  67. std::vector<_TCHAR*> lines;
  68. _TCHAR line[BUF_SIZE];
  69. FILE* fs = _tfopen(name, _T("r"));
  70. if (fs == 0)
  71. return -1;
  72.  
  73. // eliminate line containing "popwndexe"
  74. _TCHAR findstr[] = _T(POPWND_NAME);
  75. _tcslwr_s(findstr, _countof(findstr));
  76. while (_fgetts(line, _countof(line), fs) != 0) {
  77. _TCHAR* line2 = _tcsdup(line);
  78. _tcslwr_s(line, _countof(line));
  79. if (_tcsstr(line, findstr) == 0)
  80. lines.push_back(line2);
  81. else
  82. free(line2);
  83. }
  84. fclose(fs);
  85.  
  86. // save popwndexe's ini
  87. fs = _tfopen(name, _T("w"));
  88. if (fs == 0)
  89. return -1;
  90. for (std::vector<_TCHAR*>::iterator j = lines.begin(); j != lines.end(); ++j) {
  91. _fputts(*j, fs);
  92. free(*j);
  93. }
  94. fclose(fs);
  95.  
  96. return 0;
  97. }

Report this snippet  

You need to login to post a comment.