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.

76 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. event.c
  5. Abstract:
  6. Log formatted events to a file and possibly the console too
  7. Author:
  8. Steve Wood (stevewo) 09-Aug-1994
  9. Revision History:
  10. --*/
  11. #include "instaler.h"
  12. VOID
  13. CDECL
  14. LogEvent(
  15. UINT MessageId,
  16. UINT NumberOfArguments,
  17. ...
  18. )
  19. {
  20. va_list arglist;
  21. HMODULE ModuleHandle;
  22. DWORD Flags, Size;
  23. WCHAR MessageBuffer[ 512 ];
  24. PWSTR s;
  25. ULONG Args[ 24 ];
  26. PULONG p;
  27. va_start( arglist, NumberOfArguments );
  28. p = Args;
  29. while (NumberOfArguments--) {
  30. *p++ = va_arg( arglist, ULONG );
  31. }
  32. *p++ = ((GetTickCount() - StartProcessTickCount) / 1000); // Seconds since the start
  33. *p++ = 0;
  34. va_end( arglist );
  35. Size = FormatMessageW( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  36. (LPCVOID)InstalerModuleHandle,
  37. MessageId,
  38. 0,
  39. MessageBuffer,
  40. sizeof( MessageBuffer ) / sizeof( WCHAR ),
  41. (va_list *)Args
  42. );
  43. if (Size != 0) {
  44. s = MessageBuffer;
  45. while (s = wcschr( s, L'\r' )) {
  46. if (s[1] == '\n') {
  47. wcscpy( s, s+1 );
  48. }
  49. else {
  50. s += 1;
  51. }
  52. }
  53. printf( "%ws", MessageBuffer );
  54. if (InstalerLogFile) {
  55. fprintf( InstalerLogFile, "%ws", MessageBuffer );
  56. }
  57. }
  58. else {
  59. printf( "INSTALER: Unable to get message text for %08x\n", MessageId );
  60. }
  61. return;
  62. }