Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

  1. #include "stdafx.h"
  2. #include "CertObj.h"
  3. #include "common.h"
  4. #include "process.h"
  5. //////////////////////////////////////////////////////////////////
  6. BOOL GetProcessName(LPTSTR szProcname, DWORD dwSize)
  7. {
  8. TCHAR szPath[MAX_PATH], szFilename[MAX_PATH], *ptr;
  9. // Get the path to the calling process
  10. if (!GetModuleFileName(NULL, szPath, MAX_PATH))
  11. return FALSE;
  12. // Get the filename of the process without the extension
  13. ptr = _tcsrchr(szPath, '\\');
  14. if (ptr)
  15. _tcscpy(szFilename, ++ptr);
  16. else
  17. _tcscpy(szFilename, szPath);
  18. ptr = _tcsrchr(szFilename, '.');
  19. if (ptr)
  20. *ptr = 0;
  21. // Convert the name to all caps
  22. _tcsupr(szFilename);
  23. // Return the information
  24. if (_tcslen(szFilename) > dwSize)
  25. return FALSE;
  26. _tcscpy(szProcname, szFilename);
  27. return TRUE;
  28. }
  29. BOOL AmIAlreadyRemoted()
  30. {
  31. BOOL bReturn = FALSE;
  32. // check if the process i'm in is inside a Dllhost.exe
  33. TCHAR szProcName[MAX_PATH];;
  34. GetProcessName(szProcName, MAX_PATH);
  35. if (!_tcsicmp(szProcName, _T("DLLHOST")))
  36. {
  37. IISDebugOutput(_T("Remoted in Dllhost\r\n"));
  38. bReturn = TRUE;
  39. }
  40. else
  41. {
  42. IISDebugOutput(_T("InProcess\r\n"));
  43. }
  44. return bReturn;
  45. }