33{
39 LPC_MAX_MESSAGE ConnectMsg;
40
42
45 0,
48
52 0,
53 0,
54 0);
56 {
59 }
61
62 for (;;)
63 {
64 printf(
"%s: Listening for connections requests on port 0x%x...\n",
MyName, NamedPortHandle);
66 &ConnectMsg.Header);
68 {
71 }
72
73 printf(
"%s: Received connection request 0x%08x on port 0x%x.\n",
MyName,
74 ConnectMsg.Header.MessageId, NamedPortHandle);
76 ConnectMsg.Header.ClientId.UniqueProcess, ConnectMsg.Header.ClientId.UniqueThread);
77
78 printf(
"%s: Accepting connection request 0x%08x...\n",
MyName,
79 ConnectMsg.Header.MessageId);
81 NamedPortHandle,
82 & ConnectMsg.Header,
84 0,
87 {
90 }
91 printf(
"%s: Connection request 0x%08x accepted as port 0x%x.\n",
MyName,
92 ConnectMsg.Header.MessageId, PortHandle);
93
94 printf(
"%s: Completing connection for port 0x%x (0x%08x).\n",
MyName,
95 PortHandle, ConnectMsg.Header.MessageId);
98 {
101 }
102
103 printf(
"%s: Entering server loop for port 0x%x...\n",
MyName, PortHandle);
104 for(;;)
105 {
107
109 0,
113 {
114 printf(
"%s: NtReplyWaitReceivePort() failed with status = 0x%08lX.\n",
MyName,
Status);
116 }
117
119 {
120 printf(
"%s: Datagram message contents are <%s>.\n",
123 }
124 else
125 {
126 printf(
"%s: Message with type %d received on port 0x%x.\n",
MyName,
127 PORT_MESSAGE_TYPE(
Request), PortHandle);
129 printf(
"%s: Connected port 0x%x closed.\n\n",
MyName, PortHandle);
130 break;
131 }
132 }
133 }
135}
static UNICODE_STRING PortName
NTSTATUS NTAPI NtAcceptConnectPort(OUT PHANDLE PortHandle, IN PVOID PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage, IN BOOLEAN AcceptConnection, IN OUT PPORT_VIEW ServerView OPTIONAL, OUT PREMOTE_PORT_VIEW ClientView OPTIONAL)
NTSTATUS NTAPI NtCompleteConnectPort(IN HANDLE PortHandle)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static const char * MyName
#define InitializeObjectAttributes(p, n, a, r, s)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSTATUS NTAPI NtCreatePort(OUT PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, IN ULONG MaxDataLength, IN ULONG MaxPoolUsage)
NTSTATUS NTAPI NtListenPort(IN HANDLE PortHandle, OUT PPORT_MESSAGE ConnectMessage)
NTSTATUS NTAPI NtReplyWaitReceivePort(IN HANDLE PortHandle, OUT PVOID *PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage OPTIONAL, OUT PPORT_MESSAGE ReceiveMessage)