2 bug 1024 bug_1024 于 2013.07.26 20:03 提问

在使用GetThreadContext()时为什么CONTEXT获得的寄存器信息都是0?怎么解决?

顺手百度了下 说win7下才会出现这个问题 是这样吗?菜鸟第一次提问 求大神凌辱!
贴一些代码
def get_thread_context(self,thread_id=None,h_thread=None):

    context = CONTEXT()

    context.ContextFlags=CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS

    #获取句柄

    #if h_thread is None:
    self.h_thread = self.open_thread(thread_id)  
    kernel32.SuspendThread(self.h_thread)         
    if kernel32.GetThreadContext(self.h_thread, byref(context)):
        kernel32.ResumeThread(self.h_thread)
        return context 
    else:
        return False

CONTEXT定义:
class CONTEXT(Structure):

_fields_ = [

    ("ContextFlags", DWORD),
    ("Dr0", DWORD),
    ("Dr1", DWORD),
    ("Dr2", DWORD),
    ("Dr3", DWORD),
    ("Dr6", DWORD),
    ("Dr7", DWORD),
    ("FloatSave", FLOATING_SAVE_AREA),
    ("SegGs", DWORD),
    ("SegFs", DWORD),
    ("SegEs", DWORD),
    ("SegDs", DWORD),
    ("Edi", DWORD),
    ("Esi", DWORD),
    ("Ebx", DWORD),
    ("Edx", DWORD),
    ("Ecx", DWORD),
    ("Eax", DWORD),
    ("Ebp", DWORD),
    ("Eip", DWORD),
    ("SegCs", DWORD),
    ("EFlags", DWORD),
    ("Esp", DWORD),
    ("SegSs", DWORD),
    ("ExtendedRegisters", BYTE * 512),

]

1个回答

wangyaninglm
wangyaninglm   Ds   Rxr 2015.01.18 12:53
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!