_WinBase.dcl 6.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
definition module System._WinBase

import System._WinDef, StdInt

/*
 * Record definitions, size and field offsets
 */

INT_SIZE :== IF_INT_64_OR_32 8 4

:: FILETIME :== {#Char}
FILETIME_size_bytes :== 8//FILETIME_size_int * INT_SIZE
FILETIME_size_int :== 2

:: LPSYSTEMTIME :== {#Char}
SYSTEMTIME_size_bytes			:== 16//4 * INT_SIZE//16
SYSTEMTIME_wYear_offset			:== 0
SYSTEMTIME_wMonth_offset		:== 2
SYSTEMTIME_wDayOfWeek_offset	:== 4
SYSTEMTIME_wDay_offset			:== 6
SYSTEMTIME_wHour_offset			:== 8
SYSTEMTIME_wMinute_offset		:== 10
SYSTEMTIME_wSecond_offset		:== 12
SYSTEMTIME_wMilliseconds_offset	:== 14

:: LPSECURITY_ATTRIBUTES :== Int
27
:: SECURITY_ATTRIBUTES   :== {#Int}
28 29 30 31 32 33 34 35 36 37 38
:: LPTHREAD_START_ROUTINE :==Int
:: LPOVERLAPPED :== Int
OVERLAPPED_SIZE_BYTES		:== IF_INT_64_OR_32 40 20
CRITICAL_SECTION_SIZE_BYTES	:== IF_INT_64_OR_32 48 24
:: LPCRITICAL_SECTION :== Int

:: LPSTARTUPINFO :== {#Int}
STARTUPINFO_size_bytes :== 68
STARTUPINFO_size_int :== 17
STARTUPINFO_cb_int_offset :== 0
STARTUPINFO_dwFlags_int_offset :== 11
39 40
STARTUPINFO_hStdInput_int_offset :== 14
STARTUPINFO_hStdOutput_int_offset :== 15
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
STARTUPINFO_hStdError_int_offset :== 16

:: LPWIN32_FIND_DATA :== {#Char}
WIN32_FIND_DATA_size_bytes :== 320
WIN32_FIND_DATA_dwFileAttributes_bytes_offset :== 0
WIN32_FIND_DATA_ftCreationTime_bytes_offset :== 4
WIN32_FIND_DATA_ftLastAccessTime_bytes_offset :== 12
WIN32_FIND_DATA_ftLastWriteTime_bytes_offset :== 20
WIN32_FIND_DATA_nFileSizeHigh_bytes_offset :==28 
WIN32_FIND_DATA_nFileSizeLow_bytes_offset :== 32
WIN32_FIND_DATA_cFileName_bytes_offset :== 44

FILE_ATTRIBUTE_DIRECTORY :== 16

:: LPPROCESS_INFORMATION :== {#Int}
PROCESS_INFORMATION_size_bytes :== 32
PROCESS_INFORMATION_size_int :== 4
PROCESS_INFORMATION_hProcess_int_offset :== 0
PROCESS_INFORMATION_hThread_int_offset :== 1

61 62
SECURITY_ATTRIBUTES_SIZE_BYTES							:== INT_SIZE * SECURITY_ATTRIBUTES_SIZE_INT
SECURITY_ATTRIBUTES_SIZE_INT                            :== 3
63
SECURITY_ATTRIBUTES_nLength_BYTES_OFFSET				:== 0
64
SECURITY_ATTRIBUTES_nLength_INT_OFFSET				    :== 0
65 66
SECURITY_ATTRIBUTES_lpSecurityDescriptor_BYTES_OFFSET	:== INT_SIZE
SECURITY_ATTRIBUTES_bInheritHandle_BYTES_OFFSET			:== INT_SIZE * 2
67
SECURITY_ATTRIBUTES_bInheritHandle_INT_OFFSET			:== 2
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

/*
 * Macros
 */

DETACHED_PROCESS :== 8
FORMAT_MESSAGE_ALLOCATE_BUFFER :== 0x00000100
FORMAT_MESSAGE_FROM_SYSTEM :== 0x00001000
FORMAT_MESSAGE_IGNORE_INSERTS :== 0x00000200
INFINITE :== 0xFFFFFFFF
LANGUAGE_NEUTRAL_SUBLANG_DEFAULT :== 0x400
STARTF_USESTDHANDLES :== 0x00000100
STATUS_PENDING :== 0x00000103
STILL_ACTIVE :== STATUS_PENDING
WAIT_ABANDONED_0 :== 0x80
WAIT_FAILED :== 0xFFFFFFFF
WAIT_OBJECT_0 :== 0
WAIT_TIMEOUT :== 258

GENERIC_READ :== 0x80000000
GENERIC_WRITE :== 0x40000000
FILE_SHARE_READ :== 0x00000001
FILE_SHARE_WRITE :== 0x00000002

CREATE_ALWAYS		:== 2
CREATE_NEW			:== 1
OPEN_ALWAYS			:== 4
OPEN_EXISTING		:== 3
TRUNCATE_EXISTING	:== 5

FILE_ATTRIBUTE_NORMAL :== 128
LOCKFILE_EXCLUSIVE_LOCK :== 0x00000002

HEAP_ZERO_MEMORY :== 0x00000008
CREATE_SUSPENDED :== 0x00000004
SYNCHRONIZE :== 0x00100000

105 106
HANDLE_FLAG_INHERIT :== 0x00000001

107 108 109 110 111
/*
 * Windows API calls 
 */

closeHandle :: !HANDLE !*w -> (!Bool,!*w)
112
setHandleInformation :: !HANDLE !DWORD !DWORD !*w -> (!Bool, !*w)
113 114 115 116 117 118
	
createFileA :: !String !DWORD !DWORD !LPSECURITY_ATTRIBUTES 
	!DWORD !DWORD !HANDLE !*w -> (!HANDLE, !*w)
	
readFile :: !HANDLE !LPVOID !DWORD !LPDWORD !LPOVERLAPPED !*w -> (!Bool, !*w)

119
writeFile :: !HANDLE !String !DWORD !LPDWORD !LPOVERLAPPED !*w -> (!Bool, !*w)
120 121 122 123 124 125 126 127 128

setEndOfFile :: !HANDLE !*w -> (!Bool, !*w)

lockFileEx :: !HANDLE !DWORD !DWORD !DWORD !DWORD !LPOVERLAPPED !*w -> (!Bool, !*w)

unlockFile :: !HANDLE !DWORD !DWORD !DWORD !DWORD !*w -> (!Bool, !*w)

getFileSize :: !HANDLE !LPDWORD !*w -> (!DWORD, !*w)

129 130
getFullPathNameA :: !String !DWORD !String !LPTSTR !*w -> (!DWORD, !*w)

131 132 133 134 135 136 137 138
createDirectoryA :: !String !LPSECURITY_ATTRIBUTES !*w -> (!Bool, !*w)

createProcessA :: !String !String !LPSECURITY_ATTRIBUTES !LPSECURITY_ATTRIBUTES !Bool !Int !LPVOID
					!LPCTSTR !LPSTARTUPINFO !LPPROCESS_INFORMATION !*w -> (!Bool,!*w)

createProcessA_dir :: !String !String !LPSECURITY_ATTRIBUTES !LPSECURITY_ATTRIBUTES !Bool !Int !LPVOID
					!String !LPSTARTUPINFO !LPPROCESS_INFORMATION !*w -> (!Bool,!*w)

139 140
terminateProcess :: !HANDLE !Int !*w -> (!Bool, !*w)

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
deleteFileA :: !String !*w -> (!Int, !*w)

fileTimeToSystemTime :: !FILETIME !LPSYSTEMTIME !*w -> (!Bool, *w)

findClose :: !HANDLE !*w -> (!Bool, !*w)

findFirstFileA :: !String !LPWIN32_FIND_DATA !*w -> (!HANDLE, !*w)

findNextFileA :: !HANDLE !LPWIN32_FIND_DATA !*w -> (!Bool, !*w)

formatMessageA :: !DWORD !LPCVOID !DWORD !DWORD !{#LPTSTR} !DWORD !Int -> DWORD

getCurrentDirectoryA :: !DWORD !{#Char} !*w -> (!DWORD, *w)

getExitCodeProcess :: !HANDLE !*w -> (!Bool,!Int,!*w);


getLastError :: !*w -> (!Int, !*w)

localFree :: !HLOCAL -> HLOCAL

moveFileA :: !String !String !*w -> (!Bool, !*w)

removeDirectoryA :: !String !*w -> (!Bool, !*w)

setCurrentDirectoryA :: !String !*w -> (!Bool, !*w)

waitForSingleObject :: !HANDLE !Int !*env -> (!Int,!*env)

getProcessHeap :: !*env -> (!HANDLE, !*env)

heapAlloc :: !HANDLE !DWORD !SIZE_T !*env -> (!LPVOID, !*env)
heapFree :: !HANDLE !DWORD !LPVOID !*env -> (!Bool, !*env)
heapCreate :: !DWORD !SIZE_T !SIZE_T !*w -> (!HANDLE, !*w)

CreateThread :: !LPSECURITY_ATTRIBUTES !SIZE_T !LPTHREAD_START_ROUTINE !LPVOID !DWORD !*w -> (!HANDLE,!DWORD,!*w)
ResumeThread :: !HANDLE !*w -> (!DWORD, *w)

initializeCriticalSection :: !LPCRITICAL_SECTION !*w -> *w
initializeCriticalSectionAndSpinCount :: !LPCRITICAL_SECTION !DWORD !*w -> (!Bool, !*w)
enterCriticalSection :: !LPCRITICAL_SECTION !*w -> *w
leaveCriticalSection :: !LPCRITICAL_SECTION !*w -> *w

createMutexA :: !LPSECURITY_ATTRIBUTES !Bool !LPCTSTR !*env -> (!HANDLE, !*env)
releaseMutex :: !HANDLE !*env -> (!Bool, !*env)
createEventA :: !LPSECURITY_ATTRIBUTES !Bool !Bool !LPCTSTR !*w -> (!HANDLE, !*w)
setEvent :: !HANDLE !*env -> (!Bool, !*env)

WinGetThreadId :: !HANDLE !*w -> (!DWORD, !*w)
WinGetCurrentThreadId :: !*w -> (!DWORD, !*w)
WinOpenThread :: !DWORD !Bool !DWORD *w -> (!DWORD, !*w)

sleep :: !DWORD !*w -> *w
194 195 196

createPipe :: !PHANDLE !PHANDLE !SECURITY_ATTRIBUTES !DWORD !*w -> (!Bool, !*w)
peekNamedPipe :: !HANDLE !LPVOID !DWORD !LPDWORD !LPDWORD !LPDWORD !*w -> (!Bool, !*w)
197 198

GetSystemTimeAsFileTime :: !{#Int} !*World -> (!{#Int},!*World)