package win32api

import "syscall"

type Ulong int32
type Ulong_ptr uintptr

const (
	LOCKFILE_EXCLUSIVE_LOCK   DWORD = 0x00000002
	LOCKFILE_FAIL_IMMEDIATELY DWORD = 0x00000001
)

type PROCESSENTRY32 struct {
	DwSize              Ulong
	CntUsage            Ulong
	Th32ProcessID       Ulong
	Th32DefaultHeapID   Ulong_ptr
	Th32ModuleID        Ulong
	CntThreads          Ulong
	Th32ParentProcessID Ulong
	PcPriClassBase      Ulong
	DwFlags             Ulong
	SzExeFile           [260]byte
}

type MEMORYSTATUSEX struct {
	DwLength                DWORD
	DwMemoryLoad            DWORD
	UllTotalPhys            DWORDLONG
	UllAvailPhys            DWORDLONG
	UllTotalPageFile        DWORDLONG
	UllAvailPageFile        DWORDLONG
	UllTotalVirtual         DWORDLONG
	UllAvailVirtual         DWORDLONG
	UllAvailExtendedVirtual DWORDLONG
}

type USN_JOURNAL_DATA struct {
	UsnJournalID    DWORDLONG
	FirstUsn        USN
	NextUsn         USN
	LowestValidUsn  USN
	MaxUsn          USN
	MaximumSize     DWORDLONG
	AllocationDelta DWORDLONG
}

type READ_USN_JOURNAL_DATA struct {
	StartUsn          USN
	ReasonMask        DWORD
	ReturnOnlyOnClose DWORD
	Timeout           DWORDLONG
	BytesToWaitFor    DWORDLONG
	UsnJournalID      DWORDLONG
}

type USN_RECORD struct {
	RecordLength              DWORD
	MajorVersion              WORD
	MinorVersion              WORD
	FileReferenceNumber       DWORDLONG
	ParentFileReferenceNumber DWORDLONG
	Usn                       USN
	TimeStamp                 LARGE_INTEGER
	Reason                    DWORD
	SourceInfo                DWORD
	SecurityId                DWORD
	FileAttributes            DWORD
	FileNameLength            WORD
	FileNameOffset            WORD
	FileName                  [1]WCHAR
}

type MFT_ENUM_DATA struct {
	StartFileReferenceNumber DWORDLONG
	LowUsn                   USN
	HighUsn                  USN
}

const (
	FSCTL_ENUM_USN_DATA        = 0x900B3
	FSCTL_QUERY_USN_JOURNAL    = 0x900F4
	FSCTL_READ_USN_JOURNAL     = 0x900BB
	O_RDONLY                   = syscall.O_RDONLY
	O_RDWR                     = syscall.O_RDWR
	O_CREAT                    = syscall.O_CREAT
	O_WRONLY                   = syscall.O_WRONLY
	GENERIC_READ               = syscall.GENERIC_READ
	GENERIC_WRITE              = syscall.GENERIC_WRITE
	FILE_APPEND_DATA           = syscall.FILE_APPEND_DATA
	FILE_SHARE_READ            = syscall.FILE_SHARE_READ
	FILE_SHARE_WRITE           = syscall.FILE_SHARE_WRITE
	ERROR_FILE_NOT_FOUND       = syscall.ERROR_FILE_NOT_FOUND
	O_APPEND                   = syscall.O_APPEND
	O_CLOEXEC                  = syscall.O_CLOEXEC
	O_EXCL                     = syscall.O_EXCL
	O_TRUNC                    = syscall.O_TRUNC
	CREATE_ALWAYS              = syscall.CREATE_ALWAYS
	CREATE_NEW                 = syscall.CREATE_NEW
	OPEN_ALWAYS                = syscall.OPEN_ALWAYS
	TRUNCATE_EXISTING          = syscall.TRUNCATE_EXISTING
	OPEN_EXISTING              = syscall.OPEN_EXISTING
	FILE_ATTRIBUTE_NORMAL      = syscall.FILE_ATTRIBUTE_NORMAL
	FILE_FLAG_BACKUP_SEMANTICS = syscall.FILE_FLAG_BACKUP_SEMANTICS
	FILE_ATTRIBUTE_DIRECTORY   = syscall.FILE_ATTRIBUTE_DIRECTORY
	MAX_LONG_PATH              = syscall.MAX_LONG_PATH
)

type FILE_ID_DESCRIPTOR struct {
	DwSize         DWORD
	Type           DWORD
	FileId         DWORDLONG
	ObjectId       DWORDLONG
	ExtendedFileId DWORDLONG
}
