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.

173 lines
4.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: ossload.cpp
  8. //
  9. // Contents: On demand loading of msoss.dll
  10. //
  11. // Functions: OssLoad
  12. // OssUnload
  13. //
  14. // Forwarders: ossEncode
  15. // ossDecode
  16. // ossFreePDU
  17. // ossFreeBuf
  18. // ossLinkBer
  19. // ossSetEncodingRules
  20. //
  21. // History: 24-Mar-99 philh created
  22. //
  23. //--------------------------------------------------------------------------
  24. #include <windows.h>
  25. #include <asn1code.h>
  26. #include <ossglobl.h>
  27. #define OSS_ENCODE_PROC_IDX 0
  28. #define OSS_DECODE_PROC_IDX 1
  29. #define OSS_FREE_PDU_PROC_IDX 2
  30. #define OSS_FREE_BUF_PROC_IDX 3
  31. #define OSS_LINK_BER_PROC_IDX 4
  32. #define OSS_SET_ENCODING_RULES_PROC_IDX 5
  33. #define OSS_PROC_CNT 6
  34. LPSTR rgpszOssProc[OSS_PROC_CNT] = {
  35. "ossEncode", // 0
  36. "ossDecode", // 1
  37. "ossFreePDU", // 2
  38. "ossFreeBuf", // 3
  39. "ossLinkBer", // 4
  40. "ossSetEncodingRules" // 5
  41. };
  42. void *rgpvOssProc[OSS_PROC_CNT];
  43. HMODULE hmsossDll = NULL;
  44. void OssUnload()
  45. {
  46. if (hmsossDll) {
  47. FreeLibrary(hmsossDll);
  48. hmsossDll = NULL;
  49. }
  50. }
  51. BOOL OssLoad()
  52. {
  53. BOOL fRet;
  54. DWORD i;
  55. if (NULL == (hmsossDll = LoadLibraryA("msoss.dll")))
  56. goto ErrorReturn;
  57. for (i = 0; i < OSS_PROC_CNT; i++) {
  58. if (NULL == (rgpvOssProc[i] = GetProcAddress(
  59. hmsossDll, rgpszOssProc[i])))
  60. goto ErrorReturn;
  61. }
  62. fRet = TRUE;
  63. CommonReturn:
  64. return fRet;
  65. ErrorReturn:
  66. OssUnload();
  67. fRet = FALSE;
  68. goto CommonReturn;
  69. }
  70. typedef int (DLL_ENTRY* pfnossEncode)(struct ossGlobal *world,
  71. int pdunum,
  72. void *input,
  73. OssBuf *output);
  74. int DLL_ENTRY ossEncode(struct ossGlobal *world,
  75. int pdunum,
  76. void *input,
  77. OssBuf *output)
  78. {
  79. if (hmsossDll)
  80. return ((pfnossEncode) rgpvOssProc[OSS_ENCODE_PROC_IDX])(
  81. world,
  82. pdunum,
  83. input,
  84. output);
  85. else
  86. return API_DLL_NOT_LINKED;
  87. }
  88. typedef int (DLL_ENTRY* pfnossDecode)(struct ossGlobal *world,
  89. int *pdunum,
  90. OssBuf *input,
  91. void **output);
  92. int DLL_ENTRY ossDecode(struct ossGlobal *world,
  93. int *pdunum,
  94. OssBuf *input,
  95. void **output)
  96. {
  97. if (hmsossDll)
  98. return ((pfnossDecode) rgpvOssProc[OSS_DECODE_PROC_IDX])(
  99. world,
  100. pdunum,
  101. input,
  102. output);
  103. else
  104. return API_DLL_NOT_LINKED;
  105. }
  106. typedef int (DLL_ENTRY* pfnossFreePDU)(struct ossGlobal *world,
  107. int pdunum,
  108. void *data);
  109. int DLL_ENTRY ossFreePDU(struct ossGlobal *world,
  110. int pdunum,
  111. void *data)
  112. {
  113. if (hmsossDll)
  114. return ((pfnossFreePDU) rgpvOssProc[OSS_FREE_PDU_PROC_IDX])(
  115. world,
  116. pdunum,
  117. data);
  118. else
  119. return API_DLL_NOT_LINKED;
  120. }
  121. typedef void (DLL_ENTRY* pfnossFreeBuf)(struct ossGlobal *world,
  122. void *data);
  123. void DLL_ENTRY ossFreeBuf(struct ossGlobal *world,
  124. void *data)
  125. {
  126. if (hmsossDll)
  127. ((pfnossFreeBuf) rgpvOssProc[OSS_FREE_BUF_PROC_IDX])(
  128. world,
  129. data);
  130. }
  131. typedef void (DLL_ENTRY* pfnossLinkBer)(OssGlobal *world);
  132. void DLL_ENTRY ossLinkBer(OssGlobal *world)
  133. {
  134. if (hmsossDll)
  135. ((pfnossLinkBer) rgpvOssProc[OSS_LINK_BER_PROC_IDX])(world);
  136. }
  137. typedef int (DLL_ENTRY* pfnossSetEncodingRules)(struct ossGlobal *world,
  138. ossEncodingRules rules);
  139. int DLL_ENTRY ossSetEncodingRules(struct ossGlobal *world,
  140. ossEncodingRules rules)
  141. {
  142. if (hmsossDll)
  143. return ((pfnossSetEncodingRules)
  144. rgpvOssProc[OSS_SET_ENCODING_RULES_PROC_IDX])(
  145. world,
  146. rules);
  147. else
  148. return API_DLL_NOT_LINKED;
  149. }