// Code generated by 'go generate'; DO NOT EDIT.

package win32

import (
	"syscall"
	"unsafe"

	"golang.org/x/sys/windows"
)

var _ unsafe.Pointer

// Do the interface allocations only once for common
// Errno values.
const (
	errnoERROR_IO_PENDING = 997
)

var (
	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
	errERROR_EINVAL     error = syscall.EINVAL
)

// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
	switch e {
	case 0:
		return errERROR_EINVAL
	case errnoERROR_IO_PENDING:
		return errERROR_IO_PENDING
	}
	// TODO: add more here, after collecting data on the common
	// error values see on Windows. (perhaps when running
	// all.bat?)
	return e
}

var (
	modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
	modntdll    = windows.NewLazySystemDLL("ntdll.dll")

	procGetNativeSystemInfo       = modkernel32.NewProc("GetNativeSystemInfo")
	procIsWow64Process            = modkernel32.NewProc("IsWow64Process")
	procOpenProcess               = modkernel32.NewProc("OpenProcess")
	procReadProcessMemory         = modkernel32.NewProc("ReadProcessMemory")
	procVirtualQueryEx            = modkernel32.NewProc("VirtualQueryEx")
	procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess")
	procNtQueryVirtualMemory      = modntdll.NewProc("NtQueryVirtualMemory")
	procNtReadVirtualMemory       = modntdll.NewProc("NtReadVirtualMemory")
)

func _GetNativeSystemInfo(systemInfo *SystemInfo) {
	syscall.Syscall(procGetNativeSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(systemInfo)), 0, 0)
	return
}

func _IsWow64Process(hProcess HANDLE, Wow64Process PBOOL) (ret BOOL) {
	r0, _, _ := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(hProcess), uintptr(Wow64Process), 0)
	ret = BOOL(r0)
	return
}

func OpenProcess(dwDesiredAccess DWORD, bInheritHandle BOOL, dwProcessId DWORD) (handle HANDLE) {
	r0, _, _ := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(dwDesiredAccess), uintptr(bInheritHandle), uintptr(dwProcessId))
	handle = HANDLE(r0)
	return
}

func _ReadProcessMemory(hProcess HANDLE, lpBaseAddress LPCVOID, lpBuffer LPVOID, nSize SIZE_T, lpNumberOfBytesRead *SIZE_T) (ret BOOL) {
	r0, _, _ := syscall.Syscall6(procReadProcessMemory.Addr(), 5, uintptr(hProcess), uintptr(lpBaseAddress), uintptr(lpBuffer), uintptr(nSize), uintptr(unsafe.Pointer(lpNumberOfBytesRead)), 0)
	ret = BOOL(r0)
	return
}

func _VirtualQueryEx(hProcess HANDLE, lpAddress LPCVOID, lpBuffer uintptr, dwLength SIZE_T) (size SIZE_T) {
	r0, _, _ := syscall.Syscall6(procVirtualQueryEx.Addr(), 4, uintptr(hProcess), uintptr(lpAddress), uintptr(lpBuffer), uintptr(dwLength), 0, 0)
	size = SIZE_T(r0)
	return
}

func _NtQueryInformationProcess(ProcessHandle HANDLE, ProcessInformationClass ProcessInfoClass, ProcessInformation LPVOID, ProcessInformationLength ULONG, ReturnLength PULONG) (status NTSTATUS) {
	r0, _, _ := syscall.Syscall6(procNtQueryInformationProcess.Addr(), 5, uintptr(ProcessHandle), uintptr(ProcessInformationClass), uintptr(ProcessInformation), uintptr(ProcessInformationLength), uintptr(ReturnLength), 0)
	status = NTSTATUS(r0)
	return
}

func _NtQueryVirtualMemory(hProcess HANDLE, BaseAddress LPCVOID, MemoryInformationClass MEMORY_INFORMATION_CLASS, MemoryInformation PVOID, MemoryInformationLength SIZE_T, ReturnLength *SIZE_T) (status NTSTATUS) {
	r0, _, _ := syscall.Syscall6(procNtQueryVirtualMemory.Addr(), 6, uintptr(hProcess), uintptr(BaseAddress), uintptr(MemoryInformationClass), uintptr(MemoryInformation), uintptr(MemoryInformationLength), uintptr(unsafe.Pointer(ReturnLength)))
	status = NTSTATUS(r0)
	return
}

func _NtReadVirtualMemory(hProcess HANDLE, BaseAddress PVOID, Buffer PVOID, BufferLength ULONG, ReturnLength PULONG) (status NTSTATUS) {
	r0, _, _ := syscall.Syscall6(procNtReadVirtualMemory.Addr(), 5, uintptr(hProcess), uintptr(BaseAddress), uintptr(Buffer), uintptr(BufferLength), uintptr(ReturnLength), 0)
	status = NTSTATUS(r0)
	return
}
