test: urtl.c File Reference

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

# urtl.c File Reference

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

Go to the source code of this file.

## Functions

| DumpIt (IN PRTL_USER_PROCESS_PARAMETERS ArgBase)
BOOLEAN | VectorTest (IN PCH Arguments[], IN PCH Variables[], IN PCH Parameters[])
NTSTATUS | main (IN ULONG argc, IN PCH argv[], IN PCH envp[], IN ULONG DebugParameter OPTIONAL)

## Variables

PVOID | MyHeap = NULL

## Function Documentation

DumpIt | ( | IN PRTL_USER_PROCESS_PARAMETERS | ArgBase | ) |

Definition at line 27 of file urtl.c.

References DbgPrint, and VOID().

Referenced by VectorTest().

    00030 {
    00031     ULONG Base;
    00032     PSTRING Vector;
    00033     PCH *ParmVector;
    00034     ULONG i;
    00035
    00036     (VOID) RtlNormalizeProcessParameters( ArgBase );
    00037     (VOID) RtlDeNormalizeProcessParameters( ArgBase );
    00038
    00039     Base = (ULONG) ArgBase;
    00040
    00041     DbgPrint("DumpIt: ArgBase       %lx\n",ArgBase);
    00042     DbgPrint("DumpIt: MaximumLength %lx\n",ArgBase->MaximumLength);
    00043     DbgPrint("DumpIt: Length        %lx\n",ArgBase->Length);
    00044     DbgPrint("DumpIt: ArgumentCount %lx\n",ArgBase->ArgumentCount);
    00045     DbgPrint("DumpIt: Arguments     %lx\n",ArgBase->Arguments    );
    00046     DbgPrint("DumpIt: VariableCount %lx\n",ArgBase->VariableCount);
    00047     DbgPrint("DumpIt: Variables     %lx\n",ArgBase->Variables    );
    00048     DbgPrint("DumpIt: ParameterCount%lx\n",ArgBase->ParameterCount);
    00049     DbgPrint("DumpIt: Parameters    %lx\n",ArgBase->Parameters    );
    00050
    00051     if ( ArgBase->ArgumentCount ) {
    00052         Vector = (PSTRING)((PCH)ArgBase->Arguments + Base);
    00053         i = ArgBase->ArgumentCount;
    00054         while(i--){
    00055             DbgPrint("DumpIt: Argument %s\n",Vector->Buffer + Base);
    00056             Vector++;
    00057         }
    00058     }
    00059
    00060     if ( ArgBase->VariableCount ) {
    00061         Vector = (PSTRING)((PCH)ArgBase->Variables + Base);
    00062         i = ArgBase->VariableCount;
    00063         while(i--){
    00064             DbgPrint("DumpIt: Variable %s\n",Vector->Buffer + Base);
    00065             Vector++;
    00066         }
    00067     }
    00068
    00069     if ( ArgBase->ParameterCount ) {
    00070         ParmVector = (PCH *)((PCH)ArgBase->Parameters + Base);
    00071         i = ArgBase->ParameterCount;
    00072         while(i--) {
    00073             DbgPrint("DumpIt: Parameter %s\n",*ParmVector + Base);
    00074             ParmVector++;
    00075         }
    00076     }
    00077 }

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

Definition at line 110 of file urtl.c.

References c, DbgPrint, MyHeap, NULL, and VectorTest().

    00117 {
    00118     ULONG i;
    00119     char c, *s;
    00120     PCH *Arguments;
    00121     PCH *Variables;
    00122     PCH Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+2 ];
    00123
    00124     ULONG TestVector = 0;
    00125
    00126     Arguments = argv;
    00127     Variables = envp;
    00128     Parameters[ RTL_USER_PROC_PARAMS_IMAGEFILE ] =
    00129          "Full Path Specification of Image File goes here";
    00130
    00131     Parameters[ RTL_USER_PROC_PARAMS_CMDLINE ] =
    00132          "Complete Command Line goes here";
    00133
    00134     Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG ] =
    00135          "Debugging String goes here";
    00136
    00137     Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+1 ] = NULL;
    00138
    00139     MyHeap = RtlProcessHeap();
    00140
    00141
    00142 #if DBG
    00143     DbgPrint( "Entering URTL User Mode Test Program\n" );
    00144     DbgPrint( "argc = %ld\n", argc );
    00145     for (i=0; i<=argc; i++) {
    00146         DbgPrint( "argv[ %ld ]: %s\n",
    00147                   i,
    00148                   argv[ i ] ? argv[ i ] : "<NULL>"
    00149                 );
    00150         }
    00151     DbgPrint( "\n" );
    00152     for (i=0; envp[i]; i++) {
    00153         DbgPrint( "envp[ %ld ]: %s\n", i, envp[ i ] );
    00154         }
    00155 #endif
    00156     i = 1;
    00157     if (argc > 1 ) {
    00158         while (--argc) {
    00159             s = *++argv;
    00160             while ((c = *s++) != '\0') {
    00161                 switch (c) {
    00162
    00163                 case 'V':
    00164                 case 'v':
    00165                     TestVector = i++;
    00166                     break;
    00167                 default:
    00168                     DbgPrint( "urtl: invalid test code - '%s'", *argv );
    00169                     break;
    00170                 }
    00171             }
    00172         }
    00173     }
    00174
    00175     if ( TestVector ) {
    00176         VectorTest(Arguments,Variables,Parameters);
    00177     }
    00178
    00179     return( STATUS_SUCCESS );
    00180 }

BOOLEAN VectorTest | ( | IN PCH | Arguments[],
|  | IN PCH | Variables[],
|  | IN PCH | Parameters[]
| ) |

Definition at line 80 of file urtl.c.

References DbgPrint, DumpIt(), MyHeap, NTSTATUS(), RtlAllocateHeap, and TRUE.

Referenced by main().

    00085 {
    00086
    00087     PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
    00088     NTSTATUS st;
    00089
    00090     DbgPrint("VectorTest:++\n");
    00091
    00092     ProcessParameters = RtlAllocateHeap(MyHeap, 0, 2048);
    00093     ProcessParameters->MaximumLength = 2048;
    00094
    00095     st = RtlVectorsToProcessParameters(
    00096             Arguments,
    00097             Variables,
    00098             Parameters,
    00099             ProcessParameters
    00100             );
    00101
    00102     DumpIt(ProcessParameters);
    00103
    00104     DbgPrint("VectorTest:--\n");
    00105
    00106     return TRUE;
    00107 }

## Variable Documentation

PVOID MyHeap = NULL

| Definition at line 25 of file urtl.c.