3 * DESCRIPTION: Simple LPC Client
4 * PROGRAMMER: David Welch
16 const char * MyName = "LPC-CLI";
20 void debug_printf(char* fmt, ...)
26 vsprintf(buffer,fmt,args);
27 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
32 int main(int argc, char* argv[])
34 UNICODE_STRING PortName = UNICODE_STRING_INITIALIZER(TEST_PORT_NAME_U);
37 LPC_MAX_MESSAGE Request;
39 ULONG ConnectInfoLength = 0;
40 SECURITY_QUALITY_OF_SERVICE Sqos;
42 printf("%s: Lpc test client\n", MyName);
44 printf("%s: Connecting to port \"%s\"...\n", MyName, TEST_PORT_NAME);
45 ConnectInfoLength = 0;
46 ZeroMemory (& Sqos, sizeof Sqos);
47 Status = NtConnectPort(&PortHandle,
55 if (!NT_SUCCESS(Status))
57 printf("%s: NtConnectPort() failed with status = 0x%08X.\n", MyName, Status);
61 printf("%s: Connected to \"%s\" with anonymous port 0x%x.\n", MyName, TEST_PORT_NAME, PortHandle);
63 ZeroMemory(& Request, sizeof Request);
64 strcpy(Request.Data, GetCommandLineA());
65 Request.Header.DataSize = strlen(Request.Data);
66 Request.Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) +
67 Request.Header.DataSize;
69 printf("%s: Sending to port 0x%x message \"%s\"...\n",
72 (char *) Request.Data);
73 Status = NtRequestPort(PortHandle,
75 if (!NT_SUCCESS(Status))
77 printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
84 printf("%s: Sending datagram to port 0x%x succeeded.\n", MyName, PortHandle);
88 printf("%s: Disconnecting...", MyName);