1 ##########################################################################
3 # Copyright 2008-2009 VMware, Inc.
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 ##########################################################################/
26 """Win32 API type description."""
32 SHORT = Alias("SHORT", Short)
33 USHORT = Alias("USHORT", UShort)
34 INT = Alias("INT", Int)
35 UINT = Alias("UINT", UInt)
36 LONG = Alias("LONG", Long)
37 ULONG = Alias("ULONG", ULong)
38 LONGLONG = Alias("LONGLONG", LongLong)
39 FLOAT = Alias("FLOAT", Float)
41 INT8 = Alias("INT8", Int8)
42 UINT8 = Alias("UINT8", UInt8)
43 INT16 = Alias("INT16", Int16)
44 UINT16 = Alias("UINT16", UInt16)
45 INT32 = Alias("INT32", Int32)
46 UINT32 = Alias("UINT32", UInt32)
47 INT64 = Alias("INT64", Int64)
48 UINT64 = Alias("UINT64", UInt64)
50 BYTE = Alias("BYTE", UInt8)
51 WORD = Alias("WORD", UInt16)
52 DWORD = Alias("DWORD", UInt32)
54 UCHAR = Alias("UCHAR", UChar)
55 WCHAR = Alias("WCHAR", Short)
62 LPLONG = Pointer(LONG)
63 LPWORD = Pointer(WORD)
64 LPDWORD = Pointer(DWORD)
65 LPBOOL = Pointer(BOOL)
70 LPCWSTR = ConstWString
72 LARGE_INTEGER = Struct("LARGE_INTEGER", [
73 (LONGLONG, 'QuadPart'),
76 SIZE_T = Alias("SIZE_T", SizeT)
79 PVOID = OpaquePointer(VOID)
81 LPCVOID = OpaquePointer(Const(VOID))
83 def DECLARE_HANDLE(expr):
84 return Handle(expr, IntPointer(expr))
86 HANDLE = DECLARE_HANDLE("HANDLE")
87 HWND = DECLARE_HANDLE("HWND")
88 HDC = DECLARE_HANDLE("HDC")
89 HMONITOR = DECLARE_HANDLE("HMONITOR")
91 GUID = Struct("GUID", [
95 (Array(BYTE, 8), "Data4"),
97 LPGUID = Pointer(GUID)
99 REFGUID = Alias("REFGUID", Reference(GUID))
101 IID = Alias("IID", GUID)
102 REFIID = Alias("REFIID", Reference(IID))
104 CLSID = Alias("CLSID", GUID)
105 REFCLSID = Alias("REFCLSID", Reference(CLSID))
107 LUID = Struct("LUID", [
112 POINT = Struct("POINT", (
116 LPPOINT = Pointer(POINT)
118 SIZE = Struct("SIZE", (
122 LPSIZE = Pointer(SIZE)
124 RECT = Struct("RECT", (
130 LPRECT = Pointer(RECT)
132 PALETTEENTRY = Struct("PALETTEENTRY", (
138 LPPALETTEENTRY = Pointer(PALETTEENTRY)
141 RGNDATAHEADER = Struct("RGNDATAHEADER", [
149 RGNDATA = Struct("RGNDATA", [
150 (RGNDATAHEADER, "rdh"),
151 #(Char, "Buffer[1]"),
153 LPRGNDATA = Pointer(RGNDATA)
155 HMODULE = IntPointer("HMODULE")
157 FILETIME = Struct("FILETIME", [
158 (DWORD, "dwLowDateTime"),
159 (DWORD, "dwHighDateTime"),
162 COLORREF = Alias("COLORREF", DWORD)
164 LOGFONTW = Struct("LOGFONTW", [
167 (LONG, "lfEscapement"),
168 (LONG, "lfOrientation"),
171 (BYTE, "lfUnderline"),
172 (BYTE, "lfStrikeOut"),
174 (BYTE, "lfOutPrecision"),
175 (BYTE, "lfClipPrecision"),
177 (BYTE, "lfPitchAndFamily"),
178 (WString, "lfFaceName"),
181 SECURITY_ATTRIBUTES = Struct("SECURITY_ATTRIBUTES", [
183 (LPVOID, "lpSecurityDescriptor"),
184 (BOOL, "bInheritHandle"),
187 # http://msdn.microsoft.com/en-us/library/ff485842.aspx
188 # http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381.aspx
189 def MAKE_HRESULT(errors, ok = "S_OK", false = "S_FALSE"):
191 values.extend(errors)
193 "E_PENDING", # 0x8000000A
194 "E_NOTIMPL", # 0x80004001
195 "E_NOINTERFACE", # 0x80004002
196 "E_POINTER", # 0x80004003
197 "E_ABORT", # 0x80004004
198 "E_FAIL", # 0x80004005
199 "E_UNEXPECTED", # 0x8000FFFF
200 "E_ACCESSDENIED", # 0x80070005
201 "E_HANDLE", # 0x80070006
202 "E_OUTOFMEMORY", # 0x8007000E
203 "E_INVALIDARG", # 0x80070057
205 return Enum("HRESULT", values)
207 HRESULT = MAKE_HRESULT([])
210 IUnknown = Interface("IUnknown")
213 StdMethod(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
214 StdMethod(ULONG, "AddRef", ()),
215 StdMethod(ULONG, "Release", ()),