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.

575 lines
12 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ApiPath.c
  5. Abstract:
  6. This module contains individual API handlers for the NetName and
  7. NetPath APIs.
  8. SUPPORTED : I_NetNameCanonicalize, I_NetNameCompare, I_NetNameValidate,
  9. I_NetPathCanonicalize, I_NetPathCompare, I_NetPathType.
  10. Author:
  11. Shanku Niyogi (w-shanku) 04-Apr-1991
  12. Jim Waters (t-jamesw) 6-Aug-1991
  13. Revision History:
  14. --*/
  15. #include "XactSrvP.h"
  16. //
  17. // Needed for canonicalization routine prototypes.
  18. //
  19. #include <icanon.h>
  20. NTSTATUS
  21. XsI_NetNameCanonicalize (
  22. API_HANDLER_PARAMETERS
  23. )
  24. /*++
  25. Routine Description:
  26. This routine handles a call to NetI_NetNameCanonicalize.
  27. Arguments:
  28. API_HANDLER_PARAMETERS - information about the API call. See
  29. XsTypes.h for details.
  30. Return Value:
  31. NTSTATUS - STATUS_SUCCESS or reason for failure.
  32. --*/
  33. {
  34. NET_API_STATUS status;
  35. PXS_I_NET_NAME_CANONICALIZE parameters = Parameters;
  36. LPTSTR nativeName = NULL; // Native parameters
  37. LPTSTR outBuffer = NULL;
  38. DWORD outBufLen;
  39. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  40. IF_DEBUG(PATH) {
  41. NetpKdPrint(( "XsI_NetNameCanonicalize: header at %lx, params at %lx\n",
  42. Header, parameters ));
  43. }
  44. //
  45. // Translate parameters, check for errors.
  46. //
  47. XsConvertTextParameter(
  48. nativeName,
  49. (LPSTR)XsSmbGetPointer( &parameters->Name )
  50. );
  51. //
  52. // Allocate local buffer, accounting for possible differences in
  53. // character size.
  54. //
  55. outBufLen = (DWORD)STRING_SPACE_REQD(
  56. SmbGetUshort( &parameters->OutbufLen ));
  57. if (( outBuffer = NetpMemoryAllocate( outBufLen )) == NULL ) {
  58. status = NERR_NoRoom;
  59. goto cleanup;
  60. }
  61. //
  62. // Make the local call.
  63. //
  64. status = I_NetNameCanonicalize(
  65. NULL,
  66. nativeName,
  67. outBuffer,
  68. outBufLen,
  69. (DWORD)SmbGetUshort( &parameters->NameType ),
  70. (DWORD)SmbGetUlong( &parameters->Flags )
  71. );
  72. if ( !XsApiSuccess(status) ) {
  73. IF_DEBUG(API_ERRORS) {
  74. NetpKdPrint(( "XsI_NetNameCanonicalize: "
  75. "NetNameCanonicalize failed: %X\n", status ));
  76. }
  77. goto cleanup;
  78. }
  79. //
  80. // Copy return buffer, possibly translating from Unicode.
  81. //
  82. NetpCopyTStrToStr( (LPSTR)XsSmbGetPointer( &parameters->Outbuf ), outBuffer );
  83. cleanup:
  84. NetpMemoryFree( nativeName );
  85. NetpMemoryFree( outBuffer );
  86. Header->Status = (WORD)status;
  87. return STATUS_SUCCESS;
  88. } // XsI_NetNameCanonicalize
  89. NTSTATUS
  90. XsI_NetNameCompare (
  91. API_HANDLER_PARAMETERS
  92. )
  93. /*++
  94. Routine Description:
  95. This routine handles a call to I_NetNameCompare.
  96. Arguments:
  97. API_HANDLER_PARAMETERS - information about the API call. See
  98. XsTypes.h for details.
  99. Return Value:
  100. NTSTATUS - STATUS_SUCCESS or reason for failure.
  101. --*/
  102. {
  103. NET_API_STATUS status;
  104. PXS_I_NET_NAME_COMPARE parameters = Parameters;
  105. LPTSTR nativeName1 = NULL; // Native parameters
  106. LPTSTR nativeName2 = NULL;
  107. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  108. IF_DEBUG(PATH) {
  109. NetpKdPrint(( "XsI_NetNameCompare: header at %lx, params at %lx\n",
  110. Header, parameters ));
  111. }
  112. //
  113. // Translate parameters, check for errors.
  114. //
  115. XsConvertTextParameter(
  116. nativeName1,
  117. (LPSTR)XsSmbGetPointer( &parameters->Name1 )
  118. );
  119. XsConvertTextParameter(
  120. nativeName2,
  121. (LPSTR)XsSmbGetPointer( &parameters->Name2 )
  122. );
  123. //
  124. // Make the local call.
  125. //
  126. status = I_NetNameCompare(
  127. NULL,
  128. nativeName1,
  129. nativeName2,
  130. (DWORD)SmbGetUshort( &parameters->NameType ),
  131. (DWORD)SmbGetUlong( &parameters->Flags )
  132. );
  133. if ( !XsApiSuccess(status) ) {
  134. IF_DEBUG(API_ERRORS) {
  135. NetpKdPrint(( "XsI_NetNameCompare: NetNameCompare failed: "
  136. "%X\n", status));
  137. }
  138. }
  139. cleanup:
  140. NetpMemoryFree( nativeName1 );
  141. NetpMemoryFree( nativeName2 );
  142. Header->Status = (WORD)status;
  143. return STATUS_SUCCESS;
  144. } // XsI_NetNameCompare
  145. NTSTATUS
  146. XsI_NetNameValidate (
  147. API_HANDLER_PARAMETERS
  148. )
  149. /*++
  150. Routine Description:
  151. This routine handles a call to I_NetNameValidate.
  152. Arguments:
  153. API_HANDLER_PARAMETERS - information about the API call. See
  154. XsTypes.h for details.
  155. Return Value:
  156. NTSTATUS - STATUS_SUCCESS or reason for failure.
  157. --*/
  158. {
  159. NET_API_STATUS status;
  160. PXS_I_NET_NAME_VALIDATE parameters = Parameters;
  161. LPTSTR nativeName = NULL; // Native parameters
  162. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  163. IF_DEBUG(PATH) {
  164. NetpKdPrint(( "XsI_NetNameValidate: header at %lx, params at %lx\n",
  165. Header, parameters ));
  166. }
  167. try {
  168. //
  169. // Translate parameters, check for errors.
  170. //
  171. XsConvertTextParameter(
  172. nativeName,
  173. (LPSTR)XsSmbGetPointer( &parameters->Name )
  174. );
  175. //
  176. // Make the local call.
  177. //
  178. status = I_NetNameValidate(
  179. NULL,
  180. nativeName,
  181. (DWORD)SmbGetUshort( &parameters->NameType ),
  182. (DWORD)SmbGetUlong( &parameters->Flags )
  183. );
  184. if ( !XsApiSuccess(status) ) {
  185. IF_DEBUG(API_ERRORS) {
  186. NetpKdPrint(( "XsI_NetPathType: NetPathType failed: %X\n", status));
  187. }
  188. }
  189. cleanup:
  190. Header->Status = (WORD)status;
  191. } except( EXCEPTION_EXECUTE_HANDLER ) {
  192. Header->Status = (WORD)RtlNtStatusToDosError( GetExceptionCode() );
  193. }
  194. if (nativeName != NULL) {
  195. NetpMemoryFree( nativeName );
  196. }
  197. return STATUS_SUCCESS;
  198. } // XsI_NetNameValidate
  199. NTSTATUS
  200. XsI_NetPathCanonicalize (
  201. API_HANDLER_PARAMETERS
  202. )
  203. /*++
  204. Routine Description:
  205. This routine handles a call to I_NetPathCanonicalize.
  206. Arguments:
  207. API_HANDLER_PARAMETERS - information about the API call. See
  208. XsTypes.h for details.
  209. Return Value:
  210. NTSTATUS - STATUS_SUCCESS or reason for failure.
  211. --*/
  212. {
  213. NET_API_STATUS status;
  214. PXS_I_NET_PATH_CANONICALIZE parameters = Parameters;
  215. LPTSTR nativePathName = NULL; // Native parameters
  216. LPTSTR outBuffer = NULL;
  217. DWORD outBufLen;
  218. LPTSTR nativePrefix = NULL;
  219. DWORD pathType = 0;
  220. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  221. IF_DEBUG(PATH) {
  222. NetpKdPrint(( "XsI_NetPathCanonicalize: header at %lx, params at %lx\n",
  223. Header, parameters ));
  224. }
  225. //
  226. // Translate parameters, check for errors.
  227. //
  228. XsConvertTextParameter(
  229. nativePathName,
  230. (LPSTR)XsSmbGetPointer( &parameters->PathName )
  231. );
  232. XsConvertTextParameter(
  233. nativePrefix,
  234. (LPSTR)XsSmbGetPointer( &parameters->Prefix )
  235. );
  236. //
  237. // Get a copy of the input path type.
  238. //
  239. pathType = SmbGetUlong( &parameters->PathType );
  240. //
  241. // Allocate local buffer, accounting for possible differences in
  242. // character size.
  243. //
  244. outBufLen = (DWORD)STRING_SPACE_REQD(
  245. SmbGetUshort( &parameters->OutbufLen ));
  246. if (( outBuffer = (LPTSTR)NetpMemoryAllocate( outBufLen )) == NULL ) {
  247. status = NERR_NoRoom;
  248. goto cleanup;
  249. }
  250. //
  251. // Make the local call.
  252. //
  253. status = I_NetPathCanonicalize(
  254. NULL,
  255. nativePathName,
  256. outBuffer,
  257. outBufLen,
  258. nativePrefix,
  259. &pathType,
  260. (DWORD)SmbGetUlong( &parameters->Flags )
  261. );
  262. if ( !XsApiSuccess(status) ) {
  263. IF_DEBUG(API_ERRORS) {
  264. NetpKdPrint(( "XsI_NetPathCanonicalize: "
  265. "NetPathCanonicalize failed: %X\n", status));
  266. }
  267. goto cleanup;
  268. }
  269. //
  270. // Copy return buffer, possibly translating from Unicode.
  271. //
  272. NetpCopyTStrToStr( (LPSTR)XsSmbGetPointer( &parameters->Outbuf ), outBuffer );
  273. cleanup:
  274. //
  275. // Fill return parameter.
  276. //
  277. SmbPutUlong( &parameters->PathTypeOut, pathType );
  278. Header->Status = (WORD)status;
  279. NetpMemoryFree( nativePathName );
  280. NetpMemoryFree( nativePrefix );
  281. NetpMemoryFree( outBuffer );
  282. return STATUS_SUCCESS;
  283. } // XsI_NetPathCanonicalize
  284. NTSTATUS
  285. XsI_NetPathCompare (
  286. API_HANDLER_PARAMETERS
  287. )
  288. /*++
  289. Routine Description:
  290. This routine handles a call to I_NetPathCompare.
  291. Arguments:
  292. API_HANDLER_PARAMETERS - information about the API call. See
  293. XsTypes.h for details.
  294. Return Value:
  295. NTSTATUS - STATUS_SUCCESS or reason for failure.
  296. --*/
  297. {
  298. NET_API_STATUS status;
  299. PXS_I_NET_PATH_COMPARE parameters = Parameters;
  300. LPTSTR nativePathName1 = NULL; // Native parameters
  301. LPTSTR nativePathName2 = NULL;
  302. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  303. IF_DEBUG(PATH) {
  304. NetpKdPrint(( "XsI_NetPathCompare: header at %lx, params at %lx\n",
  305. Header, parameters ));
  306. }
  307. //
  308. // Translate parameters, check for errors.
  309. //
  310. XsConvertTextParameter(
  311. nativePathName1,
  312. (LPSTR)XsSmbGetPointer( &parameters->PathName1 )
  313. );
  314. XsConvertTextParameter(
  315. nativePathName2,
  316. (LPSTR)XsSmbGetPointer( &parameters->PathName2 )
  317. );
  318. //
  319. // Make the local call.
  320. //
  321. status = I_NetPathCompare(
  322. NULL,
  323. nativePathName1,
  324. nativePathName2,
  325. (DWORD)SmbGetUlong( &parameters->PathType ),
  326. (DWORD)SmbGetUlong( &parameters->Flags )
  327. );
  328. if ( !XsApiSuccess(status) ) {
  329. IF_DEBUG(API_ERRORS) {
  330. NetpKdPrint(( "XsI_NetPathCompare: NetPathCompare failed: "
  331. "%X\n", status));
  332. }
  333. }
  334. cleanup:
  335. NetpMemoryFree( nativePathName1 );
  336. NetpMemoryFree( nativePathName2 );
  337. Header->Status = (WORD)status;
  338. return STATUS_SUCCESS;
  339. } // XsI_NetPathCompare
  340. NTSTATUS
  341. XsI_NetPathType (
  342. API_HANDLER_PARAMETERS
  343. )
  344. /*++
  345. Routine Description:
  346. This routine handles a call to I_NetPathType.
  347. Arguments:
  348. API_HANDLER_PARAMETERS - information about the API call. See
  349. XsTypes.h for details.
  350. Return Value:
  351. NTSTATUS - STATUS_SUCCESS or reason for failure.
  352. --*/
  353. {
  354. NET_API_STATUS status;
  355. PXS_I_NET_PATH_TYPE parameters = Parameters;
  356. LPTSTR nativePathName = NULL; // Native parameters
  357. DWORD pathType;
  358. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  359. IF_DEBUG(PATH) {
  360. NetpKdPrint(( "XsI_NetPathType: header at %lx, params at %lx\n",
  361. Header, parameters ));
  362. }
  363. //
  364. // Translate parameters, check for errors.
  365. //
  366. XsConvertTextParameter(
  367. nativePathName,
  368. (LPSTR)XsSmbGetPointer( &parameters->PathName )
  369. );
  370. //
  371. // Make the local call.
  372. //
  373. status = I_NetPathType(
  374. NULL,
  375. nativePathName,
  376. &pathType,
  377. (DWORD)SmbGetUlong( &parameters->Flags )
  378. );
  379. if ( !XsApiSuccess(status) ) {
  380. IF_DEBUG(API_ERRORS) {
  381. NetpKdPrint(( "XsI_NetPathType: NetPathType failed: %X\n", status));
  382. }
  383. }
  384. //
  385. // Fill in return values.
  386. //
  387. SmbPutUlong( &parameters->PathType, pathType );
  388. Header->Status = (WORD)status;
  389. cleanup:
  390. NetpMemoryFree( nativePathName );
  391. return STATUS_SUCCESS;
  392. } // XsI_NetPathType
  393.