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

utxcpt4.c File Reference

#include <ntos.h>

Go to the source code of this file.

Functions

VOID bar (IN NTSTATUS Status, IN PULONG Counter)
VOID eret (IN NTSTATUS Status, IN PULONG Counter)
VOID foo (IN NTSTATUS Status)
VOID fret (IN PULONG Counter)
BOOLEAN Tkm (VOID)
 main ()
BOOLEAN Tkm ()

Variables

PTESTFCN TestFunction = Tkm


Function Documentation

VOID bar IN NTSTATUS  Status,
IN PULONG  Counter
 

Definition at line 360 of file utxcpt2.c.

References foo(), and Status.

Referenced by ExceptionTest(), and Tkm().

00364 { 00365 00366 EXCEPTION_RECORD ExceptionRecord; 00367 00368 try { 00369 foo(Status); 00370 } 00371 00372 finally { 00373 if (abnormal_termination() != 0) { 00374 *Counter = 99; 00375 } else { 00376 *Counter = 100; 00377 } 00378 } 00379 }

VOID eret IN NTSTATUS  Status,
IN PULONG  Counter
 

Definition at line 339 of file utxcpt2.c.

References foo(), and Status.

Referenced by ExceptionTest(), main(), and Tkm().

00343 { 00344 00345 EXCEPTION_RECORD ExceptionRecord; 00346 00347 try { 00348 00349 try { 00350 foo(Status); 00351 } except (exception_code() == Status) { 00352 *Counter += 1; 00353 return 0xDEADBEEF; 00354 } 00355 } finally { 00356 *Counter += 1; 00357 } 00358 }

VOID foo IN NTSTATUS  Status  ) 
 

Definition at line 382 of file utxcpt2.c.

References NULL, RtlRaiseException(), and Status.

Referenced by bar(), eret(), ExceptionTest(), ThreadThatExcepts(), and Tkm().

00385 { 00386 EXCEPTION_RECORD ExceptionRecord; 00387 LONG Counter; 00388 00389 // 00390 // Initialize exception record. 00391 // 00392 00393 ExceptionRecord.ExceptionFlags = 0; 00394 ExceptionRecord.ExceptionCode = Status; 00395 ExceptionRecord.ExceptionRecord = (PEXCEPTION_RECORD)NULL; 00396 ExceptionRecord.NumberParameters = 0; 00397 RtlRaiseException(&ExceptionRecord); 00398 }

VOID fret IN PULONG  Counter  ) 
 

Definition at line 321 of file utxcpt2.c.

Referenced by ExceptionTest(), main(), and Tkm().

00324 { 00325 00326 try { 00327 00328 try { 00329 *Counter += 1; 00330 } finally { 00331 *Counter += 1; 00332 return; 00333 } 00334 } finally { 00335 *Counter += 1; 00336 } 00337 }

main  ) 
 

Definition at line 41 of file utxcpt4.c.

References Tkm().

00042 { 00043 Tkm(); 00044 }

BOOLEAN Tkm  ) 
 

Definition at line 47 of file utxcpt4.c.

References bar(), DbgPrint, eret(), EXCEPTION_CONTINUE_SEARCH, EXCEPTION_EXECUTE_HANDLER, FALSE, foo(), fret(), NULL, RtlRaiseException(), RtlRaiseStatus(), and TRUE.

Referenced by main().

