00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <nt.h>
00022
#include <ntrtl.h>
00023
#include <nturtl.h>
00024
00025 PVOID
MyHeap =
NULL;
00026
00027 DumpIt(
00028 IN PRTL_USER_PROCESS_PARAMETERS ArgBase
00029 )
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 }
00078
00079 BOOLEAN
00080 VectorTest(
00081 IN PCH Arguments[],
00082 IN PCH Variables[],
00083 IN PCH Parameters[]
00084 )
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 }
00108
00109
NTSTATUS
00110 main(
00111 IN ULONG argc,
00112 IN PCH argv[],
00113 IN PCH envp[],
00114 IN ULONG DebugParameter OPTIONAL
00115 )
00116
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 }