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

uexec.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 uexec.c 00008 00009 Abstract: 00010 00011 Test program for the NT OS User Mode Runtime Library (URTL) 00012 00013 Author: 00014 00015 Steve Wood (stevewo) 18-Aug-1989 00016 00017 Revision History: 00018 00019 --*/ 00020 00021 #include <nt.h> 00022 #include <ntrtl.h> 00023 #include <nturtl.h> 00024 00025 #include <string.h> 00026 00027 PVOID MyHeap = NULL; 00028 00029 NTSTATUS 00030 main( 00031 IN ULONG argc, 00032 IN PCH argv[], 00033 IN PCH envp[], 00034 IN ULONG DebugParameter OPTIONAL 00035 ) 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 }

Generated on Sat May 15 19:42:10 2004 for test by doxygen 1.3.7