Dan Willemsen | 09eb3b1 | 2015-09-16 14:34:17 -0700 | [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 | |
| 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 | |
| 104 | func (c *context) ip() uintptr { return uintptr(c.eip) } |
| 105 | func (c *context) sp() uintptr { return uintptr(c.esp) } |
| 106 | |
Colin Cross | d9c6b80 | 2019-03-19 21:10:31 -0700 | [diff] [blame] | 107 | // 386 does not have link register, so this returns 0. |
| 108 | func (c *context) lr() uintptr { return 0 } |
| 109 | func (c *context) set_lr(x uintptr) {} |
| 110 | |
| 111 | func (c *context) set_ip(x uintptr) { c.eip = uint32(x) } |
| 112 | func (c *context) set_sp(x uintptr) { c.esp = uint32(x) } |
Dan Willemsen | 09eb3b1 | 2015-09-16 14:34:17 -0700 | [diff] [blame] | 113 | |
| 114 | func dumpregs(r *context) { |
| 115 | print("eax ", hex(r.eax), "\n") |
| 116 | print("ebx ", hex(r.ebx), "\n") |
| 117 | print("ecx ", hex(r.ecx), "\n") |
| 118 | print("edx ", hex(r.edx), "\n") |
| 119 | print("edi ", hex(r.edi), "\n") |
| 120 | print("esi ", hex(r.esi), "\n") |
| 121 | print("ebp ", hex(r.ebp), "\n") |
| 122 | print("esp ", hex(r.esp), "\n") |
| 123 | print("eip ", hex(r.eip), "\n") |
| 124 | print("eflags ", hex(r.eflags), "\n") |
| 125 | print("cs ", hex(r.segcs), "\n") |
| 126 | print("fs ", hex(r.segfs), "\n") |
| 127 | print("gs ", hex(r.seggs), "\n") |
| 128 | } |
| 129 | |
| 130 | type overlapped struct { |
| 131 | internal uint32 |
| 132 | internalhigh uint32 |
| 133 | anon0 [8]byte |
| 134 | hevent *byte |
| 135 | } |
Dan Willemsen | c741332 | 2018-08-27 23:21:26 -0700 | [diff] [blame] | 136 | |
| 137 | type memoryBasicInformation struct { |
| 138 | baseAddress uintptr |
| 139 | allocationBase uintptr |
| 140 | allocationProtect uint32 |
| 141 | regionSize uintptr |
| 142 | state uint32 |
| 143 | protect uint32 |
| 144 | type_ uint32 |
| 145 | } |