00050 { 00051 00052 EXCEPTION_RECORD ExceptionRecord; 00053 LONG Counter; 00054 00055 // 00056 // Announce start of exception test. 00057 // 00058 00059 DbgPrint("Start of exception test\n"); 00060 00061 // 00062 // Initialize exception record. 00063 // 00064 00065 ExceptionRecord.ExceptionCode = STATUS_INTEGER_OVERFLOW; 00066 ExceptionRecord.ExceptionFlags = 0; 00067 ExceptionRecord.ExceptionRecord = NULL; 00068 ExceptionRecord.NumberParameters = 0; 00069 00070 // 00071 // Simply try statement with a finally clause that is entered sequentially. 00072 // 00073 00074 DbgPrint(" test1..."); 00075 Counter = 0; 00076 try { 00077 Counter += 1; 00078 00079 } finally { 00080 if (abnormal_termination() == FALSE) { 00081 Counter += 1; 00082 } 00083 } 00084 00085 if (Counter != 2) { 00086 DbgPrint("failed\n"); 00087 00088 } else { 00089 DbgPrint("succeeded\n"); 00090 } 00091 00092 // 00093 // Simple try statement with an exception clause that is never executed 00094 // because there is no exception raised in the try clause. 00095 // 00096 00097 DbgPrint(" test2..."); 00098 Counter = 0; 00099 try { 00100 Counter += 1; 00101 00102 } except (Counter) { 00103 Counter += 1; 00104 } 00105 00106 if (Counter != 1) { 00107 DbgPrint("failed\n"); 00108 00109 } else { 00110 DbgPrint("succeeded\n"); 00111 } 00112 00113 // 00114 // Simple try statement with an exception handler that is never executed 00115 // because the exception expression continues execution. 00116 // 00117 00118 DbgPrint(" test3..."); 00119 Counter = 0; 00120 try { 00121 Counter -= 1; 00122 RtlRaiseException(&ExceptionRecord); 00123 00124 } except (Counter) { 00125 Counter -= 1; 00126 } 00127 00128 if (Counter != - 1) { 00129 DbgPrint("failed\n"); 00130 00131 } else { 00132 DbgPrint("succeeded\n"); 00133 } 00134 00135 // 00136 // Simple try statement with an exception clause that is always executed. 00137 // 00138 00139 DbgPrint(" test4..."); 00140 Counter = 0; 00141 try { 00142 Counter += 1; 00143 RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); 00144 00145 } except (Counter) { 00146 Counter += 1; 00147 } 00148 00149 if (Counter != 2) { 00150 DbgPrint("failed\n"); 00151 00152 } else { 00153 DbgPrint("succeeded\n"); 00154 } 00155 00156 // 00157 // Simply try statement with a finally clause that is entered as the 00158 // result of an exception. 00159 // 00160 00161 DbgPrint(" test5..."); 00162 Counter = 0; 00163 try { 00164 try { 00165 Counter += 1; 00166 RtlRaiseException(&ExceptionRecord); 00167 00168 } finally { 00169 if (abnormal_termination() != FALSE) { 00170 Counter += 1; 00171 } 00172 } 00173 00174 } except (Counter) { 00175 if (Counter == 2) { 00176 Counter += 1; 00177 } 00178 } 00179 00180 if (Counter != 3) { 00181 DbgPrint("failed\n"); 00182 00183 } else { 00184 DbgPrint("succeeded\n"); 00185 } 00186 00187 // 00188 // Simple try that calls a function which raises an exception. 00189 // 00190 00191 DbgPrint(" test6..."); 00192 Counter = 0; 00193 try { 00194 Counter += 1; 00195 foo(STATUS_ACCESS_VIOLATION); 00196 00197 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00198 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00199 Counter += 1; 00200 } 00201 00202 if (Counter != 2) { 00203 DbgPrint("failed\n"); 00204 00205 } else { 00206 DbgPrint("succeeded\n"); 00207 } 00208 00209 // 00210 // Simple try that calls a function which calls a function that 00211 // raises an exception. The first function has a finally clause 00212 // that must be executed for this test to work. 00213 // 00214 00215 DbgPrint(" test7..."); 00216 Counter = 0; 00217 try { 00218 bar(STATUS_ACCESS_VIOLATION, (PULONG)&Counter); 00219 00220 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00221 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00222 Counter -= 1; 00223 } 00224 00225 if (Counter != 98) { 00226 DbgPrint("failed\n"); 00227 00228 } else { 00229 DbgPrint("succeeded\n"); 00230 } 00231 00232 // 00233 // A try within an except 00234 // 00235 00236 DbgPrint(" test8..."); 00237 Counter = 0; 00238 try { 00239 foo(STATUS_ACCESS_VIOLATION); 00240 00241 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00242 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00243 Counter += 1; 00244 try { 00245 foo(STATUS_SUCCESS); 00246 00247 } except ((GetExceptionCode() == STATUS_SUCCESS) ? 00248 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00249 if (Counter != 1) { 00250 DbgPrint("failed..."); 00251 00252 } else { 00253 DbgPrint("succeeded..."); 00254 } 00255 00256 Counter += 1; 00257 } 00258 } 00259 00260 if (Counter != 2) { 00261 DbgPrint("failed\n"); 00262 00263 } else { 00264 DbgPrint("succeeded\n"); 00265 } 00266 00267 // 00268 // A goto from an exception clause that needs to pass 00269 // through a finally 00270 // 00271 00272 DbgPrint(" test9..."); 00273 Counter = 0; 00274 try { 00275 try { 00276 foo(STATUS_ACCESS_VIOLATION); 00277 00278 } except ((GetExceptionCode() == STATUS_ACCESS_VIOLATION) ? 00279 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 00280 Counter += 1; 00281 goto t9; 00282 } 00283 00284 } finally { 00285 Counter += 1; 00286 } 00287 00288 t9:; 00289 if (Counter != 2) { 00290 DbgPrint("failed\n"); 00291 00292 } else { 00293 DbgPrint("succeeded\n"); 00294 } 00295 00296 // 00297 // A goto from an finally clause that needs to pass 00298 // through a finally 00299 // 00300 00301 DbgPrint(" test10..."); 00302 Counter = 0; 00303 try { 00304 try { 00305 Counter += 1; 00306 00307 } finally { 00308 Counter += 1; 00309 goto t10; 00310 } 00311 00312 } finally { 00313 Counter += 1; 00314 } 00315 00316 t10:; 00317 if (Counter != 3) { 00318 DbgPrint("failed\n"); 00319 00320 } else { 00321 DbgPrint("succeeded\n"); 00322 } 00323 00324 // 00325 // A goto from an exception clause that needs to pass 00326 // through a finally into the outer finally clause. 00327 // 00328 00329 DbgPrint(" test11..."); 00330 Counter = 0; 00331 try { 00332 try { 00333 try { 00334 Counter += 1; 00335 foo(STATUS_INTEGER_OVERFLOW); 00336 00337 } except (EXCEPTION_EXECUTE_HANDLER) { 00338 Counter += 1; 00339 goto t11; 00340 } 00341 00342 } finally { 00343 Counter += 1; 00344 } 00345 t11:; 00346 } finally { 00347 Counter += 1; 00348 } 00349 00350 if (Counter != 4) { 00351 DbgPrint("failed\n"); 00352 00353 } else { 00354 DbgPrint("succeeded\n"); 00355 } 00356 00357 // 00358 // A goto from an finally clause that needs to pass 00359 // through a finally into the outer finally clause. 00360 // 00361 00362 DbgPrint(" test12..."); 00363 Counter = 0; 00364 try { 00365 try { 00366 Counter += 1; 00367 00368 } finally { 00369 Counter += 1; 00370 goto t12; 00371 } 00372 t12:; 00373 } finally { 00374 Counter += 1; 00375 } 00376 00377 if (Counter != 3) { 00378 DbgPrint("failed\n"); 00379 00380 } else { 00381 DbgPrint("succeeded\n"); 00382 } 00383 00384 // 00385 // A return from an except clause 00386 // 00387 00388 DbgPrint(" test13..."); 00389 Counter = 0; 00390 try { 00391 Counter += 1; 00392 eret(STATUS_ACCESS_VIOLATION, (PULONG)&Counter); 00393 00394 } finally { 00395 Counter += 1; 00396 } 00397 00398 if (Counter != 4) { 00399 DbgPrint("failed\n"); 00400 } else { 00401 DbgPrint("succeeded\n"); 00402 } 00403 00404 // 00405 // A return from a finally clause 00406 // 00407 00408 DbgPrint(" test14..."); 00409 Counter = 0; 00410 try { 00411 Counter += 1; 00412 fret((PULONG)&Counter); 00413 00414 } finally { 00415 Counter += 1; 00416 } 00417 00418 if (Counter != 5) { 00419 DbgPrint("failed\n"); 00420 } else { 00421 DbgPrint("succeeded\n"); 00422 } 00423 00424 // 00425 // Announce end of exception test. 00426 // 00427 00428 DbgPrint("End of exception test\n"); 00429 return TRUE; 00430 }

BOOLEAN Tkm VOID   ) 
 


Variable Documentation

PTESTFCN TestFunction = Tkm
 

Definition at line 39 of file utxcpt4.c.


Generated on Sat May 15 19:46:06 2004 for test by doxygen 1.3.7