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

uexec.c File Reference

#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <string.h>

Go to the source code of this file.

Functions

NTSTATUS main (IN ULONG argc, IN PCH argv[], IN PCH envp[], IN ULONG DebugParameter OPTIONAL)

Variables

PVOID MyHeap = NULL


Function Documentation

NTSTATUS main IN ULONG  argc,
IN PCH  argv[],
IN PCH  envp[],
IN ULONG DebugParameter  OPTIONAL
 

Definition at line 30 of file uexec.c.

References CHAR, DbgPrint, MyHeap, NT_SUCCESS, NtResumeThread(), NTSTATUS(), NtWaitForSingleObject(), NULL, RtlAllocateHeap, RtlCreateUserProcess(), Status, and TRUE.

00036 { 00037 NTSTATUS Status; 00038 STRING ImagePathName; 00039 PCHAR PathVariable, *pp; 00040 CHAR ImageNameBuffer[ 128 ]; 00041 RTL_USER_PROCESS_INFORMATION ProcessInformation; 00042 PRTL_USER_PROCESS_PARAMETERS ProcessParameters; 00043 ULONG i, CountBytes, envc, Bogus; 00044 PSTRING DstString; 00045 PCH Src, Dst; 00046 PCH Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+2 ]; 00047 00048 Parameters[ RTL_USER_PROC_PARAMS_IMAGEFILE ] = 00049 "Full Path Specification of Image File goes here"; 00050 00051 Parameters[ RTL_USER_PROC_PARAMS_CMDLINE ] = 00052 "Complete Command Line goes here"; 00053 00054 Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG ] = 00055 "Debugging String goes here"; 00056 00057 Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+1 ] = NULL; 00058 00059 MyHeap = RtlProcessHeap(); 00060 00061 #if DBG 00062 DbgPrint( "Entering UEXEC User Mode Test Program\n" ); 00063 DbgPrint( "argc = %ld\n", argc ); 00064 for (i=0; i<=argc; i++) { 00065 DbgPrint( "argv[ %ld ]: %s\n", 00066 i, 00067 argv[ i ] ? argv[ i ] : "<NULL>" 00068 ); 00069 } 00070 DbgPrint( "\n" ); 00071 for (i=0; envp[i]; i++) { 00072 DbgPrint( "envp[ %ld ]: %s\n", i, envp[ i ] ); 00073 } 00074 00075 #endif 00076 00077 PathVariable = "\\SystemRoot"; 00078 if (envp != NULL) { 00079 pp = envp; 00080 while (Src = *pp++) { 00081 if (!_strnicmp( Src, "PATH=", 5 )) { 00082 PathVariable = Src+5; 00083 break; 00084 } 00085 } 00086 } 00087 00088 DbgPrint( "PATH=%s\n", PathVariable ); 00089 00090 ProcessParameters = (PRTL_USER_PROCESS_PARAMETERS) 00091 RtlAllocateHeap( MyHeap, 0, 2048 ); 00092 ProcessParameters->MaximumLength = 2048; 00093 00094 argv[ argc ] = NULL; 00095 Status = RtlVectorsToProcessParameters( 00096 argv, 00097 envp, 00098 Parameters, 00099 ProcessParameters 00100 ); 00101 00102 ImagePathName.Buffer = ImageNameBuffer; 00103 ImagePathName.Length = 0; 00104 ImagePathName.MaximumLength = sizeof( ImageNameBuffer ); 00105 if (RtlSearchPath( PathVariable, "uexec1.exe", NULL, &ImagePathName )) { 00106 Status = RtlCreateUserProcess( &ImagePathName, 00107 NULL, 00108 NULL, 00109 NULL, 00110 TRUE, 00111 NULL, 00112 NULL, 00113 ProcessParameters, 00114 &ProcessInformation, 00115 NULL 00116 ); 00117 if (NT_SUCCESS( Status )) { 00118 Status = NtResumeThread( ProcessInformation.Thread, &Bogus ); 00119 if (NT_SUCCESS( Status )) { 00120 #if DBG 00121 DbgPrint( "UEXEC waiting for UEXEC1...\n" ); 00122 #endif 00123 Status = NtWaitForSingleObject( ProcessInformation.Process, 00124 TRUE, 00125 NULL 00126 ); 00127 } 00128 } 00129 } 00130 else { 00131 DbgPrint( "UEXEC1.EXE not found in %s\n", PathVariable ); 00132 Status = STATUS_UNSUCCESSFUL; 00133 } 00134 00135 #if DBG 00136 DbgPrint( "Leaving UEXEC User Mode Test Program\n" ); 00137 #endif 00138 00139 return( Status ); 00140 }


Variable Documentation

PVOID MyHeap = NULL
 

Definition at line 27 of file uexec.c.

Referenced by main(), and VectorTest().


Generated on Sat May 15 19:45:51 2004 for test by doxygen 1.3.7