Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. urtl.c
  5. Abstract:
  6. Usermode test program for rtl
  7. Author:
  8. Mark Lucovsky (markl) 22-Aug-1989
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. PVOID MyHeap = NULL;
  15. DumpIt(
  16. IN PRTL_USER_PROCESS_PARAMETERS ArgBase
  17. )
  18. {
  19. ULONG Base;
  20. PSTRING Vector;
  21. PCH *ParmVector;
  22. ULONG i;
  23. (VOID) RtlNormalizeProcessParameters( ArgBase );
  24. (VOID) RtlDeNormalizeProcessParameters( ArgBase );
  25. Base = (ULONG) ArgBase;
  26. DbgPrint("DumpIt: ArgBase %lx\n",ArgBase);
  27. DbgPrint("DumpIt: MaximumLength %lx\n",ArgBase->MaximumLength);
  28. DbgPrint("DumpIt: Length %lx\n",ArgBase->Length);
  29. DbgPrint("DumpIt: ArgumentCount %lx\n",ArgBase->ArgumentCount);
  30. DbgPrint("DumpIt: Arguments %lx\n",ArgBase->Arguments );
  31. DbgPrint("DumpIt: VariableCount %lx\n",ArgBase->VariableCount);
  32. DbgPrint("DumpIt: Variables %lx\n",ArgBase->Variables );
  33. DbgPrint("DumpIt: ParameterCount%lx\n",ArgBase->ParameterCount);
  34. DbgPrint("DumpIt: Parameters %lx\n",ArgBase->Parameters );
  35. if ( ArgBase->ArgumentCount ) {
  36. Vector = (PSTRING)((PCH)ArgBase->Arguments + Base);
  37. i = ArgBase->ArgumentCount;
  38. while(i--){
  39. DbgPrint("DumpIt: Argument %s\n",Vector->Buffer + Base);
  40. Vector++;
  41. }
  42. }
  43. if ( ArgBase->VariableCount ) {
  44. Vector = (PSTRING)((PCH)ArgBase->Variables + Base);
  45. i = ArgBase->VariableCount;
  46. while(i--){
  47. DbgPrint("DumpIt: Variable %s\n",Vector->Buffer + Base);
  48. Vector++;
  49. }
  50. }
  51. if ( ArgBase->ParameterCount ) {
  52. ParmVector = (PCH *)((PCH)ArgBase->Parameters + Base);
  53. i = ArgBase->ParameterCount;
  54. while(i--) {
  55. DbgPrint("DumpIt: Parameter %s\n",*ParmVector + Base);
  56. ParmVector++;
  57. }
  58. }
  59. }
  60. BOOLEAN
  61. VectorTest(
  62. IN PCH Arguments[],
  63. IN PCH Variables[],
  64. IN PCH Parameters[]
  65. )
  66. {
  67. PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
  68. NTSTATUS st;
  69. DbgPrint("VectorTest:++\n");
  70. ProcessParameters = RtlAllocateHeap(MyHeap, 0, 2048);
  71. ProcessParameters->MaximumLength = 2048;
  72. st = RtlVectorsToProcessParameters(
  73. Arguments,
  74. Variables,
  75. Parameters,
  76. ProcessParameters
  77. );
  78. DumpIt(ProcessParameters);
  79. DbgPrint("VectorTest:--\n");
  80. return TRUE;
  81. }
  82. NTSTATUS
  83. main(
  84. IN ULONG argc,
  85. IN PCH argv[],
  86. IN PCH envp[],
  87. IN ULONG DebugParameter OPTIONAL
  88. )
  89. {
  90. ULONG i;
  91. char c, *s;
  92. PCH *Arguments;
  93. PCH *Variables;
  94. PCH Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+2 ];
  95. ULONG TestVector = 0;
  96. Arguments = argv;
  97. Variables = envp;
  98. Parameters[ RTL_USER_PROC_PARAMS_IMAGEFILE ] =
  99. "Full Path Specification of Image File goes here";
  100. Parameters[ RTL_USER_PROC_PARAMS_CMDLINE ] =
  101. "Complete Command Line goes here";
  102. Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG ] =
  103. "Debugging String goes here";
  104. Parameters[ RTL_USER_PROC_PARAMS_DEBUGFLAG+1 ] = NULL;
  105. MyHeap = RtlProcessHeap();
  106. #if DBG
  107. DbgPrint( "Entering URTL User Mode Test Program\n" );
  108. DbgPrint( "argc = %ld\n", argc );
  109. for (i=0; i<=argc; i++) {
  110. DbgPrint( "argv[ %ld ]: %s\n",
  111. i,
  112. argv[ i ] ? argv[ i ] : "<NULL>"
  113. );
  114. }
  115. DbgPrint( "\n" );
  116. for (i=0; envp[i]; i++) {
  117. DbgPrint( "envp[ %ld ]: %s\n", i, envp[ i ] );
  118. }
  119. #endif
  120. i = 1;
  121. if (argc > 1 ) {
  122. while (--argc) {
  123. s = *++argv;
  124. while ((c = *s++) != '\0') {
  125. switch (c) {
  126. case 'V':
  127. case 'v':
  128. TestVector = i++;
  129. break;
  130. default:
  131. DbgPrint( "urtl: invalid test code - '%s'", *argv );
  132. break;
  133. }
  134. }
  135. }
  136. }
  137. if ( TestVector ) {
  138. VectorTest(Arguments,Variables,Parameters);
  139. }
  140. return( STATUS_SUCCESS );
  141. }