Source code of Windows XP (NT5)
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.

105 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. ALERT.C
  5. Abstract:
  6. This file contains the routine that sends the alert to the admin.
  7. Author:
  8. Rajen Shah (rajens) 28-Aug-1991
  9. Revision History:
  10. --*/
  11. //
  12. // INCLUDES
  13. //
  14. #include <eventp.h>
  15. #include <string.h>
  16. #include <lmalert.h> // LAN Manager alert structures
  17. BOOL
  18. SendAdminAlert(
  19. ULONG MessageID,
  20. ULONG NumStrings,
  21. UNICODE_STRING *pStrings
  22. )
  23. /*++
  24. Routine Description:
  25. This routine raises an ADMIN alert with the message specified.
  26. Arguments:
  27. MessageID - Message ID.
  28. NumStrings - Number of replacement strings.
  29. pStrings - Array of UNICODE_STRING Replacement strings.
  30. Return Value:
  31. NONE
  32. --*/
  33. {
  34. NET_API_STATUS NetStatus;
  35. BYTE AlertBuffer[ELF_ADMIN_ALERT_BUFFER_SIZE + sizeof(ADMIN_OTHER_INFO)];
  36. ADMIN_OTHER_INFO UNALIGNED *VariableInfo = (PADMIN_OTHER_INFO) AlertBuffer;
  37. DWORD DataSize;
  38. DWORD i;
  39. LPWSTR pReplaceString;
  40. VariableInfo->alrtad_errcode = MessageID;
  41. VariableInfo->alrtad_numstrings = NumStrings;
  42. pReplaceString = (LPWSTR)(AlertBuffer + sizeof(ADMIN_OTHER_INFO));
  43. //
  44. // Copy over the replacement strings
  45. //
  46. for (i = 0; i < NumStrings; i++)
  47. {
  48. RtlMoveMemory(pReplaceString, pStrings[i].Buffer, pStrings[i].MaximumLength);
  49. pReplaceString = (LPWSTR) ((PBYTE) pReplaceString + pStrings[i].MaximumLength);
  50. }
  51. DataSize = (DWORD) ((PBYTE) pReplaceString - (PBYTE) AlertBuffer);
  52. NetStatus = NetAlertRaiseEx(ALERT_ADMIN_EVENT,
  53. AlertBuffer,
  54. DataSize,
  55. EVENTLOG_SVC_NAMEW);
  56. if (NetStatus != NERR_Success)
  57. {
  58. ELF_LOG2(ERROR,
  59. "SendAdminAlert: NetAlertRaiseEx for alert %d failed %d\n",
  60. MessageID,
  61. NetStatus);
  62. //
  63. // Probably just not started yet, try again later
  64. //
  65. return(FALSE);
  66. }
  67. return(TRUE);
  68. }