ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

query.c
Go to the documentation of this file.
00001 /* $Id: query.c 53234 2011-08-14 17:17:02Z akhaldi $
00002  *
00003  * COPYRIGHT:       See COPYING in the top level directory
00004  * PROJECT:         ReactOS system libraries
00005  * FILE:            lib/smdll/query.c
00006  * PURPOSE:         Call SM API SM_API_QUERY_INFORMATION (not in NT)
00007  */
00008 
00009 #include <precomp.h>
00010 
00011 #define NDEBUG
00012 #include <debug.h>
00013 
00014 
00015 /**********************************************************************
00016  * NAME                         EXPORTED
00017  *  SmQueryInformation/5
00018  *
00019  * DESCRIPTION
00020  *  Ask the SM to collect some data from its internal data
00021  *  structures and send it back.
00022  *
00023  * ARGUMENTS
00024  *  hSmApiPort: handle returned by SmConnectApiPort;
00025  *  SmInformationClass: an SM information class ID:
00026  *      SM_BASIC_INFORMATION: the number of registered subsystems
00027  *  Data: pointer to storage for the information to request;
00028  *  DataLength: length in bytes of the Data buffer; it must be
00029  *      set and must match the SmInformationClass info size;
00030  *  ReturnedDataLength: optional pointer to storage to receive
00031  *      the size of the returnede data.
00032  *
00033  * RETURN VALUE
00034  *  STATUS_SUCCESS: OK you get what you asked for;
00035  *  STATUS_INFO_LENGTH_MISMATCH: you set DataLength to 0 or to a
00036  *      value that does not match whet the SmInformationClass
00037  *      requires;
00038  *  STATUS_INVALID_PARAMETER_2: bad information class;
00039  *  A port error.
00040  *
00041  */
00042 NTSTATUS WINAPI
00043 SmQueryInformation (IN      HANDLE                hSmApiPort,
00044             IN      SM_INFORMATION_CLASS  SmInformationClass,
00045             IN OUT  PVOID                 Data,
00046             IN      ULONG                 DataLength,
00047             IN OUT  PULONG                ReturnedDataLength OPTIONAL)
00048 {
00049     NTSTATUS         Status = STATUS_SUCCESS;
00050     SM_PORT_MESSAGE  SmReqMsg;
00051 
00052 
00053     if(0 == DataLength)
00054     {
00055         return STATUS_INFO_LENGTH_MISMATCH;
00056     }
00057     /* Marshal data in the port message */
00058     switch (SmInformationClass)
00059     {
00060         case SmBasicInformation:
00061             if(DataLength != sizeof (SM_BASIC_INFORMATION))
00062             {
00063                 return STATUS_INFO_LENGTH_MISMATCH;
00064             }
00065             SmReqMsg.Request.QryInfo.SmInformationClass = SmBasicInformation;
00066             SmReqMsg.Request.QryInfo.DataLength = DataLength;
00067             SmReqMsg.Request.QryInfo.BasicInformation.SubSystemCount = 0;
00068             break;
00069         case SmSubSystemInformation:
00070             if(DataLength != sizeof (SM_SUBSYSTEM_INFORMATION))
00071             {
00072                 return STATUS_INFO_LENGTH_MISMATCH;
00073             }
00074             SmReqMsg.Request.QryInfo.SmInformationClass = SmSubSystemInformation;
00075             SmReqMsg.Request.QryInfo.DataLength = DataLength;
00076             SmReqMsg.Request.QryInfo.SubSystemInformation.SubSystemId =
00077                 ((PSM_SUBSYSTEM_INFORMATION)Data)->SubSystemId;
00078             break;
00079         default:
00080             return STATUS_INVALID_PARAMETER_2;
00081     }
00082     /* SM API to invoke */
00083     SmReqMsg.SmHeader.ApiIndex = SM_API_QUERY_INFORMATION;
00084 
00085     /* Prepare the port request message */
00086     SmReqMsg.Header.u2.s2.Type = LPC_NEW_MESSAGE;
00087     SmReqMsg.Header.u1.s1.DataLength    = SM_PORT_DATA_SIZE(SmReqMsg.Request);
00088     SmReqMsg.Header.u1.s1.TotalLength = SM_PORT_MESSAGE_SIZE;
00089     Status = NtRequestWaitReplyPort (hSmApiPort, (PPORT_MESSAGE) & SmReqMsg, (PPORT_MESSAGE) & SmReqMsg);
00090     if (NT_SUCCESS(Status))
00091     {
00092         /* Unmarshal data */
00093         RtlCopyMemory (Data, & SmReqMsg.Reply.QryInfo.BasicInformation, SmReqMsg.Reply.QryInfo.DataLength);
00094         /* Use caller provided storage to store data size */
00095         if(NULL != ReturnedDataLength)
00096         {
00097             *ReturnedDataLength = SmReqMsg.Reply.QryInfo.DataLength;
00098         }
00099         return SmReqMsg.SmHeader.Status;
00100     }
00101     DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
00102     return Status;
00103 }
00104 /* EOF */

Generated on Fri May 25 2012 04:15:21 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.