Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 1 | // created by cgo -cdefs and then converted to Go |
| 2 | // cgo -cdefs defs_windows.go |
| 3 | |
| 4 | package runtime |
| 5 | |
| 6 | const ( |
| 7 | _PROT_NONE = 0 |
| 8 | _PROT_READ = 1 |
| 9 | _PROT_WRITE = 2 |
| 10 | _PROT_EXEC = 4 |
| 11 | |
| 12 | _MAP_ANON = 1 |
| 13 | _MAP_PRIVATE = 2 |
| 14 | |
| 15 | _DUPLICATE_SAME_ACCESS = 0x2 |
| 16 | _THREAD_PRIORITY_HIGHEST = 0x2 |
| 17 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 18 | _SIGINT = 0x2 |
| 19 | _CTRL_C_EVENT = 0x0 |
| 20 | _CTRL_BREAK_EVENT = 0x1 |
| 21 | |
| 22 | _CONTEXT_CONTROL = 0x10001 |
| 23 | _CONTEXT_FULL = 0x10007 |
| 24 | |
| 25 | _EXCEPTION_ACCESS_VIOLATION = 0xc0000005 |
| 26 | _EXCEPTION_BREAKPOINT = 0x80000003 |
| 27 | _EXCEPTION_FLT_DENORMAL_OPERAND = 0xc000008d |
| 28 | _EXCEPTION_FLT_DIVIDE_BY_ZERO = 0xc000008e |
| 29 | _EXCEPTION_FLT_INEXACT_RESULT = 0xc000008f |
| 30 | _EXCEPTION_FLT_OVERFLOW = 0xc0000091 |
| 31 | _EXCEPTION_FLT_UNDERFLOW = 0xc0000093 |
| 32 | _EXCEPTION_INT_DIVIDE_BY_ZERO = 0xc0000094 |
| 33 | _EXCEPTION_INT_OVERFLOW = 0xc0000095 |
| 34 | |
| 35 | _INFINITE = 0xffffffff |
| 36 | _WAIT_TIMEOUT = 0x102 |
| 37 | |
| 38 | _EXCEPTION_CONTINUE_EXECUTION = -0x1 |
| 39 | _EXCEPTION_CONTINUE_SEARCH = 0x0 |
| 40 | ) |
| 41 | |
| 42 | type systeminfo struct { |
| 43 | anon0 [4]byte |
| 44 | dwpagesize uint32 |
| 45 | lpminimumapplicationaddress *byte |
| 46 | lpmaximumapplicationaddress *byte |
| 47 | dwactiveprocessormask uint32 |
| 48 | dwnumberofprocessors uint32 |
| 49 | dwprocessortype uint32 |
| 50 | dwallocationgranularity uint32 |
| 51 | wprocessorlevel uint16 |
| 52 | wprocessorrevision uint16 |
| 53 | } |
| 54 | |
| 55 | type exceptionrecord struct { |
| 56 | exceptioncode uint32 |
| 57 | exceptionflags uint32 |
| 58 | exceptionrecord *exceptionrecord |
| 59 | exceptionaddress *byte |
| 60 | numberparameters uint32 |
| 61 | exceptioninformation [15]uint32 |
| 62 | } |
| 63 | |
| 64 | type floatingsavearea struct { |
| 65 | controlword uint32 |
| 66 | statusword uint32 |
| 67 | tagword uint32 |
| 68 | erroroffset uint32 |
| 69 | errorselector uint32 |
| 70 | dataoffset uint32 |
| 71 | dataselector uint32 |
| 72 | registerarea [80]uint8 |
| 73 | cr0npxstate uint32 |
| 74 | } |
| 75 | |
| 76 | type context struct { |
| 77 | contextflags uint32 |
| 78 | dr0 uint32 |
| 79 | dr1 uint32 |
| 80 | dr2 uint32 |
| 81 | dr3 uint32 |
| 82 | dr6 uint32 |
| 83 | dr7 uint32 |
| 84 | floatsave floatingsavearea |
| 85 | seggs uint32 |
| 86 | segfs uint32 |
| 87 | seges uint32 |
| 88 | segds uint32 |
| 89 | edi uint32 |
| 90 | esi uint32 |
| 91 | ebx uint32 |
| 92 | edx uint32 |
| 93 | ecx uint32 |
| 94 | eax uint32 |
| 95 | ebp uint32 |
| 96 | eip uint32 |
| 97 | segcs uint32 |
| 98 | eflags uint32 |
| 99 | esp uint32 |
| 100 | segss uint32 |
| 101 | extendedregisters [512]uint8 |
| 102 | } |
| 103 | |
Alex Brainman | 5c4a86d | 2015-01-14 12:25:55 +1100 | [diff] [blame] | 104 | func (c *context) ip() uintptr { return uintptr(c.eip) } |
| 105 | func (c *context) sp() uintptr { return uintptr(c.esp) } |
| 106 | |
| 107 | func (c *context) setip(x uintptr) { c.eip = uint32(x) } |
| 108 | func (c *context) setsp(x uintptr) { c.esp = uint32(x) } |
| 109 | |
Alex Brainman | e0d9342 | 2015-02-12 12:14:02 +1100 | [diff] [blame] | 110 | func dumpregs(r *context) { |
| 111 | print("eax ", hex(r.eax), "\n") |
| 112 | print("ebx ", hex(r.ebx), "\n") |
| 113 | print("ecx ", hex(r.ecx), "\n") |
| 114 | print("edx ", hex(r.edx), "\n") |
| 115 | print("edi ", hex(r.edi), "\n") |
| 116 | print("esi ", hex(r.esi), "\n") |
| 117 | print("ebp ", hex(r.ebp), "\n") |
| 118 | print("esp ", hex(r.esp), "\n") |
| 119 | print("eip ", hex(r.eip), "\n") |
| 120 | print("eflags ", hex(r.eflags), "\n") |
| 121 | print("cs ", hex(r.segcs), "\n") |
| 122 | print("fs ", hex(r.segfs), "\n") |
| 123 | print("gs ", hex(r.seggs), "\n") |
| 124 | } |
| 125 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 126 | type overlapped struct { |
| 127 | internal uint32 |
| 128 | internalhigh uint32 |
| 129 | anon0 [8]byte |
| 130 | hevent *byte |
| 131 | } |