| 2430 | } |
| 2431 | |
| 2432 | BFP_EXPORT void BFP_CALLTYPE BfpThread_GetIntRegisters(BfpThread* thread, intptr* outStackPtr, intptr* outIntRegs, int* inOutIntRegCount, BfpThreadResult* outResult) |
| 2433 | { |
| 2434 | CONTEXT ctx; |
| 2435 | intptr* curPtr = outIntRegs; |
| 2436 | CONTEXT* ctxPtr = NULL; |
| 2437 | |
| 2438 | if (*inOutIntRegCount > 48) |
| 2439 | ctxPtr = CaptureRegistersEx((HANDLE)thread, curPtr); |
| 2440 | |
| 2441 | if (ctxPtr == NULL) |
| 2442 | { |
| 2443 | memset(&ctx, 0, sizeof(CONTEXT)); |
| 2444 | ctx.ContextFlags = CONTEXT_ALL; |
| 2445 | BOOL success = ::GetThreadContext((HANDLE)thread, (CONTEXT*)&ctx); |
| 2446 | if (!success) |
| 2447 | { |
| 2448 | int error = GetLastError(); |
| 2449 | OUTRESULT(BfpThreadResult_UnknownError); |
| 2450 | return; |
| 2451 | } |
| 2452 | ctxPtr = &ctx; |
| 2453 | |
| 2454 | DWORD lastError = GetLastError(); |
| 2455 | BF_ASSERT(success); |
| 2456 | } |
| 2457 | |
| 2458 | #ifdef BF32 |
| 2459 | * outStackPtr = (intptr)ctxPtr->Esp; |
| 2460 | if (*inOutIntRegCount < (int)(curPtr - outIntRegs) + 7) |
| 2461 | { |
| 2462 | OUTRESULT(BfpThreadResult_InsufficientBuffer); |
| 2463 | return; |
| 2464 | } |
| 2465 | #else |
| 2466 | * outStackPtr = (intptr)ctxPtr->Rsp; |
| 2467 | if (*inOutIntRegCount < (int)(curPtr - outIntRegs) + 48) |
| 2468 | { |
| 2469 | OUTRESULT(BfpThreadResult_InsufficientBuffer); |
| 2470 | return; |
| 2471 | } |
| 2472 | #endif |
| 2473 | |
| 2474 | OUTRESULT(BfpThreadResult_Ok); |
| 2475 | |
| 2476 | if (outIntRegs == NULL) |
| 2477 | return; |
| 2478 | |
| 2479 | #ifdef BF32 |
| 2480 | * (curPtr++) = (intptr)ctxPtr->Eax; |
| 2481 | *(curPtr++) = (intptr)ctxPtr->Ebx; |
| 2482 | *(curPtr++) = (intptr)ctxPtr->Ecx; |
| 2483 | *(curPtr++) = (intptr)ctxPtr->Edx; |
| 2484 | *(curPtr++) = (intptr)ctxPtr->Esi; |
| 2485 | *(curPtr++) = (intptr)ctxPtr->Edi; |
| 2486 | *(curPtr++) = (intptr)ctxPtr->Ebp; |
| 2487 | #else |
| 2488 | * (curPtr++) = (intptr)ctxPtr->SegFs; // Testing |
| 2489 | *(curPtr++) = (intptr)ctxPtr->Rax; |
no test coverage detected