ReactOS  0.4.15-dev-1386-g5cb9f87
query.c File Reference
#include "precomp.h"
#include <ndk/lpctypes.h>
#include <ndk/lpcfuncs.h>
#include <sm/helper.h>
#include <debug.h>
Include dependency graph for query.c:

Go to the source code of this file.

Macros

#define NTOS_MODE_USER
 
#define NDEBUG
 

Functions

NTSTATUS WINAPI SmQueryInformation (IN HANDLE hSmApiPort, IN SM_INFORMATION_CLASS SmInformationClass, IN OUT PVOID Data, IN ULONG DataLength, IN OUT PULONG ReturnedDataLength OPTIONAL)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file query.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 10 of file query.c.

Function Documentation

◆ SmQueryInformation()

NTSTATUS WINAPI SmQueryInformation ( IN HANDLE  hSmApiPort,
IN SM_INFORMATION_CLASS  SmInformationClass,
IN OUT PVOID  Data,
IN ULONG  DataLength,
IN OUT PULONG ReturnedDataLength  OPTIONAL 
)

Definition at line 47 of file query.c.

52 {
54  SM_PORT_MESSAGE SmReqMsg;
55 
56 
57  if(0 == DataLength)
58  {
60  }
61  /* Marshal data in the port message */
62  switch (SmInformationClass)
63  {
64  case SmBasicInformation:
65  if(DataLength != sizeof (SM_BASIC_INFORMATION))
66  {
68  }
69  SmReqMsg.Request.QryInfo.SmInformationClass = SmBasicInformation;
70  SmReqMsg.Request.QryInfo.DataLength = DataLength;
71  SmReqMsg.Request.QryInfo.BasicInformation.SubSystemCount = 0;
72  break;
74  if(DataLength != sizeof (SM_SUBSYSTEM_INFORMATION))
75  {
77  }
78  SmReqMsg.Request.QryInfo.SmInformationClass = SmSubSystemInformation;
79  SmReqMsg.Request.QryInfo.DataLength = DataLength;
80  SmReqMsg.Request.QryInfo.SubSystemInformation.SubSystemId =
81  ((PSM_SUBSYSTEM_INFORMATION)Data)->SubSystemId;
82  break;
83  default:
85  }
86  /* SM API to invoke */
87  SmReqMsg.SmHeader.ApiIndex = SM_API_QUERY_INFORMATION;
88 
89  /* Prepare the port request message */
90  SmReqMsg.Header.u2.s2.Type = LPC_NEW_MESSAGE;
91  SmReqMsg.Header.u1.s1.DataLength = SM_PORT_DATA_SIZE(SmReqMsg.Request);
92  SmReqMsg.Header.u1.s1.TotalLength = SM_PORT_MESSAGE_SIZE;
93  Status = NtRequestWaitReplyPort (hSmApiPort, (PPORT_MESSAGE) & SmReqMsg, (PPORT_MESSAGE) & SmReqMsg);
94  if (NT_SUCCESS(Status))
95  {
96  /* Unmarshal data */
97  RtlCopyMemory (Data, & SmReqMsg.Reply.QryInfo.BasicInformation, SmReqMsg.Reply.QryInfo.DataLength);
98  /* Use caller provided storage to store data size */
99  if(NULL != ReturnedDataLength)
100  {
101  *ReturnedDataLength = SmReqMsg.Reply.QryInfo.DataLength;
102  }
103  return SmReqMsg.SmHeader.Status;
104  }
105  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
106  return Status;
107 }
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:695
struct _SM_SUBSYSTEM_INFORMATION * PSM_SUBSYSTEM_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
struct _SM_PORT_MESSAGE::@3499::@3501::@3503 SmHeader
#define SM_PORT_DATA_SIZE(c)
Definition: api.h:149
#define SM_API_QUERY_INFORMATION
Definition: api.h:68
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
void DPRINT(...)
Definition: polytest.cpp:61
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112
PORT_MESSAGE Header
Definition: api.h:112
#define SM_PORT_MESSAGE_SIZE
Definition: api.h:150
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __FUNCTION__
Definition: types.h:112
union _SM_PORT_MESSAGE::@3499::@3501::@3504::@3506 Request