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.

488 lines
13 KiB

  1. #ifndef __OSSHELP_HPP__
  2. #define __OSSHELP_HPP__
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. #include <it120app.h>
  6. typedef enum tagMBFTPDUType
  7. {
  8. EnumUnknownPDU,
  9. EnumFileOfferPDU,
  10. EnumFileAcceptPDU,
  11. EnumFileRejectPDU,
  12. EnumFileAbortPDU,
  13. EnumFileStartPDU,
  14. EnumFileDataPDU,
  15. EnumPrivateChannelInvitePDU,
  16. EnumPrivateChannelResponsePDU,
  17. EnumNonStandardPDU,
  18. EnumFileErrorPDU,
  19. EnumFileRequestPDU,
  20. EnumFileDenyPDU,
  21. EnumDirectoryRequestPDU,
  22. EnumDirectoryResponsePDU,
  23. EnumPrivilegeRequestPDU,
  24. EnumPrivilegeAssignPDU,
  25. EnumFileEndAcknowledgePDU,
  26. EnumChannelLeavePDU
  27. }
  28. MBFTPDUType;
  29. class GenericPDU
  30. {
  31. protected:
  32. LPSTR m_lpEncodedBuffer;
  33. LONG m_lEncodedDataLength;
  34. IT120AppletSession *m_pAppletSession;
  35. public:
  36. GenericPDU(IT120AppletSession *pAppletSession = NULL, LPCSTR lpszEncodedDataBuffer = NULL)
  37. :
  38. m_lpEncodedBuffer((LPSTR) lpszEncodedDataBuffer),
  39. m_lEncodedDataLength(0),
  40. m_pAppletSession(pAppletSession)
  41. {
  42. }
  43. ~GenericPDU(void);
  44. static MBFTPDUType GenericPDU::DecodePDU(LPSTR lpEncodedBuffer,LONG lBufferSize,
  45. class GenericPDU ** lplplpGenericPDU,
  46. LPCSTR * lpDecodedPDU,UserID MBFTUserID,
  47. IT120AppletSession *pAppletSession = NULL);
  48. void NULLDataBuffer(void) { m_lpEncodedBuffer = NULL; }
  49. LPCSTR GetBuffer(void) { return m_lpEncodedBuffer; }
  50. LONG GetBufferLength(void) { return m_lEncodedDataLength; }
  51. void FreeMCSBuffer (void);
  52. BOOL Encode(void);
  53. };
  54. typedef class GenericPDU FAR * LPGENERICPDU;
  55. const unsigned _MBFT_FILE_COMPRESSED = 0x0001;
  56. const unsigned _MBFT_STANDARD_COMPRESSSION = 0x0002;
  57. class FileOfferPDU : public GenericPDU
  58. {
  59. private:
  60. MBFTFILEHANDLE m_FileHandle;
  61. LONG m_FileSize;
  62. time_t m_FileDateTime;
  63. ChannelID m_DataChannelID;
  64. BOOL m_bAcknowledge;
  65. int m_RosterInstance;
  66. unsigned m_CompressionFlags;
  67. int m_v42bisP1;
  68. int m_v42bisP2;
  69. char m_szFileName[_MAX_PATH];
  70. char m_szCompressionFormat[255];
  71. public:
  72. FileOfferPDU(LPCSTR lpszFileName, MBFTFILEHANDLE iFileHandle,
  73. LONG FileSize,time_t FileDateTime,
  74. ChannelID wChannelID,
  75. BOOL bAcknowledge,
  76. int RosterInstance = 0,
  77. unsigned CompressionFlags = 0,
  78. LPCSTR lpszCompressionFormat = NULL,
  79. int v42bisP1 = 0,
  80. int v42bisP2 = 0);
  81. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  82. LPCSTR GetFileName(void) { return m_szFileName; }
  83. BOOL GetAcknowledge(void) { return m_bAcknowledge; }
  84. LONG GetFileSize(void) { return m_FileSize; }
  85. time_t GetFileDateTime(void) { return m_FileDateTime; }
  86. int GetRosterInstance(void) { return m_RosterInstance; }
  87. unsigned GetCompressionFlags(void) { return m_CompressionFlags; }
  88. LPCSTR GetCompressionFormat(void) { return m_szCompressionFormat; }
  89. ChannelID GetDataChannelID(void) { return m_DataChannelID; }
  90. int Getv42bisP1(void) { return m_v42bisP1; }
  91. int Getv42bisP2(void) { return m_v42bisP2; }
  92. BOOL Encode(void);
  93. };
  94. typedef class FileOfferPDU FAR * LPFILEOFFERPDU;
  95. class FileAcceptPDU : public GenericPDU
  96. {
  97. MBFTFILEHANDLE m_FileHandle;
  98. ChannelID m_DataChannelID;
  99. BOOL m_bAcknowledge;
  100. public:
  101. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  102. FileAcceptPDU(MBFTFILEHANDLE iFileHandle);
  103. BOOL Encode(void);
  104. };
  105. typedef class FileAcceptPDU FAR * LPFILEACCEPTPDU;
  106. class FileRejectPDU : public GenericPDU
  107. {
  108. MBFTFILEHANDLE m_FileHandle;
  109. public:
  110. FileRejectPDU(MBFTFILEHANDLE iFileHandle);
  111. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  112. BOOL Encode(void);
  113. };
  114. typedef class FileRejectPDU FAR * LPFILEREJECTPDU;
  115. class FileAbortPDU : public GenericPDU
  116. {
  117. MBFTFILEHANDLE m_FileHandle;
  118. ChannelID m_DataChannelID;
  119. ChannelID m_TransmitterID;
  120. public:
  121. FileAbortPDU(ChannelID wDataChannelID,
  122. ChannelID wTransmitterID,
  123. MBFTFILEHANDLE iFileHandle);
  124. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  125. ChannelID GetDataChannelID(void) { return m_DataChannelID; }
  126. ChannelID GetTransmitterID(void) { return m_TransmitterID; }
  127. BOOL Encode(void);
  128. };
  129. typedef class FileAbortPDU FAR * LPFILEABORTPDU;
  130. class FileStartPDU : public GenericPDU
  131. {
  132. MBFTFILEHANDLE m_FileHandle;
  133. LONG m_FileSize;
  134. time_t m_FileDateTime;
  135. LPCSTR m_lpszDataBuffer;
  136. BOOL m_bIsEOF;
  137. LONG m_DataLength;
  138. unsigned m_CompressionFlags;
  139. int m_v42bisP1;
  140. int m_v42bisP2;
  141. char m_szFileName[_MAX_PATH];
  142. char m_szCompressionFormat[255];
  143. public:
  144. FileStartPDU(LPCSTR lpszEncodedDataBuffer,
  145. LPCSTR lpszFileName, MBFTFILEHANDLE iFileHandle,
  146. LONG FileSize,time_t FileDateTime,
  147. LPCSTR lpszDataBuffer,int iDataLength,
  148. BOOL bIsEOF,
  149. unsigned CompressionFlags = 0,
  150. LPCSTR lpszCompressionFormat = NULL,
  151. int v42bisP1 = 0,
  152. int v42bisP2 = 0,
  153. IT120AppletSession *pAppletSession = NULL);
  154. LPCSTR GetFileName(void) { return m_szFileName; }
  155. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  156. LPCSTR GetDataBuffer(void) { return m_lpszDataBuffer; }
  157. ULONG GetDataSize(void) { return (ULONG) m_DataLength; }
  158. BOOL GetIsEOF(void) { return m_bIsEOF; }
  159. LONG GetFileSize(void) { return m_FileSize; }
  160. unsigned GetCompressionFlags(void) { return m_CompressionFlags; }
  161. LPCSTR GetCompressionFormat(void) { return m_szCompressionFormat; }
  162. int Getv42bisP1(void) { return m_v42bisP1; }
  163. int Getv42bisP2(void) { return m_v42bisP2; }
  164. BOOL Encode(void);
  165. };
  166. typedef class FileStartPDU FAR * LPFILESTARTPDU;
  167. class FileDataPDU : public GenericPDU
  168. {
  169. MBFTFILEHANDLE m_FileHandle;
  170. BOOL m_bIsEOF;
  171. BOOL m_bAbort;
  172. LPCSTR m_lpszDataBuffer;
  173. LONG m_DataLength;
  174. int m_TotalFiles;
  175. int m_FileIndex;
  176. public:
  177. FileDataPDU(LPCSTR lpszEncodedDataBuffer,
  178. MBFTFILEHANDLE iFileHandle,
  179. LPCSTR lpszDataBuffer,
  180. int iDataLength,
  181. BOOL bIsEOF,
  182. BOOL bAbort,
  183. IT120AppletSession *pAppletSession = NULL);
  184. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  185. LPCSTR GetDataBuffer(void) { return (LPCSTR) m_lpszDataBuffer; }
  186. ULONG GetDataSize(void) { return (ULONG) m_DataLength; }
  187. BOOL GetIsEOF(void) { return m_bIsEOF; }
  188. BOOL GetIsAbort(void) { return m_bAbort; }
  189. BOOL Encode(void);
  190. };
  191. typedef class FileDataPDU FAR * LPFILEDATAPDU;
  192. class PrivateChannelInvitePDU : public GenericPDU
  193. {
  194. ChannelID m_ControlChannelID;
  195. ChannelID m_DataChannelID;
  196. BOOL m_bIsBroadcast;
  197. public:
  198. PrivateChannelInvitePDU(ChannelID wControlChannelID,
  199. ChannelID wDataChannelID,
  200. BOOL bIsBroadcast);
  201. ChannelID GetControlChannel(void) { return m_ControlChannelID; }
  202. ChannelID GetDataChannel(void) { return m_DataChannelID; }
  203. BOOL Encode(void);
  204. };
  205. typedef class PrivateChannelInvitePDU FAR * LPPRIVATECHANNELINVITEPDU;
  206. class PrivateChannelResponsePDU : public GenericPDU
  207. {
  208. ChannelID m_ControlChannelID;
  209. BOOL m_bJoinedChannel;
  210. public:
  211. PrivateChannelResponsePDU(ChannelID wControlChannelID,BOOL bJoinedChannel);
  212. ChannelID GetControlChannel(void) { return m_ControlChannelID; }
  213. BOOL GetWasChannelJoined(void) { return m_bJoinedChannel; }
  214. BOOL Encode(void);
  215. };
  216. typedef class PrivateChannelResponsePDU FAR * LPPRIVATECHANNELRESPONSEPDU;
  217. class NonStandardPDU : public GenericPDU
  218. {
  219. LPCSTR m_szKey;
  220. LPVOID m_lpBuffer;
  221. unsigned m_BufferLength;
  222. public:
  223. NonStandardPDU(LPCSTR lpszEncodedDataBuffer,
  224. LPCSTR lpszKey,
  225. LPVOID lpBuffer,
  226. unsigned BufferLength,
  227. IT120AppletSession *pAppletSession = NULL);
  228. LPCSTR GetKey(void) { return m_szKey; }
  229. LPCSTR GetDataBuffer(void) { return (LPCSTR) m_lpBuffer; }
  230. ULONG GetDataSize(void) { return m_BufferLength; }
  231. BOOL Encode(void);
  232. };
  233. typedef class NonStandardPDU FAR * LPNONSTANDARDPDU;
  234. class FileErrorPDU : public GenericPDU
  235. {
  236. private:
  237. MBFTFILEHANDLE m_FileHandle;
  238. int m_ErrorType;
  239. int m_ErrorCode;
  240. public:
  241. FileErrorPDU(unsigned iFileHandle,int iErrorType,int iErrorCode);
  242. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  243. unsigned GetErrorType(void) { return m_ErrorType; }
  244. unsigned GetErrorCode(void) { return m_ErrorCode; }
  245. BOOL Encode(void);
  246. static BOOL ExtractErrorCode(LPCSTR lpszString,int iLength,
  247. int * lpAPIErrorCode);
  248. static BOOL XlatErrorCode(int * lpAPIErrorCode,
  249. int * lpMBFTErrorCode,
  250. BOOL bXlatToAPI);
  251. };
  252. typedef class FileErrorPDU FAR * LPFILEERRORPDU;
  253. class FileRequestPDU : public GenericPDU
  254. {
  255. private:
  256. ChannelID m_DataChannelID;
  257. unsigned m_uRequestHandle;
  258. char m_szFileName[_MAX_PATH];
  259. public:
  260. FileRequestPDU(LPCSTR lpszFileName,ChannelID wDataChannelID,
  261. unsigned uRequestHandle);
  262. unsigned GetRequestHandle(void) { return m_uRequestHandle; }
  263. BOOL Encode(void);
  264. };
  265. typedef class FileRequestPDU FAR * LPFILEREQUESTPDU;
  266. class FileDenyPDU : public GenericPDU
  267. {
  268. private:
  269. unsigned m_uRequestHandle;
  270. unsigned m_uReason;
  271. public:
  272. FileDenyPDU(unsigned uRequestHandle,unsigned uReason = 0);
  273. BOOL Encode(void);
  274. };
  275. typedef class FileDenyPDU FAR * LPFILEDENYPDU;
  276. class DirectoryRequestPDU : public GenericPDU
  277. {
  278. private:
  279. char m_szPathName[_MAX_PATH];
  280. public:
  281. DirectoryRequestPDU(LPCSTR lpszPathName);
  282. BOOL Encode(void);
  283. };
  284. typedef class DirectoryRequestPDU FAR * LPDIRECTORYREQUESTPDU;
  285. class DirectoryResponsePDU : public GenericPDU
  286. {
  287. private:
  288. unsigned m_uResult;
  289. public:
  290. DirectoryResponsePDU(unsigned uResult = 0);
  291. BOOL Encode(void);
  292. };
  293. typedef class DirectoryResponsePDU FAR * LPDIRECTORYRESPONSEPDU;
  294. class PrivilegeRequestPDU : public GenericPDU
  295. {
  296. private:
  297. unsigned m_PrivilegeWord;
  298. public:
  299. enum MBFTPrivilege
  300. {
  301. EnumFileTransfer = 0x0001,
  302. EnumFileRequest = 0x0002,
  303. EnumPrivateChannel = 0x0004,
  304. EnumPriority = 0x0008,
  305. EnumAbort = 0x0010,
  306. EnumNonStandard = 0x0020
  307. };
  308. PrivilegeRequestPDU(unsigned wPrivilege);
  309. BOOL Encode(void);
  310. };
  311. class PrivilegeAssignPDU : public GenericPDU
  312. {
  313. private:
  314. unsigned m_PrivilegeWord;
  315. UserID m_MBFTUserID;
  316. public:
  317. enum MBFTPrivilege
  318. {
  319. EnumFileTransfer = 0x0001,
  320. EnumFileRequest = 0x0002,
  321. EnumPrivateChannel = 0x0004,
  322. EnumPriority = 0x0008,
  323. EnumAbort = 0x0010,
  324. EnumNonStandard = 0x0020
  325. };
  326. PrivilegeAssignPDU(unsigned wPrivilege,UserID MBFTUserID = 0);
  327. BOOL Encode(void);
  328. static BOOL XlatPrivilegeCode(unsigned iPrivilegeCode,unsigned * lpMBFTCode);
  329. static unsigned ConstructPrivilegeWord(LPVOID lpStruct,
  330. ChannelID MBFTUserID);
  331. unsigned GetPrivilegeWord(void) { return m_PrivilegeWord; }
  332. };
  333. typedef class PrivilegeAssignPDU FAR * LPPRIVILEGEASSIGNPDU;
  334. class FileEndAcknowledgePDU : public GenericPDU
  335. {
  336. private:
  337. MBFTFILEHANDLE m_FileHandle;
  338. public:
  339. FileEndAcknowledgePDU(int iFileHandle);
  340. BOOL Encode(void);
  341. MBFTFILEHANDLE GetFileHandle(void) { return m_FileHandle; }
  342. };
  343. typedef class FileEndAcknowledgePDU FAR * LPFILEENDACKNOWLEDGEPDU;
  344. class ChannelLeavePDU : public GenericPDU
  345. {
  346. private:
  347. ChannelID m_ChannelID;
  348. int m_ErrorCode;
  349. public:
  350. ChannelLeavePDU(ChannelID wControlChannelID,int iErrorCode);
  351. BOOL Encode(void);
  352. ChannelID GetChannelID(void) { return m_ChannelID; }
  353. int GetErrorCode(void) { return m_ErrorCode; }
  354. };
  355. typedef class ChannelLeavePDU FAR * LPCHANNELLEAVEPDU;
  356. struct FileEndAcknowledgeStruct
  357. {
  358. MBFTFILEHANDLE m_FileHandle;
  359. };
  360. struct ChannelLeaveStruct
  361. {
  362. ChannelID m_ChannelID;
  363. int m_ErrorCode;
  364. };
  365. #endif //__OSSHELP_HPP__
  366.