00220 :
00221
00222 This function
is called in response of a read
control space state
00223 manipulation message. Its function
is to read implementation
00224 specific system data.
00225
00226 Arguments:
00227
00228 m - Supplies
the state manipulation message.
00229
00230 AdditionalData - Supplies any additional data
for the message.
00231
00232 Context - Supplies
the current context.
00233
00234 Return Value:
00235
00236 None.
00237
00238 --*/
00239
00240 {
00241
00242 PDBGKD_READ_MEMORY a = &m->u.ReadMemory;
00243 ULONG Length;
00244 STRING MessageHeader;
00245 PVOID
Buffer = AdditionalData->Buffer;
00246
00247 MessageHeader.Length =
sizeof(*m);
00248 MessageHeader.Buffer = (PCHAR)m;
00249
00250
ASSERT(AdditionalData->Length == 0);
00251
00252
if (a->TransferCount > (PACKET_MAX_SIZE -
sizeof(DBGKD_MANIPULATE_STATE))) {
00253 Length = PACKET_MAX_SIZE -
sizeof(DBGKD_MANIPULATE_STATE);
00254 }
else {
00255 Length = a->TransferCount;
00256 }
00257
00258
ASSERT(
sizeof(PVOID) ==
sizeof(ULONG));
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
switch( (ULONG_PTR)a->TargetBaseAddress ){
00270
00271
00272
00273
00274
00275
case DEBUG_CONTROL_SPACE_PCR:
00276
00277 *(PKPCR *)
Buffer =
KdpGetPcr();
00278 AdditionalData->Length =
sizeof( PKPCR );
00279 a->ActualBytesRead = AdditionalData->Length;
00280 m->ReturnStatus = STATUS_SUCCESS;
00281
break;
00282
00283
00284
00285
00286
00287
case DEBUG_CONTROL_SPACE_PRCB:
00288
00289 *(PKPRCB *)
Buffer =
KdpGetCurrentPrcb();
00290 AdditionalData->Length =
sizeof( PKPRCB );
00291 a->ActualBytesRead = AdditionalData->Length;
00292 m->ReturnStatus = STATUS_SUCCESS;
00293
break;
00294
00295
00296
00297
00298
00299
00300
case DEBUG_CONTROL_SPACE_THREAD:
00301
00302 *(
PKTHREAD *)
Buffer =
KdpGetCurrentThread();
00303 AdditionalData->Length =
sizeof(
PKTHREAD );
00304 a->ActualBytesRead = AdditionalData->Length;
00305 m->ReturnStatus = STATUS_SUCCESS;
00306
break;
00307
00308
00309
00310
00311
00312
00313
case DEBUG_CONTROL_SPACE_TEB:
00314
00315 *(PVOID *)
Buffer = (PVOID)NtCurrentTeb();
00316 AdditionalData->Length =
sizeof(
struct _TEB * );
00317 a->ActualBytesRead = AdditionalData->Length;
00318 m->ReturnStatus = STATUS_SUCCESS;
00319
break;
00320
00321
00322
00323
00324
00325
case DEBUG_CONTROL_SPACE_DPCACTIVE:
00326
00327 *(BOOLEAN *)
Buffer = KeIsExecutingDpc();
00328 AdditionalData->Length =
sizeof( ULONG );
00329 a->ActualBytesRead = AdditionalData->Length;
00330 m->ReturnStatus = STATUS_SUCCESS;
00331
break;
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
case DEBUG_CONTROL_SPACE_IPRSTATE:
00345
00346
00347
00348
00349
00350
00351
Buffer = (PVOID)( ((ULONG_PTR)
Buffer + 7) & ~7);
00352
00353 Length = (ULONG)((ULONG_PTR)&AdditionalData->Buffer[
KDP_MESSAGE_BUFFER_SIZE] -
00354 (ULONG_PTR)
Buffer);
00355
00356 AdditionalData->Length = (
USHORT)
KdpReadInternalProcessorState(
00357 Buffer,
00358 Length );
00359
00360
00361
00362
00363
00364
00365
00366
if( (AdditionalData->Length >
KDP_MESSAGE_BUFFER_SIZE) ||
00367 (AdditionalData->Length == 0) ){
00368
00369 AdditionalData->Length = 0;
00370 m->ReturnStatus = STATUS_UNSUCCESSFUL;
00371 a->ActualBytesRead = 0;
00372
00373 }
else {
00374
00375 m->ReturnStatus = STATUS_SUCCESS;
00376 a->ActualBytesRead = AdditionalData->Length;
00377
00378 }
00379
00380
break;
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
case DEBUG_CONTROL_SPACE_COUNTERS:
00394
00395
00396
00397
00398
00399
00400
Buffer = (PVOID)( ((ULONG_PTR)
Buffer + 7) & ~7);
00401
00402 Length = (ULONG)((ULONG_PTR)&AdditionalData->Buffer[
KDP_MESSAGE_BUFFER_SIZE] -
00403 (ULONG_PTR)
Buffer);
00404
00405 AdditionalData->Length = (
USHORT)
KdpReadInternalProcessorCounters(
00406 Buffer,
00407 Length );
00408
00409
00410
00411
00412
00413
00414
00415
if( (AdditionalData->Length >
KDP_MESSAGE_BUFFER_SIZE) ||
00416 (AdditionalData->Length == 0) ){
00417
00418 AdditionalData->Length = 0;
00419 m->ReturnStatus = STATUS_UNSUCCESSFUL;
00420 a->ActualBytesRead = 0;
00421
00422 }
else {
00423
00424 m->ReturnStatus = STATUS_SUCCESS;
00425 a->ActualBytesRead = AdditionalData->Length;
00426
00427 }
00428
00429
break;
00430
00431
00432
00433
00434
00435
default:
00436
00437 AdditionalData->Length = 0;
00438 m->ReturnStatus = STATUS_UNSUCCESSFUL;
00439 a->ActualBytesRead = 0;
00440
00441 }
00442
00443
KdpSendPacket(
00444 PACKET_TYPE_KD_STATE_MANIPULATE,
00445 &MessageHeader,
00446 AdditionalData
00447 );
00448 }