Package winappdbg :: Package win32 :: Module context_ia64
[hide private]
[frames] | no frames]

Source Code for Module winappdbg.win32.context_ia64

  1  # Copyright (c) 2009-2010, Mario Vilas 
  2  # All rights reserved. 
  3  # 
  4  # Redistribution and use in source and binary forms, with or without 
  5  # modification, are permitted provided that the following conditions are met: 
  6  # 
  7  #     * Redistributions of source code must retain the above copyright notice, 
  8  #       this list of conditions and the following disclaimer. 
  9  #     * Redistributions in binary form must reproduce the above copyright 
 10  #       notice,this list of conditions and the following disclaimer in the 
 11  #       documentation and/or other materials provided with the distribution. 
 12  #     * Neither the name of the copyright holder nor the names of its 
 13  #       contributors may be used to endorse or promote products derived from 
 14  #       this software without specific prior written permission. 
 15  # 
 16  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 17  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 18  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 19  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 20  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 21  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 22  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 23  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 24  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 25  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 26  # POSSIBILITY OF SUCH DAMAGE. 
 27   
 28  """ 
 29  CONTEXT structure for ia64. 
 30  """ 
 31   
 32  __revision__ = "$Id: context_ia64.py 655 2010-03-30 17:00:27Z qvasimodo $" 
 33   
 34  from defines import * 
 35   
 36  ############################################################################### 
 37  ##                                                                           ## 
 38  ##      This is an experimental file for support of Itanium processors.      ## 
 39  ##      Since I have no way of testing this -Itaniums don't come cheap-      ## 
 40  ##      it's very likely to break.                                           ## 
 41  ##                                                                           ## 
 42  ##      The file kernel32.py has to be edited for this one to be loaded.     ## 
 43  ##                                                                           ## 
 44  ##      Try at your own risk. (And tell me how it went!)                     ## 
 45  ##                                                                           ## 
 46  ############################################################################### 
 47   
 48  # The following values specify the type of access in the first parameter 
 49  # of the exception record when the exception code specifies an access 
 50  # violation. 
 51  EXCEPTION_READ_FAULT        = 0     # exception caused by a read 
 52  EXCEPTION_WRITE_FAULT       = 1     # exception caused by a write 
 53  EXCEPTION_EXECUTE_FAULT     = 2     # exception caused by an instruction fetch 
 54   
 55  CONTEXT_IA64                    = 0x00080000 
 56   
 57  CONTEXT_CONTROL                 = (CONTEXT_IA64 | 0x00000001L) 
 58  CONTEXT_LOWER_FLOATING_POINT    = (CONTEXT_IA64 | 0x00000002L) 
 59  CONTEXT_HIGHER_FLOATING_POINT   = (CONTEXT_IA64 | 0x00000004L) 
 60  CONTEXT_INTEGER                 = (CONTEXT_IA64 | 0x00000008L) 
 61  CONTEXT_DEBUG                   = (CONTEXT_IA64 | 0x00000010L) 
 62  CONTEXT_IA32_CONTROL            = (CONTEXT_IA64 | 0x00000020L)  # Includes StIPSR 
 63   
 64   
 65  CONTEXT_FLOATING_POINT          = (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT) 
 66  CONTEXT_FULL                    = (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL) 
 67  CONTEXT_ALL                     = (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL) 
 68   
 69  CONTEXT_EXCEPTION_ACTIVE        = 0x8000000 
 70  CONTEXT_SERVICE_ACTIVE          = 0x10000000 
 71  CONTEXT_EXCEPTION_REQUEST       = 0x40000000 
 72  CONTEXT_EXCEPTION_REPORTING     = 0x80000000 
 73   
 74  # // 
 75  # // Context Frame 
 76  # // 
 77  # //  This frame has a several purposes: 1) it is used as an argument to 
 78  # //  NtContinue, 2) it is used to construct a call frame for APC delivery, 
 79  # //  3) it is used to construct a call frame for exception dispatching 
 80  # //  in user mode, 4) it is used in the user level thread creation 
 81  # //  routines, and 5) it is used to to pass thread state to debuggers. 
 82  # // 
 83  # //  N.B. Because this record is used as a call frame, it must be EXACTLY 
 84  # //  a multiple of 16 bytes in length and aligned on a 16-byte boundary. 
 85  # // 
 86  # 
 87  # typedef struct _CONTEXT { 
 88  # 
 89  #     // 
 90  #     // The flags values within this flag control the contents of 
 91  #     // a CONTEXT record. 
 92  #     // 
 93  #     // If the context record is used as an input parameter, then 
 94  #     // for each portion of the context record controlled by a flag 
 95  #     // whose value is set, it is assumed that that portion of the 
 96  #     // context record contains valid context. If the context record 
 97  #     // is being used to modify a thread's context, then only that 
 98  #     // portion of the threads context will be modified. 
 99  #     // 
