ReactOS 0.4.15-dev-5669-g09dde2c
lpcclt.c
Go to the documentation of this file.
1/*
2 * DESCRIPTION: Simple LPC Client
3 * PROGRAMMER: David Welch
4 */
5#include <ddk/ntddk.h>
6#include <rosrtl/string.h>
7#include <windows.h>
8#include <stdarg.h>
9#include <string.h>
10#include <stdio.h>
11#include <stdlib.h>
12
13#include "lpctest.h"
14
15const char * MyName = "LPC-CLI";
18
19void debug_printf(char* fmt, ...)
20{
22 char buffer[255];
23
27 va_end(args);
28}
29
30
31int main(int argc, char* argv[])
32{
33 UNICODE_STRING PortName = ROS_STRING_INITIALIZER(TEST_PORT_NAME_U);
35 HANDLE PortHandle;
36 LPC_MAX_MESSAGE Request;
37 ULONG ConnectInfo;
38 ULONG ConnectInfoLength = 0;
40
41 printf("%s: Lpc test client\n", MyName);
42
43 printf("%s: Connecting to port \"%s\"...\n", MyName, TEST_PORT_NAME);
44 ConnectInfoLength = 0;
45 ZeroMemory (& Sqos, sizeof Sqos);
46 Status = NtConnectPort(&PortHandle,
47 &PortName,
48 & Sqos,
49 0,
50 0,
51 0,
52 NULL,
53 &ConnectInfoLength);
54 if (!NT_SUCCESS(Status))
55 {
56 printf("%s: NtConnectPort() failed with status = 0x%08X.\n", MyName, Status);
57 return EXIT_FAILURE;
58 }
59
60 printf("%s: Connected to \"%s\" with anonymous port 0x%x.\n", MyName, TEST_PORT_NAME, PortHandle);
61
62 ZeroMemory(& Request, sizeof Request);
64 Request.Header.DataSize = strlen(Request.Data);
65 Request.Header.MessageSize = sizeof(LPC_MESSAGE) +
66 Request.Header.DataSize;
67
68 printf("%s: Sending to port 0x%x message \"%s\"...\n",
69 MyName,
70 PortHandle,
71 (char *) Request.Data);
72 Status = NtRequestPort(PortHandle,
73 &Request.Header);
74 if (!NT_SUCCESS(Status))
75 {
76 printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
77 MyName,
78 PortHandle,
79 Status);
80 return EXIT_FAILURE;
81 }
82
83 printf("%s: Sending datagram to port 0x%x succeeded.\n", MyName, PortHandle);
84
85 Sleep(2000);
86
87 printf("%s: Disconnecting...", MyName);
88 NtClose (PortHandle);
89
90 return EXIT_SUCCESS;
91}
static UNICODE_STRING PortName
static int argc
Definition: ServiceArgs.c:12
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleA(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1468
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2003
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:94
Status
Definition: gdiplustypes.h:25
GLuint buffer
Definition: glext.h:5915
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define EXIT_FAILURE
Definition: jerror.c:33
HANDLE InputHandle
Definition: lpcclt.c:17
void debug_printf(char *fmt,...)
Definition: lpcclt.c:19
const char * MyName
Definition: lpcclt.c:15
HANDLE OutputHandle
Definition: lpcclt.c:16
#define TEST_PORT_NAME
Definition: lpctest.h:3
#define TEST_PORT_NAME_U
Definition: lpctest.h:4
struct _LPC_MESSAGE LPC_MESSAGE
#define argv
Definition: mplay32.c:18
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtConnectPort(OUT PHANDLE PortHandle, IN PUNICODE_STRING PortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN OUT PPORT_VIEW ClientView OPTIONAL, IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL, OUT PULONG MaxMessageLength OPTIONAL, IN OUT PVOID ConnectionInformation OPTIONAL, IN OUT PULONG ConnectionInformationLength OPTIONAL)
Definition: connect.c:753
NTSTATUS NTAPI NtRequestPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest)
Definition: send.c:440
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
#define args
Definition: format.c:66
Definition: match.c:390
Definition: dsound.c:943
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define ZeroMemory
Definition: winbase.h:1670