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.

61 lines
2.0 KiB

  1. #include "precomp.h"
  2. #include "ScriptKiller.h"
  3. // the only one we'll ever need
  4. CScriptKillerTimer g_scriptKillerTimer;
  5. // last meal is the scheduled execution date
  6. HRESULT CScriptKillerTimer::ScheduleAssassination(IActiveScript* pScript, FILETIME lastMeal, SCRIPTTHREADID threadID)
  7. {
  8. HRESULT hr = WBEM_E_FAILED;
  9. CScriptKiller* pKiller;
  10. if (pKiller = new CScriptKiller(pScript, lastMeal, threadID, m_pControl))
  11. hr = CKillerTimer::ScheduleAssassination(pKiller);
  12. else
  13. // allocation failed
  14. hr = WBEM_E_OUT_OF_MEMORY;
  15. return hr;
  16. }
  17. // terminate script
  18. void CScriptKiller::Die()
  19. {
  20. if (m_pScript)
  21. {
  22. EXCEPINFO info;
  23. ZeroMemory(&info, sizeof(EXCEPINFO));
  24. HRESULT hr;
  25. // regardless of what the dox say, KB article Q182946 says to pass NULL for the second parm. Really.
  26. // experimentation shows that zero-ing out the info struct works, too.
  27. //hr = pScript->InterruptScriptThread(m_threadID, &info, 0);
  28. hr = m_pScript->SetScriptState(SCRIPTSTATE_DISCONNECTED);
  29. hr = m_pScript->InterruptScriptThread(SCRIPTTHREADID_ALL, &info, 0);
  30. }
  31. /***********************
  32. stream method
  33. if (m_pStream)
  34. {
  35. EXCEPINFO info;
  36. ZeroMemory(&info, sizeof(EXCEPINFO));
  37. IActiveScript* pScript;
  38. HRESULT hr = CoGetInterfaceAndReleaseStream(m_pStream, IID_IActiveScript, (LPVOID *) &pScript);
  39. m_pStream = NULL;
  40. // regardless of what the dox say, KB article Q182946 says to pass NULL for the second parm. Really.
  41. // experimentation shows that zero-ing out the info struct works, too.
  42. //hr = pScript->InterruptScriptThread(m_threadID, &info, 0);
  43. hr = pScript->InterruptScriptThread(SCRIPTTHREADID_ALL, &info, 0);
  44. hr = pScript->SetScriptState(SCRIPTSTATE_DISCONNECTED);
  45. pScript->Release();
  46. }
  47. *****************************/
  48. }