00050 {
00051
00052 EXCEPTION_RECORD ExceptionRecord;
00053 LONG Counter;
00054
00055
00056
00057
00058
00059
DbgPrint(
"Start of exception test\n");
00060
00061
00062
00063
00064
00065 ExceptionRecord.ExceptionCode = STATUS_INTEGER_OVERFLOW;
00066 ExceptionRecord.ExceptionFlags = 0;
00067 ExceptionRecord.ExceptionRecord =
NULL;
00068 ExceptionRecord.NumberParameters = 0;
00069
00070
00071
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
00094
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
00115
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
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
00158
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
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
00211
00212
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
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
00269
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
00298
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
00326
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
00359
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
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
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
00426
00427
00428
DbgPrint(
"End of exception test\n");
00429
return TRUE;
00430 }