test: lpcquery.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# lpcquery.c File Reference

`#include "lpcp.h"`

Go to the source code of this file.

## Functions

NTSTATUS NTAPI | NtQueryInformationPort (IN HANDLE PortHandle OPTIONAL, IN PORT_INFORMATION_CLASS PortInformationClass, OUT PVOID PortInformation, IN ULONG Length, OUT PULONG ReturnLength OPTIONAL)

## Function Documentation

NTSTATUS NTAPI NtQueryInformationPort | ( | IN HANDLE PortHandle | OPTIONAL,
|  | IN PORT_INFORMATION_CLASS | PortInformationClass,
|  | OUT PVOID | PortInformation,
|  | IN ULONG | Length,
|  | OUT PULONG ReturnLength | OPTIONAL
| ) |

Definition at line 30 of file lpcquery.c.

References EXCEPTION_EXECUTE_HANDLER, KernelMode, KPROCESSOR_MODE, LpcPortObjectType, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObjectByHandle(), PAGED_CODE, PortHandle, ProbeForWrite(), ProbeForWriteUlong, and Status.

    00040                    :
    00041
    00042     This routine should be used to query an lpc port, but is pretty much a
    00043     noop.  Currently it can only indicate if the input handle is for a port
    00044     object.
    00045
    00046 Arguments:
    00047
    00048     PortHandle - Supplies the handle for the port being queried
    00049
    00050     PortInformationClass - Specifies the type information class being asked
    00051         for.  Currently ignored.
    00052
    00053     PortInformation - Supplies a pointer to the buffer to receive the
    00054         information.  Currently just probed and then ignored.
    00055
    00056     Length - Specifies, in bytes, the size of the port information buffer.
    00057
    00058     ReturnLength  - Optionally receives the size, in bytes, of the information
    00059         being returned.  Currently just probed and then ignored.
    00060
    00061 Return Value:
    00062
    00063     NTSTATUS - An appropriate status value.
    00064
    00065 --*/
    00066
    00067 {
    00068     KPROCESSOR_MODE PreviousMode;
    00069     NTSTATUS Status;
    00070     PLPCP_PORT_OBJECT PortObject;
    00071
    00072     PAGED_CODE();
    00073
    00074     //
    00075     //  Get previous processor mode and probe output argument if necessary.
    00076     //
    00077
    00078     PreviousMode = KeGetPreviousMode();
    00079
    00080     if (PreviousMode != KernelMode) {
    00081
    00082         try {
    00083
    00084             ProbeForWrite( PortInformation,
    00085                            Length,
    00086                            sizeof( ULONG ));
    00087
    00088             if (ARGUMENT_PRESENT( ReturnLength )) {
    00089
    00090                 ProbeForWriteUlong( ReturnLength );
    00091             }
    00092
    00093         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00094
    00095             return( GetExceptionCode() );
    00096         }
    00097     }
    00098
    00099     //
    00100     //  If the user gave us a handle then reference the object.  And return
    00101     //  success if we got a good reference and an error otherwise.
    00102     //
    00103
    00104     if (ARGUMENT_PRESENT( PortHandle )) {
    00105
    00106         Status = ObReferenceObjectByHandle( PortHandle,
    00107                                             GENERIC_READ,
    00108                                             LpcPortObjectType,
    00109                                             PreviousMode,
    00110                                             &PortObject,
    00111                                             NULL );
    00112
    00113         if (!NT_SUCCESS( Status )) {
    00114
    00115             return( Status );
    00116         }
    00117
    00118         ObDereferenceObject( PortObject );
    00119
    00120         return STATUS_SUCCESS;
    00121
    00122     } else {
    00123
    00124         return STATUS_INVALID_INFO_CLASS;
    00125     }
    00126 }
    }