summaryrefslogtreecommitdiffstats
path: root/private/ntos/rtl/uexec.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/rtl/uexec.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/ntos/rtl/uexec.c')
-rw-r--r--private/ntos/rtl/uexec.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/private/ntos/rtl/uexec.c b/private/ntos/rtl/uexec.c
new file mode 100644
index 000000000..71fe7a684
--- /dev/null
+++ b/private/ntos/rtl/uexec.c
@@ -0,0 +1,140 @@
+/*++
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ uexec.c
+
+Abstract:
+
+ Test program for the NT OS User Mode Runtime Library (URTL)
+
+Author:
+
+ Steve Wood (stevewo) 18-Aug-1989
+
+Revision History:
+
+--*/
+
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+
+#include <string.h>
+
+PVOID MyHeap = NULL;
+
+NTSTATUS
+main(
+ IN ULONG argc,
+ IN PCH argv[],
+ IN PCH envp[],
+ IN ULONG DebugParameter OPTIONAL
+ )
+{
+ NTSTATUS Status;
+ STRING ImagePathName;
+ PCHAR PathVariable, *pp;
+ CHAR ImageNameBuffer[ 128 ];
+ RTL_USER_PROCESS_INFORMATION ProcessInformation;
+ PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
+ ULONG i, CountBytes, envc, Bogus;
+ PSTRING DstString;
+ PCH Src, Dst;
+ PCH Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+2 ];
+
+ Parameters[ RTL_USER_PROC_PARAMS_IMAGEFILE ] =
+ "Full Path Specification of Image File goes here";
+
+ Parameters[ RTL_USER_PROC_PARAMS_CMDLINE ] =
+ "Complete Command Line goes here";
+
+ Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG ] =
+ "Debugging String goes here";
+
+ Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+1 ] = NULL;
+
+ MyHeap = RtlProcessHeap();
+
+#if DBG
+ DbgPrint( "Entering UEXEC User Mode Test Program\n" );
+ DbgPrint( "argc = %ld\n", argc );
+ for (i=0; i<=argc; i++) {
+ DbgPrint( "argv[ %ld ]: %s\n",
+ i,
+ argv[ i ] ? argv[ i ] : "<NULL>"
+ );
+ }
+ DbgPrint( "\n" );
+ for (i=0; envp[i]; i++) {
+ DbgPrint( "envp[ %ld ]: %s\n", i, envp[ i ] );
+ }
+
+#endif
+
+ PathVariable = "\\SystemRoot";
+ if (envp != NULL) {
+ pp = envp;
+ while (Src = *pp++) {
+ if (!_strnicmp( Src, "PATH=", 5 )) {
+ PathVariable = Src+5;
+ break;
+ }
+ }
+ }
+
+ DbgPrint( "PATH=%s\n", PathVariable );
+
+ ProcessParameters = (PRTL_USER_PROCESS_PARAMETERS)
+ RtlAllocateHeap( MyHeap, 0, 2048 );
+ ProcessParameters->MaximumLength = 2048;
+
+ argv[ argc ] = NULL;
+ Status = RtlVectorsToProcessParameters(
+ argv,
+ envp,
+ Parameters,
+ ProcessParameters
+ );
+
+ ImagePathName.Buffer = ImageNameBuffer;
+ ImagePathName.Length = 0;
+ ImagePathName.MaximumLength = sizeof( ImageNameBuffer );
+ if (RtlSearchPath( PathVariable, "uexec1.exe", NULL, &ImagePathName )) {
+ Status = RtlCreateUserProcess( &ImagePathName,
+ NULL,
+ NULL,
+ NULL,
+ TRUE,
+ NULL,
+ NULL,
+ ProcessParameters,
+ &ProcessInformation,
+ NULL
+ );
+ if (NT_SUCCESS( Status )) {
+ Status = NtResumeThread( ProcessInformation.Thread, &Bogus );
+ if (NT_SUCCESS( Status )) {
+#if DBG
+ DbgPrint( "UEXEC waiting for UEXEC1...\n" );
+#endif
+ Status = NtWaitForSingleObject( ProcessInformation.Process,
+ TRUE,
+ NULL
+ );
+ }
+ }
+ }
+ else {
+ DbgPrint( "UEXEC1.EXE not found in %s\n", PathVariable );
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
+#if DBG
+ DbgPrint( "Leaving UEXEC User Mode Test Program\n" );
+#endif
+
+ return( Status );
+}