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.

236 lines
7.3 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows 4.00 **/
  3. /** Copyright (C) Microsoft Corp., 1994-1995 **/
  4. /*****************************************************************/
  5. /* NWAPI95.H -- Originally NWAPI32.H, renamed due to name conflict.
  6. * common header file NW32 API DLL
  7. *
  8. * History:
  9. *
  10. * 12/14/94 vlads Created
  11. * 12/28/94 vlads Added debugging macros
  12. *
  13. */
  14. //#define STRICT // codework: get strict Windows compilation working
  15. #pragma
  16. //#define WIN32_LEAN_AND_MEAN
  17. #include <windows.h>
  18. #define DEFINE_INTERNAL_PREFIXES 1
  19. #include <msnwdef.h>
  20. #include <msnwapi.h>
  21. #include <string.h>
  22. #include <netlib.h>
  23. #pragma warning(disable : 4200) // Zero sized array
  24. #include <nwnet.h>
  25. #include <npassert.h>
  26. #include <vxdcall.h>
  27. #include <ifs32api.h>
  28. #include <msnwerr.h>
  29. #pragma warning(default : 4200)
  30. //
  31. #define SPN_SET(bits,ch) bits[(ch)/8] |= (1<<((ch) & 7))
  32. #define SPN_TEST(bits,ch) (bits[(ch)/8] & (1<<((ch) & 7)))
  33. // Null strings are quite often taken to be either a NULL pointer or a zero
  34. #define IS_EMPTY_STRING(pch) ( !pch || !*(pch) )
  35. // Macros to validate parameters:
  36. // IS_BAD_BUFFER validates that a buffer is good for writing into.
  37. // lpBuf can be NULL, in which case the buffer is not valid.
  38. // lpdwSize must be a valid pointer, but can point to a value of
  39. // 0 (i.e. a null buffer), in which case the buffer is valid.
  40. #define IS_BAD_BUFFER(lpBuf,lpdwSize) (IsBadReadPtr(lpdwSize, sizeof(LPDWORD)) || IsBadWritePtr(lpBuf, *lpdwSize))
  41. // IS_BAD_STRING validates that a valid NULL terminated string is at
  42. // the specified address. Unlike IsBadStringPtr, no limitation is placed
  43. // upon the string length.
  44. #define IS_BAD_STRING(lpString) (IsBadStringPtr(lpString, 0xffffffff))
  45. #define SEG_INSTANCE ".instance"
  46. #define SEG_SHARED ".data"
  47. #define SEG_CODE ".text"
  48. //
  49. // Macros to define process local storage:
  50. //
  51. #define BEGIN_INSTANCED_DATA data_seg(SEG_INSTANCE,"INSTANCE")
  52. #define END_INSTANCED_DATA data_seg()
  53. #define BEGIN_SHARED_DATA data_seg(SEG_SHARED,"SHARED")
  54. #define END_SHARED_DATA data_seg()
  55. #define BEGIN_READONLY_DATA data_seg(SEG_CODE,"CODE")
  56. #define END_READONLY_DATA data_seg()
  57. void NW32_EnterCriticalSection(void);
  58. void NW32_LeaveCriticalSection(void);
  59. #ifdef DEBUG
  60. extern BOOL g_fCritical;
  61. #endif
  62. #define ENTERCRITICAL NW32_EnterCriticalSection();
  63. #define LEAVECRITICAL NW32_LeaveCriticalSection();
  64. #define ASSERTCRITICAL Assert(g_fCritical);
  65. /*
  66. * External variables reference
  67. *
  68. */
  69. extern BOOL g_fThunkLayerPresent; // Is thunk layer successfully loaded
  70. extern BOOL g_fIfsmgrOpened; // -- IFSMGR -----
  71. extern BOOL g_fSvrOpened ; // -- NWSERVER ---
  72. extern BOOL g_fNSCLOpened; // -- NSCL -------
  73. extern HANDLE g_hRedirDevice ; // Handle of device for NWREDIR
  74. extern HANDLE g_hIfsmgrDevice; // -- IFSMGR
  75. extern HANDLE g_hSvrDevice ; // -- NWSERVER
  76. extern HANDLE g_hNSCLDevice; // -- NSCL
  77. extern HANDLE g_hmtxNW32; // Initialization time mutex
  78. extern HANDLE g_hmodThisDll; // Instance handle for DLL executable
  79. extern CHAR szLocalComputer[];
  80. extern HINSTANCE g_hInst16;
  81. /*
  82. extern "C" BOOL g_fNWCallsLayerPresent; // Accessed from asm modules
  83. extern "C" BOOL g_fDRVLayerPresent; // Is thunk layer successfully loaded
  84. extern "C" BOOL g_fRedirAvailable ; // Is NWREDIR Ioctl entry point available
  85. extern "C" BOOL g_fRedirVLMAvailable ;
  86. */
  87. /*
  88. * Functions prototypes
  89. *
  90. */
  91. /*
  92. // We need to do that because allocator for our classes is using out heap management
  93. void * _cdecl operator new(unsigned int size);
  94. void _cdecl operator delete(void *ptr);
  95. */
  96. //extern "C"
  97. extern HANDLE ConvertToGlobalHandle(HANDLE);
  98. BOOL WINAPI NWRedirInitializeAPI(VOID);
  99. UINT WINAPI NWRedirCallAPI(BYTE bConnectionID,win32apireq *ReqSet);
  100. BYTE WINAPI InterlockedSet(volatile BYTE *pByte);
  101. #ifdef __cplusplus
  102. extern "C" { /* Assume C declarations for C++ */
  103. #endif /* __cplusplus */
  104. WORD WINAPI NWWordSwap(WORD wIn);
  105. DWORD WINAPI NWLongSwap(DWORD dwIn);
  106. WORD _cdecl WordSwap(WORD wIn);
  107. DWORD _cdecl LongSwap(DWORD lIn);
  108. //
  109. // Buffer descriptor used for request and reply buffer fragments in the NCP RequestReply call
  110. //
  111. typedef struct {
  112. char *address;
  113. unsigned short length;
  114. } BUF_DESC;
  115. void __stdcall IFSMGR_W32_Int21(pwin32apireq preq);
  116. NW_STATUS NWRedirVLMAPI(DWORD vlmFunction,win32apireq *pReqSet);
  117. NW_STATUS VLM_NCPRequest(
  118. NWCONN_HANDLE hConn,
  119. UCHAR func,
  120. UINT reqCount, BUF_DESC *reqList,
  121. UINT replyCount, BUF_DESC *replyList);
  122. NW_STATUS WINAPI
  123. NDSRequest(NWCONN_HANDLE hConn, UINT verb, PVOID reqBuf,int reqLen, PVOID replyBuf, int *replyLen);
  124. #ifdef __cplusplus
  125. }
  126. #endif /* __cplusplus */
  127. #ifdef DEBUG
  128. // convert generic Netware status code to error message
  129. extern const char *ErrorMsg(long err);
  130. #endif
  131. #define memcpyW(x,y,z) memcpy(x,y,(z)*sizeof(WCHAR))
  132. #define memmoveW(x,y,z) memmove(x,y,(z)*sizeof(WCHAR))
  133. #define UnicodeToAnsi(u,a) WideCharToMultiByte(CP_ACP,0,u,-1,a,MAX_NDS_NAME_CHARS,0,0)
  134. #define UnicodeToAnsiBuff(u,a,l) WideCharToMultiByte(CP_ACP,0,u,l,a,2*l,0,0)
  135. #define AnsiToUnicode(a,u) MultiByteToWideChar(CP_ACP,0,a,-1,u,MAX_NDS_NAME_CHARS)
  136. // roundup to multiple of 4
  137. #define ROUNDUP4(x) (((x)+3)&(~3))
  138. // NW VLM IDs
  139. #define CONN_VLM 0x10
  140. #define MSNW_VLM 0x1f // private
  141. #define TRAN_VLM 0x20
  142. #define IPX_VLM 0x21
  143. #define TCP_VLM 0x22
  144. #define NWP_VLM 0x30
  145. #define BINDERY_VLM 0x31
  146. #define NDS_VLM 0x32
  147. #define REDIR_VLM 0x40
  148. #define PRINT_VLM 0x42
  149. #define GEN_VLM 0x43
  150. #define NETX_VLM 0x50
  151. // parameter numbers for Connection Entry fields
  152. #define CEI_ERROR 0 // Flag resettable
  153. #define CEI_NET_TYPE 1 // Word
  154. #define CEI_PERM 2 // Flag resettable
  155. #define CEI_AUTH 3 // Flag
  156. #define CEI_PBURST 4 // Flag
  157. #define CEI_CHANGING 5 // Flag resettable
  158. #define CEI_NEEDS_MAXIO 6 // Flag resettable
  159. #define CEI_PBURST_RESET 7 // Flag resettable
  160. #define CEI_VERSION 8 // Word
  161. #define CEI_REF_COUNT 9 // Word
  162. #define CEI_DIST_TIME 10 // Word
  163. #define CEI_MAX_IO 11 // Word
  164. #define CEI_NCP_SEQ 12 // Byte
  165. #define CEI_CONN_NUM 13 // Word
  166. #define CEI_ORDER_NUM 14 // Byte
  167. #define CEI_TRAN_TYPE 15 // Word
  168. #define CEI_NCPREQ_TYPE 16 // Word
  169. #define CEI_TRAN_BUF 17 // Buffer
  170. #define CEI_BCAST 18 // Flag resettable
  171. #define CEI_LIP 19 // Word
  172. #define CEI_SECURITY 20 // Byte
  173. #define CEI_RES_COUNT 21 // Word (lo = hard, high = soft)
  174. #define CEI_LOCKED 22 // Flag resettable
  175. //
  176. // Resource strings
  177. //
  178. #define IDS_RTDLL_NOT_LOADED 10
  179. #define IDS_TITLE_ERROR 11