github.com/undoio/delve@v1.9.0/pkg/proc/native/syscall_windows.go (about) 1 //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go 2 3 package native 4 5 import ( 6 "syscall" 7 8 "github.com/undoio/delve/pkg/proc/winutil" 9 ) 10 11 type _NTSTATUS int32 12 13 type _CLIENT_ID struct { 14 UniqueProcess syscall.Handle 15 UniqueThread syscall.Handle 16 } 17 18 type _THREAD_BASIC_INFORMATION struct { 19 ExitStatus _NTSTATUS 20 TebBaseAddress uintptr 21 ClientId _CLIENT_ID 22 AffinityMask uintptr 23 Priority int32 24 BasePriority int32 25 } 26 27 type _CREATE_PROCESS_DEBUG_INFO struct { 28 File syscall.Handle 29 Process syscall.Handle 30 Thread syscall.Handle 31 BaseOfImage uintptr 32 DebugInfoFileOffset uint32 33 DebugInfoSize uint32 34 ThreadLocalBase uintptr 35 StartAddress uintptr 36 ImageName uintptr 37 Unicode uint16 38 } 39 40 type _CREATE_THREAD_DEBUG_INFO struct { 41 Thread syscall.Handle 42 ThreadLocalBase uintptr 43 StartAddress uintptr 44 } 45 46 type _EXIT_PROCESS_DEBUG_INFO struct { 47 ExitCode uint32 48 } 49 50 type _LOAD_DLL_DEBUG_INFO struct { 51 File syscall.Handle 52 BaseOfDll uintptr 53 DebugInfoFileOffset uint32 54 DebugInfoSize uint32 55 ImageName uintptr 56 Unicode uint16 57 } 58 59 type _EXCEPTION_DEBUG_INFO struct { 60 ExceptionRecord _EXCEPTION_RECORD 61 FirstChance uint32 62 } 63 64 type _EXCEPTION_RECORD struct { 65 ExceptionCode uint32 66 ExceptionFlags uint32 67 ExceptionRecord *_EXCEPTION_RECORD 68 ExceptionAddress uintptr 69 NumberParameters uint32 70 ExceptionInformation [_EXCEPTION_MAXIMUM_PARAMETERS]uintptr 71 } 72 73 type _MEMORY_BASIC_INFORMATION struct { 74 BaseAddress uintptr 75 AllocationBase uintptr 76 AllocationProtect uint32 77 PartitionId uint16 78 RegionSize uint64 79 State uint32 80 Protect uint32 81 Type uint32 82 } 83 84 const ( 85 _ThreadBasicInformation = 0 86 87 _DBG_CONTINUE = 0x00010002 88 _DBG_EXCEPTION_NOT_HANDLED = 0x80010001 89 90 _EXCEPTION_DEBUG_EVENT = 1 91 _CREATE_THREAD_DEBUG_EVENT = 2 92 _CREATE_PROCESS_DEBUG_EVENT = 3 93 _EXIT_THREAD_DEBUG_EVENT = 4 94 _EXIT_PROCESS_DEBUG_EVENT = 5 95 _LOAD_DLL_DEBUG_EVENT = 6 96 _UNLOAD_DLL_DEBUG_EVENT = 7 97 _OUTPUT_DEBUG_STRING_EVENT = 8 98 _RIP_EVENT = 9 99 100 // DEBUG_ONLY_THIS_PROCESS tracks https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx 101 _DEBUG_ONLY_THIS_PROCESS = 0x00000002 102 103 _EXCEPTION_BREAKPOINT = 0x80000003 104 _EXCEPTION_SINGLE_STEP = 0x80000004 105 106 _EXCEPTION_MAXIMUM_PARAMETERS = 15 107 108 _MEM_FREE = 0x10000 109 _MEM_RESERVE = 0x2000 110 111 _PAGE_EXECUTE = 0x10 112 _PAGE_EXECUTE_READ = 0x20 113 _PAGE_EXECUTE_READWRITE = 0x40 114 _PAGE_EXECUTE_WRITECOPY = 0x80 115 _PAGE_NOACCESS = 0x01 116 _PAGE_READONLY = 0x02 117 _PAGE_READWRITE = 0x04 118 _PAGE_WRITECOPY = 0x08 119 120 _PAGE_GUARD = 0x100 121 ) 122 123 func _NT_SUCCESS(x _NTSTATUS) bool { 124 return x >= 0 125 } 126 127 // zsyscall_windows.go, an autogenerated file, wants to refer to the context 128 // structure as _CONTEXT, but we need to have it in pkg/proc/winutil.CONTEXT 129 // because it's also used on non-windows operating systems. 130 type _CONTEXT = winutil.CONTEXT 131 132 //sys _NtQueryInformationThread(threadHandle syscall.Handle, infoclass int32, info uintptr, infolen uint32, retlen *uint32) (status _NTSTATUS) = ntdll.NtQueryInformationThread 133 //sys _GetThreadContext(thread syscall.Handle, context *_CONTEXT) (err error) = kernel32.GetThreadContext 134 //sys _SetThreadContext(thread syscall.Handle, context *_CONTEXT) (err error) = kernel32.SetThreadContext 135 //sys _SuspendThread(threadid syscall.Handle) (prevsuspcount uint32, err error) [failretval==0xffffffff] = kernel32.SuspendThread 136 //sys _ResumeThread(threadid syscall.Handle) (prevsuspcount uint32, err error) [failretval==0xffffffff] = kernel32.ResumeThread 137 //sys _ContinueDebugEvent(processid uint32, threadid uint32, continuestatus uint32) (err error) = kernel32.ContinueDebugEvent 138 //sys _WriteProcessMemory(process syscall.Handle, baseaddr uintptr, buffer *byte, size uintptr, byteswritten *uintptr) (err error) = kernel32.WriteProcessMemory 139 //sys _ReadProcessMemory(process syscall.Handle, baseaddr uintptr, buffer *byte, size uintptr, bytesread *uintptr) (err error) = kernel32.ReadProcessMemory 140 //sys _DebugBreakProcess(process syscall.Handle) (err error) = kernel32.DebugBreakProcess 141 //sys _WaitForDebugEvent(debugevent *_DEBUG_EVENT, milliseconds uint32) (err error) = kernel32.WaitForDebugEvent 142 //sys _DebugActiveProcess(processid uint32) (err error) = kernel32.DebugActiveProcess 143 //sys _DebugActiveProcessStop(processid uint32) (err error) = kernel32.DebugActiveProcessStop 144 //sys _QueryFullProcessImageName(process syscall.Handle, flags uint32, exename *uint16, size *uint32) (err error) = kernel32.QueryFullProcessImageNameW 145 //sys _VirtualQueryEx(process syscall.Handle, addr uintptr, buffer *_MEMORY_BASIC_INFORMATION, length uintptr) (lengthOut uintptr) = kernel32.VirtualQueryEx 146 //sys _IsWow64Process(process syscall.Handle, wow64process *uint32) (ok uint32) = kernel32.IsWow64Process