Source file src/internal/runtime/syscall/windows/defs_windows.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Architecture-independent definitions.
     6  
     7  package windows
     8  
     9  // Pseudo handles.
    10  const (
    11  	CurrentProcess = ^uintptr(0) // -1 = current process
    12  	CurrentThread  = ^uintptr(1) // -2 = current thread
    13  )
    14  
    15  const INVALID_HANDLE_VALUE = ^uintptr(0)
    16  
    17  const DWORD_MAX = 0xffffffff
    18  
    19  const (
    20  	PROT_NONE  = 0
    21  	PROT_READ  = 1
    22  	PROT_WRITE = 2
    23  	PROT_EXEC  = 4
    24  )
    25  
    26  const (
    27  	MAP_ANON    = 1
    28  	MAP_PRIVATE = 2
    29  )
    30  
    31  const DUPLICATE_SAME_ACCESS = 0x2
    32  
    33  const THREAD_PRIORITY_HIGHEST = 0x2
    34  
    35  const (
    36  	SIGINT  = 0x2
    37  	SIGTERM = 0xF
    38  )
    39  
    40  const (
    41  	CTRL_C_EVENT        = 0x0
    42  	CTRL_BREAK_EVENT    = 0x1
    43  	CTRL_CLOSE_EVENT    = 0x2
    44  	CTRL_LOGOFF_EVENT   = 0x5
    45  	CTRL_SHUTDOWN_EVENT = 0x6
    46  )
    47  
    48  const (
    49  	EXCEPTION_ACCESS_VIOLATION     = 0xc0000005
    50  	EXCEPTION_IN_PAGE_ERROR        = 0xc0000006
    51  	EXCEPTION_BREAKPOINT           = 0x80000003
    52  	EXCEPTION_ILLEGAL_INSTRUCTION  = 0xc000001d
    53  	EXCEPTION_FLT_DENORMAL_OPERAND = 0xc000008d
    54  	EXCEPTION_FLT_DIVIDE_BY_ZERO   = 0xc000008e
    55  	EXCEPTION_FLT_INEXACT_RESULT   = 0xc000008f
    56  	EXCEPTION_FLT_OVERFLOW         = 0xc0000091
    57  	EXCEPTION_FLT_UNDERFLOW        = 0xc0000093
    58  	EXCEPTION_INT_DIVIDE_BY_ZERO   = 0xc0000094
    59  	EXCEPTION_INT_OVERFLOW         = 0xc0000095
    60  )
    61  
    62  const (
    63  	SEM_FAILCRITICALERRORS = 0x0001
    64  	SEM_NOGPFAULTERRORBOX  = 0x0002
    65  	SEM_NOOPENFILEERRORBOX = 0x8000
    66  )
    67  
    68  const WER_FAULT_REPORTING_NO_UI = 0x0020
    69  
    70  const INFINITE = 0xffffffff
    71  
    72  const WAIT_TIMEOUT = 258
    73  
    74  const FAIL_FAST_GENERATE_EXCEPTION_ADDRESS = 0x1
    75  
    76  const (
    77  	EXCEPTION_CONTINUE_EXECUTION  = -0x1
    78  	EXCEPTION_CONTINUE_SEARCH     = 0x0
    79  	EXCEPTION_CONTINUE_SEARCH_SEH = 0x1
    80  )
    81  
    82  const CREATE_WAITABLE_TIMER_HIGH_RESOLUTION = 0x00000002
    83  
    84  const (
    85  	SYNCHRONIZE        = 0x00100000
    86  	TIMER_QUERY_STATE  = 0x0001
    87  	TIMER_MODIFY_STATE = 0x0002
    88  )
    89  
    90  // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
    91  const (
    92  	STATUS_SUCCESS   = 0x00000000
    93  	STATUS_PENDING   = 0x00000103
    94  	STATUS_CANCELLED = 0xC0000120
    95  )
    96  
    97  // https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
    98  type SystemInfo struct {
    99  	ProcessorArchitecture     uint16
   100  	Reserved                  uint16
   101  	PageSize                  uint32
   102  	MinimumApplicationAddress *byte
   103  	MaximumApplicationAddress *byte
   104  	ActiveProcessorMask       uintptr
   105  	NumberOfProcessors        uint32
   106  	ProcessorType             uint32
   107  	AllocationGranularity     uint32
   108  	ProcessorLevel            uint16
   109  	ProcessorRevision         uint16
   110  }
   111  
   112  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_pointers
   113  type ExceptionPointers struct {
   114  	Record  *ExceptionRecord
   115  	Context *Context
   116  }
   117  
   118  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record
   119  type ExceptionRecord struct {
   120  	ExceptionCode        uint32
   121  	ExceptionFlags       uint32
   122  	ExceptionRecord      *ExceptionRecord
   123  	ExceptionAddress     uintptr
   124  	NumberParameters     uint32
   125  	ExceptionInformation [15]uintptr
   126  }
   127  
   128  type Handle uintptr
   129  
   130  // https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-overlapped
   131  type Overlapped struct {
   132  	Internal     uintptr
   133  	InternalHigh uintptr
   134  	Offset       uint32
   135  	OffsetHigh   uint32
   136  	HEvent       Handle
   137  }
   138  
   139  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-memory_basic_information
   140  type MemoryBasicInformation struct {
   141  	BaseAddress       uintptr
   142  	AllocationBase    uintptr
   143  	AllocationProtect uint32
   144  	PartitionId       uint16
   145  	RegionSize        uintptr
   146  	State             uint32
   147  	Protect           uint32
   148  	Type              uint32
   149  }
   150  
   151  // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfow
   152  type OSVERSIONINFOW struct {
   153  	OSVersionInfoSize uint32
   154  	MajorVersion      uint32
   155  	MinorVersion      uint32
   156  	BuildNumber       uint32
   157  	PlatformID        uint32
   158  	CSDVersion        [128]uint16
   159  }
   160  

View as plain text