100  #     // If the context record is used as an IN OUT parameter to capture 
101  #     // the context of a thread, then only those portions of the thread's 
102  #     // context corresponding to set flags will be returned. 
103  #     // 
104  #     // The context record is never used as an OUT only parameter. 
105  #     // 
106  # 
107  #     DWORD ContextFlags; 
108  #     DWORD Fill1[3];         // for alignment of following on 16-byte boundary 
109  # 
110  #     // 
111  #     // This section is specified/returned if the ContextFlags word contains 
112  #     // the flag CONTEXT_DEBUG. 
113  #     // 
114  #     // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL. 
115  #     // 
116  # 
117  #     ULONGLONG DbI0; 
118  #     ULONGLONG DbI1; 
119  #     ULONGLONG DbI2; 
120  #     ULONGLONG DbI3; 
121  #     ULONGLONG DbI4; 
122  #     ULONGLONG DbI5; 
123  #     ULONGLONG DbI6; 
124  #     ULONGLONG DbI7; 
125  # 
126  #     ULONGLONG DbD0; 
127  #     ULONGLONG DbD1; 
128  #     ULONGLONG DbD2; 
129  #     ULONGLONG DbD3; 
130  #     ULONGLONG DbD4; 
131  #     ULONGLONG DbD5; 
132  #     ULONGLONG DbD6; 
133  #     ULONGLONG DbD7; 
134  # 
135  #     // 
136  #     // This section is specified/returned if the ContextFlags word contains 
137  #     // the flag CONTEXT_LOWER_FLOATING_POINT. 
138  #     // 
139  # 
140  #     FLOAT128 FltS0; 
141  #     FLOAT128 FltS1; 
142  #     FLOAT128 FltS2; 
143  #     FLOAT128 FltS3; 
144  #     FLOAT128 FltT0; 
145  #     FLOAT128 FltT1; 
146  #     FLOAT128 FltT2; 
147  #     FLOAT128 FltT3; 
148  #     FLOAT128 FltT4; 
149  #     FLOAT128 FltT5; 
150  #     FLOAT128 FltT6; 
151  #     FLOAT128 FltT7; 
152  #     FLOAT128 FltT8; 
153  #     FLOAT128 FltT9; 
154  # 
155  #     // 
156  #     // This section is specified/returned if the ContextFlags word contains 
157  #     // the flag CONTEXT_HIGHER_FLOATING_POINT. 
158  #     // 
159  # 
160  #     FLOAT128 FltS4; 
161  #     FLOAT128 FltS5; 
162  #     FLOAT128 FltS6; 
163  #     FLOAT128 FltS7; 
164  #     FLOAT128 FltS8; 
165  #     FLOAT128 FltS9; 
166  #     FLOAT128 FltS10; 
167  #     FLOAT128 FltS11; 
168  #     FLOAT128 FltS12; 
169  #     FLOAT128 FltS13; 
170  #     FLOAT128 FltS14; 
171  #     FLOAT128 FltS15; 
172  #     FLOAT128 FltS16; 
173  #     FLOAT128 FltS17; 
174  #     FLOAT128 FltS18; 
175  #     FLOAT128 FltS19; 
176  # 
177  #     FLOAT128 FltF32; 
178  #     FLOAT128 FltF33; 
179  #     FLOAT128 FltF34; 
180  #     FLOAT128 FltF35; 
181  #     FLOAT128 FltF36; 
182  #     FLOAT128 FltF37; 
183  #     FLOAT128 FltF38; 
184  #     FLOAT128 FltF39; 
185  # 
186  #     FLOAT128 FltF40; 
187  #     FLOAT128 FltF41; 
188  #     FLOAT128 FltF42; 
189  #     FLOAT128 FltF43; 
190  #     FLOAT128 FltF44; 
191  #     FLOAT128 FltF45; 
192  #     FLOAT128 FltF46; 
193  #     FLOAT128 FltF47; 
194  #     FLOAT128 FltF48; 
195  #     FLOAT128 FltF49; 
196  # 
197  #     FLOAT128 FltF50; 
198  #     FLOAT128 FltF51; 
199  #     FLOAT128 FltF52; 
200  #     FLOAT128 FltF53; 
201  #     FLOAT128 FltF54; 
202  #     FLOAT128 FltF55; 
203  #     FLOAT128 FltF56; 
204  #     FLOAT128 FltF57; 
205  #     FLOAT128 FltF58; 
206  #     FLOAT128 FltF59; 
207  # 
208  #     FLOAT128 FltF60; 
209  #     FLOAT128 FltF61; 
210  #     FLOAT128 FltF62; 
211  #     FLOAT128 FltF63; 
212  #     FLOAT128 FltF64; 
213  #     FLOAT128 FltF65; 
214  #     FLOAT128 FltF66; 
215  #     FLOAT128 FltF67; 
216  #     FLOAT128 FltF68; 
217  #     FLOAT128 FltF69; 
218  # 
219  #     FLOAT128 FltF70; 
220  #     FLOAT128 FltF71; 
221  #     FLOAT128 FltF72; 
222  #     FLOAT128 FltF73; 
223  #     FLOAT128 FltF74; 
224  #     FLOAT128 FltF75; 
225  #     FLOAT128 FltF76; 
226  #     FLOAT128 FltF77; 
227  #     FLOAT128 FltF78; 
228  #     FLOAT128 FltF79; 
229  # 
230  #     FLOAT128 FltF80; 
231  #     FLOAT128 FltF81; 
232  #     FLOAT128 FltF82; 
233  #     FLOAT128 FltF83; 
234  #     FLOAT128 FltF84; 
235  #     FLOAT128 FltF85; 
236  #     FLOAT128 FltF86; 
237  #     FLOAT128 FltF87; 
238  #     FLOAT128 FltF88; 
239  #     FLOAT128 FltF89; 
240  # 
241  #     FLOAT128 FltF90; 
242  #     FLOAT128 FltF91; 
243  #     FLOAT128 FltF92; 
244  #     FLOAT128 FltF93; 
245  #     FLOAT128 FltF94; 
246  #     FLOAT128 FltF95; 
247  #     FLOAT128 FltF96; 
248  #     FLOAT128 FltF97; 
249  #     FLOAT128 FltF98; 
250  #     FLOAT128 FltF99; 
251  # 
252  #     FLOAT128 FltF100; 
253  #     FLOAT128 FltF101; 
254  #     FLOAT128 FltF102; 
255  #     FLOAT128 FltF103; 
256  #     FLOAT128 FltF104; 
257  #     FLOAT128 FltF105; 
258  #     FLOAT128 FltF106; 
259  #     FLOAT128 FltF107; 
260  #     FLOAT128 FltF108; 
261  #     FLOAT128 FltF109; 
262  # 
263  #     FLOAT128 FltF110; 
264  #     FLOAT128 FltF111; 
265  #     FLOAT128 FltF112; 
266  #     FLOAT128 FltF113; 
267  #     FLOAT128 FltF114; 
268  #     FLOAT128 FltF115; 
269  #     FLOAT128 FltF116; 
270  #     FLOAT128 FltF117; 
271  #     FLOAT128 FltF118; 
272  #     FLOAT128 FltF119; 
273  # 
274  #     FLOAT128 FltF120; 
275  #     FLOAT128 FltF121; 
276  #     FLOAT128 FltF122; 
277  #     FLOAT128 FltF123; 
278  #     FLOAT128 FltF124; 
279  #     FLOAT128 FltF125; 
280  #     FLOAT128 FltF126; 
281  #     FLOAT128 FltF127; 
282  # 
283  #     // 
284  #     // This section is specified/returned if the ContextFlags word contains 
285  #     // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL. 
286  #     // 
287  # 
288  #     ULONGLONG StFPSR;       //  FP status 
289  # 
290  #     // 
291  #     // This section is specified/returned if the ContextFlags word contains 
292  #     // the flag CONTEXT_INTEGER. 
293  #     // 
294  #     // N.B. The registers gp, sp, rp are part of the control context 
295  #     // 
296  # 
297  #     ULONGLONG IntGp;        //  r1, volatile 
298  #     ULONGLONG IntT0;        //  r2-r3, volatile 
299  #     ULONGLONG IntT1;        // 
300  #     ULONGLONG IntS0;        //  r4-r7, preserved 
301  #     ULONGLONG IntS1; 
302  #     ULONGLONG IntS2; 
303  #     ULONGLONG IntS3; 
304  #     ULONGLONG IntV0;        //  r8, volatile 
305  #     ULONGLONG IntT2;        //  r9-r11, volatile 
306  #     ULONGLONG IntT3; 
307  #     ULONGLONG IntT4; 
308  #     ULONGLONG IntSp;        //  stack pointer (r12), special 
309  #     ULONGLONG IntTeb;       //  teb (r13), special 
310  #     ULONGLONG IntT5;        //  r14-r31, volatile 
311  #     ULONGLONG IntT6; 
312  #     ULONGLONG IntT7; 
313  #     ULONGLONG IntT8; 
314  #     ULONGLONG IntT9; 
315  #     ULONGLONG IntT10; 
316  #     ULONGLONG IntT11; 
317  #     ULONGLONG IntT12; 
318  #     ULONGLONG IntT13; 
319  #     ULONGLONG IntT14; 
320  #     ULONGLONG IntT15; 
321  #     ULONGLONG IntT16; 
322  #     ULONGLONG IntT17; 
323  #     ULONGLONG IntT18; 
324  #     ULONGLONG IntT19; 
325  #     ULONGLONG IntT20; 
326  #     ULONGLONG IntT21; 
327  #     ULONGLONG IntT22; 
328  # 
329  #     ULONGLONG IntNats;      //  Nat bits for r1-r31 
330  #                             //  r1-r31 in bits 1 thru 31. 
331  #     ULONGLONG Preds;        //  predicates, preserved 
332  # 
333  #     ULONGLONG BrRp;         //  return pointer, b0, preserved 
334  #     ULONGLONG BrS0;         //  b1-b5, preserved 
335  #     ULONGLONG BrS1; 
336  #     ULONGLONG BrS2; 
337  #     ULONGLONG BrS3; 
338  #     ULONGLONG BrS4; 
339  #     ULONGLONG BrT0;         //  b6-b7, volatile 
340  #     ULONGLONG BrT1; 
341  # 
342  #     // 
343  #     // This section is specified/returned if the ContextFlags word contains 
344  #     // the flag CONTEXT_CONTROL. 
345  #     // 
346  # 
347  #     // Other application registers 
348  #     ULONGLONG ApUNAT;       //  User Nat collection register, preserved 
349  #     ULONGLONG ApLC;         //  Loop counter register, preserved 
350  #     ULONGLONG ApEC;         //  Epilog counter register, preserved 
351  #     ULONGLONG ApCCV;        //  CMPXCHG value register, volatile 
352  #     ULONGLONG ApDCR;        //  Default control register (TBD) 
353  # 
354  #     // Register stack info 
355  #     ULONGLONG RsPFS;        //  Previous function state, preserved 
356  #     ULONGLONG RsBSP;        //  Backing store pointer, preserved 
357  #     ULONGLONG RsBSPSTORE; 
358  #     ULONGLONG RsRSC;        //  RSE configuration, volatile 
359  #     ULONGLONG RsRNAT;       //  RSE Nat collection register, preserved 
360  # 
361  #     // Trap Status Information 
362  #     ULONGLONG StIPSR;       //  Interruption Processor Status 
363  #     ULONGLONG StIIP;        //  Interruption IP 
364  #     ULONGLONG StIFS;        //  Interruption Function State 
365  # 
366  #     // iA32 related control registers 
367  #     ULONGLONG StFCR;        //  copy of Ar21 
368  #     ULONGLONG Eflag;        //  Eflag copy of Ar24 
369  #     ULONGLONG SegCSD;       //  iA32 CSDescriptor (Ar25) 
370  #     ULONGLONG SegSSD;       //  iA32 SSDescriptor (Ar26) 
371  #     ULONGLONG Cflag;        //  Cr0+Cr4 copy of Ar27 
372  #     ULONGLONG StFSR;        //  x86 FP status (copy of AR28) 
373  #     ULONGLONG StFIR;        //  x86 FP status (copy of AR29) 
374  #     ULONGLONG StFDR;        //  x86 FP status (copy of AR30) 
375  # 
376  #       ULONGLONG UNUSEDPACK;   //  added to pack StFDR to 16-bytes 
377  # 
378  # } CONTEXT, *PCONTEXT; 
379   
380 -class CONTEXT(Structure):
381 arch = 'ia64' 382 383 _pack_ = 16 384 _fields_ = [ 385 ('ContextFlags', DWORD), 386 ('Fill1', DWORD * 3), # alignment 387 388 # CONTEXT_DEBUG 389 ('DbI0', ULONGLONG), 390 ('DbI1', ULONGLONG), 391 ('DbI2', ULONGLONG), 392 ('DbI3', ULONGLONG), 393 ('DbI4', ULONGLONG), 394 ('DbI5', ULONGLONG), 395 ('DbI6', ULONGLONG), 396 ('DbI7', ULONGLONG), 397 ('DbD0', ULONGLONG), 398 ('DbD1', ULONGLONG), 399 ('DbD2', ULONGLONG), 400 ('DbD3', ULONGLONG), 401 ('DbD4', ULONGLONG), 402 ('DbD5', ULONGLONG), 403 ('DbD6', ULONGLONG), 404 ('DbD7', ULONGLONG), 405 406 # CONTEXT_LOWER_FLOATING_POINT 407 ('FltS0', FLOAT128), 408 ('FltS1', FLOAT128), 409 ('FltS2', FLOAT128), 410 ('FltS3', FLOAT128), 411 ('FltT0', FLOAT128), 412 ('FltT1', FLOAT128), 413 ('FltT2', FLOAT128), 414 ('FltT3', FLOAT128), 415 ('FltT4', FLOAT128), 416 ('FltT5', FLOAT128), 417 ('FltT6', FLOAT128), 418 ('FltT7', FLOAT128), 419 ('FltT8', FLOAT128), 420 ('FltT9', FLOAT128), 421 422 # CONTEXT_HIGHER_FLOATING_POINT 423 ('FltS4', FLOAT128), 424 ('FltS5', FLOAT128), 425 ('FltS6', FLOAT128), 426 ('FltS7', FLOAT128), 427 ('FltS8', FLOAT128), 428 ('FltS9', FLOAT128), 429 ('FltS10', FLOAT128), 430 ('FltS11', FLOAT128), 431 ('FltS12', FLOAT128), 432 ('FltS13', FLOAT128), 433 ('FltS14', FLOAT128), 434 ('FltS15', FLOAT128), 435 ('FltS16', FLOAT128), 436 ('FltS17', FLOAT128), 437 ('FltS18', FLOAT128), 438 ('FltS19', FLOAT128), 439 ('FltF32', FLOAT128), 440 ('FltF33', FLOAT128), 441 ('FltF34', FLOAT128), 442 ('FltF35', FLOAT128), 443 ('FltF36', FLOAT128), 444 ('FltF37', FLOAT128), 445 ('FltF38', FLOAT128), 446 ('FltF39', FLOAT128), 447 ('FltF40', FLOAT128), 448 ('FltF41', FLOAT128), 449 ('FltF42', FLOAT128), 450 ('FltF43', FLOAT128), 451 ('FltF44', FLOAT128), 452 ('FltF45', FLOAT128), 453 ('FltF46', FLOAT128), 454 ('FltF47', FLOAT128), 455 ('FltF48', FLOAT128), 456 ('FltF49', FLOAT128), 457 ('FltF50', FLOAT128), 458 ('FltF51', FLOAT128), 459 ('FltF52', FLOAT128), 460 ('FltF53', FLOAT128), 461 ('FltF54', FLOAT128), 462 ('FltF55', FLOAT128), 463 ('FltF56', FLOAT128), 464 ('FltF57', FLOAT128), 465 ('FltF58', FLOAT128), 466 ('FltF59', FLOAT128), 467 ('FltF60', FLOAT128), 468 ('FltF61', FLOAT128), 469 ('FltF62', FLOAT128), 470 ('FltF63', FLOAT128), 471 ('FltF64', FLOAT128), 472 ('FltF65', FLOAT128), 473 ('FltF66', FLOAT128), 474 ('FltF67', FLOAT128), 475 ('FltF68', FLOAT128), 476 ('FltF69', FLOAT128), 477 ('FltF70', FLOAT128), 478 ('FltF71', FLOAT128), 479 ('FltF72', FLOAT128), 480 ('FltF73', FLOAT128), 481 ('FltF74', FLOAT128), 482 ('FltF75', FLOAT128), 483 ('FltF76', FLOAT128), 484 ('FltF77', FLOAT128), 485 ('FltF78', FLOAT128), 486 ('FltF79', FLOAT128), 487 ('FltF80', FLOAT128), 488 ('FltF81', FLOAT128), 489 ('FltF82', FLOAT128), 490 ('FltF83', FLOAT128), 491 ('FltF84', FLOAT128), 492 ('FltF85', FLOAT128), 493 ('FltF86', FLOAT128), 494 ('FltF87', FLOAT128), 495 ('FltF88', FLOAT128), 496 ('FltF89', FLOAT128), 497 ('FltF90', FLOAT128), 498 ('FltF91', FLOAT128), 499 ('FltF92', FLOAT128), 500 ('FltF93', FLOAT128), 501 ('FltF94', FLOAT128), 502 ('FltF95', FLOAT128), 503 ('FltF96', FLOAT128), 504 ('FltF97', FLOAT128), 505 ('FltF98', FLOAT128), 506 ('FltF99', FLOAT128), 507 ('FltF100', FLOAT128), 508 ('FltF101', FLOAT128), 509 ('FltF102', FLOAT128), 510 ('FltF103', FLOAT128), 511 ('FltF104', FLOAT128), 512 ('FltF105', FLOAT128), 513 ('FltF106', FLOAT128), 514 ('FltF107', FLOAT128), 515 ('FltF108', FLOAT128), 516 ('FltF109', FLOAT128), 517 ('FltF110', FLOAT128), 518 ('FltF111', FLOAT128), 519 ('FltF112', FLOAT128), 520 ('FltF113', FLOAT128), 521 ('FltF114', FLOAT128), 522 ('FltF115', FLOAT128), 523 ('FltF116', FLOAT128), 524 ('FltF117', FLOAT128), 525 ('FltF118', FLOAT128), 526 ('FltF119', FLOAT128), 527 ('FltF120', FLOAT128), 528 ('FltF121', FLOAT128), 529 ('FltF122', FLOAT128), 530 ('FltF123', FLOAT128), 531 ('FltF124', FLOAT128), 532 ('FltF125', FLOAT128), 533 ('FltF126', FLOAT128), 534 ('FltF127', FLOAT128), 535 536 # CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL 537 ('StFPSR', ULONGLONG), 538 539 # CONTEXT_INTEGER (except gp, sp, rp) 540 ('IntGp', ULONGLONG), # r1, volatile 541 ('IntT0', ULONGLONG), # r2-r3, volatile 542 ('IntT1', ULONGLONG), 543 ('IntS0', ULONGLONG), # r4-r7, preserved 544 ('IntS1', ULONGLONG), 545 ('IntS2', ULONGLONG), 546 ('IntS3', ULONGLONG), 547 ('IntV0', ULONGLONG), # r8, volatile 548 ('IntT2', ULONGLONG), # r9-r11, volatile 549 ('IntT3', ULONGLONG), 550 ('IntT4', ULONGLONG), 551 ('IntSp', ULONGLONG), # stack pointer (r12), special 552 ('IntTeb', ULONGLONG), # teb (r13), special 553 ('IntT5', ULONGLONG), # r14-r31, volatile 554 ('IntT6', ULONGLONG), 555 ('IntT7', ULONGLONG), 556 ('IntT8', ULONGLONG), 557 ('IntT9', ULONGLONG), 558 ('IntT10', ULONGLONG), 559 ('IntT11', ULONGLONG), 560 ('IntT12', ULONGLONG), 561 ('IntT13', ULONGLONG), 562 ('IntT14', ULONGLONG), 563 ('IntT15', ULONGLONG), 564 ('IntT16', ULONGLONG), 565 ('IntT17', ULONGLONG), 566 ('IntT18', ULONGLONG), 567 ('IntT19', ULONGLONG), 568 ('IntT20', ULONGLONG), 569 ('IntT21', ULONGLONG), 570 ('IntT22', ULONGLONG), 571 ('IntNats', ULONGLONG), # Nat bits for r1-r31 572 # r1-r31 in bits 1 thru 31. 573 ('Preds', ULONGLONG), # predicates, preserved 574 575 ('BrRp', ULONGLONG), # return pointer, b0, preserved 576 ('BrS0', ULONGLONG), # b1-b5, preserved 577 ('BrS1', ULONGLONG), 578 ('BrS2', ULONGLONG), 579 ('BrS3', ULONGLONG), 580 ('BrS4', ULONGLONG), 581 ('BrT0', ULONGLONG), # b6-b7, volatile 582 ('BrT1', ULONGLONG), 583 584 # CONTEXT_CONTROL 585 586 # Other application registers 587 ('ApUNAT', ULONGLONG), # User Nat collection register, preserved 588 ('ApLC', ULONGLONG), # Loop counter register, preserved 589 ('ApEC', ULONGLONG), # Epilog counter register, preserved 590 ('ApCCV', ULONGLONG), # CMPXCHG value register, volatile 591 ('ApDCR', ULONGLONG), # Default control register (TBD) 592 593 # Register stack info 594 ('RsPFS', ULONGLONG), # Previous function state, preserved 595 ('RsBSP', ULONGLONG), # Backing store pointer, preserved 596 ('RsBSPSTORE', ULONGLONG), 597 ('RsRSC', ULONGLONG), # RSE configuration, volatile 598 ('RsRNAT', ULONGLONG), # RSE Nat collection register, preserved 599 600 # Trap Status Information 601 ('StIPSR', ULONGLONG), # Interruption Processor Status 602 ('StIIP', ULONGLONG), # Interruption IP 603 ('StIFS', ULONGLONG), # Interruption Function State 604 605 # iA32 related control registers 606 ('StFCR', ULONGLONG), # copy of Ar21 607 ('Eflag', ULONGLONG), # Eflag copy of Ar24 608 ('SegCSD', ULONGLONG), # iA32 CSDescriptor (Ar25) 609 ('SegSSD', ULONGLONG), # iA32 SSDescriptor (Ar26) 610 ('Cflag', ULONGLONG), # Cr0+Cr4 copy of Ar27 611 ('StFSR', ULONGLONG), # x86 FP status (copy of AR28) 612 ('StFIR', ULONGLONG), # x86 FP status (copy of AR29) 613 ('StFDR', ULONGLONG), # x86 FP status (copy of AR30) 614 ('UNUSEDPACK', ULONGLONG), # added to pack StFDR to 16-bytes 615 ]
616 617 PCONTEXT = POINTER(CONTEXT) 618 LPCONTEXT = PCONTEXT 619
620 -class Context(dict):
621 """ 622 Register context dictionary for the %s architecture. 623 """ % CONTEXT.arch 624 arch = CONTEXT.arch 625 626 # See http://msdn.microsoft.com/en-us/library/cc266544.aspx 627
628 - def __get_gp(self):
629 return self['IntGp']
630 - def __set_gp(self, value):
631 self['IntGp'] = value
632 gp = property(__get_gp, __set_gp) 633
634 - def __get_sp(self):
635 return self['IntSp']
636 - def __set_sp(self, value):
637 self['IntSp'] = value
638 sp = property(__get_sp, __set_sp) 639
640 - def __get_rp(self):
641 return self['IntRp']
642 - def __set_rp(self, value):
643 self['IntRp'] = value
644 rp = property(__get_rp, __set_rp)
645 646 ############################################################################### 647 648 # BOOL WINAPI GetThreadContext( 649 # __in HANDLE hThread, 650 # __inout LPCONTEXT lpContext 651 # );
652 -def GetThreadContext(hThread, ContextFlags = None):
653 _GetThreadContext = windll.kernel32.GetThreadContext 654 _GetThreadContext.argtypes = [HANDLE, LPCONTEXT] 655 _GetThreadContext.restype = bool 656 _GetThreadContext.errcheck = RaiseIfZero 657 658 if ContextFlags is None: 659 ContextFlags = CONTEXT_ALL 660 lpContext = CONTEXT() 661 lpContext.ContextFlags = ContextFlags 662 _GetThreadContext(hThread, ctypes.byref(lpContext)) 663 return lpContext.to_dict()
664 665 # BOOL WINAPI SetThreadContext( 666 # __in HANDLE hThread, 667 # __in const CONTEXT* lpContext 668 # );
669 -def SetThreadContext(hThread, lpContext):
670 _SetThreadContext = windll.kernel32.SetThreadContext 671 _SetThreadContext.argtypes = [HANDLE, LPCONTEXT] 672 _SetThreadContext.restype = bool 673 _SetThreadContext.errcheck = RaiseIfZero 674 675 if isinstance(lpContext, dict): 676 lpContext = CONTEXT.from_dict(lpContext) 677 _SetThreadContext(hThread, ctypes.byref(lpContext))
678