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.

105 lines
2.3 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. BYTE * pToFar = AlertBuffer + ELF_ADMIN_ALERT_BUFFER_SIZE + sizeof(ADMIN_OTHER_INFO);
  38. DWORD DataSize;
  39. DWORD i;
  40. LPWSTR pReplaceString;
  41. VariableInfo->alrtad_errcode = MessageID;
  42. VariableInfo->alrtad_numstrings = NumStrings;
  43. pReplaceString = (LPWSTR)(AlertBuffer + sizeof(ADMIN_OTHER_INFO));
  44. //
  45. // Copy over the replacement strings
  46. //
  47. for (i = 0; i < NumStrings; i++)
  48. {
  49. if((BYTE *)(pReplaceString + pStrings[i].MaximumLength) < pToFar)
  50. RtlMoveMemory(pReplaceString, pStrings[i].Buffer, pStrings[i].MaximumLength);
  51. pReplaceString = (LPWSTR) ((PBYTE) pReplaceString + pStrings[i].MaximumLength);
  52. }
  53. DataSize = (DWORD) ((PBYTE) pReplaceString - (PBYTE) AlertBuffer);
  54. NetStatus = NetAlertRaiseEx(ALERT_ADMIN_EVENT,
  55. AlertBuffer,
  56. DataSize,
  57. EVENTLOG_SVC_NAMEW);
  58. if (NetStatus != NERR_Success)
  59. {
  60. ELF_LOG2(ERROR,
  61. "SendAdminAlert: NetAlertRaiseEx for alert %d failed %d\n",
  62. MessageID,
  63. NetStatus);
  64. //
  65. // Probably just not started yet, try again later
  66. //
  67. return(FALSE);
  68. }
  69. return(TRUE);
  70. }