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

execpgm.c
Go to the documentation of this file.
00001 /* $Id: execpgm.c 37763 2008-11-30 11:42:05Z sginsberg $
00002  *
00003  * COPYRIGHT:       See COPYING in the top level directory
00004  * PROJECT:         ReactOS system libraries
00005  * FILE:            lib/smlib/execpgm.c
00006  * PURPOSE:         Call SM API SM_API_EXECPGM
00007  */
00008 #include "precomp.h"
00009 
00010 #define NDEBUG
00011 #include <debug.h>
00012 
00013 /**********************************************************************
00014  * NAME                         EXPORTED
00015  *  SmExecuteProgram/2
00016  *
00017  * DESCRIPTION
00018  *  This function is used to make the SM start an environment
00019  *  subsystem server process.
00020  *
00021  * ARGUMENTS
00022  *  hSmApiPort: port handle returned by SmConnectApiPort;
00023  *  Pgm       : name of the subsystem (to be used by the SM to
00024  *              lookup the image name from the registry).
00025  *              Valid names are: DEBUG, WINDOWS, POSIX, OS2,
00026  *              and VMS.
00027  *
00028  * RETURN VALUE
00029  *  Success status as handed by the SM reply; otherwise a failure
00030  *  status code.
00031  */
00032 NTSTATUS WINAPI
00033 SmExecuteProgram (IN HANDLE          hSmApiPort,
00034           IN PUNICODE_STRING Pgm)
00035 {
00036   NTSTATUS         Status;
00037   SM_PORT_MESSAGE  SmReqMsg;
00038 
00039 
00040   DPRINT("SMLIB: %s(%08lx,'%S') called\n",
00041     __FUNCTION__, hSmApiPort, Pgm->Buffer);
00042 
00043   /* Check Pgm's length */
00044   if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
00045   {
00046     return STATUS_INVALID_PARAMETER;
00047   }
00048   /* Marshal Pgm in the LPC message */
00049   RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
00050   SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;
00051   RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,
00052          Pgm->Buffer,
00053          Pgm->Length);
00054 
00055   /* SM API to invoke */
00056   SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;
00057 
00058   /* LPC message */
00059   SmReqMsg.Header.u2.s2.Type = LPC_NEW_MESSAGE;
00060   SmReqMsg.Header.u1.s1.DataLength    = SM_PORT_DATA_SIZE(SmReqMsg.Request);
00061   SmReqMsg.Header.u1.s1.TotalLength = SM_PORT_MESSAGE_SIZE;
00062 
00063   DPRINT("SMLIB: %s:\n"
00064       "  u2.s2.Type = %d\n"
00065       "  u1.s1.DataLength    = %d\n"
00066       "  u1.s1.TotalLength = %d\n"
00067       "  sizeof(PORT_MESSAGE)==%d\n",
00068       __FUNCTION__,
00069       SmReqMsg.Header.u2.s2.Type,
00070       SmReqMsg.Header.u1.s1.DataLength,
00071       SmReqMsg.Header.u1.s1.TotalLength,
00072       sizeof(PORT_MESSAGE));
00073 
00074   /* Call SM and wait for a reply */
00075   Status = NtRequestWaitReplyPort (hSmApiPort, (PPORT_MESSAGE) & SmReqMsg, (PPORT_MESSAGE) & SmReqMsg);
00076   if (NT_SUCCESS(Status))
00077   {
00078     return SmReqMsg.SmHeader.Status;
00079   }
00080   DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
00081   return Status;
00082 }
00083 
00084 /* EOF */

Generated on Sun May 27 2012 04:37:03 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.