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.

85 lines
1.8 KiB

  1. #include "precomp.h"
  2. #define MAX_MSG_LENGTH 512
  3. VOID
  4. OEMfprintf(
  5. IN HANDLE hHandle,
  6. IN PWCHAR pwszUnicode
  7. )
  8. {
  9. PCHAR achOem;
  10. DWORD dwLen, dwWritten;
  11. dwLen = WideCharToMultiByte( CP_OEMCP,
  12. 0,
  13. pwszUnicode,
  14. -1,
  15. NULL,
  16. 0,
  17. NULL,
  18. NULL );
  19. achOem = malloc(dwLen);
  20. if (achOem)
  21. {
  22. WideCharToMultiByte( CP_OEMCP,
  23. 0,
  24. pwszUnicode,
  25. -1,
  26. achOem,
  27. dwLen,
  28. NULL,
  29. NULL );
  30. WriteFile( hHandle, achOem, dwLen-1, &dwWritten, NULL );
  31. free(achOem);
  32. }
  33. }
  34. #define OEMprintf(pwszUnicode) \
  35. OEMfprintf( GetStdHandle(STD_OUTPUT_HANDLE), pwszUnicode)
  36. int _cdecl
  37. wmain (
  38. int argc,
  39. WCHAR *argv[]
  40. )
  41. {
  42. DWORD dwMsglen;
  43. PWCHAR pwszOutput;
  44. WCHAR rgwcInput[MAX_MSG_LENGTH];
  45. pwszOutput = NULL;
  46. do
  47. {
  48. dwMsglen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
  49. NULL,
  50. MSG_HELP,
  51. 0L,
  52. (PWCHAR)&pwszOutput,
  53. 0,
  54. NULL);
  55. if(dwMsglen == 0)
  56. {
  57. break;
  58. }
  59. OEMprintf(pwszOutput);
  60. }while(FALSE);
  61. if(pwszOutput)
  62. {
  63. LocalFree(pwszOutput);
  64. }
  65. return ERROR;
  66. }