Windows NT 4.0 source code leak
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.

187 lines
2.9 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. nsiutil.hxx
  5. Abstract:
  6. This module contains utility functions used by the NSI client wrappers.
  7. Author:
  8. Steven Zeck (stevez) 03/27/92
  9. --*/
  10. #define UNUSED(t) (void) t
  11. #if !defined(NTENV) && DBG
  12. void
  13. RtlAssert(
  14. void * FailedAssertion,
  15. void * FileName,
  16. unsigned long LineNumber,
  17. char * Message
  18. );
  19. #define ASSERT( exp ) \
  20. if (!(exp)) \
  21. RtlAssert( #exp, __FILE__, __LINE__, 0 )
  22. #else
  23. #define ASSERT( exp )
  24. #endif
  25. unsigned char *
  26. CopyString(
  27. IN char * String
  28. );
  29. unsigned char *
  30. RegGetString(
  31. IN void * RegHandle,
  32. IN char * KeyName
  33. );
  34. void
  35. GetDefaultEntrys(
  36. IN void * Key
  37. );
  38. #ifdef NTENV
  39. extern void
  40. GlobalMutexRequest (
  41. void
  42. );
  43. extern void
  44. GlobalMutexClear (
  45. void
  46. );
  47. #define RequestGlobalMutex() GlobalMutexRequest()
  48. #define ClearGlobalMutex() GlobalMutexClear()
  49. #else
  50. #define RequestGlobalMutex()
  51. #define ClearGlobalMutex()
  52. #endif
  53. extern RPC_STATUS NsiToRpcStatus[];
  54. inline RPC_STATUS
  55. NsiMapStatus(
  56. IN UNSIGNED16 Status
  57. )
  58. {
  59. ASSERT(Status < NSI_S_STATUS_MAX);
  60. return((Status < NSI_S_STATUS_MAX)?
  61. NsiToRpcStatus[Status]: RPC_S_INTERNAL_ERROR);
  62. }
  63. /*++
  64. Class Definition:
  65. WIDE_STRING
  66. Abstract:
  67. This class abstracts the creation of unicode strings. It is normaly
  68. used as an automatic variable to a wrapper function that has an
  69. ASCII interface over a UNICODE one.
  70. --*/
  71. class WIDE_STRING
  72. {
  73. private:
  74. typedef enum { // Indicate how the string was allocated
  75. AllocMemory, // Allocated memory, which must be freed
  76. AllocReference, // Referenced a existing UNICODE string
  77. AllocError // Out of memory indicator
  78. } ALLOC_TYPE;
  79. unsigned short * String; // Unicode string
  80. ALLOC_TYPE AllocMode; // Allocation type
  81. public:
  82. // Construct a unicode string from a ASCII or UNICODE
  83. WIDE_STRING(
  84. IN unsigned char * String
  85. );
  86. WIDE_STRING(
  87. IN unsigned short * StringIn
  88. )
  89. {
  90. AllocMode = AllocReference;
  91. String = StringIn;
  92. }
  93. ~WIDE_STRING()
  94. {
  95. if (AllocMode == AllocMemory)
  96. I_RpcFree(String);
  97. }
  98. // Check to see of constructor failed due to out of memory.
  99. int
  100. OutOfMemory(
  101. )
  102. {
  103. return(AllocMode == AllocError);
  104. }
  105. // Return a pointer to the string.
  106. unsigned short *
  107. operator &()
  108. {
  109. return(String);
  110. }
  111. };
  112. #ifdef NTENV
  113. #define UnicodeToRtString(UnicodeString) RPC_S_OK
  114. void
  115. AsciiToUnicodeNT(
  116. OUT unsigned short *String,
  117. IN unsigned char *AsciiString
  118. );
  119. #else
  120. #define UnicodeToRtString(UnicodeString) UnicodeToAscii(UnicodeString)
  121. #endif
  122. int
  123. UnicodeToAscii(
  124. unsigned short *UnicodeString
  125. );
  126. UNSIGNED16
  127. MapException(
  128. IN RPC_STATUS Exception
  129. );
  130. extern WIDE_STRING *DefaultName;
  131. extern long DefaultSyntax;
  132. extern int fSyntaxDefaultsLoaded;