From 412b6b5bf82c6c74e0d4dd3f914ac9616a2b9366 Mon Sep 17 00:00:00 2001 From: Daniel Doubrovkine Date: Fri, 7 Sep 2012 12:24:14 -0400 Subject: [PATCH] Added field order in Win32 APIs, fixed Windows JNA tests. --- .../com/sun/jna/platform/win32/DsGetDC.java | 8 + .../src/com/sun/jna/platform/win32/Guid.java | 2 + .../com/sun/jna/platform/win32/LMAccess.java | 24 +- .../com/sun/jna/platform/win32/NTSecApi.java | 18 +- .../com/sun/jna/platform/win32/Netapi32.java | 1 - .../com/sun/jna/platform/win32/SetupApi.java | 4 + .../com/sun/jna/platform/win32/ShellAPI.java | 2 + .../src/com/sun/jna/platform/win32/Sspi.java | 14 + .../com/sun/jna/platform/win32/Tlhelp32.java | 2 + .../com/sun/jna/platform/win32/VerRsrc.java | 2 + .../src/com/sun/jna/platform/win32/Wdm.java | 4 + .../com/sun/jna/platform/win32/WinBase.java | 20 +- .../com/sun/jna/platform/win32/WinCrypt.java | 4 + .../com/sun/jna/platform/win32/WinDef.java | 2 + .../com/sun/jna/platform/win32/WinGDI.java | 11 + .../src/com/sun/jna/platform/win32/WinNT.java | 2127 +++++++++-------- .../com/sun/jna/platform/win32/WinUser.java | 26 + .../com/sun/jna/platform/win32/Winioctl.java | 3 + .../com/sun/jna/platform/win32/Winspool.java | 6 +- .../com/sun/jna/platform/win32/Winsvc.java | 4 + .../jna/platform/win32/Advapi32UtilTest.java | 4 +- .../sun/jna/platform/win32/Netapi32Test.java | 12 +- src/com/sun/jna/Structure.java | 7 +- test/com/sun/jna/win32/W32APIMapperTest.java | 2 + test/com/sun/jna/win32/W32StdCallTest.java | 2 + 25 files changed, 1257 insertions(+), 1054 deletions(-) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java index 0abfe5a582..15ab892ae2 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java @@ -100,6 +100,8 @@ public DOMAIN_CONTROLLER_INFO(Pointer memory) { * subnet that the computer is in with a valid site. */ public WString ClientSiteName; + + { setFieldOrder(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName" }); } } /** @@ -112,6 +114,8 @@ public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Struc } public DOMAIN_CONTROLLER_INFO.ByReference dci; + + { setFieldOrder(new String[] { "dci" }); } } /** @@ -195,6 +199,8 @@ public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.By */ public GUID DomainGuid; + { setFieldOrder(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" }); } + public DS_DOMAIN_TRUSTS() { } @@ -212,6 +218,8 @@ public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.B } public DS_DOMAIN_TRUSTS.ByReference t; + + { setFieldOrder(new String[] { "t" }); } /** * Returns domain trusts. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Guid.java b/contrib/platform/src/com/sun/jna/platform/win32/Guid.java index 39b3c7db80..393359f312 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Guid.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Guid.java @@ -89,5 +89,7 @@ public GUID(byte[] data) { public short Data2; public short Data3; public byte[] Data4 = new byte[8]; + + { setFieldOrder(new String[] { "Data1", "Data2", "Data3", "Data4" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java index c7d3ce0998..c76220ca6e 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java @@ -36,6 +36,8 @@ public LOCALGROUP_INFO_0(Pointer memory) { } public WString lgrui0_name; + + { setFieldOrder(new String[] { "lgrui0_name" }); } } public static class LOCALGROUP_INFO_1 extends Structure { @@ -50,6 +52,8 @@ public LOCALGROUP_INFO_1(Pointer memory) { public WString lgrui1_name; public WString lgrui1_comment; + + { setFieldOrder(new String[] { "lgrui1_name", "lgrui1_comment" }); } } // @@ -80,6 +84,8 @@ public USER_INFO_0(Pointer memory) { * Pointer to a Unicode string that specifies the name of the user account. */ public WString usri0_name; + + { setFieldOrder(new String[] { "usri0_name" }); } } /** @@ -136,6 +142,8 @@ public USER_INFO_1(Pointer memory) { * logon script file. */ public WString usri1_script_path; + + { setFieldOrder(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" }); } } /** @@ -206,7 +214,9 @@ public USER_INFO_23(Pointer memory) { * A pointer to a SID structure that contains the security identifier (SID) * that uniquely identifies the user. The NetUserAdd and NetUserSetInfo functions ignore this member. */ - public PSID.ByReference usri23_user_sid; + public PSID.ByReference usri23_user_sid; + + { setFieldOrder(new String[] { "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid" }); } } /** @@ -226,6 +236,8 @@ public GROUP_USERS_INFO_0(Pointer memory) { * Pointer to a null-terminated Unicode character string that specifies a name. */ public WString grui0_name; + + { setFieldOrder(new String[] { "grui0_name" }); } } /** @@ -245,6 +257,8 @@ public LOCALGROUP_USERS_INFO_0(Pointer memory) { * Pointer to a Unicode string specifying the name of a local group to which the user belongs. */ public WString lgrui0_name; + + { setFieldOrder(new String[] { "lgrui0_name" }); } } /** @@ -267,6 +281,8 @@ public GROUP_INFO_0(Pointer memory) { * the name of the global group. */ public WString grpi0_name; + + { setFieldOrder(new String[] { "grpi0_name" }); } } /** @@ -294,6 +310,8 @@ public GROUP_INFO_1(Pointer memory) { * string. The comment can contain MAXCOMMENTSZ characters. */ public WString grpi1_comment; + + { setFieldOrder(new String[] { "grpi1_name", "grpi1_comment" }); } } /** @@ -331,6 +349,8 @@ public GROUP_INFO_2(Pointer memory) { * and SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi2_attributes; + + { setFieldOrder(new String[] { "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes" }); } } /** @@ -368,6 +388,8 @@ public GROUP_INFO_3(Pointer memory) { * SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi3_attributes; + + { setFieldOrder(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid" }); } } // diff --git a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java index 0178ec8281..8f27553c7e 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java @@ -52,6 +52,8 @@ public static class ByReference extends LSA_UNICODE_STRING implements Structure. */ public Pointer Buffer; + { setFieldOrder(new String[] { "Length", "MaximumLength", "Buffer" }); } + /** * String representation of the buffer. * @return @@ -97,11 +99,15 @@ public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure { public PSID.ByReference Sid; public LSA_UNICODE_STRING DnsName; public LSA_UNICODE_STRING NetbiosName; + + { setFieldOrder(new String[] { "Sid", "DnsName", "NetbiosName" }); } } public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure { public int Length; public Pointer Buffer; + + { setFieldOrder(new String[] { "Length", "Buffer" }); } } public static class LSA_FOREST_TRUST_RECORD extends Structure { @@ -144,7 +150,9 @@ public static class ByReference extends UNION implements Structure.ByReference * Data type depending on ForestTrustType. */ public UNION u; - + + { setFieldOrder(new String[] { "Flags", "ForestTrustType", "Time", "u" }); } + public void read() { super.read(); @@ -171,6 +179,8 @@ public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Stru } public LSA_FOREST_TRUST_RECORD.ByReference tr; + + { setFieldOrder(new String[] { "tr" }); } } public static class LSA_FOREST_TRUST_INFORMATION extends Structure { @@ -198,6 +208,8 @@ public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements public PLSA_FOREST_TRUST_RECORD[] getEntries() { return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount); } + + { setFieldOrder(new String[] { "RecordCount" }); } } /** * The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority @@ -209,6 +221,8 @@ public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements } - public LSA_FOREST_TRUST_INFORMATION.ByReference fti; + public LSA_FOREST_TRUST_INFORMATION.ByReference fti; + + { setFieldOrder(new String[] { "fti" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java b/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java index 67c90c9ecd..4ea9cd0122 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java @@ -16,7 +16,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; -import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; import com.sun.jna.ptr.IntByReference; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java b/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java index 59e5e3b6da..06edd25eb8 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java @@ -282,6 +282,8 @@ public SP_DEVICE_INTERFACE_DATA(Pointer memory) { * Reserved. Do not use. */ public Pointer Reserved; + + { setFieldOrder(new String[] { "cbSize", "InterfaceClassGuid", "Flags", "Reserved" }); } } /** @@ -330,5 +332,7 @@ public SP_DEVINFO_DATA(Pointer memory) { * Reserved. For internal use only. */ public Pointer Reserved; + + { setFieldOrder(new String[] { "cbSize", "InterfaceClassGuid", "DevInst", "Reserved" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java index 8f49c3f56d..65fb6628b0 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java @@ -108,5 +108,7 @@ public String encodePaths(String[] paths) { } return encoded + "\0"; } + + { setFieldOrder(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java index e30c7fef99..0fa4224ca9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java @@ -136,6 +136,8 @@ public interface Sspi extends StdCallLibrary { public static class SecHandle extends Structure { public Pointer dwLower; public Pointer dwUpper; + + { setFieldOrder(new String[] { "dwLower", "dwUpper" }); } public static class ByReference extends SecHandle implements Structure.ByReference { @@ -172,6 +174,8 @@ public static class ByReference extends PSecHandle implements Structure.ByRefere * The first entry in an array of SecPkgInfo structures. */ public SecHandle.ByReference secHandle; + + { setFieldOrder(new String[] { "secHandle" }); } public PSecHandle() { @@ -251,6 +255,8 @@ public byte[] getBytes() { */ public Pointer pvBuffer; + { setFieldOrder(new String[] { "cbBuffer", "BufferType", "pvBuffer" }); } + /** * Create a new SECBUFFER_EMPTY buffer. */ @@ -314,6 +320,8 @@ public static class SecBufferDesc extends Structure { */ public SecBuffer.ByReference[] pBuffers; + { setFieldOrder(new String[] { "ulVersion", "cBuffers", "pBuffers" }); } + /** * Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer. */ @@ -378,6 +386,8 @@ public SECURITY_INTEGER() { dwLower = 0; dwUpper = 0; } + + { setFieldOrder(new String[] { "dwLower", "dwUpper" }); } } /** @@ -411,6 +421,8 @@ public PSecPkgInfo() { public SecPkgInfo.ByReference[] toArray(int size) { return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size); } + + { setFieldOrder(new String[] { "poPkgInfo" }); } } /** @@ -462,5 +474,7 @@ public SecPkgInfo() { wRPCID = 0; cbMaxToken = 0; } + + { setFieldOrder(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java index d0f8aec57f..88f5fa76d5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java @@ -135,5 +135,7 @@ public PROCESSENTRY32(Pointer memory) { * retrieve the full path of the executable file for a 64-bit process. */ public char[] szExeFile = new char[WinDef.MAX_PATH]; + + { setFieldOrder(new String[] { "dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java index d442ceb8ec..825af04242 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java @@ -113,5 +113,7 @@ public VS_FIXEDFILEINFO(Pointer memory) { * The least significant 32 bits of the file's 64-bit binary creation date and time stamp. */ public WinDef.DWORD dwFileDateLS; + + { setFieldOrder(new String[] { "dwSignature", "dwStrucVersion", "dwFileVersionMS", "dwFileVersionLS", "dwProductVersionMS", "dwProductVersionLS", "dwFileFlagsMask", "dwFileFlags", "dwFileOS", "dwFileType", "dwFileSubtype", "dwFileDateMS", "dwFileDateLS" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java index be6f45e927..a12e008bcb 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java @@ -62,6 +62,8 @@ public KEY_BASIC_INFORMATION(Pointer memory) { */ public char[] Name; /** + * Name of the key. + * Name of the key. * Name of the key. * @return String. */ @@ -74,6 +76,8 @@ public void read() { Name = new char[NameLength / 2]; readField("Name"); } + + { setFieldOrder(new String[] { "LastWriteTime", "TitleIndex", "NameLength", "Name" }); } } /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java index 38c91e216f..1efe758957 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java @@ -169,7 +169,9 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD { */ public static class FILETIME extends Structure { public int dwLowDateTime; - public int dwHighDateTime; + public int dwHighDateTime; + + { setFieldOrder(new String[] { "dwLowDateTime", "dwHighDateTime" }); } public static class ByReference extends FILETIME implements Structure.ByReference { public ByReference() { @@ -292,6 +294,8 @@ public static class SYSTEMTIME extends Structure { public short wSecond; // The millisecond. The valid values for this member are 0 through 999. public short wMilliseconds; + + { setFieldOrder(new String[] { "wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds" }); } } /** @@ -380,6 +384,8 @@ public static class OVERLAPPED extends Structure { public int Offset; public int OffsetHigh; public HANDLE hEvent; + + { setFieldOrder(new String[] { "Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent" }); } } int INFINITE = 0xFFFFFFFF; @@ -412,6 +418,8 @@ public static class ByReference extends PI implements Structure.ByReference { * Reserved for future use. */ public WORD wReserved; + + { setFieldOrder(new String[] { "wProcessorArchitecture", "wReserved" }); } } /** Unnamed inner union. */ @@ -482,6 +490,8 @@ public static class ByReference extends UNION implements Structure.ByReference { * Architecture-dependent processor revision. */ public WORD wProcessorRevision; + + { setFieldOrder(new String[] { "processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision" }); } } /** @@ -534,6 +544,8 @@ public static class MEMORYSTATUSEX extends Structure { public MEMORYSTATUSEX() { dwLength = new DWORD(size()); } + + { setFieldOrder(new String[] { "dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual" }); } }; /** @@ -563,6 +575,8 @@ public static class SECURITY_ATTRIBUTES extends Structure { public SECURITY_ATTRIBUTES() { dwLength = new DWORD(size()); } + + { setFieldOrder(new String[] { "dwLength", "lpSecurityDescriptor", "bInheritHandle" }); } } /** @@ -735,6 +749,8 @@ public static class STARTUPINFO extends Structure { public STARTUPINFO() { cb = new DWORD(size()); } + + { setFieldOrder(new String[] { "cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError" }); } } /** @@ -774,6 +790,8 @@ public static class PROCESS_INFORMATION extends Structure { */ public DWORD dwThreadId; + { setFieldOrder(new String[] { "hProcess", "hThread", "dwProcessId", "dwThreadId" }); } + public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference { public ByReference() { } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java index 0c37d911c1..5a7545625c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java @@ -58,6 +58,8 @@ public DATA_BLOB(String s) { * A pointer to a block of data bytes. */ public Pointer pbData; + + { setFieldOrder(new String[] { "cbData", "pbData" }); } /** * Get byte data. @@ -100,6 +102,8 @@ public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) { * A string containing the text of a prompt to be displayed. */ public String szPrompt; + + { setFieldOrder(new String[] { "cbSize", "dwPromptFlags", "hwndApp", "szPrompt" }); } } // diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java index a9b78eea1c..45fcb2b847 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java @@ -323,6 +323,8 @@ public class RECT extends Structure { public int right; public int bottom; + { setFieldOrder(new String[] { "left", "top", "right", "bottom" }); } + public Rectangle toRectangle() { return new Rectangle(left, top, right-left, bottom-top); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java index 2f54d435b8..411b1098f9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java @@ -30,6 +30,8 @@ public class RGNDATAHEADER extends Structure { public int nCount; public int nRgnSize; public RECT rcBound; + + { setFieldOrder(new String[] { "dwSize", "iType", "nCount", "nRgnSize", "rcBound" }); } } public class RGNDATA extends Structure { @@ -39,6 +41,8 @@ public RGNDATA(int bufferSize) { Buffer = new byte[bufferSize]; allocateMemory(); } + + { setFieldOrder(new String[] { "rdh", "Buffer" }); } } public int RGN_AND = 1; @@ -63,6 +67,8 @@ public RGNDATA(int bufferSize) { public int BI_PNG = 5; public class BITMAPINFOHEADER extends Structure { + { setFieldOrder(new String[] { "biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant" }); } + public int biSize = size(); public int biWidth; public int biHeight; @@ -81,11 +87,16 @@ public class RGBQUAD extends Structure { public byte rgbGreen; public byte rgbRed; public byte rgbReserved = 0; + + { setFieldOrder(new String[] { "rgbBlue", "rgbGreen", "rgbRed", "rgbReserved" }); } } public class BITMAPINFO extends Structure { public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); public RGBQUAD[] bmiColors = new RGBQUAD[1]; + + { setFieldOrder(new String[] { "bmiHeader", "bmiColors" }); } + public BITMAPINFO() { this(1); } public BITMAPINFO(int size) { bmiColors = new RGBQUAD[size]; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java index ca05b8f970..e4bc667a3b 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java @@ -234,23 +234,25 @@ public abstract class TOKEN_TYPE { * The LUID_AND_ATTRIBUTES structure represents a locally unique identifier (LUID) and its attributes. */ public static class LUID_AND_ATTRIBUTES extends Structure { - /** - * Specifies an LUID value. - */ - public LUID Luid; - - /** - * Specifies attributes of the LUID. This value contains up to 32 one-bit flags. - * Its meaning is dependent on the definition and use of the LUID. - */ - public DWORD Attributes; - - public LUID_AND_ATTRIBUTES() {} - - public LUID_AND_ATTRIBUTES(LUID luid, DWORD attributes) { - this.Luid = luid; - this.Attributes = attributes; - } + /** + * Specifies an LUID value. + */ + public LUID Luid; + + /** + * Specifies attributes of the LUID. This value contains up to 32 one-bit flags. + * Its meaning is dependent on the definition and use of the LUID. + */ + public DWORD Attributes; + + public LUID_AND_ATTRIBUTES() {} + + public LUID_AND_ATTRIBUTES(LUID luid, DWORD attributes) { + this.Luid = luid; + this.Attributes = attributes; + } + + { setFieldOrder(new String[] { "Luid", "Attributes" }); } } /** @@ -258,24 +260,26 @@ public LUID_AND_ATTRIBUTES(LUID luid, DWORD attributes) { * attributes. SIDs are used to uniquely identify users or groups. */ public static class SID_AND_ATTRIBUTES extends Structure { - public SID_AND_ATTRIBUTES() { - super(); - } - - public SID_AND_ATTRIBUTES(Pointer memory) { - super(memory); - } - - /** - * Pointer to a SID structure. - */ - public PSID.ByReference Sid; - - /** - * Specifies attributes of the SID. This value contains up to 32 one-bit flags. - * Its meaning depends on the definition and use of the SID. - */ - public int Attributes; + public SID_AND_ATTRIBUTES() { + super(); + } + + public SID_AND_ATTRIBUTES(Pointer memory) { + super(memory); + } + + /** + * Pointer to a SID structure. + */ + public PSID.ByReference Sid; + + /** + * Specifies attributes of the SID. This value contains up to 32 one-bit flags. + * Its meaning depends on the definition and use of the SID. + */ + public int Attributes; + + { setFieldOrder(new String[] { "Sid", "Attributes" }); } } /** @@ -283,105 +287,114 @@ public SID_AND_ATTRIBUTES(Pointer memory) { * security identifier (SID) that will be applied to newly created objects. */ public static class TOKEN_OWNER extends Structure { - public TOKEN_OWNER() { - super(); - } - - public TOKEN_OWNER(int size) { - super(new Memory(size)); - } - - public TOKEN_OWNER(Pointer memory) { - super(memory); - read(); - } - - /** - * Pointer to a SID structure representing a user who will become the owner of any - * objects created by a process using this access token. The SID must be one of the - * user or group SIDs already in the token. - */ - public PSID.ByReference Owner; // PSID - } - - public static class PSID extends Structure { - public static class ByReference extends PSID implements Structure.ByReference { - } - - public PSID() { - super(); - } - - public PSID(byte[] data) { - super(new Memory(data.length)); - getPointer().write(0, data, 0, data.length); - read(); - } - - public PSID(int size) { - super(new Memory(size)); - } - - public PSID(Pointer memory) { - super(memory); - read(); - } - - public byte[] getBytes() { - int len = Advapi32.INSTANCE.GetLengthSid(this); - return getPointer().getByteArray(0, len); - } - - public Pointer sid; - } - - public static class PSIDByReference extends ByReference { - public PSIDByReference() { - this(null); - } - - public PSIDByReference(PSID h) { - super(Pointer.SIZE); - setValue(h); - } - - public void setValue(PSID h) { - getPointer().setPointer(0, h != null ? h.getPointer() : null); - } - - public PSID getValue() { - Pointer p = getPointer().getPointer(0); - if (p == null) { - return null; - } else { - return new PSID(p); - } - } + public TOKEN_OWNER() { + super(); + } + + public TOKEN_OWNER(int size) { + super(new Memory(size)); + } + + public TOKEN_OWNER(Pointer memory) { + super(memory); + read(); + } + + /** + * Pointer to a SID structure representing a user who will become the owner of any + * objects created by a process using this access token. The SID must be one of the + * user or group SIDs already in the token. + */ + public PSID.ByReference Owner; // PSID + + { setFieldOrder(new String[] { "Owner" }); } + } + + public static class PSID extends Structure { + + public static class ByReference extends PSID implements Structure.ByReference { + + } + + public PSID() { + super(); + } + + public PSID(byte[] data) { + super(new Memory(data.length)); + getPointer().write(0, data, 0, data.length); + read(); + } + + public PSID(int size) { + super(new Memory(size)); + } + + public PSID(Pointer memory) { + super(memory); + read(); + } + + public byte[] getBytes() { + int len = Advapi32.INSTANCE.GetLengthSid(this); + return getPointer().getByteArray(0, len); + } + + public Pointer sid; + + { setFieldOrder(new String[] { "sid" }); } + } + + public static class PSIDByReference extends ByReference { + + public PSIDByReference() { + this(null); + } + + public PSIDByReference(PSID h) { + super(Pointer.SIZE); + setValue(h); + } + + public void setValue(PSID h) { + getPointer().setPointer(0, h != null ? h.getPointer() : null); + } + + public PSID getValue() { + Pointer p = getPointer().getPointer(0); + if (p == null) { + return null; + } else { + return new PSID(p); + } + } } /** * The TOKEN_USER structure identifies the user associated with an access token. */ public static class TOKEN_USER extends Structure { - public TOKEN_USER() { - super(); - } - - public TOKEN_USER(Pointer memory) { - super(memory); - read(); - } + public TOKEN_USER() { + super(); + } + + public TOKEN_USER(Pointer memory) { + super(memory); + read(); + } + + public TOKEN_USER(int size) { + super(new Memory(size)); + } - public TOKEN_USER(int size) { - super(new Memory(size)); - } - - /** - * Specifies a SID_AND_ATTRIBUTES structure representing the user associated with - * the access token. There are currently no attributes defined for user security - * identifiers (SIDs). - */ - public SID_AND_ATTRIBUTES User; + /** + * Specifies a SID_AND_ATTRIBUTES structure representing the user associated with + * the access token. There are currently no attributes defined for user security + * identifiers (SIDs). + */ + public SID_AND_ATTRIBUTES User; + + { setFieldOrder(new String[] { "User" }); } } /** @@ -389,56 +402,60 @@ public TOKEN_USER(int size) { * (SIDs) in an access token. */ public static class TOKEN_GROUPS extends Structure { - public TOKEN_GROUPS() { - super(); - } - - public TOKEN_GROUPS(Pointer memory) { - super(memory); - read(); - } - - public TOKEN_GROUPS(int size) { - super(new Memory(size)); - } - - /** - * Specifies the number of groups in the access token. - */ - public int GroupCount; - public SID_AND_ATTRIBUTES Group0; + public TOKEN_GROUPS() { + super(); + } + + public TOKEN_GROUPS(Pointer memory) { + super(memory); + read(); + } + + public TOKEN_GROUPS(int size) { + super(new Memory(size)); + } - /** - * Specifies an array of SID_AND_ATTRIBUTES structures that contain a set of SIDs - * and corresponding attributes. - */ - public SID_AND_ATTRIBUTES[] getGroups() { - return (SID_AND_ATTRIBUTES[]) Group0.toArray(GroupCount); - } + /** + * Specifies the number of groups in the access token. + */ + public int GroupCount; + public SID_AND_ATTRIBUTES Group0; + + /** + * Specifies an array of SID_AND_ATTRIBUTES structures that contain a set of SIDs + * and corresponding attributes. + */ + public SID_AND_ATTRIBUTES[] getGroups() { + return (SID_AND_ATTRIBUTES[]) Group0.toArray(GroupCount); + } + + { setFieldOrder(new String[] { "GroupCount", "Group0" }); } } /** * The TOKEN_PRIVILEGES structure contains information about a set of privileges for an access token. */ public static class TOKEN_PRIVILEGES extends Structure { - /** - * This must be set to the number of entries in the Privileges array. - */ - public DWORD PrivilegeCount; - - /** - * Specifies an array of LUID_AND_ATTRIBUTES structures. - * Each structure contains the LUID and attributes of a privilege. - */ - public LUID_AND_ATTRIBUTES Privileges[]; - - /** - * @param nbOfPrivileges Desired size of the Privileges array - */ - public TOKEN_PRIVILEGES(int nbOfPrivileges) { - PrivilegeCount = new DWORD(nbOfPrivileges); - Privileges = new LUID_AND_ATTRIBUTES[nbOfPrivileges]; - } + /** + * This must be set to the number of entries in the Privileges array. + */ + public DWORD PrivilegeCount; + + /** + * Specifies an array of LUID_AND_ATTRIBUTES structures. + * Each structure contains the LUID and attributes of a privilege. + */ + public LUID_AND_ATTRIBUTES Privileges[]; + + /** + * @param nbOfPrivileges Desired size of the Privileges array + */ + public TOKEN_PRIVILEGES(int nbOfPrivileges) { + PrivilegeCount = new DWORD(nbOfPrivileges); + Privileges = new LUID_AND_ATTRIBUTES[nbOfPrivileges]; + } + + { setFieldOrder(new String[] { "PrivilegeCount", "Privileges" }); } } /** @@ -642,43 +659,46 @@ public abstract class SID_NAME_USE { * for input. */ public static class FILE_NOTIFY_INFORMATION extends Structure { - public int NextEntryOffset; - public int Action; - public int FileNameLength; - // filename is not nul-terminated, so we can't use a String/WString - public char[] FileName = new char[1]; - - private FILE_NOTIFY_INFORMATION() { - } - - public FILE_NOTIFY_INFORMATION(int size) { - if (size < size()) { - throw new IllegalArgumentException("Size must greater than " + size() + ", requested " + size); - } - allocateMemory(size); - } - - /** WARNING: this filename may be either the short or long form of the filename. */ - public String getFilename() { - return new String(FileName, 0, FileNameLength/2); - } - - public void read() { - // avoid reading filename until we know how long it is - FileName = new char[0]; - super.read(); - FileName = getPointer().getCharArray(12, FileNameLength/2); - } - - public FILE_NOTIFY_INFORMATION next() { - if (NextEntryOffset == 0) { - return null; - } - FILE_NOTIFY_INFORMATION next = new FILE_NOTIFY_INFORMATION(); - next.useMemory(getPointer(), NextEntryOffset); - next.read(); - return next; - } + public int NextEntryOffset; + public int Action; + public int FileNameLength; + // filename is not nul-terminated, so we can't use a String/WString + public char[] FileName = new char[1]; + + { setFieldOrder(new String[] { "NextEntryOffset", "Action", "FileNameLength", "FileName" }); } + + private FILE_NOTIFY_INFORMATION() { + + } + + public FILE_NOTIFY_INFORMATION(int size) { + if (size < size()) { + throw new IllegalArgumentException("Size must greater than " + size() + ", requested " + size); + } + allocateMemory(size); + } + + /** WARNING: this filename may be either the short or long form of the filename. */ + public String getFilename() { + return new String(FileName, 0, FileNameLength/2); + } + + public void read() { + // avoid reading filename until we know how long it is + FileName = new char[0]; + super.read(); + FileName = getPointer().getCharArray(12, FileNameLength/2); + } + + public FILE_NOTIFY_INFORMATION next() { + if (NextEntryOffset == 0) { + return null; + } + FILE_NOTIFY_INFORMATION next = new FILE_NOTIFY_INFORMATION(); + next.useMemory(getPointer(), NextEntryOffset); + next.read(); + return next; + } } /** @@ -929,118 +949,123 @@ public FILE_NOTIFY_INFORMATION next() { * that generated it until the system is restarted. */ public static class LUID extends Structure { - public int LowPart; - public int HighPart; + public int LowPart; + public int HighPart; + + { setFieldOrder(new String[] { "LowPart", "HighPart" }); } } /** * A 64-bit integer; */ public static class LARGE_INTEGER extends Structure { - public static class ByReference extends LARGE_INTEGER - implements Structure.ByReference { - } + public static class ByReference extends LARGE_INTEGER implements Structure.ByReference { + + } + + public static class LowHigh extends Structure { + public DWORD LowPart; + public DWORD HighPart; + { setFieldOrder(new String[] { "LowPart", "HighPart" }); } + } - public static class LowHigh extends Structure { - public DWORD LowPart; - public DWORD HighPart; - } - - public static class UNION extends Union { - public LowHigh lh; - public long value; - } - - public UNION u; - - /** - * Low DWORD. - * @return - * DWORD. - */ - public DWORD getLow() { - return u.lh.LowPart; - } - - /** - * High DWORD. - * @return - * DWORD. - */ - public DWORD getHigh() { - return u.lh.HighPart; - } - - /** - * 64-bit value. - * @return - * 64-bit value. - */ - public long getValue() { - return u.value; - } + public static class UNION extends Union { + public LowHigh lh; + public long value; + } + + public UNION u; + + { setFieldOrder(new String[] { "u" }); } + + /** + * Low DWORD. + * @return + * DWORD. + */ + public DWORD getLow() { + return u.lh.LowPart; + } + + /** + * High DWORD. + * @return + * DWORD. + */ + public DWORD getHigh() { + return u.lh.HighPart; + } + + /** + * 64-bit value. + * @return + * 64-bit value. + */ + public long getValue() { + return u.value; + } } /** * Handle to an object. */ public static class HANDLE extends PointerType { - private boolean immutable; - - public HANDLE() {} - - public HANDLE(Pointer p) { - setPointer(p); - immutable = true; - } - - /** Override to the appropriate object for INVALID_HANDLE_VALUE. */ - public Object fromNative(Object nativeValue, FromNativeContext context) { - Object o = super.fromNative(nativeValue, context); - if (WinBase.INVALID_HANDLE_VALUE.equals(o)) { - return WinBase.INVALID_HANDLE_VALUE; - } - return o; - } - - public void setPointer(Pointer p) { - if (immutable) { - throw new UnsupportedOperationException("immutable reference"); - } - - super.setPointer(p); - } + private boolean immutable; + + public HANDLE() {} + + public HANDLE(Pointer p) { + setPointer(p); + immutable = true; + } + + /** Override to the appropriate object for INVALID_HANDLE_VALUE. */ + public Object fromNative(Object nativeValue, FromNativeContext context) { + Object o = super.fromNative(nativeValue, context); + if (WinBase.INVALID_HANDLE_VALUE.equals(o)) { + return WinBase.INVALID_HANDLE_VALUE; + } + return o; + } + + public void setPointer(Pointer p) { + if (immutable) { + throw new UnsupportedOperationException("immutable reference"); + } + + super.setPointer(p); + } } /** * LPHANDLE */ public static class HANDLEByReference extends ByReference { - public HANDLEByReference() { - this(null); - } - - public HANDLEByReference(HANDLE h) { - super(Pointer.SIZE); - setValue(h); - } - - public void setValue(HANDLE h) { - getPointer().setPointer(0, h != null ? h.getPointer() : null); - } - - public HANDLE getValue() { - Pointer p = getPointer().getPointer(0); - if (p == null) { - return null; - } - if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p)) { - return WinBase.INVALID_HANDLE_VALUE; - } - HANDLE h = new HANDLE(); - h.setPointer(p); - return h; - } + public HANDLEByReference() { + this(null); + } + + public HANDLEByReference(HANDLE h) { + super(Pointer.SIZE); + setValue(h); + } + + public void setValue(HANDLE h) { + getPointer().setPointer(0, h != null ? h.getPointer() : null); + } + + public HANDLE getValue() { + Pointer p = getPointer().getPointer(0); + if (p == null) { + return null; + } + if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p)) { + return WinBase.INVALID_HANDLE_VALUE; + } + HANDLE h = new HANDLE(); + h.setPointer(p); + return h; + } } @@ -1049,12 +1074,12 @@ public HANDLE getValue() { * nonzero to represent an error code or status information. */ class HRESULT extends NativeLong { - public HRESULT() { - } - - public HRESULT(int value) { - super(value); - } + public HRESULT() { + } + + public HRESULT(int value) { + super(value); + } } /** @@ -1063,405 +1088,405 @@ public HRESULT(int value) { * from this list. */ public abstract class WELL_KNOWN_SID_TYPE { - /** - * Indicates a null SID. - */ - public static final int WinNullSid = 0; - - /** - * Indicates a SID that matches everyone. - */ - public static final int WinWorldSid = 1; - - /** - * Indicates a local SID. - */ - public static final int WinLocalSid = 2; - - /** - * Indicates a SID that matches the owner or creator of an object. - */ - public static final int WinCreatorOwnerSid = 3; - - /** - * Indicates a SID that matches the creator group of an object. - */ - public static final int WinCreatorGroupSid = 4; - - /** - * Indicates a creator owner server SID. - */ - public static final int WinCreatorOwnerServerSid = 5; - - /** - * Indicates a creator group server SID. - */ - public static final int WinCreatorGroupServerSid = 6; - - /** - * Indicates a SID for the Windows NT authority. - */ - public static final int WinNtAuthoritySid = 7; - - /** - * Indicates a SID for a dial-up account. - */ - public static final int WinDialupSid = 8; - - /** - * Indicates a SID for a network account. This SID is added to the process of a token - * when it logs on across a network. The corresponding logon type is - * LOGON32_LOGON_NETWORK. - */ - public static final int WinNetworkSid = 9; - - /** - * Indicates a SID for a batch process. This SID is added to the process of a token - * when it logs on as a batch job. The corresponding logon type is LOGON32_LOGON_BATCH. - */ - public static final int WinBatchSid = 10; - - /** - * Indicates a SID for an interactive account. This SID is added to the process of a - * token when it logs on interactively. The corresponding logon type is - * LOGON32_LOGON_INTERACTIVE. - */ - public static final int WinInteractiveSid = 11; - - /** - * Indicates a SID for a service. This SID is added to the process of a token when it - * logs on as a service. The corresponding logon type is LOGON32_LOGON_bSERVICE. - */ - public static final int WinServiceSid = 12; - - /** - * Indicates a SID for the anonymous account. - */ - public static final int WinAnonymousSid = 13; - - /** - * Indicates a proxy SID. - */ - public static final int WinProxySid = 14; - - /** - * Indicates a SID for an enterprise controller. - */ - public static final int WinEnterpriseControllersSid = 15; - - /** - * Indicates a SID for self. - */ - public static final int WinSelfSid = 16; - - /** - * Indicates a SID that matches any authenticated user. - */ - public static final int WinAuthenticatedUserSid = 17; - - /** - * Indicates a SID for restricted code. - */ - public static final int WinRestrictedCodeSid = 18; - - /** - * Indicates a SID that matches a terminal server account. - */ - public static final int WinTerminalServerSid = 19; - - /** - * Indicates a SID that matches remote logons. - */ - public static final int WinRemoteLogonIdSid = 20; - - /** - * Indicates a SID that matches logon IDs. - */ - public static final int WinLogonIdsSid = 21; - - /** - * Indicates a SID that matches the local system. - */ - public static final int WinLocalSystemSid = 22; - - /** - * Indicates a SID that matches a local service. - */ - public static final int WinLocalServiceSid = 23; - - /** - * Indicates a SID that matches a network service. - */ - public static final int WinNetworkServiceSid = 24; - - /** - * Indicates a SID that matches the domain account. - */ - public static final int WinBuiltinDomainSid = 25; - - /** - * Indicates a SID that matches the administrator account. - */ - public static final int WinBuiltinAdministratorsSid = 26; - - /** - * Indicates a SID that matches built-in user accounts. - */ - public static final int WinBuiltinUsersSid = 27; - - /** - * Indicates a SID that matches the guest account. - */ - public static final int WinBuiltinGuestsSid = 28; - - /** - * Indicates a SID that matches the power users group. - */ - public static final int WinBuiltinPowerUsersSid = 29; - - /** - * Indicates a SID that matches the account operators account. - */ - public static final int WinBuiltinAccountOperatorsSid = 30; - - /** - * Indicates a SID that matches the system operators group. - */ - public static final int WinBuiltinSystemOperatorsSid = 31; - - /** - * Indicates a SID that matches the print operators group. - */ - public static final int WinBuiltinPrintOperatorsSid = 32; - - /** - * Indicates a SID that matches the backup operators group. - */ - public static final int WinBuiltinBackupOperatorsSid = 33; - - /** - * Indicates a SID that matches the replicator account. - */ - public static final int WinBuiltinReplicatorSid = 34; - - /** - * Indicates a SID that matches pre-Windows 2000 compatible accounts. - */ - public static final int WinBuiltinPreWindows2000CompatibleAccessSid = 35; - - /** - * Indicates a SID that matches remote desktop users. - */ - public static final int WinBuiltinRemoteDesktopUsersSid = 36; - - /** - * Indicates a SID that matches the network operators group. - */ - public static final int WinBuiltinNetworkConfigurationOperatorsSid = 37; - - /** - * Indicates a SID that matches the account administrators group. - */ - public static final int WinAccountAdministratorSid = 38; - - /** - * Indicates a SID that matches the account guest group. - */ - public static final int WinAccountGuestSid = 39; - - /** - * Indicates a SID that matches account Kerberos target group. - */ - public static final int WinAccountKrbtgtSid = 40; - - /** - * Indicates a SID that matches the account domain administrator group. - */ - public static final int WinAccountDomainAdminsSid = 41; - - /** - * Indicates a SID that matches the account domain users group. - */ - public static final int WinAccountDomainUsersSid = 42; - - /** - * Indicates a SID that matches the account domain guests group. - */ - public static final int WinAccountDomainGuestsSid = 43; - - /** - * Indicates a SID that matches the account computer group. - */ - public static final int WinAccountComputersSid = 44; - - /** - * Indicates a SID that matches the account controller group. - */ - public static final int WinAccountControllersSid = 45; - - /** - * Indicates a SID that matches the certificate administrators group. - */ - public static final int WinAccountCertAdminsSid = 46; - - /** - * Indicates a SID that matches the schema administrators group. - */ - public static final int WinAccountSchemaAdminsSid = 47; - - /** - * Indicates a SID that matches the enterprise administrators group. - */ - public static final int WinAccountEnterpriseAdminsSid = 48; - - /** - * Indicates a SID that matches the policy administrators group. - */ - public static final int WinAccountPolicyAdminsSid = 49; - - /** - * Indicates a SID that matches the RAS and IAS server account. - */ - public static final int WinAccountRasAndIasServersSid = 50; - - /** - * Indicates a SID present when the Microsoft NTLM authentication package - * authenticated the client. - */ - public static final int WinNTLMAuthenticationSid = 51; - - /** - * Indicates a SID present when the Microsoft Digest authentication package - * authenticated the client. - */ - public static final int WinDigestAuthenticationSid = 52; - - /** - * Indicates a SID present when the Secure Channel (SSL/TLS) authentication - * package authenticated the client. - */ - public static final int WinSChannelAuthenticationSid = 53; - - /** - * Indicates a SID present when the user authenticated from within the forest - * or across a trust that does not have the selective authentication option - * enabled. If this SID is present, then WinOtherOrganizationSid cannot be present. - */ - public static final int WinThisOrganizationSid = 54; - - /** - * Indicates a SID present when the user authenticated across a forest with the - * selective authentication option enabled. If this SID is present, then - * WinThisOrganizationSid cannot be present. - */ - public static final int WinOtherOrganizationSid = 55; - - /** - * Indicates a SID that allows a user to create incoming forest trusts. It is added - * to the token of users who are a member of the Incoming Forest Trust Builders - * built-in group in the root domain of the forest. - */ - public static final int WinBuiltinIncomingForestTrustBuildersSid = 56; - - /** - * Indicates a SID that matches the performance monitor user group. - */ - public static final int WinBuiltinPerfMonitoringUsersSid = 57; - - /** - * Indicates a SID that matches the performance log user group. - */ - public static final int WinBuiltinPerfLoggingUsersSid = 58; - - /** - * Indicates a SID that matches the Windows Authorization Access group. - */ - public static final int WinBuiltinAuthorizationAccessSid = 59; - - /** - * Indicates a SID is present in a server that can issue Terminal Server licenses. - */ - public static final int WinBuiltinTerminalServerLicenseServersSid = 60; - - /** - * - */ - public static final int WinBuiltinDCOMUsersSid = 61; - - /** - * - */ - public static final int WinBuiltinIUsersSid = 62; - - /** - * - */ - public static final int WinIUserSid = 63; - - /** - * - */ - public static final int WinBuiltinCryptoOperatorsSid = 64; - - /** - * - */ - public static final int WinUntrustedLabelSid = 65; - - /** - * - */ - public static final int WinLowLabelSid = 66; - - /** - * - */ - public static final int WinMediumLabelSid = 67; - - /** - * - */ - public static final int WinHighLabelSid = 68; - - /** - * - */ - public static final int WinSystemLabelSid = 69; - - /** - * - */ - public static final int WinWriteRestrictedCodeSid = 70; - - /** - * - */ - public static final int WinCreatorOwnerRightsSid = 71; - - /** - * - */ - public static final int WinCacheablePrincipalsGroupSid = 72; - - /** - * - */ - public static final int WinNonCacheablePrincipalsGroupSid = 73; - - /** - * - */ - public static final int WinEnterpriseReadonlyControllersSid = 74; - - /** - * Indicates a SID that matches a read-only enterprise domain controller. - */ - public static final int WinAccountReadonlyControllersSid = 75; - - /** - * Indicates a SID that matches the built-in DCOM certification services access group. - */ - public static final int WinBuiltinEventLogReadersGroup = 76; + /** + * Indicates a null SID. + */ + public static final int WinNullSid = 0; + + /** + * Indicates a SID that matches everyone. + */ + public static final int WinWorldSid = 1; + + /** + * Indicates a local SID. + */ + public static final int WinLocalSid = 2; + + /** + * Indicates a SID that matches the owner or creator of an object. + */ + public static final int WinCreatorOwnerSid = 3; + + /** + * Indicates a SID that matches the creator group of an object. + */ + public static final int WinCreatorGroupSid = 4; + + /** + * Indicates a creator owner server SID. + */ + public static final int WinCreatorOwnerServerSid = 5; + + /** + * Indicates a creator group server SID. + */ + public static final int WinCreatorGroupServerSid = 6; + + /** + * Indicates a SID for the Windows NT authority. + */ + public static final int WinNtAuthoritySid = 7; + + /** + * Indicates a SID for a dial-up account. + */ + public static final int WinDialupSid = 8; + + /** + * Indicates a SID for a network account. This SID is added to the process of a token + * when it logs on across a network. The corresponding logon type is + * LOGON32_LOGON_NETWORK. + */ + public static final int WinNetworkSid = 9; + + /** + * Indicates a SID for a batch process. This SID is added to the process of a token + * when it logs on as a batch job. The corresponding logon type is LOGON32_LOGON_BATCH. + */ + public static final int WinBatchSid = 10; + + /** + * Indicates a SID for an interactive account. This SID is added to the process of a + * token when it logs on interactively. The corresponding logon type is + * LOGON32_LOGON_INTERACTIVE. + */ + public static final int WinInteractiveSid = 11; + + /** + * Indicates a SID for a service. This SID is added to the process of a token when it + * logs on as a service. The corresponding logon type is LOGON32_LOGON_bSERVICE. + */ + public static final int WinServiceSid = 12; + + /** + * Indicates a SID for the anonymous account. + */ + public static final int WinAnonymousSid = 13; + + /** + * Indicates a proxy SID. + */ + public static final int WinProxySid = 14; + + /** + * Indicates a SID for an enterprise controller. + */ + public static final int WinEnterpriseControllersSid = 15; + + /** + * Indicates a SID for self. + */ + public static final int WinSelfSid = 16; + + /** + * Indicates a SID that matches any authenticated user. + */ + public static final int WinAuthenticatedUserSid = 17; + + /** + * Indicates a SID for restricted code. + */ + public static final int WinRestrictedCodeSid = 18; + + /** + * Indicates a SID that matches a terminal server account. + */ + public static final int WinTerminalServerSid = 19; + + /** + * Indicates a SID that matches remote logons. + */ + public static final int WinRemoteLogonIdSid = 20; + + /** + * Indicates a SID that matches logon IDs. + */ + public static final int WinLogonIdsSid = 21; + + /** + * Indicates a SID that matches the local system. + */ + public static final int WinLocalSystemSid = 22; + + /** + * Indicates a SID that matches a local service. + */ + public static final int WinLocalServiceSid = 23; + + /** + * Indicates a SID that matches a network service. + */ + public static final int WinNetworkServiceSid = 24; + + /** + * Indicates a SID that matches the domain account. + */ + public static final int WinBuiltinDomainSid = 25; + + /** + * Indicates a SID that matches the administrator account. + */ + public static final int WinBuiltinAdministratorsSid = 26; + + /** + * Indicates a SID that matches built-in user accounts. + */ + public static final int WinBuiltinUsersSid = 27; + + /** + * Indicates a SID that matches the guest account. + */ + public static final int WinBuiltinGuestsSid = 28; + + /** + * Indicates a SID that matches the power users group. + */ + public static final int WinBuiltinPowerUsersSid = 29; + + /** + * Indicates a SID that matches the account operators account. + */ + public static final int WinBuiltinAccountOperatorsSid = 30; + + /** + * Indicates a SID that matches the system operators group. + */ + public static final int WinBuiltinSystemOperatorsSid = 31; + + /** + * Indicates a SID that matches the print operators group. + */ + public static final int WinBuiltinPrintOperatorsSid = 32; + + /** + * Indicates a SID that matches the backup operators group. + */ + public static final int WinBuiltinBackupOperatorsSid = 33; + + /** + * Indicates a SID that matches the replicator account. + */ + public static final int WinBuiltinReplicatorSid = 34; + + /** + * Indicates a SID that matches pre-Windows 2000 compatible accounts. + */ + public static final int WinBuiltinPreWindows2000CompatibleAccessSid = 35; + + /** + * Indicates a SID that matches remote desktop users. + */ + public static final int WinBuiltinRemoteDesktopUsersSid = 36; + + /** + * Indicates a SID that matches the network operators group. + */ + public static final int WinBuiltinNetworkConfigurationOperatorsSid = 37; + + /** + * Indicates a SID that matches the account administrators group. + */ + public static final int WinAccountAdministratorSid = 38; + + /** + * Indicates a SID that matches the account guest group. + */ + public static final int WinAccountGuestSid = 39; + + /** + * Indicates a SID that matches account Kerberos target group. + */ + public static final int WinAccountKrbtgtSid = 40; + + /** + * Indicates a SID that matches the account domain administrator group. + */ + public static final int WinAccountDomainAdminsSid = 41; + + /** + * Indicates a SID that matches the account domain users group. + */ + public static final int WinAccountDomainUsersSid = 42; + + /** + * Indicates a SID that matches the account domain guests group. + */ + public static final int WinAccountDomainGuestsSid = 43; + + /** + * Indicates a SID that matches the account computer group. + */ + public static final int WinAccountComputersSid = 44; + + /** + * Indicates a SID that matches the account controller group. + */ + public static final int WinAccountControllersSid = 45; + + /** + * Indicates a SID that matches the certificate administrators group. + */ + public static final int WinAccountCertAdminsSid = 46; + + /** + * Indicates a SID that matches the schema administrators group. + */ + public static final int WinAccountSchemaAdminsSid = 47; + + /** + * Indicates a SID that matches the enterprise administrators group. + */ + public static final int WinAccountEnterpriseAdminsSid = 48; + + /** + * Indicates a SID that matches the policy administrators group. + */ + public static final int WinAccountPolicyAdminsSid = 49; + + /** + * Indicates a SID that matches the RAS and IAS server account. + */ + public static final int WinAccountRasAndIasServersSid = 50; + + /** + * Indicates a SID present when the Microsoft NTLM authentication package + * authenticated the client. + */ + public static final int WinNTLMAuthenticationSid = 51; + + /** + * Indicates a SID present when the Microsoft Digest authentication package + * authenticated the client. + */ + public static final int WinDigestAuthenticationSid = 52; + + /** + * Indicates a SID present when the Secure Channel (SSL/TLS) authentication + * package authenticated the client. + */ + public static final int WinSChannelAuthenticationSid = 53; + + /** + * Indicates a SID present when the user authenticated from within the forest + * or across a trust that does not have the selective authentication option + * enabled. If this SID is present, then WinOtherOrganizationSid cannot be present. + */ + public static final int WinThisOrganizationSid = 54; + + /** + * Indicates a SID present when the user authenticated across a forest with the + * selective authentication option enabled. If this SID is present, then + * WinThisOrganizationSid cannot be present. + */ + public static final int WinOtherOrganizationSid = 55; + + /** + * Indicates a SID that allows a user to create incoming forest trusts. It is added + * to the token of users who are a member of the Incoming Forest Trust Builders + * built-in group in the root domain of the forest. + */ + public static final int WinBuiltinIncomingForestTrustBuildersSid = 56; + + /** + * Indicates a SID that matches the performance monitor user group. + */ + public static final int WinBuiltinPerfMonitoringUsersSid = 57; + + /** + * Indicates a SID that matches the performance log user group. + */ + public static final int WinBuiltinPerfLoggingUsersSid = 58; + + /** + * Indicates a SID that matches the Windows Authorization Access group. + */ + public static final int WinBuiltinAuthorizationAccessSid = 59; + + /** + * Indicates a SID is present in a server that can issue Terminal Server licenses. + */ + public static final int WinBuiltinTerminalServerLicenseServersSid = 60; + + /** + * + */ + public static final int WinBuiltinDCOMUsersSid = 61; + + /** + * + */ + public static final int WinBuiltinIUsersSid = 62; + + /** + * + */ + public static final int WinIUserSid = 63; + + /** + * + */ + public static final int WinBuiltinCryptoOperatorsSid = 64; + + /** + * + */ + public static final int WinUntrustedLabelSid = 65; + + /** + * + */ + public static final int WinLowLabelSid = 66; + + /** + * + */ + public static final int WinMediumLabelSid = 67; + + /** + * + */ + public static final int WinHighLabelSid = 68; + + /** + * + */ + public static final int WinSystemLabelSid = 69; + + /** + * + */ + public static final int WinWriteRestrictedCodeSid = 70; + + /** + * + */ + public static final int WinCreatorOwnerRightsSid = 71; + + /** + * + */ + public static final int WinCacheablePrincipalsGroupSid = 72; + + /** + * + */ + public static final int WinNonCacheablePrincipalsGroupSid = 73; + + /** + * + */ + public static final int WinEnterpriseReadonlyControllersSid = 74; + + /** + * Indicates a SID that matches a read-only enterprise domain controller. + */ + public static final int WinAccountReadonlyControllersSid = 75; + + /** + * Indicates a SID that matches the built-in DCOM certification services access group. + */ + public static final int WinBuiltinEventLogReadersGroup = 76; } /** @@ -1484,47 +1509,49 @@ public abstract class WELL_KNOWN_SID_TYPE { * is used with the GetVersionEx function. */ public static class OSVERSIONINFO extends Structure { - /** - * Size of this data structure, in bytes. Set this member to sizeof(OSVERSIONINFO) - * before calling the GetVersionEx function. - */ - public DWORD dwOSVersionInfoSize; - - /** - * Major version number of the operating system. - */ - public DWORD dwMajorVersion; - - /** - * Minor version number of the operating system. - */ - public DWORD dwMinorVersion; - - /** - * Build number of the operating system. - */ - public DWORD dwBuildNumber; - - /** - * Operating system platform. - */ - public DWORD dwPlatformId; - - /** - * Pointer to a null-terminated string, such as "Service Pack 3", - * that indicates the latest Service Pack installed on the system. - */ - public char szCSDVersion[]; + /** + * Size of this data structure, in bytes. Set this member to sizeof(OSVERSIONINFO) + * before calling the GetVersionEx function. + */ + public DWORD dwOSVersionInfoSize; + + /** + * Major version number of the operating system. + */ + public DWORD dwMajorVersion; - public OSVERSIONINFO() { - szCSDVersion = new char[128]; - dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFO) - } - - public OSVERSIONINFO(Pointer memory) { - useMemory(memory); - read(); - } + /** + * Minor version number of the operating system. + */ + public DWORD dwMinorVersion; + + /** + * Build number of the operating system. + */ + public DWORD dwBuildNumber; + + /** + * Operating system platform. + */ + public DWORD dwPlatformId; + + /** + * Pointer to a null-terminated string, such as "Service Pack 3", + * that indicates the latest Service Pack installed on the system. + */ + public char szCSDVersion[]; + + { setFieldOrder(new String[] { "dwOSVersionInfoSize", "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", "dwPlatformId", "szCSDVersion" }); } + + public OSVERSIONINFO() { + szCSDVersion = new char[128]; + dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFO) + } + + public OSVERSIONINFO(Pointer memory) { + useMemory(memory); + read(); + } } /** @@ -1533,74 +1560,76 @@ public OSVERSIONINFO(Pointer memory) { * installed on the system. */ public static class OSVERSIONINFOEX extends Structure { - /** - * The size of this data structure, in bytes. - */ - public DWORD dwOSVersionInfoSize; - - /** - * The major version number of the operating system. - */ - public DWORD dwMajorVersion; - - /** - * The minor version number of the operating system. - */ - public DWORD dwMinorVersion; - - /** - * The build number of the operating system. - */ - public DWORD dwBuildNumber; - - /** - * The operating system platform. This member can be VER_PLATFORM_WIN32_NT. - */ - public DWORD dwPlatformId; - - /** - * A null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack - * installed on the system. If no Service Pack has been installed, the string is empty. - */ - public char szCSDVersion[]; - - /** - * The major version number of the latest Service Pack installed on the system. For example, for - * Service Pack 3, the major version number is 3. If no Service Pack has been installed, the value - * is zero. - */ - public WORD wServicePackMajor; - - /** - * The minor version number of the latest Service Pack installed on the system. For example, for - * Service Pack 3, the minor version number is 0. - */ - public WORD wServicePackMinor; - - /** - * A bit mask that identifies the product suites available on the system. - */ - public WORD wSuiteMask; - - /** - * Any additional information about the system. - */ - public byte wProductType; - - /** - * Reserved for future use. - */ - public byte wReserved; + /** + * The size of this data structure, in bytes. + */ + public DWORD dwOSVersionInfoSize; - public OSVERSIONINFOEX() { - szCSDVersion = new char[128]; - dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFOEX) - } - - public OSVERSIONINFOEX(Pointer memory) { - useMemory(memory); - read(); - } + /** + * The major version number of the operating system. + */ + public DWORD dwMajorVersion; + + /** + * The minor version number of the operating system. + */ + public DWORD dwMinorVersion; + + /** + * The build number of the operating system. + */ + public DWORD dwBuildNumber; + + /** + * The operating system platform. This member can be VER_PLATFORM_WIN32_NT. + */ + public DWORD dwPlatformId; + + /** + * A null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack + * installed on the system. If no Service Pack has been installed, the string is empty. + */ + public char szCSDVersion[]; + + /** + * The major version number of the latest Service Pack installed on the system. For example, for + * Service Pack 3, the major version number is 3. If no Service Pack has been installed, the value + * is zero. + */ + public WORD wServicePackMajor; + + /** + * The minor version number of the latest Service Pack installed on the system. For example, for + * Service Pack 3, the minor version number is 0. + */ + public WORD wServicePackMinor; + + /** + * A bit mask that identifies the product suites available on the system. + */ + public WORD wSuiteMask; + + /** + * Any additional information about the system. + */ + public byte wProductType; + + /** + * Reserved for future use. + */ + public byte wReserved; + + { setFieldOrder(new String[] { "dwOSVersionInfoSize", "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", "dwPlatformId", "szCSDVersion", "wServicePackMajor", "wServicePackMinor", "wSuiteMask", "wProductType", "wReserved" }); } + + public OSVERSIONINFOEX() { + szCSDVersion = new char[128]; + dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFOEX) + } + + public OSVERSIONINFOEX(Pointer memory) { + useMemory(memory); + read(); + } } int VER_EQUAL = 1; @@ -1690,105 +1719,108 @@ public OSVERSIONINFOEX(Pointer memory) { * ReadEventLog function. */ public static class EVENTLOGRECORD extends Structure { - /** - * Size of this event record, in bytes. Note that this value is stored at both ends - * of the entry to ease moving forward or backward through the log. The length includes - * any pad bytes inserted at the end of the record for DWORD alignment. - */ - public DWORD Length; - - /** - * Reserved. - */ - public DWORD Reserved; - - /** - * Record number of the record. This value can be used with the EVENTLOG_SEEK_READ flag in - * the ReadEventLog function to begin reading at a specified record. - */ - public DWORD RecordNumber; - - /** - * Time at which this entry was submitted. This time is measured in the number of seconds - * elapsed since 00:00:00 January 1, 1970, Universal Coordinated Time. - */ - public DWORD TimeGenerated; - - /** - * Time at which this entry was received by the service to be written to the log. - * This time is measured in the number of seconds elapsed since 00:00:00 January 1, - * 1970, Universal Coordinated Time. - */ - public DWORD TimeWritten; - - /** - * Event identifier. The value is specific to the event source for the event, and is used - * with source name to locate a description string in the message file for the event source. - */ - public DWORD EventID; - - /** - * Type of event. - */ - public WORD EventType; - - /** - * Number of strings present in the log (at the position indicated by StringOffset). - * These strings are merged into the message before it is displayed to the user. - */ - public WORD NumStrings; - - /** - * Category for this event. The meaning of this value depends on the event source. - */ - public WORD EventCategory; - - /** - * Reserved. - */ - public WORD ReservedFlags; - - /** - * Reserved. - */ - public DWORD ClosingRecordNumber; - - /** - * Offset of the description strings within this event log record. - */ - public DWORD StringOffset; - - /** - * Size of the UserSid member, in bytes. This value can be zero if no security identifier was provided. - */ - public DWORD UserSidLength; - - /** - * Offset of the security identifier (SID) within this event log record. - * To obtain the user name for this SID, use the LookupAccountSid function. - */ - public DWORD UserSidOffset; - - /** - * Size of the event-specific data (at the position indicated by DataOffset), in bytes. - */ - public DWORD DataLength; - - /** - * Offset of the event-specific information within this event log record, in bytes. - * This information could be something specific (a disk driver might log the number - * of retries, for example), followed by binary information specific to the event - * being logged and to the source that generated the entry. - */ - public DWORD DataOffset; + /** + * Size of this event record, in bytes. Note that this value is stored at both ends + * of the entry to ease moving forward or backward through the log. The length includes + * any pad bytes inserted at the end of the record for DWORD alignment. + */ + public DWORD Length; - public EVENTLOGRECORD() { - } + /** + * Reserved. + */ + public DWORD Reserved; - public EVENTLOGRECORD(Pointer p) { - super(p); - read(); - } + /** + * Record number of the record. This value can be used with the EVENTLOG_SEEK_READ flag in + * the ReadEventLog function to begin reading at a specified record. + */ + public DWORD RecordNumber; + + /** + * Time at which this entry was submitted. This time is measured in the number of seconds + * elapsed since 00:00:00 January 1, 1970, Universal Coordinated Time. + */ + public DWORD TimeGenerated; + + /** + * Time at which this entry was received by the service to be written to the log. + * This time is measured in the number of seconds elapsed since 00:00:00 January 1, + * 1970, Universal Coordinated Time. + */ + public DWORD TimeWritten; + + /** + * Event identifier. The value is specific to the event source for the event, and is used + * with source name to locate a description string in the message file for the event source. + */ + public DWORD EventID; + + /** + * Type of event. + */ + public WORD EventType; + + /** + * Number of strings present in the log (at the position indicated by StringOffset). + * These strings are merged into the message before it is displayed to the user. + */ + public WORD NumStrings; + + /** + * Category for this event. The meaning of this value depends on the event source. + */ + public WORD EventCategory; + + /** + * Reserved. + */ + public WORD ReservedFlags; + + /** + * Reserved. + */ + public DWORD ClosingRecordNumber; + + /** + * Offset of the description strings within this event log record. + */ + public DWORD StringOffset; + + /** + * Size of the UserSid member, in bytes. This value can be zero if no security identifier was provided. + */ + public DWORD UserSidLength; + + /** + * Offset of the security identifier (SID) within this event log record. + * To obtain the user name for this SID, use the LookupAccountSid function. + */ + public DWORD UserSidOffset; + + /** + * Size of the event-specific data (at the position indicated by DataOffset), in bytes. + */ + public DWORD DataLength; + + /** + * Offset of the event-specific information within this event log record, in bytes. + * This information could be something specific (a disk driver might log the number + * of retries, for example), followed by binary information specific to the event + * being logged and to the source that generated the entry. + */ + public DWORD DataOffset; + + { setFieldOrder(new String[] { "Length", "Reserved", "RecordNumber", "TimeGenerated", "TimeWritten", "EventID", "EventType", "NumStrings", "EventCategory", "ReservedFlags", "ClosingRecordNumber", "StringOffset", "UserSidLength", "UserSidOffset", "DataLength", "DataOffset" }); } + + public EVENTLOGRECORD() { + + } + + public EVENTLOGRECORD(Pointer p) { + super(p); + read(); + } } // @@ -1858,168 +1890,185 @@ public EVENTLOGRECORD(Pointer p) { int UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000; public static class SECURITY_DESCRIPTOR extends Structure { - public static class ByReference extends SECURITY_DESCRIPTOR implements Structure.ByReference { - } - - public SECURITY_DESCRIPTOR() { - } - - public SECURITY_DESCRIPTOR(byte[] data) { - super(); - this.data = data; - useMemory(new Memory(data.length)); - } - - public SECURITY_DESCRIPTOR(Pointer memory) { - super(memory); + public static class ByReference extends SECURITY_DESCRIPTOR implements Structure.ByReference { + + } + + public SECURITY_DESCRIPTOR() { + + } + + public SECURITY_DESCRIPTOR(byte[] data) { + super(); + this.data = data; + useMemory(new Memory(data.length)); + } + + public SECURITY_DESCRIPTOR(Pointer memory) { + super(memory); + } + + public byte[] data; + + { setFieldOrder(new String[] { "data" }); } } - public byte[] data; - } - public static class ACL extends Structure { - public ACL() { } - public ACL(Pointer pointer) { - super(pointer); - read(); - ACEs = new ACCESS_ACEStructure[AceCount]; - int offset = size(); - for (int i=0; i < AceCount; i++) { - Pointer share = pointer.share(offset); - // ACE_HEADER.AceType - final byte aceType = share.getByte(0); - ACCESS_ACEStructure ace = null; - switch (aceType) { - case ACCESS_ALLOWED_ACE_TYPE: - ace = new ACCESS_ALLOWED_ACE(share); - break; - case ACCESS_DENIED_ACE_TYPE: - ace = new ACCESS_DENIED_ACE(share); - break; - default: - throw new IllegalArgumentException("Unknwon ACE type " + aceType); - } - ACEs[i] = ace; - offset += ace.AceSize; - } - } + public ACL() { + + } + + public ACL(Pointer pointer) { + super(pointer); + read(); + ACEs = new ACCESS_ACEStructure[AceCount]; + int offset = size(); + for (int i=0; i < AceCount; i++) { + Pointer share = pointer.share(offset); + // ACE_HEADER.AceType + final byte aceType = share.getByte(0); + ACCESS_ACEStructure ace = null; + switch (aceType) { + case ACCESS_ALLOWED_ACE_TYPE: + ace = new ACCESS_ALLOWED_ACE(share); + break; + case ACCESS_DENIED_ACE_TYPE: + ace = new ACCESS_DENIED_ACE(share); + break; + default: + throw new IllegalArgumentException("Unknwon ACE type " + aceType); + } + ACEs[i] = ace; + offset += ace.AceSize; + } + } - public byte AclRevision; - public byte Sbz1; - public short AclSize; - public short AceCount; - public short Sbz2; + public byte AclRevision; + public byte Sbz1; + public short AclSize; + public short AceCount; + public short Sbz2; - ACCESS_ACEStructure[] ACEs; + ACCESS_ACEStructure[] ACEs; + + { setFieldOrder(new String[] { "AclRevision", "Sbz1", "AclSize", "AceCount", "Sbz2" }); } - public ACCESS_ACEStructure[] getACEStructures() { - return ACEs; - } + public ACCESS_ACEStructure[] getACEStructures() { + return ACEs; + } } public static class SECURITY_DESCRIPTOR_RELATIVE extends Structure { - public static class ByReference extends SECURITY_DESCRIPTOR_RELATIVE implements Structure.ByReference { - } - - public byte Revision; - public byte Sbz1; - public short Control; - public int Owner; - public int Group; - public int Sacl; - public int Dacl; - - private ACL DACL = null; - - public SECURITY_DESCRIPTOR_RELATIVE() { - } - - public SECURITY_DESCRIPTOR_RELATIVE(byte[] data) { - super(new Memory(data.length)); - getPointer().write(0, data, 0, data.length); - setDacl(); - } + public static class ByReference extends SECURITY_DESCRIPTOR_RELATIVE implements Structure.ByReference { + + } - public SECURITY_DESCRIPTOR_RELATIVE(Memory memory) { - super(memory); - setDacl(); - } - - public ACL getDiscretionaryACL() { - return DACL; - } + public byte Revision; + public byte Sbz1; + public short Control; + public int Owner; + public int Group; + public int Sacl; + public int Dacl; + + private ACL DACL = null; - private final void setDacl() { - read(); - if (Dacl != 0) { - DACL = new ACL(getPointer().share(Dacl)); - } - } + { setFieldOrder(new String[] { "Revision", "Sbz1", "Control", "Owner", "Group", "Sacl", "Dacl" }); } + + public SECURITY_DESCRIPTOR_RELATIVE() { + + } + + public SECURITY_DESCRIPTOR_RELATIVE(byte[] data) { + super(new Memory(data.length)); + getPointer().write(0, data, 0, data.length); + setDacl(); + } + + public SECURITY_DESCRIPTOR_RELATIVE(Memory memory) { + super(memory); + setDacl(); + } + + public ACL getDiscretionaryACL() { + return DACL; + } + + private final void setDacl() { + read(); + if (Dacl != 0) { + DACL = new ACL(getPointer().share(Dacl)); + } + } } public static abstract class ACEStructure extends Structure { - public byte AceType; - public byte AceFlags; - public short AceSize; - - PSID psid; - - public ACEStructure(Pointer p) { - super(p); - } - - public String getSidString() { - return Advapi32Util.convertSidToStringSid(psid); - } + public byte AceType; + public byte AceFlags; + public short AceSize; + + PSID psid; + + { setFieldOrder(new String[] { "AceType", "AceFlags", "AceSize", "psid" }); } - public PSID getSID() { - return psid; - } + public ACEStructure(Pointer p) { + super(p); + } + + public String getSidString() { + return Advapi32Util.convertSidToStringSid(psid); + } + + public PSID getSID() { + return psid; + } } /* ACE header */ public static class ACE_HEADER extends ACEStructure { - public ACE_HEADER(Pointer p) { - super(p); - read(); - } + public ACE_HEADER(Pointer p) { + super(p); + read(); + } } /** * ACCESS_ALLOWED_ACE and ACCESS_DENIED_ACE have the same structure layout */ public static abstract class ACCESS_ACEStructure extends ACEStructure { - public ACCESS_ACEStructure(Pointer p) { - super(p); - read(); - // AceSize - size of public members of the structure + size of DWORD (SidStart) - int sizeOfSID = super.AceSize - size() + 4; - // ACE_HEADER + size of int (Mask) - int offsetOfSID = 4 + 4; - byte[] data = p.getByteArray(offsetOfSID, sizeOfSID); - psid = new PSID(data); - } - - public int Mask; - - /** - * first 4 bytes of the SID - */ - public DWORD SidStart; + public ACCESS_ACEStructure(Pointer p) { + super(p); + read(); + // AceSize - size of public members of the structure + size of DWORD (SidStart) + int sizeOfSID = super.AceSize - size() + 4; + // ACE_HEADER + size of int (Mask) + int offsetOfSID = 4 + 4; + byte[] data = p.getByteArray(offsetOfSID, sizeOfSID); + psid = new PSID(data); + } + + public int Mask; + + /** + * first 4 bytes of the SID + */ + public DWORD SidStart; + + { setFieldOrder(new String[] { "Mask", "SidStart" }); } } /* Access allowed ACE */ public static class ACCESS_ALLOWED_ACE extends ACCESS_ACEStructure { - public ACCESS_ALLOWED_ACE(Pointer p) { - super(p); + public ACCESS_ALLOWED_ACE(Pointer p) { + super(p); + } } - } - + /* Access denied ACE */ public static class ACCESS_DENIED_ACE extends ACCESS_ACEStructure { - public ACCESS_DENIED_ACE(Pointer p) { - super(p); - } + public ACCESS_DENIED_ACE(Pointer p) { + super(p); + } } /* ACE types */ diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java index 3addbc8195..46fcbb7fdf 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java @@ -63,6 +63,8 @@ public class GUITHREADINFO extends Structure { public HWND hwndMoveSize; public HWND hwndCaret; public RECT rcCaret; + + { setFieldOrder(new String[] { "cbSize", "flags", "hwndActive", "hwndFocus", "hwndCapture", "hwndMenuOwner", "hwndMoveSize", "hwndCaret", "rcCaret" }); } } public class WINDOWINFO extends Structure { @@ -76,6 +78,8 @@ public class WINDOWINFO extends Structure { public int cyWindowBorders; public short atomWindowType; public short wCreatorVersion; + + { setFieldOrder(new String[] { "cbSize", "rcWindow", "rcClient", "dwStyle", "dwExStyle", "dwWindowStatus", "cxWindowBorders", "cyWindowBorders", "atomWindowType", "wCreatorVersion" }); } } int GWL_EXSTYLE = -20; @@ -112,6 +116,8 @@ public POINT(int x, int y) { this.x = x; this.y = y; } + + { setFieldOrder(new String[] { "x", "y" }); } } public class MSG extends Structure { @@ -121,6 +127,8 @@ public class MSG extends Structure { public LPARAM lParam; public int time; public POINT pt; + + { setFieldOrder(new String[] { "hWnd", "message", "wParam", "lParam", "time", "pt" }); } } public class FLASHWINFO extends Structure { @@ -129,6 +137,8 @@ public class FLASHWINFO extends Structure { public int dwFlags; public int uCount; public int dwTimeout; + + { setFieldOrder(new String[] { "cbSize", "hWnd", "dwFlags", "uCount", "dwTimeout" }); } } public interface WNDENUMPROC extends StdCallCallback { @@ -148,6 +158,8 @@ public SIZE(int w, int h) { this.cx = w; this.cy = h; } + + { setFieldOrder(new String[] { "cx", "cy" }); } } int AC_SRC_OVER = 0x00; @@ -160,6 +172,8 @@ public class BLENDFUNCTION extends Structure { public byte BlendFlags = 0; // only valid value public byte SourceConstantAlpha; public byte AlphaFormat; + + { setFieldOrder(new String[] { "BlendOp", "BlendFlags", "SourceConstantAlpha", "AlphaFormat" }); } } int VK_SHIFT = 16; @@ -259,6 +273,8 @@ public class KBDLLHOOKSTRUCT extends Structure { public int flags; public int time; public ULONG_PTR dwExtraInfo; + + { setFieldOrder(new String[] { "vkCode", "scanCode", "flags", "time", "dwExtraInfo" }); } } int SM_CXSCREEN = 0; @@ -485,6 +501,8 @@ public HARDWAREINPUT(Pointer memory) { public WinDef.DWORD uMsg; public WinDef.WORD wParamL; public WinDef.WORD wParamH; + + { setFieldOrder(new String[] { "uMsg", "wParamL", "wParamH" }); } } /** @@ -517,6 +535,8 @@ public INPUT(Pointer memory) { public WinDef.DWORD type; public INPUT_UNION input = new INPUT_UNION(); + { setFieldOrder(new String[] { "type", "input" }); } + public static class INPUT_UNION extends Union { public INPUT_UNION() { @@ -604,6 +624,8 @@ public KEYBDINPUT(Pointer memory) { * information. */ public BaseTSD.ULONG_PTR dwExtraInfo; + + { setFieldOrder(new String[] { "wVk", "wScan", "dwFlags", "time", "dwExtraInfo" }); } } /** @@ -634,12 +656,16 @@ public MOUSEINPUT(Pointer memory) { public WinDef.DWORD dwFlags; public WinDef.DWORD time; public BaseTSD.ULONG_PTR dwExtraInfo; + + { setFieldOrder(new String[] { "dx", "dy", "mouseData", "dwFlags", "time", "dwExtraInfo" }); } } /** * Contains the time of the last input. */ public static class LASTINPUTINFO extends Structure { + { setFieldOrder(new String[] { "cbSize", "dwTime" }); } + public int cbSize = size(); // Tick count of when the last input event was received. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java index ee3c36ac5d..4b8c81b6bd 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java @@ -61,5 +61,8 @@ public STORAGE_DEVICE_NUMBER(Pointer memory) { * The partition number of the device, if the device can be partitioned. Otherwise, this member is -1. */ public int PartitionNumber; + + + { setFieldOrder(new String[] { "DeviceType", "DeviceNumber", "PartitionNumber" }); } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java index fbf770c8be..e3c3a7cc12 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java @@ -86,7 +86,9 @@ public static class PRINTER_INFO_1 extends Structure { public String pDescription; public String pName; public String pComment; - + + { setFieldOrder(new String[] { "Flags", "pDescription", "pName", "pComment" }); } + public PRINTER_INFO_1() { } @@ -100,6 +102,8 @@ public static class PRINTER_INFO_4 extends Structure { public String pPrinterName; public String pServerName; public DWORD Attributes; + + { setFieldOrder(new String[] { "pPrinterName", "pServerName", "Attributes" }); } public PRINTER_INFO_4() { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java index 632f591064..71e0a35227 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java @@ -101,6 +101,7 @@ public SERVICE_STATUS() { super(); } + { setFieldOrder(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" }); } } /** @@ -180,8 +181,11 @@ public class SERVICE_STATUS_PROCESS extends Structure { * This member can be one of the following values: 0, or SERVICE_RUNS_IN_SYSTEM_PROCESS */ public int dwServiceFlags; + + { setFieldOrder(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint", "dwProcessId", "dwServiceFlags" }); } public SERVICE_STATUS_PROCESS() { + } public SERVICE_STATUS_PROCESS(int size) { diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java index c0c542fe54..0253c259e9 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java @@ -173,9 +173,9 @@ public void testRegistryKeyExists() { public void testRegistryValueExists() { assertFalse(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, - "Software\\Microsoft", "")); + "Software\\JavaSoft", "")); assertFalse(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, - "Software\\Microsoft", "KeyDoesNotExist")); + "Software\\JavaSoft", "KeyDoesNotExist")); assertTrue(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control", "SystemBootDevice")); } diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java index 5a37ff252e..973c0bbff7 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java @@ -12,6 +12,8 @@ */ package com.sun.jna.platform.win32; +import java.util.ArrayList; + import junit.framework.TestCase; import com.sun.jna.WString; @@ -25,6 +27,7 @@ import com.sun.jna.platform.win32.NTSecApi.LSA_FOREST_TRUST_RECORD; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_RECORD; +import com.sun.jna.platform.win32.Netapi32Util.DomainTrust; import com.sun.jna.platform.win32.Netapi32Util.User; import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT; import com.sun.jna.ptr.IntByReference; @@ -235,13 +238,14 @@ public void testDsEnumerateDomainTrusts() { return; IntByReference domainCount = new IntByReference(); - PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference(); + PointerByReference domainsPointerRef = new PointerByReference(); assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts( - null, DsGetDC.DS_DOMAIN_VALID_FLAGS, domains, domainCount)); + null, DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainCount)); assertTrue(domainCount.getValue() >= 0); - DS_DOMAIN_TRUSTS[] trusts = domains.getTrusts(domainCount.getValue()); + DS_DOMAIN_TRUSTS domains = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue()); + DS_DOMAIN_TRUSTS trusts[] = (DS_DOMAIN_TRUSTS[]) domains.toArray(new DS_DOMAIN_TRUSTS[domainCount.getValue()]); for(DS_DOMAIN_TRUSTS trust : trusts) { assertTrue(trust.NetbiosDomainName.length() > 0); assertTrue(trust.DnsDomainName.length() > 0); @@ -251,6 +255,6 @@ public void testDsEnumerateDomainTrusts() { } assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( - domains.getPointer())); + domainsPointerRef.getValue())); } } diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java index 274e16b7fc..25fe5992a4 100644 --- a/src/com/sun/jna/Structure.java +++ b/src/com/sun/jna/Structure.java @@ -136,7 +136,7 @@ private static class MemberOrder { String arch = System.getProperty("os.arch").toLowerCase(); isPPC = "ppc".equals(arch) || "powerpc".equals(arch); isSPARC = "sparc".equals(arch); - isARM = "arm".equals(arch); + isARM = "arm".equals(arch); } /** Use the platform default alignment. */ @@ -821,15 +821,16 @@ protected List getFields(boolean force) { List flist = getFieldList(); List fieldOrder = getFieldOrder(); if (fieldOrder.size() < flist.size() && flist.size() > 1) { + boolean predictableFieldOrder = Boolean.getBoolean("jna.predictable_field_order"); if (force) { - if (!Boolean.getBoolean("jna.predictable_field_order")) { + if (! predictableFieldOrder) { throw new Error("You must call Structure.setFieldOrder() in the base constructor for " + getClass() + " to ensure that JNA can accurately determine your Structure's memory layout. To avoid this message, either call Structure.setFieldOrder() in your Structures constructor, or set jna.predictable_field_order=true if you are certain the VM you are using provides fields in a predictable order."); } if (REQUIRES_FIELD_ORDER) { throw new Error("This VM does not store fields in a predictable order; you must use Structure.setFieldOrder on " + getClass() + " to explicitly indicate the field order: " + System.getProperty("java.vendor") + ", " + System.getProperty("java.version")); } } - if (!Boolean.getBoolean("jna.predictable_field_order")) { + if (! predictableFieldOrder) { return null; } } diff --git a/test/com/sun/jna/win32/W32APIMapperTest.java b/test/com/sun/jna/win32/W32APIMapperTest.java index e6c98a067e..3bcfd12754 100644 --- a/test/com/sun/jna/win32/W32APIMapperTest.java +++ b/test/com/sun/jna/win32/W32APIMapperTest.java @@ -33,6 +33,7 @@ public static class TestStructure extends Structure { public String string2; public boolean bool; public boolean bool2; + { setFieldOrder(new String[] { "string", "string2", "bool", "bool2" }); } } String returnWStringArgument(String arg); boolean returnInt32Argument(boolean arg); @@ -44,6 +45,7 @@ public static class TestStructure extends Structure { public String string2; public boolean bool; public boolean bool2; + { setFieldOrder(new String[] { "string", "string2", "bool", "bool2" }); } } String returnStringArgument(String arg); boolean returnInt32Argument(boolean arg); diff --git a/test/com/sun/jna/win32/W32StdCallTest.java b/test/com/sun/jna/win32/W32StdCallTest.java index 5ddf49a36f..61422b2c5d 100644 --- a/test/com/sun/jna/win32/W32StdCallTest.java +++ b/test/com/sun/jna/win32/W32StdCallTest.java @@ -31,6 +31,7 @@ public class W32StdCallTest extends TestCase { public static interface TestLibrary extends StdCallLibrary { public static class Inner extends Structure { public double value; + { setFieldOrder(new String[] { "value" }); } } public static class TestStructure extends Structure { public static class ByValue extends TestStructure implements Structure.ByValue { } @@ -39,6 +40,7 @@ public static class ByValue extends TestStructure implements Structure.ByValue { public int i; public long j; public Inner inner; + { setFieldOrder(new String[] { "c", "s", "i", "j", "inner" }); } } int returnInt32ArgumentStdCall(int arg); TestStructure.ByValue returnStructureByValueArgumentStdCall(TestStructure.ByValue arg);