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

tprofile.c File Reference

#include <nt.h>

Go to the source code of this file.

Functions

 main ()


Function Documentation

main  ) 
 

Definition at line 24 of file tprofile.c.

References Buffer, DbgPrint, NtAllocateVirtualMemory(), NtClose(), NtCreateProfile(), NtStartProfile(), NTSTATUS(), NtStopProfile(), and NULL.

00025 { 00026 HANDLE Profile, Profile2; 00027 ULONG Hack; 00028 PULONG Buffer; 00029 HANDLE CurrentProcessHandle; 00030 ULONG Size1; 00031 NTSTATUS status; 00032 00033 Buffer = &Hack; 00034 00035 CurrentProcessHandle = NtCurrentProcess(); 00036 00037 status = NtCreateProfile (&Profile, 00038 CurrentProcessHandle, 00039 NULL, 00040 0xFFFFFFFF, 00041 16, 00042 Buffer, 00043 (ULONG)64*1024, 00044 ProfileTime, 00045 (KAFFINITY)-1); 00046 00047 if (status != STATUS_SUCCESS) { 00048 DbgPrint("(Expected) create profile #1 failed - status %lx\n", status); 00049 } 00050 00051 status = NtStartProfile (Profile); 00052 if (status != STATUS_SUCCESS) { 00053 DbgPrint("(Expected) start profile #1 failed - status %lx\n", status); 00054 } 00055 00056 status = NtStopProfile (Profile); 00057 if (status != STATUS_SUCCESS) { 00058 DbgPrint("(Expected) stop profile #1 failed - status %lx\n", status); 00059 } 00060 00061 Size1 = 1024*64; 00062 Buffer = NULL; 00063 00064 status = NtAllocateVirtualMemory (CurrentProcessHandle, (PVOID *)&Buffer, 00065 0, &Size1, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 00066 00067 // 00068 // This should fail as buffersize is too small. 00069 // 00070 00071 status = NtCreateProfile (&Profile, 00072 NtCurrentProcess(), 00073 NULL, 00074 0xFFFFFFFF, 00075 16, 00076 Buffer, 00077 (ULONG)64*1024, 00078 ProfileTime, 00079 (KAFFINITY)-1); 00080 00081 if (status != STATUS_SUCCESS) { 00082 DbgPrint("(Expected) create profile #2 failed - status %lx\n", status); 00083 } 00084 00085 status = NtStartProfile (Profile); 00086 if (status != STATUS_SUCCESS) { 00087 DbgPrint("(Expected) start profile #2 failed - status %lx\n", status); 00088 } 00089 00090 status = NtStopProfile (Profile); 00091 if (status != STATUS_SUCCESS) { 00092 DbgPrint("(Expected) stop profile #2 failed - status %lx\n", status); 00093 } 00094 00095 status = NtClose (Profile); 00096 00097 // 00098 // This should succeed. 00099 // 00100 00101 status = NtCreateProfile (&Profile, 00102 NtCurrentProcess(), 00103 NULL, 00104 0xFFFFFFFF, 00105 18, 00106 Buffer, 00107 (ULONG)64*1024, 00108 ProfileTime, 00109 (KAFFINITY)-1); 00110 00111 if (status != STATUS_SUCCESS) { 00112 DbgPrint("(Unexpected) create profile #3 failed - status %lx\n", status); 00113 } 00114 00115 status = NtStartProfile (Profile); 00116 if (status != STATUS_SUCCESS) { 00117 DbgPrint("(Unexpected) start profile #3 failed - status %lx\n", status); 00118 } 00119 00120 status = NtStopProfile (Profile); 00121 if (status != STATUS_SUCCESS) { 00122 DbgPrint("(Unexpected) stop profile #3 failed - status %lx\n", status); 00123 } 00124 00125 status = NtClose (Profile); 00126 00127 // 00128 // Attempt to create a profile that can't work because the 00129 // address range is too big. 00130 // 00131 00132 status = NtCreateProfile (&Profile, 00133 NtCurrentProcess(), 00134 (PVOID)0x203030, 00135 0xffffffff, 00136 6, 00137 Buffer, 00138 (ULONG)64*1024, 00139 ProfileTime, 00140 (KAFFINITY)-1); 00141 00142 if (status != STATUS_SUCCESS) { 00143 DbgPrint("(Expected) create profile #4 failed - status %lx\n", status); 00144 } 00145 00146 status = NtStartProfile (Profile); 00147 if (status != STATUS_SUCCESS) { 00148 DbgPrint("(Expected) start profile #4 failed - status %lx\n", status); 00149 } 00150 00151 status = NtStopProfile (Profile); 00152 if (status != STATUS_SUCCESS) { 00153 DbgPrint("(Expected) stop profile #4 failed - status %lx\n", status); 00154 } 00155 00156 status = NtClose (Profile); 00157 00158 // 00159 // Attempt to create a sucessful profile. 00160 // 00161 00162 status = NtCreateProfile (&Profile, 00163 NtCurrentProcess(), 00164 (PVOID)0x80000000, 00165 0x7fffffff, 00166 17, 00167 Buffer, 00168 (ULONG)64*1024, 00169 ProfileTime, 00170 (KAFFINITY)-1); 00171 00172 if (status != STATUS_SUCCESS) { 00173 DbgPrint("(Unexpected) create profile #5 failed - status %lx\n", status); 00174 } 00175 00176 status = NtStartProfile (Profile); 00177 if (status != STATUS_SUCCESS) { 00178 DbgPrint("(Unexpected) start profile #5 failed - status %lx\n", status); 00179 } 00180 00181 status = NtStopProfile (Profile); 00182 if (status != STATUS_SUCCESS) { 00183 DbgPrint("(Unexpected) stop profile #5 failed - status %lx\n", status); 00184 } 00185 00186 // 00187 // now start it again. 00188 // 00189 00190 status = NtStartProfile (Profile); 00191 if (status != STATUS_SUCCESS) { 00192 DbgPrint("(Unexpected) start profile #6.1 failed - status %lx\n", status); 00193 } 00194 00195 // 00196 // now start it again, should fail. 00197 // 00198 00199 status = NtStartProfile (Profile); 00200 if (status != STATUS_SUCCESS) { 00201 DbgPrint("(Expected) start profile #6.2 failed - status %lx\n", status); 00202 } 00203 00204 // 00205 // now create another one (using the same buffer). 00206 // 00207 00208 status = NtCreateProfile (&Profile2, 00209 NtCurrentProcess(), 00210 NULL, 00211 0x3000000, 00212 15, 00213 Buffer, 00214 (ULONG)64*1024, 00215 ProfileTime, 00216 (KAFFINITY)-1); 00217 00218 00219 if (status != STATUS_SUCCESS) { 00220 DbgPrint("create profile #7 failed - status %lx\n", status); 00221 } 00222 00223 status = NtStartProfile (Profile2); 00224 if (status != STATUS_SUCCESS) { 00225 DbgPrint("start profile #7.1 failed - status %lx\n", status); 00226 } 00227 00228 status = NtStopProfile (Profile2); 00229 if (status != STATUS_SUCCESS) { 00230 DbgPrint("stop profile #7.2 failed - status %lx\n", status); 00231 } 00232 00233 status = NtStopProfile (Profile2); 00234 if (status != STATUS_SUCCESS) { 00235 DbgPrint("(Expected) stop profile #7.3 failed - status %lx\n", status); 00236 } 00237 00238 status = NtStartProfile (Profile2); 00239 if (status != STATUS_SUCCESS) { 00240 DbgPrint("start profile #7.4 failed - status %lx\n", status); 00241 } 00242 00243 status = NtClose (Profile); 00244 if (status != STATUS_SUCCESS) { 00245 DbgPrint("close profile #7.5 failed - status %lx\n", status); 00246 } 00247 00248 return status; 00249 }


Generated on Sat May 15 19:45:48 2004 for test by doxygen 1.3.7