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.

566 lines
13 KiB

  1. page ,132
  2. if 0
  3. /*++
  4. Copyright (c) 1991 Microsoft Corporation
  5. Module Name:
  6. netapis.asm
  7. Abstract:
  8. This module contains the resident code part of the stub redir TSR for NT
  9. VDM net support. The routines contained herein are the Lan Manager API
  10. stubs:
  11. NetIRemoteAPI
  12. NetMessageBufferSend
  13. NetNullTransactAPI
  14. NetServerEnum
  15. NetServiceControl
  16. NetTransactAPI
  17. NetUseAdd
  18. NetUseDel
  19. NetUseEnum
  20. NetUseGetInfo
  21. NetWkstaGetInfo
  22. NetWkstaSetInfo
  23. Author:
  24. Richard L Firth (rfirth) 05-Sep-1991
  25. Environment:
  26. Dos mode only
  27. Revision History:
  28. 05-Sep-1991 rfirth
  29. Created
  30. --*/
  31. endif
  32. .xlist ; don't list these include files
  33. .xcref ; turn off cross-reference listing
  34. include dosmac.inc ; Break macro etc (for following include files only)
  35. include dossym.inc ; User_<Reg> defines
  36. include mult.inc ; MultNET
  37. include error.inc ; DOS errors - ERROR_INVALID_FUNCTION
  38. include syscall.inc ; DOS system call numbers
  39. include rdrint2f.inc ; redirector Int 2f numbers
  40. include segorder.inc ; segments
  41. include enumapis.inc ; dispatch codes
  42. include debugmac.inc ; DbgPrint macro
  43. include localmac.inc ; DbgPrint macro
  44. include asmmacro.inc ; language extensions
  45. include rdrsvc.inc ; BOP and SVC macros/dispatch codes
  46. include sf.inc ; SFT definitions/structure
  47. .cref ; switch cross-reference back on
  48. .list ; switch listing back on
  49. subttl ; kill subtitling started in include file
  50. .286 ; all code in this module 286 compatible
  51. ResidentCodeStart
  52. assume cs:ResidentCode
  53. assume ds:nothing
  54. assume es:nothing
  55. assume ss:nothing
  56. extrn SetNetErrorCodeAx:near
  57. ;
  58. ; if we are remoting NetUserSetInfo with an unencrypted password, we need
  59. ; somewhere in 16-bit memory to store the encrypted password. Hence, this:
  60. ;
  61. password_buffer db 16 dup(?)
  62. ; *** NetIRemoteAPI
  63. ; *
  64. ; * Remotes API requests to a server. Creates a transaction smb. The
  65. ; * return data buffer address and length are in the caller's parameters.
  66. ; *
  67. ; * This is an internal API so the parameters are trusted.
  68. ; *
  69. ; * Function = 5F3Fh
  70. ; *
  71. ; * ENTRY CX = API number
  72. ; * ES:BX = pointer to caller parameters
  73. ; * DS:SI = pointer to ASCIZ parameter descriptor string
  74. ; * DS:DI = pointer to ASCIZ data descriptor string
  75. ; * DS:DX = pointer to ASCIZ aux data descriptor string
  76. ; *
  77. ; * EXIT CF = 1
  78. ; * AX = Error code
  79. ; *
  80. ; * CF = 0
  81. ; * Output depends on type of request
  82. ; *
  83. ; * USES ax, flags
  84. ; *
  85. ; * ASSUMES nothing
  86. ; *
  87. ; ***
  88. public NetIRemoteAPI
  89. NetIRemoteAPI proc near
  90. mov ax,offset cs:password_buffer
  91. SVC SVC_RDRIREMOTEAPI
  92. ;
  93. ; all routines in this module come here for exit processing
  94. ;
  95. common_net_api_exit:
  96. jc common_api_error_exit ; quick return on success
  97. ret
  98. common_api_error_exit:
  99. push ax
  100. DosCallBack GET_USER_STACK
  101. pop [si].User_Ax ; return failure status in caller's ax
  102. call SetNetErrorCodeAx ; set up to return 16-bit error to app
  103. stc ; failure indication
  104. ret
  105. NetIRemoteAPI endp
  106. ; *** NetMessageBufferSend
  107. ; *
  108. ; * Function = 5F40h
  109. ; *
  110. ; * ENTRY DS:DX = NetMessageBufferSendStruct:
  111. ; *
  112. ; * char FAR * NMBSS_NetName; /* asciz net name. */
  113. ; * char FAR * NMBSS_Buffer; /* pointer to buffer. */
  114. ; * unsigned int NMBSS_BufSize; /* size of buffer. */
  115. ; *
  116. ; * EXIT CF = 0
  117. ; * Success
  118. ; *
  119. ; * CF = 1
  120. ; * AX = Error code
  121. ; *
  122. ; * USES
  123. ; *
  124. ; * ASSUMES nothing
  125. ; *
  126. ; ***
  127. public NetMessageBufferSend
  128. NetMessageBufferSend proc
  129. SVC SVC_RDRMESSAGEBUFFERSEND
  130. jmps common_net_api_exit
  131. NetMessageBufferSend endp
  132. ; *** NetNullTransactApi
  133. ; *
  134. ; * Function = 5F54h
  135. ; *
  136. ; * ENTRY DS:SI = transaction packet
  137. ; *
  138. ; * EXIT CF = 1
  139. ; * AX = Error code
  140. ; *
  141. ; * CF = 0
  142. ; * Success
  143. ; *
  144. ; * USES
  145. ; *
  146. ; * ASSUMES nothing
  147. ; *
  148. ; ***
  149. public NetNullTransactAPI
  150. NetNullTransactAPI proc near
  151. SVC SVC_RDRNULLTRANSACTAPI
  152. jmps common_net_api_exit
  153. NetNullTransactAPI endp
  154. ; *** NetServerEnum
  155. ; *
  156. ; * Function = 5F4Ch
  157. ; *
  158. ; * ENTRY BL = level (0 or 1)
  159. ; * CX = size of buffer
  160. ; * ES:DI = buffer
  161. ; *
  162. ; * EXIT CF = 1
  163. ; * AX = Error code:
  164. ; * NERR_BufTooSmall
  165. ; * ERROR_MORE_DATA
  166. ; *
  167. ; * CF = 0
  168. ; * BX = entries read
  169. ; * CX = total available
  170. ; *
  171. ; * USES
  172. ; *
  173. ; * ASSUMES nothing
  174. ; *
  175. ; ***
  176. public NetServerEnum
  177. NetServerEnum proc near
  178. mov al,4ch
  179. jmp short common_server_enum
  180. NetServerEnum endp
  181. ; *** NetServerEnum2
  182. ; *
  183. ; * Function = 5F53h
  184. ; *
  185. ; * ENTRY DS:SI = NetServerEnum2Struct:
  186. ; * DW Level
  187. ; * DD Buffer
  188. ; * DW Buflen
  189. ; * DD Type
  190. ; * DD Domain
  191. ; *
  192. ; * EXIT CF = 1
  193. ; * AX = Error code:
  194. ; * NERR_BufTooSmall
  195. ; * ERROR_MORE_DATA
  196. ; *
  197. ; * CF = 0
  198. ; * BX = entries read
  199. ; * CX = total available
  200. ; *
  201. ; * USES
  202. ; *
  203. ; * ASSUMES nothing
  204. ; *
  205. ; ***
  206. public NetServerEnum2
  207. NetServerEnum2 proc near
  208. mov al,53h
  209. common_server_enum:
  210. SVC SVC_RDRSERVERENUM
  211. ;
  212. ; we are going to set the caller's BX and CX irrespective of whether we have
  213. ; meaningful values in them. This function
  214. ; is used to unpack a real-mode buffer into a protect-mode buffer, and it uses
  215. ; the returned EntriesRead in BX to do so. It's bad because it doesn't
  216. ; look at the return code until after its tried to unpack BX elements from its
  217. ; buffer. This took me a day to find out why its
  218. ; blowing up in 16-bit windows protect-mode netapi.dll, and probably means that
  219. ; if the real DOS redir ever returned anything other than a list of servers,
  220. ; then windows would fall over too. (Actually, the real redir does the right
  221. ; thing. This is what you get for believing comments, and not reading the code
  222. ; #^*&^@@*&%!)
  223. ;
  224. pushf
  225. push ax
  226. DosCallBack GET_USER_STACK
  227. mov [si].User_Bx,bx
  228. mov [si].User_Cx,cx
  229. pop ax ; error status or XXXX
  230. popf ; error indication
  231. @@: jmps common_net_api_exit
  232. NetServerEnum2 endp
  233. ; *** NetServiceControl
  234. ; *
  235. ; * Returns information about the state of a service, or applies a control
  236. ; * to a service (and its dependents). We only allow INTERROGATE under NT
  237. ; * since we don't want DOS apps starting and stopping the NT services. In
  238. ; * most cases they couldn't anyway, since a DOS program will most likely
  239. ; * be running in an account with not enough privilege to control the
  240. ; * services (ie an admin is very likely to be using only 32-bit tools
  241. ; * to control services)
  242. ; *
  243. ; * Function = 5F42h
  244. ; *
  245. ; * ENTRY ES:BX = NetServiceControlStruct:
  246. ; * char far* ServiceName
  247. ; * unsigned short BufLen
  248. ; * char far* Buffer (service_info_2)
  249. ; * DL = opcode:
  250. ; * 0 = interrogate
  251. ; * 1 = pause
  252. ; * 2 = continue
  253. ; * 3 = uninstall
  254. ; * 4 - 127 = reserved
  255. ; * 128 - 255 = OEM defined
  256. ; *
  257. ; * EXIT CF = 0
  258. ; * Buffer contains service_info_2 structure for requested service
  259. ; *
  260. ; * CF = 1
  261. ; * AX = error code:
  262. ; * NERR_ServiceCtlNotValid
  263. ; * NERR_BufTooSmall
  264. ; * NERR_ServiceNotInstalled
  265. ; * ERROR_INVALID_PARAMETER (NEW)
  266. ; *
  267. ; * USES ax, flags
  268. ; *
  269. ; * ASSUMES nothing
  270. ; *
  271. ; ***
  272. public NetServiceControl
  273. NetServiceControl proc near
  274. SVC SVC_RDRSERVICECONTROL
  275. jmps common_net_api_exit
  276. NetServiceControl endp
  277. ; *** NetTransactAPI
  278. ; *
  279. ; * Function = 5F3Dh
  280. ; *
  281. ; * ENTRY DS:SI = transaction packet
  282. ; *
  283. ; * EXIT CF = 1
  284. ; * AX = Error code
  285. ; *
  286. ; * CF = 0
  287. ; * Success
  288. ; *
  289. ; * USES
  290. ; *
  291. ; * ASSUMES nothing
  292. ; *
  293. ; ***
  294. public NetTransactAPI
  295. NetTransactAPI proc near
  296. SVC SVC_RDRTRANSACTAPI
  297. jmps common_net_api_exit
  298. NetTransactAPI endp
  299. ; *** NetUseAdd
  300. ; *
  301. ; * Function = 5F47h
  302. ; *
  303. ; * ENTRY BX = level
  304. ; * CX = buffer length
  305. ; * DS:SI = server name for remote call (MBZ)
  306. ; * ES:DI = buffer containing use_info_1 structure
  307. ; *
  308. ; * EXIT CF = 0
  309. ; * Success
  310. ; *
  311. ; * CF = 1
  312. ; * AX = Error code
  313. ; *
  314. ; * USES
  315. ; *
  316. ; * ASSUMES nothing
  317. ; *
  318. ; ***
  319. public NetUseAdd
  320. NetUseAdd proc
  321. SVC SVC_RDRUSEADD
  322. jmps common_net_api_exit
  323. NetUseAdd endp
  324. ; *** NetUseDel
  325. ; *
  326. ; * Function = 5F48h
  327. ; *
  328. ; * ENTRY BX = force flag
  329. ; * DS:SI = server name for remote call (MBZ)
  330. ; * ES:DI = use name
  331. ; *
  332. ; * EXIT CF = 0
  333. ; * Success
  334. ; *
  335. ; * CF = 1
  336. ; * AX = Error code
  337. ; *
  338. ; * USES
  339. ; *
  340. ; * ASSUMES nothing
  341. ; *
  342. ; ***
  343. public NetUseDel
  344. NetUseDel proc
  345. SVC SVC_RDRUSEDEL
  346. jmps common_net_api_exit
  347. NetUseDel endp
  348. ; *** NetUseEnum
  349. ; *
  350. ; * Function = 5F46h
  351. ; *
  352. ; * ENTRY BX = level of info required - 0 or 1
  353. ; * CX = buffer length
  354. ; * ES:DI = buffer for enum info
  355. ; *
  356. ; * EXIT CF = 0
  357. ; * CX = Entries Read
  358. ; * DX = Total number of entries available
  359. ; *
  360. ; * CF = 1
  361. ; * AX = Error code
  362. ; *
  363. ; * USES
  364. ; *
  365. ; * ASSUMES nothing
  366. ; *
  367. ; ***
  368. public NetUseEnum
  369. NetUseEnum proc
  370. SVC SVC_RDRUSEENUM
  371. pushf ; error indication
  372. push ax ; error code
  373. ;
  374. ; return EntriesRead and TotalEntries regardless of error
  375. ;
  376. DosCallBack GET_USER_STACK
  377. mov [si].User_Cx,cx
  378. mov [si].User_Dx,dx
  379. pop ax
  380. popf
  381. jmpc common_api_error_exit ; error
  382. ret
  383. NetUseEnum endp
  384. ; *** NetUseGetInfo
  385. ; *
  386. ; * Function = 5F49h
  387. ; *
  388. ; * ENTRY DS:DX = NetUseGetInfoStruc:
  389. ; *
  390. ; * const char FAR* NUGI_usename; /* ASCIZ redirected device name */
  391. ; * short NUGI_level; /* level of info */
  392. ; * char FAR* NUGI_buffer; /* buffer for returned info */
  393. ; * unsigned short NUGI_buflen; /* size of buffer */
  394. ; *
  395. ; * EXIT CF = 0
  396. ; * DX = size of entry returned (or size of buffer required)
  397. ; *
  398. ; * CF = 1
  399. ; * AX = Error code
  400. ; *
  401. ; * USES
  402. ; *
  403. ; * ASSUMES nothing
  404. ; *
  405. ; ***
  406. public NetUseGetInfo
  407. NetUseGetInfo proc
  408. SVC SVC_RDRUSEGETINFO
  409. jmpc common_api_error_exit
  410. DosCallBack GET_USER_STACK
  411. mov [si].User_Dx,dx
  412. clc
  413. ret
  414. NetUseGetInfo endp
  415. ; *** NetWkstaGetInfo
  416. ; *
  417. ; * Function = 5F44h
  418. ; *
  419. ; * ENTRY BX = level of information - 0, 1, 10
  420. ; * CX = size of caller's buffer
  421. ; * DS:SI = server name for remote call (Must Be Null)
  422. ; * ES:DI = caller's buffer
  423. ; *
  424. ; * EXIT CF = 0
  425. ; * DX = size of buffer required for request
  426. ; * AX = NERR_Success (0)
  427. ; *
  428. ; * CF = 1
  429. ; * AX = Error code
  430. ; * NERR_BufTooSmall (2123)
  431. ; * Caller's buffer not large enough to hold even fixed
  432. ; * part of structure
  433. ; *
  434. ; * ERROR_MORE_DATA (234)
  435. ; * Caller's buffer large enough to hold fixed structure
  436. ; * part of data, but not all variable parts too
  437. ; *
  438. ; * USES
  439. ; *
  440. ; * ASSUMES nothing
  441. ; *
  442. ; ***
  443. public NetWkstaGetInfo
  444. NetWkstaGetInfo proc
  445. SVC SVC_RDRWKSTAGETINFO
  446. pushf ; save error indication in carry
  447. push ax ; save error code
  448. DosCallBack GET_USER_STACK
  449. mov [si].User_Dx,dx ; user's dx = buffer required
  450. pop ax ; ax = error code or ?
  451. popf ; carry flag = error (1) or no error
  452. jmps common_net_api_exit ; if error, store it, and return
  453. NetWkstaGetInfo endp
  454. ; *** NetWkstaSetInfo
  455. ; *
  456. ; * Function = 5F45h
  457. ; *
  458. ; * ENTRY BX = level - MBZ
  459. ; * CX = buffer size
  460. ; * DX = parm num
  461. ; * DS:SI = server name for remote call (MBZ)
  462. ; * ES:DI = caller's buffer
  463. ; *
  464. ; * EXIT CF = 0
  465. ; * Success
  466. ; *
  467. ; * CF = 1
  468. ; * AX = Error code
  469. ; *
  470. ; * USES
  471. ; *
  472. ; * ASSUMES nothing
  473. ; *
  474. ; ***
  475. public NetWkstaSetInfo
  476. NetWkstaSetInfo proc
  477. SVC SVC_RDRWKSTASETINFO
  478. jmps common_net_api_exit
  479. NetWkstaSetInfo endp
  480. ResidentCodeEnd
  481. end