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  	ERROR_ACCESS_DENIED = 5
    64  )
    65  
    66  const (
    67  	SEM_FAILCRITICALERRORS = 0x0001
    68  	SEM_NOGPFAULTERRORBOX  = 0x0002
    69  	SEM_NOOPENFILEERRORBOX = 0x8000
    70  )
    71  
    72  const WER_FAULT_REPORTING_NO_UI = 0x0020
    73  
    74  const INFINITE = 0xffffffff
    75  
    76  const WAIT_TIMEOUT = 258
    77  
    78  const FAIL_FAST_GENERATE_EXCEPTION_ADDRESS = 0x1
    79  
    80  const (
    81  	EXCEPTION_CONTINUE_EXECUTION  = -0x1
    82  	EXCEPTION_CONTINUE_SEARCH     = 0x0
    83  	EXCEPTION_CONTINUE_SEARCH_SEH = 0x1
    84  )
    85  
    86  const CREATE_WAITABLE_TIMER_HIGH_RESOLUTION = 0x00000002
    87  
    88  const (
    89  	SYNCHRONIZE        = 0x00100000
    90  	TIMER_QUERY_STATE  = 0x0001
    91  	TIMER_MODIFY_STATE = 0x0002
    92  )
    93  
    94  // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
    95  const (
    96  	STATUS_SUCCESS   = 0x00000000
    97  	STATUS_PENDING   = 0x00000103
    98  	STATUS_CANCELLED = 0xC0000120
    99  )
   100  
   101  // https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
   102  type SystemInfo struct {
   103  	ProcessorArchitecture     uint16
   104  	Reserved                  uint16
   105  	PageSize                  uint32
   106  	MinimumApplicationAddress *byte
   107  	MaximumApplicationAddress *byte
   108  	ActiveProcessorMask       uintptr
   109  	NumberOfProcessors        uint32
   110  	ProcessorType             uint32
   111  	AllocationGranularity     uint32
   112  	ProcessorLevel            uint16
   113  	ProcessorRevision         uint16
   114  }
   115  
   116  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_pointers
   117  type ExceptionPointers struct {
   118  	Record  *ExceptionRecord
   119  	Context *Context
   120  }
   121  
   122  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record
   123  type ExceptionRecord struct {
   124  	ExceptionCode        uint32
   125  	ExceptionFlags       uint32
   126  	ExceptionRecord      *ExceptionRecord
   127  	ExceptionAddress     uintptr
   128  	NumberParameters     uint32
   129  	ExceptionInformation [15]uintptr
   130  }
   131  
   132  type Handle uintptr
   133  
   134  // https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-overlapped
   135  type Overlapped struct {
   136  	Internal     uintptr
   137  	InternalHigh uintptr
   138  	Offset       uint32
   139  	OffsetHigh   uint32
   140  	HEvent       Handle
   141  }
   142  
   143  // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-memory_basic_information
   144  type MemoryBasicInformation struct {
   145  	BaseAddress       uintptr
   146  	AllocationBase    uintptr
   147  	AllocationProtect uint32
   148  	PartitionId       uint16
   149  	RegionSize        uintptr
   150  	State             uint32
   151  	Protect           uint32
   152  	Type              uint32
   153  }
   154  
   155  // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfow
   156  type OSVERSIONINFOW struct {
   157  	OSVersionInfoSize uint32
   158  	MajorVersion      uint32
   159  	MinorVersion      uint32
   160  	BuildNumber       uint32
   161  	PlatformID        uint32
   162  	CSDVersion        [128]uint16
   163  }
   164  

View as plain text