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.

86 lines
1.6 KiB

  1. //
  2. // Enable driver verifier support for ntoskrnl
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. // module: genutil.cxx
  7. // author: DMihai
  8. // created: 04/19/99
  9. // description: genaral purpose utility routines
  10. //
  11. #include <windows.h>
  12. #include <tchar.h>
  13. #include "resutil.hxx"
  14. #include "genutil.hxx"
  15. //////////////////////////////////////////////////////////////
  16. void
  17. __cdecl
  18. DisplayMessage(
  19. UINT uFormatResId,
  20. ... )
  21. {
  22. TCHAR strMsgFormat[ 256 ];
  23. BOOL bResult;
  24. va_list prms;
  25. va_start (prms, uFormatResId);
  26. bResult = GetStringFromResources(
  27. uFormatResId,
  28. strMsgFormat,
  29. ARRAY_LEN( strMsgFormat ) );
  30. if( bResult == TRUE )
  31. {
  32. _vtprintf ( strMsgFormat, prms);
  33. _tprintf ( _TEXT( "\n" ) );
  34. }
  35. va_end (prms);
  36. }
  37. ///////////////////////////////////////////////////////////////////
  38. //
  39. // Function:
  40. //
  41. // ConvertAnsiStringToTcharString
  42. //
  43. // Description:
  44. //
  45. // This function converts an ANSI string to a TCHAR string,
  46. // that is ANSO or UNICODE.
  47. //
  48. // The function is needed because the system returns the active
  49. // modules as ANSI strings.
  50. //
  51. BOOL
  52. ConvertAnsiStringToTcharString (
  53. LPBYTE Source,
  54. ULONG SourceLength,
  55. LPTSTR Destination,
  56. ULONG DestinationLength)
  57. {
  58. ULONG Index;
  59. for (Index = 0;
  60. Index < SourceLength && Index < DestinationLength - 1;
  61. Index++) {
  62. if (Source[Index] == 0) {
  63. break;
  64. }
  65. Destination[Index] = (TCHAR)(Source[Index]);
  66. }
  67. Destination[Index] = 0;
  68. return TRUE;
  69. }