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.

1004 lines
22 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. psxmsg.h
  5. Abstract:
  6. This module contains the message format used to communicate transmit
  7. POSIX system services between PSX and its clients.
  8. Author:
  9. Mark Lucovsky (markl) 14-Mar-1989
  10. Revision History:
  11. --*/
  12. #ifndef _PSXMSG_
  13. #define _PSXMSG_
  14. #include <nt.h>
  15. #include <types.h>
  16. #include <signal.h>
  17. #include <utime.h>
  18. #include <sys\times.h>
  19. //
  20. // Define debugging flag as false if not defined already.
  21. //
  22. #ifndef DBG
  23. #define DBG 0
  24. #endif
  25. //
  26. // Define IF_DEBUG macro that can be used to enable debugging code that is
  27. // optimized out if the debugging flag is false.
  28. //
  29. #if DBG
  30. #define IF_DEBUG if (TRUE)
  31. #else
  32. #define IF_DEBUG if (FALSE)
  33. #endif
  34. //
  35. // The following describes the connection information used for
  36. // posix api connections
  37. //
  38. typedef
  39. VOID
  40. (*PSIGNALDELIVERER) (
  41. IN PCONTEXT Context,
  42. IN sigset_t PreviousBlockMask,
  43. IN int Signal,
  44. IN _handler Handler
  45. );
  46. typedef
  47. VOID
  48. (*PNULLAPICALLER) (
  49. IN PCONTEXT Context
  50. );
  51. //
  52. // SubSystemData field in PEB points to the following data structure for
  53. // POSIX applications. Initial contents are passed back via the connection
  54. // information structure when the client process connects to the POSIX
  55. // Emulation Subsystem server
  56. //
  57. typedef struct _PEB_PSX_DATA {
  58. ULONG Length;
  59. PVOID ClientStartAddress;
  60. HANDLE SessionPortHandle;
  61. PVOID SessionDataBaseAddress;
  62. } PEB_PSX_DATA, *PPEB_PSX_DATA;
  63. typedef struct _PSX_DIRECTORY_PREFIX {
  64. STRING NtCurrentWorkingDirectory;
  65. STRING PsxCurrentWorkingDirectory;
  66. STRING PsxRoot;
  67. } PSX_DIRECTORY_PREFIX, *PPSX_DIRECTORY_PREFIX;
  68. typedef struct _PSX_API_CONNECTINFO {
  69. PSIGNALDELIVERER SignalDeliverer;
  70. PNULLAPICALLER NullApiCaller;
  71. PPSX_DIRECTORY_PREFIX DirectoryPrefix;
  72. PEB_PSX_DATA InitialPebPsxData;
  73. ULONG SessionUniqueId;
  74. } PSX_API_CONNECTINFO, *PPSX_API_CONNECTINFO;
  75. #define PSXSRV_VERSION 0x100390
  76. //
  77. // This is only defined here instead of the obvious place because the
  78. // server needs to copy it from one process to another during exec.
  79. //
  80. typedef struct _CLIENT_OPEN_FILE {
  81. BOOLEAN Open;
  82. BOOLEAN FdIsConsole;
  83. ULONG Flags; // descriptor flags
  84. } CLIENT_OPEN_FILE, *PCLIENT_OPEN_FILE;
  85. //
  86. // These Constants define the Posix Api Numbers
  87. // NOTE that the initialization of the ApiDispatch table in server\apiloop.c
  88. // matches this exactly.
  89. //
  90. typedef enum _PSXAPINUMBER {
  91. PsxForkApi,
  92. PsxExecApi,
  93. PsxWaitPidApi,
  94. PsxExitApi,
  95. PsxKillApi,
  96. PsxSigActionApi,
  97. PsxSigProcMaskApi,
  98. PsxSigPendingApi,
  99. PsxSigSuspendApi,
  100. PsxAlarmApi,
  101. PsxGetIdsApi,
  102. PsxSetUidApi,
  103. PsxSetGidApi,
  104. PsxGetGroupsApi,
  105. PsxGetLoginApi,
  106. PsxCUserIdApi,
  107. PsxSetSidApi,
  108. PsxSetPGroupIdApi,
  109. PsxUnameApi,
  110. PsxTimeApi,
  111. PsxGetProcessTimesApi,
  112. PsxTtyNameApi,
  113. PsxIsattyApi,
  114. PsxSysconfApi,
  115. PsxOpenApi,
  116. PsxUmaskApi,
  117. PsxLinkApi,
  118. PsxMkDirApi,
  119. PsxMkFifoApi,
  120. PsxRmDirApi,
  121. PsxRenameApi,
  122. PsxStatApi,
  123. PsxFStatApi,
  124. PsxAccessApi,
  125. PsxChmodApi,
  126. PsxChownApi,
  127. PsxUtimeApi,
  128. PsxPathConfApi,
  129. PsxFPathConfApi,
  130. PsxPipeApi,
  131. PsxDupApi,
  132. PsxDup2Api,
  133. PsxCloseApi,
  134. PsxReadApi,
  135. PsxWriteApi,
  136. PsxFcntlApi,
  137. PsxLseekApi,
  138. PsxTcGetAttrApi,
  139. PsxTcSetAttrApi,
  140. PsxTcSendBreakApi,
  141. PsxTcDrainApi,
  142. PsxTcFlushApi,
  143. PsxTcFlowApi,
  144. PsxTcGetPGrpApi,
  145. PsxTcSetPGrpApi,
  146. PsxGetPwUidApi,
  147. PsxGetPwNamApi,
  148. PsxGetGrGidApi,
  149. PsxGetGrNamApi,
  150. PsxUnlinkApi,
  151. PsxReadDirApi,
  152. PsxFtruncateApi,
  153. PsxNullApi,
  154. #ifdef PSX_SOCKET
  155. PsxSocketApi,
  156. PsxAcceptApi,
  157. PsxBindApi,
  158. PsxConnectApi,
  159. PsxGetPeerNameApi,
  160. PsxGetSockNameApi,
  161. PsxGetSockOptApi,
  162. PsxListenApi,
  163. PsxRecvApi,
  164. PsxRecvFromApi,
  165. PsxSendApi,
  166. PsxSendToApi,
  167. PsxSetSockOptApi,
  168. PsxShutdownApi,
  169. #endif // PSX_SOCKET
  170. PsxMaxApiNumber
  171. } PSXAPINUMBER;
  172. //
  173. // Each of the following structures define the layout of the Arguments portion
  174. // of the PSX_API_MSG that the Api expects.
  175. //
  176. //
  177. // PsxForkApi
  178. //
  179. //
  180. typedef struct _PSX_FORK_MSG {
  181. IN PVOID StackBase;
  182. IN PVOID StackLimit;
  183. IN PVOID StackAllocationBase;
  184. #if defined(_IA64_)
  185. IN PVOID BStoreLimit;
  186. #endif
  187. } PSX_FORK_MSG, *PPSX_FORK_MSG;
  188. //
  189. // PsxExecApi
  190. //
  191. typedef struct _PSX_EXEC_MSG {
  192. IN UNICODE_STRING Path;
  193. IN PCHAR Args; // args + environ, in view mem
  194. } PSX_EXEC_MSG, *PPSX_EXEC_MSG;
  195. //
  196. // PsxWaitPidApi
  197. //
  198. typedef struct _PSX_WAITPID_MSG {
  199. IN pid_t Pid;
  200. OUT ULONG StatLocValue;
  201. IN ULONG Options;
  202. } PSX_WAITPID_MSG, *PPSX_WAITPID_MSG;
  203. //
  204. // PsxExitApi
  205. //
  206. typedef struct _PSX_EXIT_MSG {
  207. IN ULONG ExitStatus;
  208. } PSX_EXIT_MSG, *PPSX_EXIT_MSG;
  209. //
  210. // PsxKillApi
  211. //
  212. typedef struct _PSX_KILL_MSG {
  213. IN pid_t Pid;
  214. IN ULONG Sig;
  215. } PSX_KILL_MSG, *PPSX_KILL_MSG;
  216. //
  217. // PsxSigActionApi
  218. //
  219. typedef struct _PSX_SIGACTION_MSG {
  220. IN ULONG Sig;
  221. IN struct sigaction *ActSpecified;
  222. IN struct sigaction Act;
  223. IN struct sigaction *OactSpecified;
  224. OUT struct sigaction Oact;
  225. } PSX_SIGACTION_MSG, *PPSX_SIGACTION_MSG;
  226. //
  227. // PsxSigProcMaskApi
  228. //
  229. typedef struct _PSX_SIGPROCMASK_MSG {
  230. IN ULONG How;
  231. IN sigset_t *SetSpecified;
  232. IN sigset_t Set;
  233. OUT sigset_t Oset;
  234. } PSX_SIGPROCMASK_MSG, *PPSX_SIGPROCMASK_MSG;
  235. //
  236. // PsxSigPendingApi
  237. //
  238. typedef struct _PSX_SIGPENDING_MSG {
  239. OUT sigset_t Set;
  240. } PSX_SIGPENDING_MSG, *PPSX_SIGPENDING_MSG;
  241. //
  242. // PsxSigSuspendApi
  243. //
  244. typedef struct _PSX_SIGSUSPEND_MSG {
  245. IN PVOID SigMaskSpecified;
  246. IN sigset_t SigMask;
  247. } PSX_SIGSUSPEND_MSG, *PPSX_SIGSUSPEND_MSG;
  248. //
  249. // PsxAlarmApi
  250. //
  251. typedef struct _PSX_ALARM_MSG {
  252. IN BOOLEAN CancelAlarm;
  253. IN LARGE_INTEGER Seconds;
  254. OUT LARGE_INTEGER PreviousSeconds;
  255. } PSX_ALARM_MSG, *PPSX_ALARM_MSG;
  256. //
  257. // PsxSleepApi
  258. //
  259. typedef struct _PSX_SLEEP_MSG {
  260. IN ULONG Seconds;
  261. OUT LARGE_INTEGER PreviousSeconds;
  262. } PSX_SLEEP_MSG, *PPSX_SLEEP_MSG;
  263. //
  264. // PsxGetIdsApi
  265. //
  266. typedef struct _PSX_GETIDS_MSG {
  267. OUT pid_t Pid;
  268. OUT pid_t ParentPid;
  269. OUT pid_t GroupId;
  270. OUT uid_t RealUid;
  271. OUT uid_t EffectiveUid;
  272. OUT gid_t RealGid;
  273. OUT gid_t EffectiveGid;
  274. } PSX_GETIDS_MSG, *PPSX_GETIDS_MSG;
  275. //
  276. // PsxSetUidApi
  277. //
  278. typedef struct _PSX_SETUID_MSG {
  279. IN uid_t Uid;
  280. } PSX_SETUID_MSG, *PPSX_SETUID_MSG;
  281. //
  282. // PsxSetGidApi
  283. //
  284. typedef struct _PSX_SETGID_MSG {
  285. IN gid_t Gid;
  286. } PSX_SETGID_MSG, *PPSX_SETGID_MSG;
  287. //
  288. // PsxGetLoginApi (USES VIEW MEMORY)
  289. //
  290. typedef struct _PSX_GETLOGIN_MSG {
  291. IN OUT STRING LoginName;
  292. } PSX_GETLOGIN_MSG, *PPSX_GETLOGIN_MSG;
  293. //
  294. // PsxCUserIdApi (USES VIEW MEMORY)
  295. //
  296. typedef struct _PSX_CUSERID_MSG {
  297. IN OUT STRING UserName;
  298. } PSX_CUSERID_MSG, *PPSX_CUSERID_MSG;
  299. //
  300. // PsxSetSidApi
  301. //
  302. // No Arguments
  303. //
  304. //
  305. // PsxSetPGroupIdApi
  306. //
  307. typedef struct _PSX_SETPGROUPID_MSG {
  308. IN pid_t Pid;
  309. IN pid_t Pgid;
  310. } PSX_SETPGROUPID_MSG, *PPSX_SETPGROUPID_MSG;
  311. //
  312. // PsxUnameApi (USES VIEW MEMORY)
  313. //
  314. typedef struct _PSX_UNAME_MSG {
  315. OUT struct utsname *Name;
  316. } PSX_UNAME_MSG, *PPSX_UNAME_MSG;
  317. //
  318. // PsxTimeApi
  319. //
  320. typedef struct _PSX_TIME_MSG {
  321. OUT LARGE_INTEGER Time;
  322. } PSX_TIME_MSG, *PPSX_TIME_MSG;
  323. //
  324. // PsxGetProcessTimesApi
  325. //
  326. typedef struct _PSX_GETPROCESSTIMES_MSG {
  327. OUT struct tms ProcessTimes;
  328. } PSX_GETPROCESSTIMES_MSG, *PPSX_GETPROCESSTIMES_MSG;
  329. //
  330. // PsxTtyNameApi (USES VIEW MEMORY)
  331. //
  332. typedef struct _PSX_TTYNAME_MSG {
  333. IN LONG FileDes;
  334. IN OUT STRING TtyName;
  335. } PSX_TTYNAME_MSG, *PPSX_TTYNAME_MSG;
  336. //
  337. // PsxIsattyApi
  338. //
  339. typedef struct _PSX_ISATTY_MSG {
  340. IN LONG FileDes;
  341. OUT ULONG Command;
  342. } PSX_ISATTY_MSG, *PPSX_ISATTY_MSG;
  343. //
  344. // PsxSysconfApi
  345. //
  346. typedef struct _PSX_SYSCONF_MSG {
  347. IN ULONG Name;
  348. } PSX_SYSCONF_MSG, *PPSX_SYSCONF_MSG;
  349. //
  350. // PsxOpenApi (USES VIEW MEMORY)
  351. //
  352. typedef struct _PSX_OPEN_MSG {
  353. IN UNICODE_STRING Path_U;
  354. IN OUT ULONG Flags; // used as flags on input and output
  355. IN OUT mode_t Mode; // used as handle value on output
  356. } PSX_OPEN_MSG, *PPSX_OPEN_MSG;
  357. //
  358. // PsxUmaskApi
  359. //
  360. typedef struct _PSX_UMASK_MSG {
  361. IN mode_t Cmask;
  362. } PSX_UMASK_MSG, *PPSX_UMASK_MSG;
  363. //
  364. // PsxLinkApi (USES VIEW MEMORY)
  365. //
  366. typedef struct _PSX_LINK_MSG {
  367. IN UNICODE_STRING OldName;
  368. IN UNICODE_STRING NewName;
  369. } PSX_LINK_MSG, *PPSX_LINK_MSG;
  370. //
  371. // PsxMkDirApi (USES VIEW MEMORY)
  372. //
  373. typedef struct _PSX_MKDIR_MSG {
  374. IN UNICODE_STRING Path_U;
  375. IN mode_t Mode;
  376. } PSX_MKDIR_MSG, *PPSX_MKDIR_MSG;
  377. //
  378. // PsxMkFifoApi (USES VIEW MEMORY)
  379. //
  380. typedef struct _PSX_MKFIFO_MSG {
  381. IN UNICODE_STRING Path_U;
  382. IN mode_t Mode;
  383. } PSX_MKFIFO_MSG, *PPSX_MKFIFO_MSG;
  384. //
  385. // PsxRmDirApi (USES VIEW MEMORY)
  386. //
  387. typedef struct _PSX_RMDIR_MSG {
  388. IN UNICODE_STRING Path_U;
  389. } PSX_RMDIR_MSG, *PPSX_RMDIR_MSG;
  390. //
  391. // PsxRenameApi (USES VIEW MEMORY)
  392. //
  393. typedef struct _PSX_RENAME_MSG {
  394. IN UNICODE_STRING OldName;
  395. IN UNICODE_STRING NewName;
  396. } PSX_RENAME_MSG, *PPSX_RENAME_MSG;
  397. //
  398. // PsxStatApi (USES VIEW MEMORY)
  399. //
  400. typedef struct _PSX_STAT_MSG {
  401. IN UNICODE_STRING Path_U;
  402. OUT struct stat *StatBuf;
  403. } PSX_STAT_MSG, *PPSX_STAT_MSG;
  404. //
  405. // PsxFStatApi
  406. //
  407. typedef struct _PSX_FSTAT_MSG {
  408. IN LONG FileDes;
  409. OUT struct stat *StatBuf;
  410. } PSX_FSTAT_MSG, *PPSX_FSTAT_MSG;
  411. //
  412. // PsxAccessApi (USES VIEW MEMORY)
  413. //
  414. typedef struct _PSX_ACCESS_MSG {
  415. IN UNICODE_STRING Path_U;
  416. IN LONG Amode;
  417. } PSX_ACCESS_MSG, *PPSX_ACCESS_MSG;
  418. //
  419. // PsxChmodApi (USES VIEW MEMORY)
  420. //
  421. typedef struct _PSX_CHMOD_MSG {
  422. IN UNICODE_STRING Path_U;
  423. IN mode_t Mode;
  424. } PSX_CHMOD_MSG, *PPSX_CHMOD_MSG;
  425. //
  426. // PsxChownApi (USES VIEW MEMORY)
  427. //
  428. typedef struct _PSX_CHOWN_MSG {
  429. IN UNICODE_STRING Path_U;
  430. IN uid_t Owner;
  431. IN gid_t Group;
  432. } PSX_CHOWN_MSG, *PPSX_CHOWN_MSG;
  433. //
  434. // PsxUtimeApi (USES VIEW MEMORY)
  435. //
  436. typedef struct _PSX_UTIME_MSG {
  437. IN UNICODE_STRING Path_U;
  438. IN struct utimbuf *TimesSpecified;
  439. IN struct utimbuf Times;
  440. } PSX_UTIME_MSG, *PPSX_UTIME_MSG;
  441. //
  442. // PsxPathConfApi (USES VIEW MEMORY)
  443. //
  444. typedef struct _PSX_PATHCONF_MSG {
  445. IN UNICODE_STRING Path;
  446. IN ULONG Name;
  447. } PSX_PATHCONF_MSG, *PPSX_PATHCONF_MSG;
  448. //
  449. // PsxFPathConfApi
  450. //
  451. typedef struct _PSX_FPATHCONF_MSG {
  452. IN LONG FileDes;
  453. IN ULONG Name;
  454. } PSX_FPATHCONF_MSG, *PPSX_FPATHCONF_MSG;
  455. //
  456. // PsxPipeApi
  457. //
  458. typedef struct _PSX_PIPE_MSG {
  459. IN LONG FileDes0;
  460. IN LONG FileDes1;
  461. } PSX_PIPE_MSG, *PPSX_PIPE_MSG;
  462. //
  463. // PsxDupApi
  464. //
  465. typedef struct _PSX_DUP_MSG {
  466. IN LONG FileDes;
  467. } PSX_DUP_MSG, *PPSX_DUP_MSG;
  468. //
  469. // PsxDup2Api
  470. //
  471. typedef struct _PSX_DUP2_MSG {
  472. OUT LONG FileDes;
  473. OUT LONG FileDes2;
  474. } PSX_DUP2_MSG, *PPSX_DUP2_MSG;
  475. //
  476. // PsxCloseApi
  477. //
  478. typedef struct _PSX_CLOSE_MSG {
  479. IN LONG FileDes;
  480. } PSX_CLOSE_MSG, *PPSX_CLOSE_MSG;
  481. //
  482. // PsxReadApi (USES VIEW MEMORY)
  483. //
  484. typedef struct _PSX_READ_MSG {
  485. IN LONG FileDes;
  486. OUT PUCHAR Buf;
  487. IN LONG Nbytes;
  488. ULONG Scratch1;
  489. ULONG Scratch2;
  490. OUT ULONG Command;
  491. } PSX_READ_MSG, *PPSX_READ_MSG;
  492. //
  493. // PsxReadDirApi (USES VIEW MEMORY)
  494. //
  495. typedef struct _PSX_READDIR_MSG {
  496. IN LONG FileDes;
  497. OUT PUCHAR Buf;
  498. IN LONG Nbytes;
  499. IN BOOLEAN RestartScan;
  500. } PSX_READDIR_MSG, *PPSX_READDIR_MSG;
  501. //
  502. // PsxWriteApi (USES VIEW MEMORY)
  503. //
  504. typedef struct _PSX_WRITE_MSG {
  505. IN LONG FileDes;
  506. IN PUCHAR Buf;
  507. IN LONG Nbytes;
  508. ULONG Scratch1;
  509. ULONG Scratch2;
  510. OUT ULONG Command;
  511. } PSX_WRITE_MSG, *PPSX_WRITE_MSG;
  512. //
  513. // Values for READ_MSG.Command and WRITE_MSG.Command
  514. //
  515. #define IO_COMMAND_DONE 0
  516. #define IO_COMMAND_DO_CONSIO 1
  517. //
  518. // PsxFcntlApi
  519. //
  520. typedef struct _PSX_FCNTL_MSG {
  521. IN LONG FileDes;
  522. IN int Command;
  523. IN union {
  524. struct flock *pf;
  525. int i;
  526. } u;
  527. } PSX_FCNTL_MSG, *PPSX_FCNTL_MSG;
  528. //
  529. // PsxLseekApi
  530. //
  531. typedef struct _PSX_LSEEK_MSG {
  532. IN LONG FileDes;
  533. IN LONG Whence;
  534. IN off_t Offset;
  535. } PSX_LSEEK_MSG, *PPSX_LSEEK_MSG;
  536. //
  537. // PsxTcGetAttr
  538. //
  539. typedef struct _PSX_TCGETATTR_MSG {
  540. IN LONG FileDes;
  541. OUT struct termios *Termios;
  542. } PSX_TCGETATTR_MSG, *PPSX_TCGETATTR_MSG;
  543. //
  544. // PsxTcSetAttr
  545. //
  546. typedef struct _PSX_TCSETATTR_MSG {
  547. IN LONG FileDes;
  548. IN LONG OptionalActions;
  549. IN struct termios *Termios;
  550. } PSX_TCSETATTR_MSG, *PPSX_TCSETATTR_MSG;
  551. //
  552. // PsxTcSendBreak
  553. //
  554. typedef struct _PSX_TCSENDBREAK_MSG {
  555. IN LONG FileDes;
  556. IN LONG Duration;
  557. } PSX_TCSENDBREAK_MSG, *PPSX_TCSENDBREAK_MSG;
  558. //
  559. // PsxTcDrain
  560. //
  561. typedef struct _PSX_TCDRAIN_MSG {
  562. IN LONG FileDes;
  563. } PSX_TCDRAIN_MSG, *PPSX_TCDRAIN_MSG;
  564. //
  565. // PsxTcFlush
  566. //
  567. typedef struct _PSX_TCFLUSH_MSG {
  568. IN LONG FileDes;
  569. IN LONG QueueSelector;
  570. } PSX_TCFLUSH_MSG, *PPSX_TCFLUSH_MSG;
  571. //
  572. // PsxTcFlow
  573. //
  574. typedef struct _PSX_TCFLOW_MSG {
  575. IN LONG FileDes;
  576. IN LONG Action;
  577. } PSX_TCFLOW_MSG, *PPSX_TCFLOW_MSG;
  578. //
  579. // PsxTcGetPGrp
  580. //
  581. typedef struct _PSX_TCGETPGRP_MSG {
  582. IN LONG FileDes;
  583. } PSX_TCGETPGRP_MSG, *PPSX_TCGETPGRP_MSG;
  584. //
  585. // PsxTcSetPGrp
  586. //
  587. typedef struct _PSX_TCSETPGRP_MSG {
  588. IN LONG FileDes;
  589. IN pid_t PGrpId;
  590. } PSX_TCSETPGRP_MSG, *PPSX_TCSETPGRP_MSG;
  591. //
  592. // PsxGetPwUid
  593. //
  594. typedef struct _PSX_GETPWUID_MSG {
  595. IN uid_t Uid;
  596. IN struct passwd *PwBuf;
  597. OUT int Length;
  598. } PSX_GETPWUID_MSG, *PPSX_GETPWUID_MSG;
  599. //
  600. // PsxGetPwNam
  601. //
  602. typedef struct _PSX_GETPWNAM_MSG {
  603. IN char *Name;
  604. IN struct passwd *PwBuf;
  605. OUT int Length;
  606. } PSX_GETPWNAM_MSG, *PPSX_GETPWNAM_MSG;
  607. //
  608. // PsxGetGrGid
  609. //
  610. typedef struct _PSX_GETGRGID_MSG {
  611. IN gid_t Gid;
  612. IN struct group *GrBuf;
  613. OUT int Length;
  614. } PSX_GETGRGID_MSG, *PPSX_GETGRGID_MSG;
  615. //
  616. // PsxGetGrNam
  617. //
  618. typedef struct _PSX_GETGRNAM_MSG {
  619. IN char *Name;
  620. IN struct group *GrBuf;
  621. OUT int Length;
  622. } PSX_GETGRNAM_MSG, *PPSX_GETGRNAM_MSG;
  623. //
  624. // PsxGetGroups
  625. //
  626. typedef struct _PSX_GETGROUPS_MSG {
  627. IN int NGroups;
  628. IN gid_t *GroupList;
  629. } PSX_GETGROUPS_MSG, *PPSX_GETGROUPS_MSG;
  630. //
  631. // PsxUnlink
  632. //
  633. typedef struct _PSX_UNLINK_MSG {
  634. IN UNICODE_STRING Path_U;
  635. } PSX_UNLINK_MSG, *PPSX_UNLINK_MSG;
  636. //
  637. // PsxFtruncate
  638. //
  639. typedef struct _PSX_FTRUNCATE_MSG {
  640. IN LONG FileDes;
  641. IN off_t Length;
  642. } PSX_FTRUNCATE_MSG, *PPSX_FTRUNCATE_MSG;
  643. #ifdef PSX_SOCKET
  644. //
  645. // -------- Messages for sockets.
  646. //
  647. //
  648. // PsxSocket
  649. //
  650. typedef struct _PSX_SOCKET_MSG {
  651. IN INT AddressFamily;
  652. IN INT Type;
  653. IN INT Protocol;
  654. } PSX_SOCKET_MSG, *PPSX_SOCKET_MSG;
  655. //
  656. // PsxAccept
  657. //
  658. typedef struct _PSX_ACCEPT_MSG {
  659. IN INT Socket;
  660. IN struct sockaddr *Address;
  661. IN OUT INT AddressLength;
  662. } PSX_ACCEPT_MSG, *PPSX_ACCEPT_MSG;
  663. typedef struct _PSX_BIND_MSG {
  664. IN INT Socket;
  665. IN struct sockaddr *Name;
  666. IN INT NameLength;
  667. } PSX_BIND_MSG, *PPSX_BIND_MSG;
  668. typedef struct _PSX_CONNECT_MSG {
  669. IN INT Socket;
  670. IN struct sockaddr *Name;
  671. IN INT NameLength;
  672. } PSX_CONNECT_MSG, *PPSX_CONNECT_MSG;
  673. typedef struct _PSX_GETPEERNAME_MSG {
  674. IN INT Socket;
  675. IN struct sockaddr *Name;
  676. IN OUT INT NameLength;
  677. } PSX_GETPEERNAME_MSG, *PPSX_GETPEERNAME_MSG;
  678. typedef struct _PSX_GETSOCKNAME_MSG {
  679. IN INT Socket;
  680. IN struct sockaddr *Name;
  681. IN OUT INT NameLength;
  682. } PSX_GETSOCKNAME_MSG, *PPSX_GETSOCKNAME_MSG;
  683. typedef struct _PSX_GETSOCKOPT_MSG {
  684. IN INT Socket;
  685. IN INT Level;
  686. IN INT OptName;
  687. IN PCHAR OptVal;
  688. IN OUT INT OptVal;
  689. } PSX_GETSOCKOPT_MSG, *PPSX_GETSOCKOPT_MSG;
  690. typedef struct _PSX_LISTEN_MSG {
  691. IN INT Socket;
  692. IN INT BackLog;
  693. } PSX_LISTEN_MSG, *PPSX_LISTEN_MSG;
  694. typedef struct _PSX_RECV_MSG {
  695. IN INT Socket;
  696. IN PCHAR Buffer;
  697. IN INT Length;
  698. IN INT Flags;
  699. } PSX_RECV_MSG, *PPSX_RECV_MSG;
  700. typedef struct _PSX_RECVFROM_MSG {
  701. IN INT Socket;
  702. IN PCHAR Buffer;
  703. IN INT Length;
  704. IN INT Flags;
  705. IN struct sockaddr *From;
  706. IN INT FromLength;
  707. } PSX_RECVFROM_MSG, *PPSX_RECVFROM_MSG;
  708. typdef struct _PSX_SEND_MSG {
  709. IN INT Socket;
  710. IN PCHAR Buffer;
  711. IN INT Length;
  712. IN INT Flags;
  713. } PSX_SEND_MSG, *PPSX_SEND_MSG;
  714. typedef struct _PSX_SENDTO_MSG {
  715. IN INT Socket;
  716. IN PCHAR Buffer;
  717. IN INT Length;
  718. IN INT Flags;
  719. IN struct sockaddr *To;
  720. IN INT ToLength;
  721. } PSX_SENDTO_MSG, *PPSX_SENDTO_MSG;
  722. typdef struct _PSX_SETSOCKOPT_MSG {
  723. IN INT Socket;
  724. IN INT Level;
  725. IN INT OptName;
  726. IN PCHAR OptVal;
  727. IN INT OptLen;
  728. } PSX_SETSOCKOPT_MSG, *PPSX_SETSOCKOPT_MSG;
  729. typdef struct _PSX_SHUTDOWN_MSG {
  730. IN INT Socket;
  731. IN INT How;
  732. } PSX_SHUTDOWN_MSG, *PPSX_SHUTDOWN_MSG;
  733. #endif // SOCKET
  734. //
  735. // Each API message is overlayed on top of a PORT_MESSAGE. In addition to
  736. // the common PORT_MESSAGE header (SenderId..MsgInfo), the PSX API message
  737. // format standardizes the first few words of MsgValue. The following data
  738. // structure defines the standard PSX API message header. Each API overlays
  739. // an API specific structure on top of the ArgumentArray.
  740. //
  741. #define MAXPSXAPIARGS (16 - 5)
  742. #define MAXPSXAPIARGS_BYTES ( 4 * MAXPSXAPIARGS )
  743. //
  744. // Each PSX Api Message contains:
  745. //
  746. // Lpc Port Message - Fixed size and not counted in the data length
  747. // Psx Overhead (PSXMSGOVERHEAD)
  748. // *ApiPort
  749. // ApiNumber
  750. // Error
  751. // ReturnValue
  752. // DataBlock
  753. // Signal
  754. // Union Data - Per API Structure
  755. //
  756. //
  757. // For Lpc purposes, the TotalLength of a message is sizeof(PSX_API_MSG)
  758. // and the DataLength is PSXMSGOVERHEAD + the sizeof the per API structure
  759. //
  760. //
  761. #define PSXMSGOVERHEAD 24
  762. typedef struct _PSX_API_MSG {
  763. PORT_MESSAGE h;
  764. union {
  765. PSX_API_CONNECTINFO ConnectionRequest;
  766. struct {
  767. struct _APIPORT *ApiPort; // Supplied by ApiDispatch
  768. ULONG ApiNumber; // Supplied by client range valid by ApiDispatch
  769. ULONG Error; // 0'd by ApiDispatch service sets to errno value if appropriate
  770. ULONG ReturnValue; // Api Function Return Code
  771. PVOID DataBlock; // Null or Pointer into message buffer
  772. ULONG Signal; // Signal, if Error == EINTR
  773. union {
  774. PSX_FORK_MSG Fork;
  775. PSX_EXEC_MSG Exec;
  776. PSX_WAITPID_MSG WaitPid;
  777. PSX_EXIT_MSG Exit;
  778. PSX_KILL_MSG Kill;
  779. PSX_SIGACTION_MSG SigAction;
  780. PSX_SIGPROCMASK_MSG SigProcMask;
  781. PSX_SIGPENDING_MSG SigPending;
  782. PSX_SIGSUSPEND_MSG SigSuspend;
  783. PSX_ALARM_MSG Alarm;
  784. PSX_GETIDS_MSG GetIds;
  785. PSX_SETUID_MSG SetUid;
  786. PSX_SETGID_MSG SetGid;
  787. PSX_GETGROUPS_MSG GetGroups;
  788. PSX_GETLOGIN_MSG GetLogin;
  789. PSX_CUSERID_MSG CUserId;
  790. PSX_SETPGROUPID_MSG SetPGroupId;
  791. PSX_UNAME_MSG Uname;
  792. PSX_TIME_MSG Time;
  793. PSX_GETPROCESSTIMES_MSG GetProcessTimes;
  794. PSX_TTYNAME_MSG TtyName;
  795. PSX_ISATTY_MSG Isatty;
  796. PSX_SYSCONF_MSG Sysconf;
  797. PSX_OPEN_MSG Open;
  798. PSX_UMASK_MSG Umask;
  799. PSX_LINK_MSG Link;
  800. PSX_MKDIR_MSG MkDir;
  801. PSX_MKFIFO_MSG MkFifo;
  802. PSX_RMDIR_MSG RmDir;
  803. PSX_RENAME_MSG Rename;
  804. PSX_STAT_MSG Stat;
  805. PSX_FSTAT_MSG FStat;
  806. PSX_ACCESS_MSG Access;
  807. PSX_CHMOD_MSG Chmod;
  808. PSX_CHOWN_MSG Chown;
  809. PSX_UTIME_MSG Utime;
  810. PSX_PATHCONF_MSG PathConf;
  811. PSX_FPATHCONF_MSG FPathConf;
  812. PSX_PIPE_MSG Pipe;
  813. PSX_DUP_MSG Dup;
  814. PSX_DUP2_MSG Dup2;
  815. PSX_CLOSE_MSG Close;
  816. PSX_READ_MSG Read;
  817. PSX_READDIR_MSG ReadDir;
  818. PSX_WRITE_MSG Write;
  819. PSX_FCNTL_MSG Fcntl;
  820. PSX_LSEEK_MSG Lseek;
  821. PSX_TCGETATTR_MSG TcGetAttr;
  822. PSX_TCSETATTR_MSG TcSetAttr;
  823. PSX_TCSENDBREAK_MSG TcSendBreak;
  824. PSX_TCDRAIN_MSG TcDrain;
  825. PSX_TCFLUSH_MSG TcFlush;
  826. PSX_TCFLOW_MSG TcFlow;
  827. PSX_TCGETPGRP_MSG TcGetPGrp;
  828. PSX_TCSETPGRP_MSG TcSetPGrp;
  829. PSX_GETPWUID_MSG GetPwUid;
  830. PSX_GETPWNAM_MSG GetPwNam;
  831. PSX_GETGRGID_MSG GetGrGid;
  832. PSX_GETGRNAM_MSG GetGrNam;
  833. PSX_UNLINK_MSG Unlink;
  834. PSX_FTRUNCATE_MSG Ftruncate;
  835. #ifdef PSX_SOCKET
  836. PSX_SOCKET_MSG Socket;
  837. PSX_ACCEPT_MSG Accept;
  838. PSX_BIND_MSG Bind;
  839. PSX_CONNECT_MSG Connect;
  840. PSX_GETPEERNAME_MSG GetPeerName;
  841. PSX_GETSOCKNAME_MSG GetSockName;
  842. PSX_GETSOCKOPT_MSG GetSockOpt;
  843. PSX_LISTEN_MSG Listen;
  844. PSX_RECV_MSG Recv;
  845. PSX_RECVFROM_MSG RecvFrom;
  846. PSX_SEND_MSG Send;
  847. PSX_SENDTO_MSG SendTo;
  848. PSX_SETSOCKOPT_MSG SetSockOpt;
  849. PSX_SHUTDOWN_MSG Shutdown;
  850. #endif // PSX_SOCKET
  851. } u;
  852. };
  853. };
  854. } PSX_API_MSG;
  855. typedef PSX_API_MSG *PPSX_API_MSG;
  856. #define PSX_API_MSG_LENGTH(TypeSize) \
  857. sizeof(PSX_API_MSG)<<16 | (PSXMSGOVERHEAD + (TypeSize))
  858. #define PSX_FORMAT_API_MSG(m,Number,TypeSize) \
  859. (m).h.u1.Length = PSX_API_MSG_LENGTH((TypeSize)); \
  860. (m).h.u2.ZeroInit = 0L; \
  861. (m).ApiNumber = (Number)
  862. //
  863. // PSX_CLIENT_PORT_MEMORY_SIZE defines how much address space should be
  864. // reserved for passing data to the POSIX Server. The memory is visible
  865. // to both the client and server processes.
  866. //
  867. #define PSX_CLIENT_PORT_MEMORY_SIZE 0x8000
  868. #define PSX_SS_API_PORT_NAME L"\\PSXSS\\ApiPort"
  869. #endif // _PSXMSG_