ReactOS  0.4.13-dev-563-g0561610
creport.c File Reference
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ddk/ntddk.h>
#include "dumpinfo.h"
Include dependency graph for creport.c:

Go to the source code of this file.

Macros

#define PROTO_LPC
 
#define LPC_CONNECT_FLAG1   0x00000001
 
#define LPC_CONNECT_FLAG2   0x00000010
 
#define LPC_CONNECT_FLAG3   0x00000100
 
#define LPC_CONNECT_FLAG4   0x00001000
 
#define LPC_CONNECT_FLAG5   0x00010000
 
#define BUF_SIZE   1024
 
#define MAXARG   5000000
 

Functions

 NTSTATUS (WINAPI *CreatePort)(PVOID Buffer
 
VOID TryCreatePort (char *port_name)
 
 main (int argc, char *argv[])
 

Variables

IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL
 
IN POBJECT_ATTRIBUTES PortAttributes IN ACCESS_MASK DesiredAccess
 
IN POBJECT_ATTRIBUTES PortAttributes IN ACCESS_MASK IN DWORD Unknown3
 
IN POBJECT_ATTRIBUTES PortAttributes IN ACCESS_MASK IN DWORD IN ULONG Flags
 
IN CINT ObjectInformationClass
 
IN CINT OUT PVOID ObjectInformation
 
IN CINT OUT PVOID IN ULONG Length
 
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
 

Macro Definition Documentation

◆ BUF_SIZE

#define BUF_SIZE   1024

Definition at line 46 of file creport.c.

◆ LPC_CONNECT_FLAG1

#define LPC_CONNECT_FLAG1   0x00000001

Definition at line 18 of file creport.c.

◆ LPC_CONNECT_FLAG2

#define LPC_CONNECT_FLAG2   0x00000010

Definition at line 19 of file creport.c.

◆ LPC_CONNECT_FLAG3

#define LPC_CONNECT_FLAG3   0x00000100

Definition at line 20 of file creport.c.

◆ LPC_CONNECT_FLAG4

#define LPC_CONNECT_FLAG4   0x00001000

Definition at line 21 of file creport.c.

◆ LPC_CONNECT_FLAG5

#define LPC_CONNECT_FLAG5   0x00010000

Definition at line 22 of file creport.c.

◆ MAXARG

#define MAXARG   5000000

Definition at line 47 of file creport.c.

◆ PROTO_LPC

#define PROTO_LPC

Definition at line 14 of file creport.c.

Function Documentation

◆ main()

main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 135 of file creport.c.

136 {
137  HINSTANCE ntdll;
138 
139  if (argc != 2)
140  {
141  printf("WNT LPC Port Creator\n");
142  printf("Usage: %s [port_name]\n",argv[0]);
144  }
145  printf("LoadLibrary(NTDLL)\n");
146  ntdll = LoadLibrary("NTDLL");
147  if (ntdll == NULL)
148  {
149  printf("Could not load NTDLL\n");
150  return EXIT_FAILURE;
151  }
152  printf("GetProcAddress(NTDLL.NtCreatePort)\n");
153  CreatePort = (VOID*) GetProcAddress(
154  ntdll,
155  "NtCreatePort"
156  );
157  if (CreatePort == NULL)
158  {
159  FreeLibrary(ntdll);
160  printf("Could not find NTDLL.NtCreatePort\n");
161  return EXIT_FAILURE;
162  }
163  printf("GetProcAddress(NTDLL.NtQueryObject)\n");
164  QueryObject = (VOID*) GetProcAddress(
165  ntdll,
166  "NtQueryObject"
167  );
168  if (QueryObject == NULL)
169  {
170  FreeLibrary(ntdll);
171  printf("Could not find NTDLL.NtQueryObject\n");
172  return EXIT_FAILURE;
173  }
174  printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
175  YieldExecution = (VOID*) GetProcAddress(
176  ntdll,
177  "NtYieldExecution"
178  );
179  if (YieldExecution == NULL)
180  {
181  FreeLibrary(ntdll);
182  printf("Could not find NTDLL.NtYieldExecution\n");
183  return EXIT_FAILURE;
184  }
185  printf("TryCreatePort(%s)\n",argv[1]);
186  TryCreatePort(argv[1]);
187  printf("Done\n");
188  return EXIT_SUCCESS;
189 }
static int argc
Definition: ServiceArgs.c:12
#define LoadLibrary
Definition: winbase.h:3676
#define argv
Definition: mplay32.c:18
VOID TryCreatePort(char *port_name)
Definition: creport.c:51
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
#define EXIT_FAILURE
Definition: jerror.c:33
#define GetProcAddress(x, y)
Definition: compat.h:410
void exit(int exitcode)
Definition: _exit.c:33
#define printf
Definition: config.h:203

◆ NTSTATUS()

NTSTATUS ( WINAPI CreatePort)

◆ TryCreatePort()

VOID TryCreatePort ( char port_name)

Definition at line 51 of file creport.c.

52 {
53  DWORD Status = 0;
54  HANDLE Port = 0;
55  int i;
58  WORD Name [BUF_SIZE] = {0};
59  int dwx = 0;
60  char * port_name_save = port_name;
61 
62  /*
63  * Convert the port's name to Unicode.
64  */
65  for (
66  PortName.Length = 0;
67  ( *port_name
68  && (PortName.Length < BUF_SIZE)
69  );
70  )
71  {
72  Name[PortName.Length++] = (WORD) *port_name++;
73  }
74  Name[PortName.Length] = 0;
75 
76  PortName.Length = PortName.Length * sizeof (WORD);
79  /*
80  * Prepare the port object attributes.
81  */
83  sizeof (OBJECT_ATTRIBUTES);
84  ObjectAttributes.RootDirectory =
85  NULL;
86  ObjectAttributes.ObjectName =
87  & PortName;
88  ObjectAttributes.Attributes =
89  0; //OBJ_CASE_INSENSITIVE --> STATUS_INVALID_PARAMETER ==> case sensitive!;
90  ObjectAttributes.SecurityDescriptor =
91  NULL;
92  ObjectAttributes.SecurityQualityOfService =
93  NULL;
94  /*
95  * Try to issue a connection request.
96  */
97  Port = 0;
98  Status = CreatePort(
99  & Port,
101  0, /* ACCESS_MASK? */
102  0, /* Unknown3 */
104  );
105  if (Status == STATUS_SUCCESS)
106  {
107  DumpInfo(
108  Name,
109  Status,
110  "created",
111  Port
112  );
113  /* Hot waiting */
114  for (dwx=0; dwx<MAXARG; ++dwx)
115  {
116  YieldExecution();
117  }
118  if (FALSE == CloseHandle(Port))
119  {
120  printf(
121  "Could not close the port handle %08X.\n",
122  Port
123  );
124  }
125  return;
126  }
127  printf(
128  "Creating port \"%s\" failed (Status = %08X).\n",
129  port_name_save,
130  Status
131  );
132 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
CPPORT Port[4]
Definition: headless.c:34
#define CloseHandle
Definition: compat.h:398
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:54
#define BUF_SIZE
Definition: creport.c:46
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID DumpInfo(LPCWSTR Name, NTSTATUS Status, LPCWSTR Comment, HANDLE Port)
Definition: dumpinfo.c:70
smooth NULL
Definition: ftsmooth.c:416
struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAXARG
Definition: creport.c:47
#define LPC_CONNECT_FLAG5
Definition: creport.c:22
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define printf
Definition: config.h:203
IN PUNICODE_STRING PortName
Definition: conport.c:35

Referenced by main().

Variable Documentation

◆ DesiredAccess

IN POBJECT_ATTRIBUTES PortAttributes IN ACCESS_MASK DesiredAccess

Definition at line 28 of file creport.c.

◆ Flags

Definition at line 28 of file creport.c.

◆ Length

Definition at line 37 of file creport.c.

◆ ObjectInformation

IN CINT OUT PVOID ObjectInformation

Definition at line 37 of file creport.c.

◆ ObjectInformationClass

IN CINT ObjectInformationClass

Definition at line 37 of file creport.c.

◆ OPTIONAL

IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL

Definition at line 28 of file creport.c.

◆ ResultLength

IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength

Definition at line 37 of file creport.c.

◆ Unknown3

IN POBJECT_ATTRIBUTES PortAttributes IN ACCESS_MASK IN DWORD Unknown3

Definition at line 28 of file creport.c.