trunk contents moved to root

This commit is contained in:
Jindra Petřík
2014-05-10 20:50:57 +02:00
parent 1b851e66a8
commit 199a4d0c2b
2296 changed files with 0 additions and 0 deletions
@@ -0,0 +1,844 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sun.jna.platform.win32;
/**
*
* @author JPEXS
*/
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Advapi32.dll Interface.
*
* @author dblock[at]dblock.org
*/
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves the name of the user associated with the current thread.
* http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx
*
* @param buffer Buffer to receive the user's logon name.
* @param len On input, the size of the buffer, on output the number of
* characters copied into the buffer, including the terminating null
* character.
* @return True if succeeded.
*/
public boolean GetUserNameW(char[] buffer, IntByReference len);
/**
* The LogonUser function attempts to log a user on to the local computer.
* The local computer is the computer from which LogonUser was called. You
* cannot use LogonUser to log on to a remote computer. You specify the user
* with a user name and domain, and authenticate the user with a plaintext
* password. If the function succeeds, you receive a handle to a token that
* represents the logged-on user. You can then use this token handle to
* impersonate the specified user or, in most cases, to create a process
* that runs in the context of the specified user.
*
* @param lpszUsername A pointer to a null-terminated string that specifies
* the name of the user. This is the name of the user account to log on to.
* If you use the user principal name (UPN) format, user@DNS_domain_name,
* the lpszDomain parameter must be NULL.
* @param lpszDomain A pointer to a null-terminated string that specifies
* the name of the domain or server whose account database contains the
* lpszUsername account. If this parameter is NULL, the user name must be
* specified in UPN format. If this parameter is ".", the function validates
* the account using only the local account database.
* @param lpszPassword A pointer to a null-terminated string that specifies
* the plaintext password for the user account specified by lpszUsername.
* @param logonType The type of logon operation to perform.
* @param logonProvider Specifies the logon provider.
* @param phToken A pointer to a handle variable that receives a handle to a
* token that represents the specified user.
* @return If the function succeeds, the function returns nonzero. If the
* function fails, it returns zero. To get extended error information, call
* GetLastError.
*/
public boolean LogonUser(
String lpszUsername,
String lpszDomain,
String lpszPassword,
int logonType,
int logonProvider,
HANDLEByReference phToken);
/**
* The OpenThreadToken function opens the access token associated with a
* thread.
*
* @param ThreadHandle Handle to the thread whose access token is opened.
* @param DesiredAccess Specifies an access mask that specifies the
* requested types of access to the access token. These requested access
* types are reconciled against the token's discretionary access control
* list (DACL) to determine which accesses are granted or denied.
* @param OpenAsSelf Indicates whether the access check is to be made
* against the security context of the thread calling the OpenThreadToken
* function or against the security context of the process for the calling
* thread.
* @param TokenHandle Pointer to a variable that receives the handle to the
* newly opened access token.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean OpenThreadToken(
HANDLE ThreadHandle,
int DesiredAccess,
boolean OpenAsSelf,
HANDLEByReference TokenHandle);
/**
* The OpenProcessToken function opens the access token associated with a
* process.
*
* @param ProcessHandle Handle to the process whose access token is opened.
* The process must have the PROCESS_QUERY_INFORMATION access permission.
* @param DesiredAccess Specifies an access mask that specifies the
* requested types of access to the access token. These requested access
* types are compared with the discretionary access control list (DACL) of
* the token to determine which accesses are granted or denied.
* @param TokenHandle Pointer to a handle that identifies the newly opened
* access token when the function returns.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean OpenProcessToken(
HANDLE ProcessHandle,
int DesiredAccess,
HANDLEByReference TokenHandle);
/**
* The DuplicateToken function creates a new access token that duplicates
* one already in existence.
*
* @param ExistingTokenHandle Handle to an access token opened with
* TOKEN_DUPLICATE access.
* @param ImpersonationLevel Specifies a SECURITY_IMPERSONATION_LEVEL
* enumerated type that supplies the impersonation level of the new token.
* @param DuplicateTokenHandle Pointer to a variable that receives a handle
* to the duplicate token. This handle has TOKEN_IMPERSONATE and TOKEN_QUERY
* access to the new token.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean DuplicateToken(
HANDLE ExistingTokenHandle,
int ImpersonationLevel,
HANDLEByReference DuplicateTokenHandle);
/**
* The DuplicateTokenEx function creates a new access token that duplicates
* an existing token. This function can create either a primary token or an
* impersonation token.
*
* @param hExistingToken A handle to an access token opened with
* TOKEN_DUPLICATE access.
* @param dwDesiredAccess Specifies the requested access rights for the new
* token.
* @param lpTokenAttributes A pointer to a SECURITY_ATTRIBUTES structure
* that specifies a security descriptor for the new token and determines
* whether child processes can inherit the token.
* @param ImpersonationLevel Specifies a value from the
* SECURITY_IMPERSONATION_LEVEL enumeration that indicates the impersonation
* level of the new token.
* @param TokenType Specifies one of the following values from the
* TOKEN_TYPE enumeration.
* @param phNewToken A pointer to a HANDLE variable that receives the new
* token.
* @return If the function succeeds, the function returns a nonzero value.
* If the function fails, it returns zero. To get extended error
* information, call GetLastError.
*/
public boolean DuplicateTokenEx(
HANDLE hExistingToken,
int dwDesiredAccess,
WinBase.SECURITY_ATTRIBUTES lpTokenAttributes,
int ImpersonationLevel,
int TokenType,
HANDLEByReference phNewToken);
/**
* Retrieves a specified type of information about an access token. The
* calling process must have appropriate access rights to obtain the
* information.
*
* @param tokenHandle Handle to an access token from which information is
* retrieved. If TokenInformationClass specifies TokenSource, the handle
* must have TOKEN_QUERY_SOURCE access. For all other TokenInformationClass
* values, the handle must have TOKEN_QUERY access.
* @param tokenInformationClass Specifies a value from the
* TOKEN_INFORMATION_CLASS enumerated type to identify the type of
* information the function retrieves.
* @param tokenInformation Pointer to a buffer the function fills with the
* requested information. The structure put into this buffer depends upon
* the type of information specified by the TokenInformationClass parameter.
* @param tokenInformationLength Specifies the size, in bytes, of the buffer
* pointed to by the TokenInformation parameter. If TokenInformation is
* NULL, this parameter must be zero.
* @param returnLength Pointer to a variable that receives the number of
* bytes needed for the buffer pointed to by the TokenInformation parameter.
* If this value is larger than the value specified in the
* TokenInformationLength parameter, the function fails and stores no data
* in the buffer.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean GetTokenInformation(
HANDLE tokenHandle,
int tokenInformationClass,
Structure tokenInformation,
int tokenInformationLength,
IntByReference returnLength);
/**
* The ImpersonateLoggedOnUser function lets the calling thread impersonate
* the security context of a logged-on user. The user is represented by a
* token handle.
*
* @param hToken Handle to a primary or impersonation access token that
* represents a logged-on user. This can be a token handle returned by a
* call to LogonUser, CreateRestrictedToken, DuplicateToken,
* DuplicateTokenEx, OpenProcessToken, or OpenThreadToken functions. If
* hToken is a primary token, it must have TOKEN_QUERY and TOKEN_DUPLICATE
* access. If hToken is an impersonation token, it must have TOKEN_QUERY and
* TOKEN_IMPERSONATE access.
* @return If the function succeeds, the return value is nonzero.
*/
public boolean ImpersonateLoggedOnUser(HANDLE hToken);
/**
* The ImpersonateSelf function obtains an access token that impersonates
* the security context of the calling process. The token is assigned to the
* calling thread.
*
* @param ImpersonationLevel Specifies a SECURITY_IMPERSONATION_LEVEL
* enumerated type that supplies the impersonation level of the new token.
* @return If the function succeeds, the return value is nonzero.
*/
public boolean ImpersonateSelf(int ImpersonationLevel);
/**
* The RevertToSelf function terminates the impersonation of a client
* application.
*
* @return If the function succeeds, the return value is nonzero.
*/
public boolean RevertToSelf();
/**
* The RegOpenKeyEx function opens the specified registry key. Note that key
* names are not case sensitive.
*
* @param hKey Handle to an open key.
* @param lpSubKey Pointer to a null-terminated string containing the name
* of the subkey to open.
* @param ulOptions Reserved; must be zero.
* @param samDesired Access mask that specifies the desired access rights to
* the key. The function fails if the security descriptor of the key does
* not permit the requested access for the calling process.
* @param phkResult Pointer to a variable that receives a handle to the
* opened key. If the key is not one of the predefined registry keys, call
* the RegCloseKey function after you have finished using the handle.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegOpenKeyEx(HKEY hKey, String lpSubKey, int ulOptions, int samDesired,
HKEYByReference phkResult);
/**
* The RegQueryValueEx function retrieves the type and data for a specified
* value name associated with an open registry key.
*
* @param hKey Handle to an open key. The key must have been opened with the
* KEY_QUERY_VALUE access right.
* @param lpValueName Pointer to a null-terminated string containing the
* name of the value to query. If lpValueName is NULL or an empty string,
* "", the function retrieves the type and data for the key's unnamed or
* default value, if any.
* @param lpReserved Reserved; must be NULL.
* @param lpType Pointer to a variable that receives a code indicating the
* type of data stored in the specified value.
* @param lpData Pointer to a buffer that receives the value's data. This
* parameter can be NULL if the data is not required. If the data is a
* string, the function checks for a terminating null character. If one is
* not found, the string is stored with a null terminator if the buffer is
* large enough to accommodate the extra character. Otherwise, the string is
* stored as is.
* @param lpcbData Pointer to a variable that specifies the size of the
* buffer pointed to by the lpData parameter, in bytes. When the function
* returns, this variable contains the size of the data copied to lpData.
* The lpcbData parameter can be NULL only if lpData is NULL. If the data
* has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes
* any terminating null character or characters. If the buffer specified by
* lpData parameter is not large enough to hold the data, the function
* returns ERROR_MORE_DATA and stores the required buffer size in the
* variable pointed to by lpcbData. In this case, the contents of the lpData
* buffer are undefined. If lpData is NULL, and lpcbData is non-NULL, the
* function returns ERROR_SUCCESS and stores the size of the data, in bytes,
* in the variable pointed to by lpcbData. This enables an application to
* determine the best way to allocate a buffer for the value's data.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, char[] lpData, IntByReference lpcbData);
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, IntByReference lpData, IntByReference lpcbData);
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, Pointer lpData, IntByReference lpcbData);
/**
* The RegCloseKey function releases a handle to the specified registry key.
*
* @param hKey Handle to the open key to be closed. The handle must have
* been opened by the RegCreateKeyEx, RegOpenKeyEx, or RegConnectRegistry
* function.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegCloseKey(HKEY hKey);
/**
* The RegDeleteValue function removes a named value from the specified
* registry key. Note that value names are not case sensitive.
*
* @param hKey Handle to an open key. The key must have been opened with the
* KEY_SET_VALUE access right.
* @param lpValueName Pointer to a null-terminated string that names the
* value to remove. If this parameter is NULL or an empty string, the value
* set by the RegSetValue function is removed.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegDeleteValue(HKEY hKey, String lpValueName);
/**
* The RegSetValueEx function sets the data and type of a specified value
* under a registry key.
*
* @param hKey Handle to an open key. The key must have been opened with the
* KEY_SET_VALUE access right.
* @param lpValueName Pointer to a string containing the name of the value
* to set. If a value with this name is not already present in the key, the
* function adds it to the key. If lpValueName is NULL or an empty string,
* "", the function sets the type and data for the key's unnamed or default
* value.
* @param Reserved Reserved; must be zero.
* @param dwType Type of data pointed to by the lpData parameter.
* @param lpData Pointer to a buffer containing the data to be stored with
* the specified value name.
* @param cbData Size of the information pointed to by the lpData parameter,
* in bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ,
* cbData must include the size of the terminating null character or
* characters.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
char[] lpData, int cbData);
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
byte[] lpData, int cbData);
/**
*
* @param hKey
* @param lpSubKey
* @param Reserved
* @param lpClass
* @param dwOptions
* @param samDesired
* @param lpSecurityAttributes
* @param phkResult
* @param lpdwDisposition
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegCreateKeyEx(HKEY hKey, String lpSubKey, int Reserved, String lpClass,
int dwOptions, int samDesired, SECURITY_ATTRIBUTES lpSecurityAttributes,
HKEYByReference phkResult, IntByReference lpdwDisposition);
/**
*
* @param hKey
* @param name
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegDeleteKey(HKEY hKey, String name);
/**
* The RegEnumKeyEx function enumerates subkeys of the specified open
* registry key. The function retrieves information about one subkey each
* time it is called.
*
* @param hKey Handle to an open key. The key must have been opened with the
* KEY_ENUMERATE_SUB_KEYS access right.
* @param dwIndex Index of the subkey to retrieve. This parameter should be
* zero for the first call to the RegEnumKeyEx function and then incremented
* for subsequent calls. Because subkeys are not ordered, any new subkey
* will have an arbitrary index. This means that the function may return
* subkeys in any order.
* @param lpName Pointer to a buffer that receives the name of the subkey,
* including the terminating null character. The function copies only the
* name of the subkey, not the full key hierarchy, to the buffer.
* @param lpcName Pointer to a variable that specifies the size of the
* buffer specified by the lpName parameter, in TCHARs. This size should
* include the terminating null character. When the function returns, the
* variable pointed to by lpcName contains the number of characters stored
* in the buffer. The count returned does not include the terminating null
* character.
* @param reserved Reserved; must be NULL.
* @param lpClass Pointer to a buffer that receives the null-terminated
* class string of the enumerated subkey. This parameter can be NULL.
* @param lpcClass Pointer to a variable that specifies the size of the
* buffer specified by the lpClass parameter, in TCHARs. The size should
* include the terminating null character. When the function returns,
* lpcClass contains the number of characters stored in the buffer. The
* count returned does not include the terminating null character. This
* parameter can be NULL only if lpClass is NULL.
* @param lpftLastWriteTime Pointer to a variable that receives the time at
* which the enumerated subkey was last written.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegEnumKeyEx(HKEY hKey, int dwIndex, char[] lpName, IntByReference lpcName,
IntByReference reserved, char[] lpClass, IntByReference lpcClass,
WinBase.FILETIME lpftLastWriteTime);
/**
* The RegEnumValue function enumerates the values for the specified open
* registry key. The function copies one indexed value name and data block
* for the key each time it is called.
*
* @param hKey Handle to an open key. The key must have been opened with the
* KEY_QUERY_VALUE access right.
* @param dwIndex Index of the value to be retrieved. This parameter should
* be zero for the first call to the RegEnumValue function and then be
* incremented for subsequent calls. Because values are not ordered, any new
* value will have an arbitrary index. This means that the function may
* return values in any order.
* @param lpValueName Pointer to a buffer that receives the name of the
* value, including the terminating null character.
* @param lpcchValueName Pointer to a variable that specifies the size of
* the buffer pointed to by the lpValueName parameter, in TCHARs. This size
* should include the terminating null character. When the function returns,
* the variable pointed to by lpcValueName contains the number of characters
* stored in the buffer. The count returned does not include the terminating
* null character.
* @param reserved Reserved; must be NULL.
* @param lpType Pointer to a variable that receives a code indicating the
* type of data stored in the specified value.
* @param lpData Pointer to a buffer that receives the data for the value
* entry. This parameter can be NULL if the data is not required.
* @param lpcbData Pointer to a variable that specifies the size of the
* buffer pointed to by the lpData parameter, in bytes.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegEnumValue(HKEY hKey, int dwIndex, char[] lpValueName,
IntByReference lpcchValueName, IntByReference reserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
/**
* The RegQueryInfoKey function retrieves information about the specified
* registry key.
*
* @param hKey A handle to an open key. The key must have been opened with
* the KEY_QUERY_VALUE access right.
* @param lpClass A pointer to a buffer that receives the null-terminated
* class string of the key. This parameter can be ignored. This parameter
* can be NULL.
* @param lpcClass A pointer to a variable that specifies the size of the
* buffer pointed to by the lpClass parameter, in characters.
* @param lpReserved Reserved; must be NULL.
* @param lpcSubKeys A pointer to a variable that receives the number of
* subkeys that are contained by the specified key. This parameter can be
* NULL.
* @param lpcMaxSubKeyLen A pointer to a variable that receives the size of
* the key's subkey with the longest name, in characters, not including the
* terminating null character. This parameter can be NULL.
* @param lpcMaxClassLen A pointer to a variable that receives the size of
* the longest string that specifies a subkey class, in characters. The
* count returned does not include the terminating null character. This
* parameter can be NULL.
* @param lpcValues A pointer to a variable that receives the number of
* values that are associated with the key. This parameter can be NULL.
* @param lpcMaxValueNameLen A pointer to a variable that receives the size
* of the key's longest value name, in characters. The size does not include
* the terminating null character. This parameter can be NULL.
* @param lpcMaxValueLen A pointer to a variable that receives the size of
* the longest data component among the key's values, in bytes. This
* parameter can be NULL.
* @param lpcbSecurityDescriptor A pointer to a variable that receives the
* size of the key's security descriptor, in bytes. This parameter can be
* NULL.
* @param lpftLastWriteTime A pointer to a FILETIME structure that receives
* the last write time. This parameter can be NULL.
* @return If the function succeeds, the return value is ERROR_SUCCESS. If
* the function fails, the return value is a nonzero error code defined in
* Winerror.h.
*/
public int RegQueryInfoKey(HKEY hKey, char[] lpClass,
IntByReference lpcClass, IntByReference lpReserved,
IntByReference lpcSubKeys, IntByReference lpcMaxSubKeyLen,
IntByReference lpcMaxClassLen, IntByReference lpcValues,
IntByReference lpcMaxValueNameLen, IntByReference lpcMaxValueLen,
IntByReference lpcbSecurityDescriptor,
WinBase.FILETIME lpftLastWriteTime);
/**
* Retrieves a registered handle to the specified event log.
*
* @param lpUNCServerName The Universal Naming Convention (UNC) name of the
* remote server on which this operation is to be performed. If this
* parameter is NULL, the local computer is used.
* @param lpSourceName The name of the event source whose handle is to be
* retrieved. The source name must be a subkey of a log under the Eventlog
* registry key. However, the Security log is for system use only.
* @return If the function succeeds, the return value is a handle to the
* event log. If the function fails, the return value is NULL. To get
* extended error information, call GetLastError. The function returns
* ERROR_ACCESS_DENIED if lpSourceName specifies the Security event log.
*/
public HANDLE RegisterEventSource(String lpUNCServerName, String lpSourceName);
/**
* Closes the specified event log.
*
* @param hEventLog A handle to the event log. The RegisterEventSource
* function returns this handle.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean DeregisterEventSource(HANDLE hEventLog);
/**
* Opens a handle to the specified event log.
*
* @param lpUNCServerName The Universal Naming Convention (UNC) name of the
* remote server on which the event log is to be opened. If this parameter
* is NULL, the local computer is used.
* @param lpSourceName The name of the log. If you specify a custom log and
* it cannot be found, the event logging service opens the Application log;
* however, there will be no associated message or category string file.
* @return If the function succeeds, the return value is the handle to an
* event log. If the function fails, the return value is NULL. To get
* extended error information, call GetLastError.
*/
public HANDLE OpenEventLog(String lpUNCServerName, String lpSourceName);
/**
* Closes the specified event log.
*
* @param hEventLog A handle to the event log to be closed. The OpenEventLog
* or OpenBackupEventLog function returns this handle.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean CloseEventLog(HANDLE hEventLog);
/**
* Retrieves the number of records in the specified event log.
*
* @param hEventLog A handle to the open event log. The OpenEventLog or
* OpenBackupEventLog function returns this handle.
* @param NumberOfRecords A pointer to a variable that receives the number
* of records in the specified event log.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean GetNumberOfEventLogRecords(HANDLE hEventLog, IntByReference NumberOfRecords);
/**
* Clears the specified event log, and optionally saves the current copy of
* the log to a backup file.
*
* @param hEventLog A handle to the event log to be cleared. The
* OpenEventLog function returns this handle.
* @param lpBackupFileName The absolute or relative path of the backup file.
* If this file already exists, the function fails. If the lpBackupFileName
* parameter is NULL, the event log is not backed up.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError. The ClearEventLog function can fail if
* the event log is empty or the backup file already exists.
*/
public boolean ClearEventLog(HANDLE hEventLog, String lpBackupFileName);
/**
* Saves the specified event log to a backup file. The function does not
* clear the event log.
*
* @param hEventLog A handle to the open event log. The OpenEventLog
* function returns this handle.
* @param lpBackupFileName The absolute or relative path of the backup file.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean BackupEventLog(HANDLE hEventLog, String lpBackupFileName);
/**
* Opens a handle to a backup event log created by the BackupEventLog
* function.
*
* @param lpUNCServerName The Universal Naming Convention (UNC) name of the
* remote server on which this operation is to be performed. If this
* parameter is NULL, the local computer is used.
* @param lpFileName The full path of the backup file.
* @return If the function succeeds, the return value is a handle to the
* backup event log. If the function fails, the return value is NULL. To get
* extended error information, call GetLastError.
*/
public HANDLE OpenBackupEventLog(String lpUNCServerName, String lpFileName);
/**
* Reads the specified number of entries from the specified event log. The
* function can be used to read log entries in chronological or reverse
* chronological order.
*
* @param hEventLog A handle to the event log to be read. The OpenEventLog
* function returns this handle.
* @param dwReadFlags Use the following flag values to indicate how to read
* the log file.
* @param dwRecordOffset The record number of the log-entry at which the
* read operation should start. This parameter is ignored unless dwReadFlags
* includes the EVENTLOG_SEEK_READ flag.
* @param lpBuffer An application-allocated buffer that will receive one or
* more EVENTLOGRECORD structures. This parameter cannot be NULL, even if
* the nNumberOfBytesToRead parameter is zero. The maximum size of this
* buffer is 0x7ffff bytes.
* @param nNumberOfBytesToRead The size of the lpBuffer buffer, in bytes.
* This function will read as many log entries as will fit in the buffer;
* the function will not return partial entries.
* @param pnBytesRead A pointer to a variable that receives the number of
* bytes read by the function.
* @param pnMinNumberOfBytesNeeded A pointer to a variable that receives the
* required size of the lpBuffer buffer. This value is valid only this
* function returns zero and GetLastError returns ERROR_INSUFFICIENT_BUFFER.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean ReadEventLog(HANDLE hEventLog, int dwReadFlags, int dwRecordOffset,
Pointer lpBuffer, int nNumberOfBytesToRead, IntByReference pnBytesRead,
IntByReference pnMinNumberOfBytesNeeded);
/**
* The GetOldestEventLogRecord function retrieves the absolute record number
* of the oldest record in the specified event log.
*
* @param hEventLog Handle to the open event log. This handle is returned by
* the OpenEventLog or OpenBackupEventLog function.
* @param OldestRecord Pointer to a variable that receives the absolute
* record number of the oldest record in the specified event log.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean GetOldestEventLogRecord(HANDLE hEventLog, IntByReference OldestRecord);
/**
* Creates a new process and its primary thread. The new process runs in the
* security context of the user represented by the specified token.
*
* Typically, the process that calls the CreateProcessAsUser function must
* have the SE_INCREASE_QUOTA_NAME privilege and may require the
* SE_ASSIGNPRIMARYTOKEN_NAME privilege if the token is not assignable. If
* this function fails with ERROR_PRIVILEGE_NOT_HELD (1314), use the
* CreateProcessWithLogonW function instead. CreateProcessWithLogonW
* requires no special privileges, but the specified user account must be
* allowed to log on interactively. Generally, it is best to use
* CreateProcessWithLogonW to create a process with alternate credentials.
*
* @param hToken A handle to the primary token that represents a user.
* @param lpApplicationName The name of the module to be executed.
* @param lpCommandLine The command line to be executed.
* @param lpProcessAttributes A pointer to a SECURITY_ATTRIBUTES structure
* that specifies a security descriptor for the new process object and
* determines whether child processes can inherit the returned handle to the
* process.
* @param lpThreadAttributes A pointer to a SECURITY_ATTRIBUTES structure
* that specifies a security descriptor for the new thread object and
* determines whether child processes can inherit the returned handle to the
* thread.
* @param bInheritHandles If this parameter is TRUE, each inheritable handle
* in the calling process is inherited by the new process. If the parameter
* is FALSE, the handles are not inherited. Note that inherited handles have
* the same value and access rights as the original handles.
* @param dwCreationFlags The flags that control the priority class and the
* creation of the process. For a list of values, see Process Creation
* Flags.
* @param lpEnvironment A pointer to an environment block for the new
* process. If this parameter is NULL, the new process uses the environment
* of the calling process.
*
* An environment block consists of a null-terminated block of
* null-terminated strings. Each string is in the following form:
* name=value\0
* @param lpCurrentDirectory The full path to the current directory for the
* process. The string can also specify a UNC path.
* @param lpStartupInfo A pointer to a STARTUPINFO or STARTUPINFOEX
* structure.
* @param lpProcessInformation A pointer to a PROCESS_INFORMATION structure
* that receives identification information about the new process.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean CreateProcessAsUser(
HANDLE hToken,
String lpApplicationName,
String lpCommandLine,
SECURITY_ATTRIBUTES lpProcessAttributes,
SECURITY_ATTRIBUTES lpThreadAttributes,
boolean bInheritHandles,
int dwCreationFlags,
String lpEnvironment,
String lpCurrentDirectory,
WinBase.STARTUPINFO lpStartupInfo,
WinBase.PROCESS_INFORMATION lpProcessInformation);
/**
* The AdjustTokenPrivileges function enables or disables privileges in the
* specified access token. Enabling or disabling privileges in an access
* token requires TOKEN_ADJUST_PRIVILEGES access.
*
* @param TokenHandle A handle to the access token that contains the
* privileges to be modified.
* @param DisableAllPrivileges Specifies whether the function disables all
* of the token's privileges.
* @param NewState A pointer to a TOKEN_PRIVILEGES structure that specifies
* an array of privileges and their attributes.
* @param BufferLength Specifies the size, in bytes, of the buffer pointed
* to by the PreviousState parameter. This parameter can be zero if the
* PreviousState parameter is NULL.
* @param PreviousState A pointer to a buffer that the function fills with a
* TOKEN_PRIVILEGES structure that contains the previous state of any
* privileges that the function modifies.
* @param ReturnLength A pointer to a variable that receives the required
* size, in bytes, of the buffer pointed to by the PreviousState parameter.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean AdjustTokenPrivileges(
HANDLE TokenHandle,
boolean DisableAllPrivileges,
WinNT.TOKEN_PRIVILEGES NewState,
int BufferLength,
WinNT.TOKEN_PRIVILEGES PreviousState,
IntByReference ReturnLength);
/**
* The LookupPrivilegeName function retrieves the name that corresponds to
* the privilege represented on a specific system by a specified locally
* unique identifier (LUID).
*
* @param lpSystemName A pointer to a null-terminated string that specifies
* the name of the system on which the privilege name is retrieved. If a
* null string is specified, the function attempts to find the privilege
* name on the local system.
* @param lpLuid A pointer to the LUID by which the privilege is known on
* the target system.
* @param lpName A pointer to a buffer that receives a null-terminated
* string that represents the privilege name. For example, this string could
* be "SeSecurityPrivilege".
* @param cchName A pointer to a variable that specifies the size, in a
* TCHAR value, of the lpName buffer.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean LookupPrivilegeName(
String lpSystemName,
WinNT.LUID lpLuid,
char[] lpName,
IntByReference cchName);
/**
* The LookupPrivilegeValue function retrieves the locally unique identifier
* (LUID) used on a specified system to locally represent the specified
* privilege name.
*
* @param lpSystemName A pointer to a null-terminated string that specifies
* the name of the system on which the privilege name is retrieved. If a
* null string is specified, the function attempts to find the privilege
* name on the local system.
* @param lpName A pointer to a null-terminated string that specifies the
* name of the privilege, as defined in the Winnt.h header file. For
* example, this parameter could specify the constant, SE_SECURITY_NAME, or
* its corresponding string, "SeSecurityPrivilege".
* @param lpLuid A pointer to a variable that receives the LUID by which the
* privilege is known on the system specified by the lpSystemName parameter.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
public boolean LookupPrivilegeValue(
String lpSystemName,
String lpName,
WinNT.LUID lpLuid);
}
@@ -0,0 +1,982 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sun.jna.platform.win32;
/**
*
* @author JPEXS
*/
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
/**
* Advapi32 utility API.
*
* @author dblock[at]dblock.org
*/
public abstract class Advapi32Util {
/**
* An account.
*/
public static class Account {
/**
* Account name.
*/
public String name;
/**
* Account domain.
*/
public String domain;
/**
* Account SID.
*/
public byte[] sid;
/**
* String representation of the account SID.
*/
public String sidString;
/**
* Account type, one of SID_NAME_USE.
*/
public int accountType;
/**
* Fully qualified account name.
*/
public String fqn;
}
/**
* Checks whether a registry key exists.
*
* @param root HKEY_LOCAL_MACHINE, etc.
* @param key Path to the registry key.
* @return True if the key exists.
*/
public static boolean registryKeyExists(HKEY root, String key) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
switch (rc) {
case W32Errors.ERROR_SUCCESS:
Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
return true;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
}
/**
* Checks whether a registry value exists.
*
* @param root HKEY_LOCAL_MACHINE, etc.
* @param key Registry key path.
* @param value Value name.
* @return True if the value exists.
*/
public static boolean registryValueExists(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
try {
switch (rc) {
case W32Errors.ERROR_SUCCESS:
break;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
switch (rc) {
case W32Errors.ERROR_SUCCESS:
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
return true;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
} finally {
if (phkKey.getValue() != null && phkKey.getValue() != WinBase.INVALID_HANDLE_VALUE) {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get a registry REG_SZ value.
*
* @param root Root key.
* @param key Registry path.
* @param value Name of the value to retrieve.
* @return String value.
*/
public static String registryGetStringValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_SZ) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
char[] data = new char[lpcbData.getValue()];
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return Native.toString(data);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry REG_EXPAND_SZ value.
*
* @param root Root key.
* @param key Registry path.
* @param value Name of the value to retrieve.
* @return String value.
*/
public static String registryGetExpandableStringValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_EXPAND_SZ) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
char[] data = new char[lpcbData.getValue()];
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return Native.toString(data);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry REG_MULTI_SZ value.
*
* @param root Root key.
* @param key Registry path.
* @param value Name of the value to retrieve.
* @return String value.
*/
public static String[] registryGetStringArray(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_MULTI_SZ) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
Memory data = new Memory(lpcbData.getValue());
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
ArrayList<String> result = new ArrayList<>();
int offset = 0;
while (offset < data.size()) {
String s = data.getString(offset, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
result.add(s);
}
return result.toArray(new String[result.size()]);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry REG_BINARY value.
*
* @param root Root key.
* @param key Registry path.
* @param value Name of the value to retrieve.
* @return String value.
*/
public static byte[] registryGetBinaryValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_BINARY) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_BINARY");
}
byte[] data = new byte[lpcbData.getValue()];
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return data;
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry DWORD value.
*
* @param root Root key.
* @param key Registry key path.
* @param value Name of the value to retrieve.
* @return Integer value.
*/
public static int registryGetIntValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_DWORD) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
IntByReference data = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return data.getValue();
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Create a registry key.
*
* @param hKey Parent key.
* @param keyName Key name.
* @return True if the key was created, false otherwise.
*/
public static boolean registryCreateKey(HKEY hKey, String keyName) {
HKEYByReference phkResult = new HKEYByReference();
IntByReference lpdwDisposition = new IntByReference();
int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, WinNT.REG_OPTION_NON_VOLATILE,
WinNT.KEY_READ, null, phkResult, lpdwDisposition);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
return WinNT.REG_CREATED_NEW_KEY == lpdwDisposition.getValue();
}
/**
* Create a registry key.
*
* @param root Root key.
* @param parentPath Path to an existing registry key.
* @param keyName Key name.
* @return True if the key was created, false otherwise.
*/
public static boolean registryCreateKey(HKEY root, String parentPath, String keyName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, parentPath, 0, WinNT.KEY_CREATE_SUB_KEY, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
return registryCreateKey(phkKey.getValue(), keyName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set an integer value in registry.
*
* @param hKey Parent key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetIntValue(HKEY hKey, String name, int value) {
byte[] data = new byte[4];
data[0] = (byte) (value & 0xff);
data[1] = (byte) ((value >> 8) & 0xff);
data[2] = (byte) ((value >> 16) & 0xff);
data[3] = (byte) ((value >> 24) & 0xff);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_DWORD, data, 4);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set an integer value in registry.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetIntValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a string value in registry.
*
* @param hKey Parent key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetStringValue(HKEY hKey, String name, String value) {
char[] data = Native.toCharArray(value);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ,
data, data.length * Native.WCHAR_SIZE);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a string value in registry.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetStringValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set an expandable string value in registry.
*
* @param hKey Parent key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetExpandableStringValue(HKEY hKey, String name, String value) {
char[] data = Native.toCharArray(value);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_EXPAND_SZ,
data, data.length * Native.WCHAR_SIZE);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a string value in registry.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param name Value name.
* @param value Value to write to registry.
*/
public static void registrySetExpandableStringValue(HKEY root, String keyPath, String name, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetExpandableStringValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a string array value in registry.
*
* @param hKey Parent key.
* @param name Name.
* @param arr Array of strings to write to registry.
*/
public static void registrySetStringArray(HKEY hKey, String name, String[] arr) {
int size = 0;
for (String s : arr) {
size += s.length() * Native.WCHAR_SIZE;
size += Native.WCHAR_SIZE;
}
int offset = 0;
Memory data = new Memory(size);
for (String s : arr) {
data.setString(offset, s, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
}
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_MULTI_SZ,
data.getByteArray(0, size), size);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a string array value in registry.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param name Value name.
* @param arr Array of strings to write to registry.
*/
public static void registrySetStringArray(HKEY root, String keyPath, String name, String[] arr) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetStringArray(phkKey.getValue(), name, arr);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a binary value in registry.
*
* @param hKey Parent key.
* @param name Value name.
* @param data Data to write to registry.
*/
public static void registrySetBinaryValue(HKEY hKey, String name, byte[] data) {
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_BINARY, data, data.length);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a binary value in registry.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param name Value name.
* @param data Data to write to registry.
*/
public static void registrySetBinaryValue(HKEY root, String keyPath, String name, byte[] data) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetBinaryValue(phkKey.getValue(), name, data);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Delete a registry key.
*
* @param hKey Parent key.
* @param keyName Name of the key to delete.
*/
public static void registryDeleteKey(HKEY hKey, String keyName) {
int rc = Advapi32.INSTANCE.RegDeleteKey(hKey, keyName);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Delete a registry key.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param keyName Name of the key to delete.
*/
public static void registryDeleteKey(HKEY root, String keyPath, String keyName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registryDeleteKey(phkKey.getValue(), keyName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Delete a registry value.
*
* @param hKey Parent key.
* @param valueName Name of the value to delete.
*/
public static void registryDeleteValue(HKEY hKey, String valueName) {
int rc = Advapi32.INSTANCE.RegDeleteValue(hKey, valueName);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Delete a registry value.
*
* @param root Root key.
* @param keyPath Path to an existing registry key.
* @param valueName Name of the value to delete.
*/
public static void registryDeleteValue(HKEY root, String keyPath, String valueName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registryDeleteValue(phkKey.getValue(), valueName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get names of the registry key's sub-keys.
*
* @param hKey Registry key.
* @return Array of registry key names.
*/
public static String[] registryGetKeys(HKEY hKey) {
IntByReference lpcSubKeys = new IntByReference();
IntByReference lpcMaxSubKeyLen = new IntByReference();
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null,
lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
ArrayList<String> keys = new ArrayList<>(lpcSubKeys.getValue());
char[] name = new char[lpcMaxSubKeyLen.getValue() + 1];
for (int i = 0; i < lpcSubKeys.getValue(); i++) {
IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1);
rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName,
null, null, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
keys.add(Native.toString(name));
}
return keys.toArray(new String[keys.size()]);
}
/**
* Get names of the registry key's sub-keys.
*
* @param root Root key.
* @param keyPath Path to a registry key.
* @return Array of registry key names.
*/
public static String[] registryGetKeys(HKEY root, String keyPath) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
return registryGetKeys(phkKey.getValue());
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a table of registry values.
*
* @param hKey Registry key.
* @return Table of values.
*/
public static TreeMap<String, Object> registryGetValues(HKEY hKey) {
IntByReference lpcValues = new IntByReference();
IntByReference lpcMaxValueNameLen = new IntByReference();
IntByReference lpcMaxValueLen = new IntByReference();
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null, null,
null, null, lpcValues, lpcMaxValueNameLen, lpcMaxValueLen, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
TreeMap<String, Object> keyValues = new TreeMap<>();
char[] name = new char[lpcMaxValueNameLen.getValue() + 1];
byte[] data = new byte[lpcMaxValueLen.getValue()];
for (int i = 0; i < lpcValues.getValue(); i++) {
IntByReference lpcchValueName = new IntByReference(lpcMaxValueNameLen.getValue() + 1);
IntByReference lpcbData = new IntByReference(lpcMaxValueLen.getValue());
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegEnumValue(hKey, i, name, lpcchValueName, null,
lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
String nameString = Native.toString(name);
Memory byteData = new Memory(lpcbData.getValue());
byteData.write(0, data, 0, lpcbData.getValue());
switch (lpType.getValue()) {
case WinNT.REG_DWORD: {
keyValues.put(nameString, byteData.getInt(0));
break;
}
case WinNT.REG_SZ:
case WinNT.REG_EXPAND_SZ: {
keyValues.put(nameString, byteData.getString(0, true));
break;
}
case WinNT.REG_BINARY: {
keyValues.put(nameString, byteData.getByteArray(0, lpcbData.getValue()));
break;
}
case WinNT.REG_MULTI_SZ: {
Memory stringData = new Memory(lpcbData.getValue());
stringData.write(0, data, 0, lpcbData.getValue());
ArrayList<String> result = new ArrayList<>();
int offset = 0;
while (offset < stringData.size()) {
String s = stringData.getString(offset, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
result.add(s);
}
keyValues.put(nameString, result.toArray(new String[result.size()]));
break;
}
default:
throw new RuntimeException("Unsupported type: " + lpType.getValue());
}
}
return keyValues;
}
/**
* Get a table of registry values.
*
* @param root Registry root.
* @param keyPath Regitry key path.
* @return Table of values.
*/
public static TreeMap<String, Object> registryGetValues(HKEY root, String keyPath) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
return registryGetValues(phkKey.getValue());
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Converts a map of environment variables to an environment block suitable
* for {@link Advapi32#CreateProcessAsUser}. This environment block consists
* of null-terminated blocks of null-terminated strings. Each string is in
* the following form: name=value\0
*
* @param environment Environment variables
* @return A environment block
*/
public static String getEnvironmentBlock(Map<String, String> environment) {
StringBuilder out = new StringBuilder();
for (Entry<String, String> entry : environment.entrySet()) {
if (entry.getValue() != null) {
out.append(entry.getKey()).append("=").append(entry.getValue()).append("\0");
}
}
return out.toString() + "\0";
}
/**
* Event log types.
*/
public static enum EventLogType {
Error,
Warning,
Informational,
AuditSuccess,
AuditFailure
}
/**
* An event log record.
*/
public static class EventLogRecord {
private EVENTLOGRECORD _record = null;
private final String _source;
private byte[] _data;
private String[] _strings;
/**
* Raw record data.
*
* @return EVENTLOGRECORD.
*/
public EVENTLOGRECORD getRecord() {
return _record;
}
/**
* Event Id.
*
* @return Integer.
*/
public int getEventId() {
return _record.EventID.intValue();
}
/**
* Event source.
*
* @return String.
*/
public String getSource() {
return _source;
}
/**
* Status code for the facility, part of the Event ID.
*
* @return Status code.
*/
public int getStatusCode() {
return _record.EventID.intValue() & 0xFFFF;
}
/**
* 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.
*
* @return Integer.
*/
public int getRecordNumber() {
return _record.RecordNumber.intValue();
}
/**
* Record length, with data.
*
* @return Number of bytes in the record including data.
*/
public int getLength() {
return _record.Length.intValue();
}
/**
* Strings associated with this event.
*
* @return Array of strings or null.
*/
public String[] getStrings() {
return _strings;
}
/**
* Event log type.
*
* @return Event log type.
*/
public EventLogType getType() {
switch (_record.EventType.intValue()) {
case WinNT.EVENTLOG_SUCCESS:
case WinNT.EVENTLOG_INFORMATION_TYPE:
return EventLogType.Informational;
case WinNT.EVENTLOG_AUDIT_FAILURE:
return EventLogType.AuditFailure;
case WinNT.EVENTLOG_AUDIT_SUCCESS:
return EventLogType.AuditSuccess;
case WinNT.EVENTLOG_ERROR_TYPE:
return EventLogType.Error;
case WinNT.EVENTLOG_WARNING_TYPE:
return EventLogType.Warning;
default:
throw new RuntimeException("Invalid type: " + _record.EventType.intValue());
}
}
/**
* Raw data associated with the record.
*
* @return Array of bytes or null.
*/
public byte[] getData() {
return _data;
}
public EventLogRecord(Pointer pevlr) {
_record = new EVENTLOGRECORD(pevlr);
_source = pevlr.getString(_record.size(), true);
// data
if (_record.DataLength.intValue() > 0) {
_data = pevlr.getByteArray(_record.DataOffset.intValue(),
_record.DataLength.intValue());
}
// strings
if (_record.NumStrings.intValue() > 0) {
ArrayList<String> strings = new ArrayList<>();
int count = _record.NumStrings.intValue();
long offset = _record.StringOffset.intValue();
while (count > 0) {
String s = pevlr.getString(offset, true);
strings.add(s);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
count--;
}
_strings = strings.toArray(new String[strings.size()]);
}
}
}
}
@@ -0,0 +1,32 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.LONG;
import com.sun.jna.platform.win32.WinDef.LPVOID;
import com.sun.jna.platform.win32.WinDef.WORD;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class BITMAP extends Structure {
public LONG bmType;
public LONG bmWidth;
public LONG bmHeight;
public LONG bmWidthBytes;
public WORD bmPlanes;
public WORD bmBitsPixel;
public LPVOID bmBits;
@Override
protected List getFieldOrder() {
return Arrays.asList("bmType", "bmWidth", "bmHeight", "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits");
}
}
+136
View File
@@ -0,0 +1,136 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on basetsd.h (various types)
*
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision. Use when casting a pointer to a
* long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* PULONG_PTR
*/
public static final class ULONG_PTRByReference extends ByReference {
public ULONG_PTRByReference() {
this(new ULONG_PTR(0));
}
public ULONG_PTRByReference(ULONG_PTR value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(ULONG_PTR value) {
if (Pointer.SIZE == 4) {
getPointer().setInt(0, value.intValue());
} else {
getPointer().setLong(0, value.longValue());
}
}
public ULONG_PTR getValue() {
return new ULONG_PTR(Pointer.SIZE == 4
? getPointer().getInt(0)
: getPointer().getLong(0));
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point. Use for a count
* that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
+320
View File
@@ -0,0 +1,320 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.WinDef.HRGN;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Definition (incomplete) of <code>gdi32.dll</code>.
*/
public interface Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = (Gdi32) Native.loadLibrary("gdi32", Gdi32.class,
W32APIOptions.DEFAULT_OPTIONS);
/**
* The ExtCreateRegion function creates a region from the specified region
* and transformation data.
*
* @param lpXform Pointer to an XFORM structure that defines the
* transformation to be performed on the region. If this pointer is NULL,
* the identity transformation is used.
* @param nCount Specifies the number of bytes pointed to by lpRgnData.
* @param lpRgnData Pointer to a RGNDATA structure that contains the region
* data in logical units.
* @return If the function succeeds, the return value is the value of the
* region. If the function fails, the return value is NULL. To get extended
* error information, call GetLastError.
*/
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
/**
* The CombineRgn function combines two regions and stores the result in a
* third region. The two regions are combined according to the specified
* mode.
*
* @param hrgnDest Handle to a new region with dimensions defined by
* combining two other regions.
* @param hrgnSrc1 Handle to the first of two regions to be combined.
* @param hrgnSrc2 Handle to the second of two regions to be combined.
* @param fnCombineMode Specifies a mode indicating how the two regions will
* be combined.
* @return The return value specifies the type of the resulting region.
*/
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
int fnCombineMode);
/**
* The CreateRectRgn function creates a rectangular region.
*
* @param nLeftRect Specifies the x-coordinate of the upper-left corner of
* the region in logical units.
* @param nTopRect Specifies the y-coordinate of the upper-left corner of
* the region in logical units.
* @param nRightRect Specifies the x-coordinate of the lower-right corner of
* the region in logical units.
* @param nBottomRect Specifies the y-coordinate of the lower-right corner
* of the region in logical units.
* @return If the function succeeds, the return value is the handle to the
* region. If the function fails, the return value is NULL. To get extended
* error information, call GetLastError.
*/
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The CreateRoundRectRgn function creates a rectangular region with rounded
* corners.
*
* @param nLeftRect Specifies the x-coordinate of the upper-left corner of
* the region in logical units.
* @param nTopRect Specifies the y-coordinate of the upper-left corner of
* the region in logical units.
* @param nRightRect Specifies the x-coordinate of the lower-right corner of
* the region in logical units.
* @param nBottomRect Specifies the y-coordinate of the lower-right corner
* of the region in logical units.
* @param nWidthEllipse Specifies the width of the ellipse used to create
* the rounded corners in logical units.
* @param nHeightEllipse Specifies the height of the ellipse used to create
* the rounded corners in logical units.
* @return If the function succeeds, the return value is the handle to the
* region. If the function fails, the return value is NULL. To get extended
* error information, call GetLastError.
*/
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
/**
* The CreatePolyPolygonRgn function creates a region consisting of a series
* of polygons. The polygons can overlap.
*
* @param lppt Pointer to an array of POINT structures that define the
* vertices of the polygons in logical units. The polygons are specified
* consecutively. Each polygon is presumed closed and each vertex is
* specified only once.
* @param lpPolyCounts Pointer to an array of integers, each of which
* specifies the number of points in one of the polygons in the array
* pointed to by lppt.
* @param nCount Specifies the total number of integers in the array pointed
* to by lpPolyCounts.
* @param fnPolyFillMode Specifies the fill mode used to determine which
* pixels are in the region.
* @return If the function succeeds, the return value is the handle to the
* region. If the function fails, the return value is zero. To get extended
* error information, call GetLastError.
*/
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
int nCount, int fnPolyFillMode);
/**
* The SetRectRgn function converts a region into a rectangular region with
* the specified coordinates.
*
* @param hrgn Handle to the region.
* @param nLeftRect Specifies the x-coordinate of the upper-left corner of
* the rectangular region in logical units.
* @param nTopRect Specifies the y-coordinate of the upper-left corner of
* the rectangular region in logical units.
* @param nRightRect Specifies the x-coordinate of the lower-right corner of
* the rectangular region in logical units.
* @param nBottomRect Specifies the y-coordinate of the lower-right corner
* of the rectangular region in logical units.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The SetPixel function sets the pixel at the specified coordinates to the
* specified color.
*
* @param hDC Handle to the device context.
* @param x Specifies the x-coordinate, in logical units, of the point to be
* set.
* @param y Specifies the y-coordinate, in logical units, of the point to be
* set.
* @param crColor Specifies the color to be used to paint the point. To
* create a COLORREF color value, use the RGB macro.
* @return If the function succeeds, the return value is the RGB value that
* the function sets the pixel to. This value may differ from the color
* specified by crColor; that occurs when an exact match for the specified
* color cannot be found. If the function fails, the return value is 1. To
* get extended error information, call GetLastError. This can be the
* following value.
*/
int SetPixel(HDC hDC, int x, int y, int crColor);
/**
* The CreateCompatibleDC function creates a memory device context (DC)
* compatible with the specified device.
*
* @param hDC Handle to an existing DC. If this handle is NULL, the function
* creates a memory DC compatible with the application's current screen.
* @return If the function succeeds, the return value is the handle to a
* memory DC. If the function fails, the return value is NULL. To get
* extended error information, call GetLastError.
*/
HDC CreateCompatibleDC(HDC hDC);
/**
* The DeleteDC function deletes the specified device context (DC).
*
* @param hDC Handle to the device context.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean DeleteDC(HDC hDC);
/**
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB
* and, optionally, sets the bitmap bits.
*
* @param hDC Handle to a device context.
* @param lpbmih Pointer to a bitmap information header structure, which may
* be one of those shown in the following table.
* @param fdwInit Specifies how the system initializes the bitmap bits.
* @param lpbInit Pointer to an array of bytes containing the initial bitmap
* data.
* @param lpbmi Pointer to a BITMAPINFO structure that describes the
* dimensions and color format of the array pointed to by the lpbInit
* parameter.
* @param fuUsage Specifies whether the bmiColors member of the BITMAPINFO
* structure was initialized and, if so, whether bmiColors contains explicit
* red, green, blue (RGB) values or palette indexes. The fuUsage parameter
* must be one of the following values.
* @return If the function succeeds, the return value is a handle to the
* compatible bitmap. If the function fails, the return value is NULL. To
* get extended error information, call GetLastError.
*/
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
/**
* The CreateDIBSection function creates a DIB that applications can write
* to directly. The function gives you a pointer to the location of the
* bitmap bit values. You can supply a handle to a file-mapping object that
* the function will use to create the bitmap, or you can let the system
* allocate the memory for the bitmap.
*
* @param hDC Handle to a device context. If the value of iUsage is
* DIB_PAL_COLORS, the function uses this device context's logical palette
* to initialize the DIB colors.
* @param pbmi Pointer to a BITMAPINFO structure that specifies various
* attributes of the DIB, including the bitmap dimensions and colors.
* @param iUsage Specifies the type of data contained in the bmiColors array
* member of the BITMAPINFO structure pointed to by pbmi (either logical
* palette indexes or literal RGB values).
* @param ppvBits Pointer to a variable that receives a pointer to the
* location of the DIB bit values.
* @param hSection Handle to a file-mapping object that the function will
* use to create the DIB. This parameter can be NULL.
* @param dwOffset Specifies the offset from the beginning of the
* file-mapping object referenced by hSection where storage for the bitmap
* bit values is to begin.
* @return Specifies the offset from the beginning of the file-mapping
* object referenced by hSection where storage for the bitmap bit values is
* to begin.
*/
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
PointerByReference ppvBits, Pointer hSection, int dwOffset);
/**
* The CreateCompatibleBitmap function creates a bitmap compatible with the
* device that is associated with the specified device context.
*
* @param hDC Handle to a device context.
* @param width Specifies the bitmap width, in pixels.
* @param height Specifies the bitmap height, in pixels.
* @return If the function succeeds, the return value is a handle to the
* compatible bitmap (DDB). If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
/**
* The SelectObject function selects an object into the specified device
* context (DC). The new object replaces the previous object of the same
* type.
*
* @param hDC Handle to the DC.
* @param hGDIObj Handle to the object to be selected.
* @return If the selected object is not a region and the function succeeds,
* the return value is a handle to the object being replaced. If the
* selected object is a region and the function succeeds, the return value
* is one of the REGION values.
*/
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
/**
* The DeleteObject function deletes a logical pen, brush, font, bitmap,
* region, or palette, freeing all system resources associated with the
* object. After the object is deleted, the specified handle is no longer
* valid.
*
* @param hObject Handle to a logical pen, brush, font, bitmap, region, or
* palette.
* @return If the function succeeds, the return value is nonzero. If the
* specified handle is not valid or is currently selected into a DC, the
* return value is zero. To get extended error information, call
* GetLastError.
*/
boolean DeleteObject(HANDLE hObject);
/**
* The GetDeviceCaps function retrieves device-specific information for the
* specified device.
*
* @param hdc A handle to the DC.
* @param nIndex The item to be returned.
* @return The return value specifies the value of the desired item. When
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
* 16bpp, the return value is 16.
*/
int GetDeviceCaps(HDC hdc, int nIndex);
/**
* The GetDIBits function retrieves the bits fo the specified compatible
* bitmap and copies them into a buffer as a DIB using the specified format.
*
* @param hdc A handle to the device context.
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
* (DDB).
* @param uStartScan The first scan line to retrieve
* @param cScanLines The number of scan lines to retrieve.
* @param lpvBits A pointer to a buffer to receive the bitmap data. If this
* parameter is <code>null</code>, the function passes the dimensions and
* format of the bitmap to the {@link BITMAPINFO} structure pointed to by
* the <i>lpbi</i> parameter.
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
* the desired format for the DIB data.
* @param uUsage The format of the bmiColors member of the {@link
* BITMAPINFO} structure.
* @return
*/
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
int GetObject(HANDLE hgdiobj, int cbBuffer, Structure lpvObject);
DWORD GetPixel(HDC hdc, int nXPos, int nYPos);
HANDLE CreateSolidBrush(DWORD crColor);
}
@@ -0,0 +1,29 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class ICONINFO extends Structure {
public boolean fIcon;
public DWORD xHotspot;
public DWORD yHotspot;
public HBITMAP hbmMask;
public HBITMAP hbmColor;
@Override
protected List getFieldOrder() {
return Arrays.asList("fIcon", "xHotspot", "yHotspot", "hbmMask", "hbmColor");
}
}
@@ -0,0 +1,300 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.W32APIOptions;
// TODO: Auto-generated Javadoc
/**
* Interface definitions for <code>kernel32.dll</code>. Includes additional
* alternate mappings from {@link WinNT} which make use of NIO buffers.
*/
public interface Kernel32 extends WinNT {
/**
* The instance.
*/
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32",
Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CloseHandle function closes an open object handle.
*
* @param hObject Handle to an open object. This parameter can be a pseudo
* handle or INVALID_HANDLE_VALUE.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean CloseHandle(HANDLE hObject);
/**
* Terminates the specified process and all of its threads.
*
* @param hProcess A handle to the process to be terminated.
* @param uExitCode The exit code to be used by the process and threads
* terminated as a result of this call.
* @return If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended error
* information, call GetLastError.
*/
boolean TerminateProcess(HANDLE hProcess, int uExitCode);
/**
* Writes data to the specified file or input/output (I/O) device.
*
* @param hFile A handle to the file or I/O device (for example, a file,
* file stream, physical disk, volume, console buffer, tape drive, socket,
* communications resource, mailslot, or pipe).
* @param lpBuffer A pointer to the buffer containing the data to be written
* to the file or device.
* @param nNumberOfBytesToWrite The number of bytes to be written to the
* file or device.
* @param lpNumberOfBytesWritten A pointer to the variable that receives the
* number of bytes written when using a synchronous hFile parameter.
* @param lpOverlapped A pointer to an OVERLAPPED structure is required if
* the hFile parameter was opened with FILE_FLAG_OVERLAPPED, otherwise this
* parameter can be NULL.
* @return If the function succeeds, the return value is nonzero (TRUE). If
* the function fails, or is completing asynchronously, the return value is
* zero (FALSE). To get extended error information, call the GetLastError
* function.
*/
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
IntByReference lpNumberOfBytesWritten,
WinBase.OVERLAPPED lpOverlapped);
boolean ReadFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToRead, IntByReference lpNumberOfBytesRead, WinBase.OVERLAPPED lpOverlapped);
//
// Define the NamedPipe definitions
//
//
// Define the dwOpenMode values for CreateNamedPipe
//
public static final int PIPE_ACCESS_INBOUND = 0x00000001;
public static final int PIPE_ACCESS_OUTBOUND = 0x00000002;
public static final int PIPE_ACCESS_DUPLEX = 0x00000003;
//
// Define the Named Pipe End flags for GetNamedPipeInfo
//
public static final int PIPE_CLIENT_END = 0x00000000;
public static final int PIPE_SERVER_END = 0x00000001;
//
// Define the dwPipeMode values for CreateNamedPipe
//
public static final int PIPE_WAIT = 0x00000000;
public static final int PIPE_NOWAIT = 0x00000001;
public static final int PIPE_READMODE_BYTE = 0x00000000;
public static final int PIPE_READMODE_MESSAGE = 0x00000002;
public static final int PIPE_TYPE_BYTE = 0x00000000;
public static final int PIPE_TYPE_MESSAGE = 0x00000004;
public static final int PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000;
public static final int PIPE_REJECT_REMOTE_CLIENTS = 0x00000008;
//
// Define the well known values for CreateNamedPipe nMaxInstances
//
public static final int PIPE_UNLIMITED_INSTANCES = 255;
//
// Define the values for process priority
//
public static final int ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000;
public static final int BELOW_NORMAL_PRIORITY_CLASS = 0x00004000;
public static final int HIGH_PRIORITY_CLASS = 0x00000080;
public static final int IDLE_PRIORITY_CLASS = 0x00000040;
public static final int NORMAL_PRIORITY_CLASS = 0x00000020;
public static final int PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000;
public static final int PROCESS_MODE_BACKGROUND_END = 0x00200000;
public static final int REALTIME_PRIORITY_CLASS = 0x00000100;
// __out
// HANDLE
// WINAPI
// CreateNamedPipe(
// __in LPCWSTR lpName,
// __in DWORD dwOpenMode,
// __in DWORD dwPipeMode,
// __in DWORD nMaxInstances,
// __in DWORD nOutBufferSize,
// __in DWORD nInBufferSize,
// __in DWORD nDefaultTimeOut,
// __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
// );
HANDLE CreateNamedPipe(String lpName, int dwOpenMode, int dwPipeMode, int nMaxInstances, int nOutBufferSize, int nInBufferSize, int nDefaultTimeOut,
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
// WINBASEAPI
// BOOL
// WINAPI
// ConnectNamedPipe(
// __in HANDLE hNamedPipe,
// __inout_opt LPOVERLAPPED lpOverlapped
// );
boolean ConnectNamedPipe(HANDLE hNamedPipe, WinBase.OVERLAPPED lpOverlapped);
// WINBASEAPI
// BOOL
// WINAPI
// DisconnectNamedPipe(
// __in HANDLE hNamedPipe
// );
boolean DisconnectNamedPipe(HANDLE hNamedPipe);
/**
* Waits until the specified object is in the signaled state or the time-out
* interval elapses. To enter an alertable wait state, use the
* WaitForSingleObjectEx function. To wait for multiple objects, use the
* WaitForMultipleObjects.
*
* @param hHandle A handle to the object. For a list of the object types
* whose handles can be specified, see the following Remarks section. If
* this handle is closed while the wait is still pending, the function's
* behavior is undefined. The handle must have the SYNCHRONIZE access right.
* For more information, see Standard Access Rights.
* @param dwMilliseconds The time-out interval, in milliseconds. If a
* nonzero value is specified, the function waits until the object is
* signaled or the interval elapses. If dwMilliseconds is zero, the function
* does not enter a wait state if the object is not signaled; it always
* returns immediately. If dwMilliseconds is INFINITE, the function will
* return only when the object is signaled.
* @return If the function succeeds, the return value indicates the event
* that caused the function to return.
*/
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
/**
* This function returns a pseudohandle for the current process.
*
* @return The return value is a pseudohandle to the current process.
*/
HANDLE GetCurrentProcess();
int SetProcessAffinityMask(HANDLE hProcess, int mask);
int SetPriorityClass(HANDLE hProcess, int dwPriorityClass);
/**
* This function returns a handle to an existing process object.
*
* @param fdwAccess Not supported; set to zero.
* @param fInherit Not supported; set to FALSE.
* @param IDProcess Specifies the process identifier of the process to open.
* @return An open handle to the specified process indicates success. NULL
* indicates failure. To get extended error information, call GetLastError.
*/
HANDLE OpenProcess(int fdwAccess, boolean fInherit, DWORD IDProcess);
/**
* The GetSystemInfo function returns information about the current system.
*
* @param lpSystemInfo Pointer to a SYSTEM_INFO structure that receives the
* information.
*/
void GetSystemInfo(SYSTEM_INFO lpSystemInfo);
public static final int PROCESS_VM_READ = 0x0010;
public static final int PROCESS_VM_WRITE = 0x0020;
public static final int PROCESS_QUERY_INFORMATION = 0x0400;
public static final int PROCESS_VM_OPERATION = 0x0008;
SIZE_T VirtualQueryEx(HANDLE hProcess, Pointer lpAddress, MEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
/**
* The GetLastError function retrieves the calling thread's last-error code
* value. The last-error code is maintained on a per-thread basis. Multiple
* threads do not overwrite each other's last-error code.
*
* @return The return value is the calling thread's last-error code value.
*/
int GetLastError();
public static int MEM_COMMIT = 0x1000;
public static int MEM_FREE = 0x10000;
public static int MEM_RESERVE = 0x2000;
public static int MEM_IMAGE = 0x1000000;
public static int MEM_MAPPED = 0x40000;
public static int MEM_PRIVATE = 0x20000;
boolean ReadProcessMemory(HANDLE hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);
/**
* Takes a snapshot of the specified processes, as well as the heaps,
* modules, and threads used by these processes.
*
* @param dwFlags The portions of the system to be included in the snapshot.
*
* @param th32ProcessID The process identifier of the process to be included
* in the snapshot. This parameter can be zero to indicate the current
* process. This parameter is used when the TH32CS_SNAPHEAPLIST,
* TH32CS_SNAPMODULE, TH32CS_SNAPMODULE32, or TH32CS_SNAPALL value is
* specified. Otherwise, it is ignored and all processes are included in the
* snapshot.
*
* If the specified process is the Idle process or one of the CSRSS
* processes, this function fails and the last error code is
* ERROR_ACCESS_DENIED because their access restrictions prevent user-level
* code from opening them.
*
* If the specified process is a 64-bit process and the caller is a 32-bit
* process, this function fails and the last error code is
* ERROR_PARTIAL_COPY (299).
*
* @return If the function succeeds, it returns an open handle to the
* specified snapshot.
*
* If the function fails, it returns INVALID_HANDLE_VALUE. To get extended
* error information, call GetLastError. Possible error codes include
* ERROR_BAD_LENGTH.
*/
HANDLE CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID);
/**
* Retrieves information about the first process encountered in a system
* snapshot.
*
* @param hSnapshot A handle to the snapshot returned from a previous call
* to the CreateToolhelp32Snapshot function.
* @param lppe A pointer to a PROCESSENTRY32 structure. It contains process
* information such as the name of the executable file, the process
* identifier, and the process identifier of the parent process.
* @return Returns TRUE if the first entry of the process list has been
* copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error
* value is returned by the GetLastError function if no processes exist or
* the snapshot does not contain process information.
*/
boolean Process32First(HANDLE hSnapshot, PROCESSENTRY32 lppe);
/**
* Retrieves information about the next process recorded in a system
* snapshot.
*
* @param hSnapshot A handle to the snapshot returned from a previous call
* to the CreateToolhelp32Snapshot function.
* @param lppe A pointer to a PROCESSENTRY32 structure.
* @return Returns TRUE if the next entry of the process list has been
* copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error
* value is returned by the GetLastError function if no processes exist or
* the snapshot does not contain process information.
*/
boolean Process32Next(HANDLE hSnapshot, PROCESSENTRY32 lppe);
public static int TH32CS_SNAPPROCESS = 0x00000002;
//Needed for some Windows 7 Versions
//boolean EnumProcesses(int[] ProcessIDsOut, int size, int[] BytesReturned);
int GetProcessImageFileNameW(HANDLE Process, char[] outputname, int lenght);
DWORD QueryDosDevice(String lpDeviceName, char[] lpTargetPath, int lenght);
boolean VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, int flNewProtect, IntByReference lpflOldProtect);
}
@@ -0,0 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.BaseTSD.SIZE_T;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class MEMORY_BASIC_INFORMATION extends Structure {
public Pointer baseAddress;
public Pointer allocationBase;
public NativeLong allocationProtect;
public SIZE_T regionSize;
public NativeLong state;
public NativeLong protect;
public NativeLong type;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"baseAddress", "allocationBase", "allocationProtect",
"regionSize", "state", "protect", "type"});
}
}
@@ -0,0 +1,85 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
public class PROCESSENTRY32 extends Structure {
public static class ByReference extends PROCESSENTRY32 implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public PROCESSENTRY32() {
dwSize = new WinDef.DWORD(size());
}
public PROCESSENTRY32(Pointer memory) {
super(memory);
read();
}
/**
* The size of the structure, in bytes. Before calling the Process32First
* function, set this member to sizeof(PROCESSENTRY32). If you do not
* initialize dwSize, Process32First fails.
*/
public WinDef.DWORD dwSize;
/**
* This member is no longer used and is always set to zero.
*/
public WinDef.DWORD cntUsage;
/**
* The process identifier.
*/
public WinNT.DWORD th32ProcessID;
/**
* This member is no longer used and is always set to zero.
*/
public BaseTSD.ULONG_PTR th32DefaultHeapID;
/**
* This member is no longer used and is always set to zero.
*/
public WinDef.DWORD th32ModuleID;
/**
* The number of execution threads started by the process.
*/
public WinDef.DWORD cntThreads;
/**
* The identifier of the process that created this process (its parent
* process).
*/
public WinDef.DWORD th32ParentProcessID;
/**
* The base priority of any threads created by this process.
*/
public WinDef.LONG pcPriClassBase;
/**
* This member is no longer used, and is always set to zero.
*/
public WinDef.DWORD dwFlags;
/**
* The name of the executable file for the process. To retrieve the full
* path to the executable file, call the Module32First function and check
* the szExePath member of the MODULEENTRY32 structure that is returned.
* However, if the calling process is a 32-bit process, you must call the
* QueryFullProcessImageName function to retrieve the full path of the
* executable file for a 64-bit process.
*/
public char[] szExeFile = new char[WinDef.MAX_PATH];
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile"});
}
}
+22
View File
@@ -0,0 +1,22 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
*
* @author petrik
*/
public interface Psapi extends StdCallLibrary {
Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class);
//For some Windows 7 Versions and older down to XP
//boolean EnumProcesses(int[] ProcessIDsOut, int size, int[] BytesReturned);
int GetProcessImageFileNameW(HANDLE Process, char[] outputname, int lenght);
}
@@ -0,0 +1,36 @@
package com.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinReg.HKEY;
import java.util.Arrays;
import java.util.List;
public class SHELLEXECUTEINFO extends Structure {
public int cbSize = size();
public int fMask;
public HWND hwnd;
public WString lpVerb;
public WString lpFile;
public WString lpParameters;
public WString lpDirectory;
public int nShow;
public HINSTANCE hInstApp;
public Pointer lpIDList;
public WString lpClass;
public HKEY hKeyClass;
public int dwHotKey;
public HANDLE hMonitor;
public HANDLE hProcess;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", "lpDirectory", "nShow", "hInstApp", "lpIDList",
"lpClass", "hKeyClass", "dwHotKey", "hMonitor", "hProcess"});
}
}
@@ -0,0 +1,29 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HICON;
import java.util.Arrays;
import java.util.List;
/**
*
* @author JPEXS
*/
public class SHFILEINFO extends Structure {
public HICON hIcon;
public int iIcon;
public DWORD dwAttributes;
public char[] szDisplayName = new char[260];
public char[] szTypeName = new char[80];
@Override
protected List getFieldOrder() {
return Arrays.asList("hIcon", "iIcon", "dwAttributes", "szDisplayName", "szTypeName");
}
}
@@ -0,0 +1,41 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.BaseTSD.DWORD_PTR;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Shell32.dll Interface.
*/
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* @param lpExecInfo
* @return true if successful. Otherwise false.
*/
boolean ShellExecuteEx(SHELLEXECUTEINFO lpExecInfo);
UINT ExtractIconEx(String lpszFile, int nIconIndex, PointerByReference phiconLarge, PointerByReference phiconSmall, UINT nIcons);
DWORD_PTR SHGetFileInfo(String pszPath, int dwFileAttributes, SHFILEINFO psfi, int cbFileInfo, int uFlags);
public static final int SHGFI_ICON = 0x000000100;
public static final int SHGFI_SMALLICON = 0x000000001;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,181 @@
/* Copyright (c) 2010,2011 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.platform.win32.WinNT.HRESULT;
// TODO: Auto-generated Javadoc
/**
* Utility class for some common error functions.
*/
public abstract class W32Errors implements WinError {
/**
* Generic test for success on any status value (non-negative numbers
* indicate success).
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(int hr) {
return hr >= 0;
}
/**
* and the inverse.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(int hr) {
return hr < 0;
}
/**
* Succeeded.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(HRESULT hr) {
if (hr != null) {
return SUCCEEDED(hr.intValue());
} else {
return false;
}
}
/**
* Failed.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(HRESULT hr) {
if (hr != null) {
return FAILED(hr.intValue());
} else {
return false;
}
}
/**
* Extract error code from HRESULT.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
/**
* Extract error code from SCODE.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_CODE(int sc) {
return sc & 0xFFFF;
}
/**
* Return the facility.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
/**
* Scode facility.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* Return the severity.
*
* @param hr the hr
* @return the short
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
/**
* Scode severity.
*
* @param sc the sc
* @return the short
*/
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* Create an HRESULT value from component pieces.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Make scode.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Map a WIN32 error value into a HRESULT Note: This assumes that WIN32
* errors fall in the range -32k to=32k.
*
* @param x original w32 error code
* @return the converted value
*/
public static final HRESULT HRESULT_FROM_WIN32(int x) {
int f = FACILITY_WIN32;
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16)
| 0x80000000);
}
/**
* FACILITY_USERMODE_FILTER_MANAGER
*
* Translation macro for converting: NTSTATUS --> HRESULT.
*
* @param x the x
* @return the int
*/
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
int f = FACILITY_USERMODE_FILTER_MANAGER;
return (((x) & 0x8000FFFF) | (f <<= 16));
}
}
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sun.jna.platform.win32;
/**
*
* @author JPEXS
*/
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Win32 exception.
*
* @author dblock[at]dblock[dot]org
*/
public class Win32Exception extends RuntimeException {
private static final long serialVersionUID = 1L;
private HRESULT _hr;
/**
* Returns the error code of the error.
*
* @return Error code.
*/
public HRESULT getHR() {
return _hr;
}
/**
* New Win32 exception from HRESULT.
*
* @param hr HRESULT
*/
public Win32Exception(HRESULT hr) {
//super(Kernel32Util.formatMessageFromHR(hr));
_hr = hr;
}
/**
* New Win32 exception from an error code, usually obtained from
* GetLastError.
*
* @param code Error code.
*/
public Win32Exception(int code) {
this(W32Errors.HRESULT_FROM_WIN32(code));
}
}
+899
View File
@@ -0,0 +1,899 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.win32.StdCallLibrary;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* Ported from Winbase.h (kernel32.dll/kernel services). Microsoft Windows SDK
* 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
/**
* Constant value representing an invalid HANDLE.
*/
HANDLE INVALID_HANDLE_VALUE
= new HANDLE(Pointer.createConstant(Pointer.SIZE == 8
? -1 : 0xFFFFFFFFL));
/**
* Maximum computer name length. The value is 15 on Mac, 31 on everything
* else.
*/
int MAX_COMPUTERNAME_LENGTH = Platform.isMac() ? 15 : 31;
/**
* This logon type is intended for users who will be interactively using the
* computer, such as a user being logged on by a terminal server, remote
* shell, or similar process. This logon type has the additional expense of
* caching logon information for disconnected operations; therefore, it is
* inappropriate for some client/server applications, such as a mail server.
*/
int LOGON32_LOGON_INTERACTIVE = 2;
/**
* This logon type is intended for high performance servers to authenticate
* plaintext passwords. The LogonUser function does not cache credentials
* for this logon type.
*/
int LOGON32_LOGON_NETWORK = 3;
/**
* This logon type is intended for batch servers, where processes may be
* executing on behalf of a user without their direct intervention. This
* type is also for higher performance servers that process many plaintext
* authentication attempts at a time, such as mail or Web servers. The
* LogonUser function does not cache credentials for this logon type.
*/
int LOGON32_LOGON_BATCH = 4;
/**
* Indicates a service-type logon. The account provided must have the
* service privilege enabled.
*/
int LOGON32_LOGON_SERVICE = 5;
/**
* This logon type is for GINA DLLs that log on users who will be
* interactively using the computer. This logon type can generate a unique
* audit record that shows when the workstation was unlocked.
*/
int LOGON32_LOGON_UNLOCK = 7;
/**
* This logon type preserves the name and password in the authentication
* package, which allows the server to make connections to other network
* servers while impersonating the client. A server can accept plaintext
* credentials from a client, call LogonUser, verify that the user can
* access the system across the network, and still communicate with other
* servers.
*/
int LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
/**
* This logon type allows the caller to clone its current token and specify
* new credentials for outbound connections. The new logon session has the
* same local identifier but uses different credentials for other network
* connections. This logon type is supported only by the
* LOGON32_PROVIDER_WINNT50 logon provider.
*/
int LOGON32_LOGON_NEW_CREDENTIALS = 9;
/**
* Use the standard logon provider for the system. The default security
* provider is negotiate, unless you pass NULL for the domain name and the
* user name is not in UPN format. In this case, the default provider is
* NTLM.
*/
int LOGON32_PROVIDER_DEFAULT = 0;
/**
* Use the Windows NT 3.5 logon provider.
*/
int LOGON32_PROVIDER_WINNT35 = 1;
/**
* Use the NTLM logon provider.
*/
int LOGON32_PROVIDER_WINNT40 = 2;
/**
* Use the negotiate logon provider.
*/
int LOGON32_PROVIDER_WINNT50 = 3;
/**
* If this flag is set, a child process created with the bInheritHandles
* parameter of CreateProcess set to TRUE will inherit the object handle.
*/
int HANDLE_FLAG_INHERIT = 1;
/**
* If this flag is set, calling the {@link Kernel32#CloseHandle} function
* will not close the object handle.
*/
int HANDLE_FLAG_PROTECT_FROM_CLOSE = 2;
// STARTUPINFO flags
int STARTF_USESHOWWINDOW = 0x001;
int STARTF_USESIZE = 0x002;
int STARTF_USEPOSITION = 0x004;
int STARTF_USECOUNTCHARS = 0x008;
int STARTF_USEFILLATTRIBUTE = 0x010;
int STARTF_RUNFULLSCREEN = 0x020;
int STARTF_FORCEONFEEDBACK = 0x040;
int STARTF_FORCEOFFFEEDBACK = 0x080;
int STARTF_USESTDHANDLES = 0x100;
// Process Creation flags
int DEBUG_PROCESS = 0x00000001;
int DEBUG_ONLY_THIS_PROCESS = 0x00000002;
int CREATE_SUSPENDED = 0x00000004;
int DETACHED_PROCESS = 0x00000008;
int CREATE_NEW_CONSOLE = 0x00000010;
int CREATE_NEW_PROCESS_GROUP = 0x00000200;
int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
int CREATE_SEPARATE_WOW_VDM = 0x00000800;
int CREATE_SHARED_WOW_VDM = 0x00001000;
int CREATE_FORCEDOS = 0x00002000;
int INHERIT_PARENT_AFFINITY = 0x00010000;
int CREATE_PROTECTED_PROCESS = 0x00040000;
int EXTENDED_STARTUPINFO_PRESENT = 0x00080000;
int CREATE_BREAKAWAY_FROM_JOB = 0x01000000;
int CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000;
int CREATE_DEFAULT_ERROR_MODE = 0x04000000;
int CREATE_NO_WINDOW = 0x08000000;
/* Invalid return values */
int INVALID_FILE_SIZE = 0xFFFFFFFF;
int INVALID_SET_FILE_POINTER = 0xFFFFFFFF;
int INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF;
/**
* Return code for a process still active.
*/
int STILL_ACTIVE = WinNT.STATUS_PENDING;
/**
* The FILETIME structure is a 64-bit value representing the number of
* 100-nanosecond intervals since January 1, 1601 (UTC). Conversion code in
* this class Copyright 2002-2004 Apache Software Foundation.
*
* @author Rainer Klute ([email protected]) for the Apache Software
* Foundation (org.apache.poi.hpsf)
*/
public static class FILETIME extends Structure {
public int dwLowDateTime;
public int dwHighDateTime;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"dwLowDateTime", "dwHighDateTime"});
}
public static class ByReference extends FILETIME implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public FILETIME(Date date) {
long rawValue = dateToFileTime(date);
dwHighDateTime = (int) (rawValue >> 32 & 0xffffffffL);
dwLowDateTime = (int) (rawValue & 0xffffffffL);
}
public FILETIME() {
}
public FILETIME(Pointer memory) {
super(memory);
read();
}
/**
* <p>
* The difference between the Windows epoch (1601-01-01 00:00:00) and
* the Unix epoch (1970-01-01 00:00:00) in milliseconds:
* 11644473600000L. (Use your favorite spreadsheet program to verify the
* correctness of this value. By the way, did you notice that you can
* tell from the epochs which operating system is the modern one?
* :-))</p>
*/
private static final long EPOCH_DIFF = 11644473600000L;
/**
* <p>
* Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME
* structure holds a date and time associated with a file. The structure
* identifies a 64-bit integer specifying the number of 100-nanosecond
* intervals which have passed since January 1, 1601. This 64-bit value
* is split into the two double words stored in the structure.</p>
*
* @param high The higher double word of the FILETIME structure.
* @param low The lower double word of the FILETIME structure.
* @return The Windows FILETIME as a {@link Date}.
*/
public static Date filetimeToDate(final int high, final int low) {
final long filetime = (long) high << 32 | low & 0xffffffffL;
final long ms_since_16010101 = filetime / (1000 * 10);
final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF;
return new Date(ms_since_19700101);
}
/**
* <p>
* Converts a {@link Date} into a filetime.</p>
*
* @param date The date to be converted
* @return The filetime
*
* @see #filetimeToDate
*/
public static long dateToFileTime(final Date date) {
final long ms_since_19700101 = date.getTime();
final long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF;
return ms_since_16010101 * 1000 * 10;
}
public Date toDate() {
return filetimeToDate(dwHighDateTime, dwLowDateTime);
}
public long toLong() {
return toDate().getTime();
}
@Override
public String toString() {
return super.toString() + ": " + toDate().toString(); //$NON-NLS-1$
}
}
/* Local Memory Flags */
int LMEM_FIXED = 0x0000;
int LMEM_MOVEABLE = 0x0002;
int LMEM_NOCOMPACT = 0x0010;
int LMEM_NODISCARD = 0x0020;
int LMEM_ZEROINIT = 0x0040;
int LMEM_MODIFY = 0x0080;
int LMEM_DISCARDABLE = 0x0F00;
int LMEM_VALID_FLAGS = 0x0F72;
int LMEM_INVALID_HANDLE = 0x8000;
int LHND = (LMEM_MOVEABLE | LMEM_ZEROINIT);
int LPTR = (LMEM_FIXED | LMEM_ZEROINIT);
/* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */
int LMEM_DISCARDED = 0x4000;
int LMEM_LOCKCOUNT = 0x00FF;
/**
* Specifies a date and time, using individual members for the month, day,
* year, weekday, hour, minute, second, and millisecond. The time is either
* in coordinated universal time (UTC) or local time, depending on the
* function that is being called.
* http://msdn.microsoft.com/en-us/library/ms724950(VS.85).aspx
*/
public static class SYSTEMTIME extends Structure {
// The year. The valid values for this member are 1601 through 30827.
public short wYear;
// The month. The valid values for this member are 1 through 12.
public short wMonth;
// The day of the week. The valid values for this member are 0 through 6.
public short wDayOfWeek;
// The day of the month. The valid values for this member are 1 through 31.
public short wDay;
// The hour. The valid values for this member are 0 through 23.
public short wHour;
// The minute. The valid values for this member are 0 through 59.
public short wMinute;
// The second. The valid values for this member are 0 through 59.
public short wSecond;
// The millisecond. The valid values for this member are 0 through 999.
public short wMilliseconds;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds"});
}
}
/**
* The lpBuffer parameter is a pointer to a PVOID pointer, and that the
* nSize parameter specifies the minimum number of TCHARs to allocate for an
* output message buffer. The function allocates a buffer large enough to
* hold the formatted message, and places a pointer to the allocated buffer
* at the address specified by lpBuffer. The caller should use the LocalFree
* function to free the buffer when it is no longer needed.
*/
int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
/**
* Insert sequences in the message definition are to be ignored and passed
* through to the output buffer unchanged. This flag is useful for fetching
* a message for later formatting. If this flag is set, the Arguments
* parameter is ignored.
*/
int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
/**
* The lpSource parameter is a pointer to a null-terminated message
* definition. The message definition may contain insert sequences, just as
* the message text in a message table resource may. Cannot be used with
* FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM.
*/
int FORMAT_MESSAGE_FROM_STRING = 0x00000400;
/**
* The lpSource parameter is a module handle containing the message-table
* resource(s) to search. If this lpSource handle is NULL, the current
* process's application image file will be searched. Cannot be used with
* FORMAT_MESSAGE_FROM_STRING.
*/
int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
/**
* The function should search the system message-table resource(s) for the
* requested message. If this flag is specified with
* FORMAT_MESSAGE_FROM_HMODULE, the function searches the system message
* table if the message is not found in the module specified by lpSource.
* Cannot be used with FORMAT_MESSAGE_FROM_STRING. If this flag is
* specified, an application can pass the result of the GetLastError
* function to retrieve the message text for a system-defined error.
*/
int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;
/**
* The Arguments parameter is not a va_list structure, but is a pointer to
* an array of values that represent the arguments. This flag cannot be used
* with 64-bit argument values. If you are using 64-bit values, you must use
* the va_list structure.
*/
int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
/**
* The drive type cannot be determined.
*/
int DRIVE_UNKNOWN = 0;
/**
* The root path is invalid, for example, no volume is mounted at the path.
*/
int DRIVE_NO_ROOT_DIR = 1;
/**
* The drive is a type that has removable media, for example, a floppy drive
* or removable hard disk.
*/
int DRIVE_REMOVABLE = 2;
/**
* The drive is a type that cannot be removed, for example, a fixed hard
* drive.
*/
int DRIVE_FIXED = 3;
/**
* The drive is a remote (network) drive.
*/
int DRIVE_REMOTE = 4;
/**
* The drive is a CD-ROM drive.
*/
int DRIVE_CDROM = 5;
/**
* The drive is a RAM disk.
*/
int DRIVE_RAMDISK = 6;
/**
* The OVERLAPPED structure contains information used in asynchronous (or
* overlapped) input and output (I/O).
*/
public static class OVERLAPPED extends Structure {
public ULONG_PTR Internal;
public ULONG_PTR InternalHigh;
public int Offset;
public int OffsetHigh;
public HANDLE hEvent;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent"});
}
}
int INFINITE = 0xFFFFFFFF;
/**
* Contains information about the current computer system. This includes the
* architecture and type of the processor, the number of processors in the
* system, the page size, and other such information.
*/
public static class SYSTEM_INFO extends Structure {
/**
* Unnamed inner structure.
*/
public static class PI extends Structure {
public static class ByReference extends PI implements Structure.ByReference {
}
/**
* System's processor architecture. This value can be one of the
* following values:
*
* PROCESSOR_ARCHITECTURE_UNKNOWN PROCESSOR_ARCHITECTURE_INTEL
* PROCESSOR_ARCHITECTURE_IA64 PROCESSOR_ARCHITECTURE_AMD64
*/
public WORD wProcessorArchitecture;
/**
* Reserved for future use.
*/
public WORD wReserved;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"wProcessorArchitecture", "wReserved"});
}
}
/**
* Unnamed inner union.
*/
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
/**
* An obsolete member that is retained for compatibility with
* Windows NT 3.5 and earlier. New applications should use the
* wProcessorArchitecture branch of the union. Windows Me/98/95: The
* system always sets this member to zero, the value defined for
* PROCESSOR_ARCHITECTURE_INTEL.
*/
public DWORD dwOemID;
/**
* Processor architecture (unnamed struct).
*/
public PI pi;
}
/**
* Processor architecture (unnamed union).
*/
public UNION processorArchitecture;
/**
* Page size and the granularity of page protection and commitment.
*/
public DWORD dwPageSize;
/**
* Pointer to the lowest memory address accessible to applications and
* dynamic-link libraries (DLLs).
*/
public Pointer lpMinimumApplicationAddress;
/**
* Pointer to the highest memory address accessible to applications and
* DLLs.
*/
public Pointer lpMaximumApplicationAddress;
/**
* Mask representing the set of processors configured into the system.
* Bit 0 is processor 0; bit 31 is processor 31.
*/
public DWORD_PTR dwActiveProcessorMask;
/**
* Number of processors in the system.
*/
public DWORD dwNumberOfProcessors;
/**
* An obsolete member that is retained for compatibility with Windows NT
* 3.5 and Windows Me/98/95. Use the wProcessorArchitecture,
* wProcessorLevel, and wProcessorRevision members to determine the type
* of processor. PROCESSOR_INTEL_386 PROCESSOR_INTEL_486
* PROCESSOR_INTEL_PENTIUM
*/
public DWORD dwProcessorType;
/**
* Granularity for the starting address at which virtual memory can be
* allocated.
*/
public DWORD dwAllocationGranularity;
/**
* System's architecture-dependent processor level. It should be used
* only for display purposes. To determine the feature set of a
* processor, use the IsProcessorFeaturePresent function. If
* wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL,
* wProcessorLevel is defined by the CPU vendor. If
* wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64,
* wProcessorLevel is set to 1.
*/
public WORD wProcessorLevel;
/**
* Architecture-dependent processor revision.
*/
public WORD wProcessorRevision;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"});
}
}
/**
* Contains information about the current state of both physical and virtual
* memory, including extended memory. The GlobalMemoryStatusEx function
* stores information in this structure.
*/
public static class MEMORYSTATUSEX extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD dwLength;
/**
* A number between 0 and 100 that specifies the approximate percentage
* of physical memory that is in use (0 indicates no memory use and 100
* indicates full memory use).
*/
public DWORD dwMemoryLoad;
/**
* The amount of actual physical memory, in bytes.
*/
public DWORDLONG ullTotalPhys;
/**
* The amount of physical memory currently available, in bytes. This is
* the amount of physical memory that can be immediately reused without
* having to write its contents to disk first. It is the sum of the size
* of the standby, free, and zero lists.
*/
public DWORDLONG ullAvailPhys;
/**
* The current committed memory limit for the system or the current
* process, whichever is smaller, in bytes.
*/
public DWORDLONG ullTotalPageFile;
/**
* The maximum amount of memory the current process can commit, in
* bytes. This value is equal to or smaller than the system-wide
* available commit value.
*/
public DWORDLONG ullAvailPageFile;
/**
* The size of the user-mode portion of the virtual address space of the
* calling process, in bytes.
*/
public DWORDLONG ullTotalVirtual;
/**
* The amount of unreserved and uncommitted memory currently in the
* user-mode portion of the virtual address space of the calling
* process, in bytes.
*/
public DWORDLONG ullAvailVirtual;
/**
* Reserved. This value is always 0.
*/
public DWORDLONG ullAvailExtendedVirtual;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual"});
}
public MEMORYSTATUSEX() {
dwLength = new DWORD(size());
}
};
/**
* The SECURITY_ATTRIBUTES structure contains the security descriptor for an
* object and specifies whether the handle retrieved by specifying this
* structure is inheritable. This structure provides security settings for
* objects created by various functions, such as Kernel32#CreateFile,
* Kernel32#CreatePipe, or Advapi32#RegCreateKeyEx.
*/
public static class SECURITY_ATTRIBUTES extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD dwLength;
/**
* A pointer to a SECURITY_DESCRIPTOR structure that controls access to
* the object.
*/
public Pointer lpSecurityDescriptor;
/**
* A Boolean value that specifies whether the returned handle is
* inherited when a new process is created
*/
public boolean bInheritHandle;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"dwLength", "lpSecurityDescriptor", "bInheritHandle"});
}
public SECURITY_ATTRIBUTES() {
dwLength = new DWORD(size());
}
}
/**
* Specifies the window station, desktop, standard handles, and appearance
* of the main window for a process at creation time.
*/
public static class STARTUPINFO extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD cb;
/**
* Reserved; must be NULL.
*/
public String lpReserved;
/**
* The name of the desktop, or the name of both the desktop and window
* station for this process. A backslash in the string indicates that
* the string includes both the desktop and window station names. For
* more information, see Thread Connection to a Desktop.
*/
public String lpDesktop;
/**
* For console processes, this is the title displayed in the title bar
* if a new console window is created. If NULL, the name of the
* executable file is used as the window title instead. This parameter
* must be NULL for GUI or console processes that do not create a new
* console window.
*/
public String lpTitle;
/**
* If dwFlags specifies STARTF_USEPOSITION, this member is the x offset
* of the upper left corner of a window if a new window is created, in
* pixels. Otherwise, this member is ignored.
*
* The offset is from the upper left corner of the screen. For GUI
* processes, the specified position is used the first time the new
* process calls CreateWindow to create an overlapped window if the x
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwX;
/**
* If dwFlags specifies STARTF_USEPOSITION, this member is the y offset
* of the upper left corner of a window if a new window is created, in
* pixels. Otherwise, this member is ignored.
*
* The offset is from the upper left corner of the screen. For GUI
* processes, the specified position is used the first time the new
* process calls CreateWindow to create an overlapped window if the y
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwY;
/**
* If dwFlags specifies STARTF_USESIZE, this member is the width of the
* window if a new window is created, in pixels. Otherwise, this member
* is ignored.
*
* For GUI processes, this is used only the first time the new process
* calls CreateWindow to create an overlapped window if the nWidth
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwXSize;
/**
* If dwFlags specifies STARTF_USESIZE, this member is the height of the
* window if a new window is created, in pixels. Otherwise, this member
* is ignored.
*
* For GUI processes, this is used only the first time the new process
* calls CreateWindow to create an overlapped window if the nHeight
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwYSize;
/**
* If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is
* created in a console process, this member specifies the screen buffer
* width, in character columns. Otherwise, this member is ignored.
*/
public DWORD dwXCountChars;
/**
* If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is
* created in a console process, this member specifies the screen buffer
* height, in character rows. Otherwise, this member is ignored.
*/
public DWORD dwYCountChars;
/**
* If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the
* initial text and background colors if a new console window is created
* in a console application. Otherwise, this member is ignored.
*
* This value can be any combination of the following values:
* FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED,
* FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN,
* BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following
* combination of values produces red text on a white background:
*
* FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE
*/
public DWORD dwFillAttribute;
/**
* A bit field that determines whether certain STARTUPINFO members are
* used when the process creates a window.
*/
public int dwFlags;
/**
* If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of
* the values that can be specified in the nCmdShow parameter for the
* ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this
* member is ignored.
*
* For GUI processes, the first time ShowWindow is called, its nCmdShow
* parameter is ignored wShowWindow specifies the default value. In
* subsequent calls to ShowWindow, the wShowWindow member is used if the
* nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT.
*/
public WORD wShowWindow;
/**
* Reserved for use by the C Run-time; must be zero.
*/
public WORD cbReserved2;
/**
* Reserved for use by the C Run-time; must be NULL.
*/
public ByteByReference lpReserved2;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard input handle for the process. If STARTF_USESTDHANDLES is not
* specified, the default for standard input is the keyboard buffer.
*
* If dwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey
* value that is sent as the wParam parameter of a WM_SETHOTKEY message
* to the first eligible top-level window created by the application
* that owns the process. If the window is created with the WS_POPUP
* window style, it is not eligible unless the WS_EX_APPWINDOW extended
* window style is also set. For more information, see CreateWindowEx.
*
* Otherwise, this member is ignored.
*/
public HANDLE hStdInput;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard output handle for the process. Otherwise, this member is
* ignored and the default for standard output is the console window's
* buffer.
*/
public HANDLE hStdOutput;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard error handle for the process. Otherwise, this member is
* ignored and the default for standard error is the console window's
* buffer.
*/
public HANDLE hStdError;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError"});
}
public STARTUPINFO() {
cb = new DWORD(size());
}
}
/**
* Contains information about a newly created process and its primary
* thread. It is used with the CreateProcess, CreateProcessAsUser,
* CreateProcessWithLogonW, or CreateProcessWithTokenW function.
*/
public static class PROCESS_INFORMATION extends Structure {
/**
* A handle to the newly created process. The handle is used to specify
* the process in all functions that perform operations on the process
* object.
*/
public HANDLE hProcess;
/**
* A handle to the primary thread of the newly created process. The
* handle is used to specify the thread in all functions that perform
* operations on the thread object.
*/
public HANDLE hThread;
/**
* A value that can be used to identify a process. The value is valid
* from the time the process is created until all handles to the process
* are closed and the process object is freed; at this point, the
* identifier may be reused.
*/
public DWORD dwProcessId;
/**
* A value that can be used to identify a thread. The value is valid
* from the time the thread is created until all handles to the thread
* are closed and the thread object is freed; at this point, the
* identifier may be reused.
*/
public DWORD dwThreadId;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"hProcess", "hThread", "dwProcessId", "dwThreadId"});
}
public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public PROCESS_INFORMATION() {
}
public PROCESS_INFORMATION(Pointer memory) {
super(memory);
read();
}
}
/**
* If the file is to be moved to a different volume, the function simulates
* the move by using the CopyFile and DeleteFile functions.
*
* This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT.
*/
int MOVEFILE_COPY_ALLOWED = 0x2;
/**
* Reserved for future use.
*/
int MOVEFILE_CREATE_HARDLINK = 0x10;
/**
* The system does not move the file until the operating system is
* restarted. The system moves the file immediately after AUTOCHK is
* executed, but before creating any paging files. Consequently, this
* parameter enables the function to delete paging files from previous
* startups.
*
* This value can be used only if the process is in the context of a user
* who belongs to the administrators group or the LocalSystem account.
*
* This value cannot be used with MOVEFILE_COPY_ALLOWED.
*
* Windows Server 2003 and Windows XP: For information about special
* situations where this functionality can fail, and a suggested workaround
* solution, see Files are not exchanged when Windows Server 2003 restarts
* if you use the MoveFileEx function to schedule a replacement for some
* files in the Help and Support Knowledge Base.
*
* Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for
* dwFlags, you cannot also prepend the file name that is specified by
* lpExistingFileName with "\\?".
*/
int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;
/**
* The function fails if the source file is a link source, but the file
* cannot be tracked after the move. This situation can occur if the
* destination is a volume formatted with the FAT file system.
*/
int MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20;
/**
* If a file named lpNewFileName exists, the function replaces its contents
* with the contents of the lpExistingFileName file, provided that security
* requirements regarding access control lists (ACLs) are met. For more
* information, see the Remarks section of this topic.
*
* This value cannot be used if lpNewFileName or lpExistingFileName names a
* directory.
*/
int MOVEFILE_REPLACE_EXISTING = 0x1;
/**
* The function does not return until the file is actually moved on the
* disk.
*
* Setting this value guarantees that a move performed as a copy and delete
* operation is flushed to disk before the function returns. The flush
* occurs at the end of the copy operation.
*
* This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.
*/
int MOVEFILE_WRITE_THROUGH = 0x8;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+130
View File
@@ -0,0 +1,130 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jna.platform.win32;
/**
*
* @author petrik
*/
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.win32.StdCallLibrary;
import java.util.Arrays;
import java.util.List;
/**
* Ported from WinGDI.h. Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface WinGDI extends StdCallLibrary {
public int RDH_RECTANGLES = 1;
public class RGNDATAHEADER extends Structure {
public int dwSize = size();
public int iType = RDH_RECTANGLES; // required
public int nCount;
public int nRgnSize;
public RECT rcBound;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"dwSize", "iType", "nCount", "nRgnSize", "rcBound"});
}
}
public class RGNDATA extends Structure {
public RGNDATAHEADER rdh;
public byte[] Buffer;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"rdh", "Buffer"});
}
public RGNDATA() {
this(1);
}
public RGNDATA(int bufferSize) {
Buffer = new byte[bufferSize];
allocateMemory();
}
}
public int RGN_AND = 1;
public int RGN_OR = 2;
public int RGN_XOR = 3;
public int RGN_DIFF = 4;
public int RGN_COPY = 5;
public int ERROR = 0;
public int NULLREGION = 1;
public int SIMPLEREGION = 2;
public int COMPLEXREGION = 3;
public int ALTERNATE = 1;
public int WINDING = 2;
public int BI_RGB = 0;
public int BI_RLE8 = 1;
public int BI_RLE4 = 2;
public int BI_BITFIELDS = 3;
public int BI_JPEG = 4;
public int BI_PNG = 5;
public class BITMAPINFOHEADER extends Structure {
public int biSize = size();
public int biWidth;
public int biHeight;
public short biPlanes;
public short biBitCount;
public int biCompression;
public int biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public int biClrUsed;
public int biClrImportant;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant"});
}
}
public class RGBQUAD extends Structure {
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved = 0;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"rgbBlue", "rgbGreen", "rgbRed", "rgbReserved"});
}
}
public class BITMAPINFO extends Structure {
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
public RGBQUAD[] bmiColors = new RGBQUAD[1];
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"bmiHeader", "bmiColors"});
}
public BITMAPINFO() {
this(1);
}
public BITMAPINFO(int size) {
bmiColors = new RGBQUAD[size];
}
}
public int DIB_RGB_COLORS = 0;
public int DIB_PAL_COLORS = 1;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,80 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* This module contains the function prototypes and constant, type and structure
* definitions for the Windows 32-Bit Registry API. Ported from WinReg.h
* Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface WinReg extends StdCallLibrary {
public static class HKEY extends HANDLE {
public HKEY() {
}
public HKEY(Pointer p) {
super(p);
}
public HKEY(int value) {
super(new Pointer(value));
}
}
public static final class HKEYByReference extends ByReference {
public HKEYByReference() {
this(null);
}
public HKEYByReference(HKEY h) {
super(Pointer.SIZE);
setValue(h);
}
public void setValue(HKEY h) {
getPointer().setPointer(0, h != null ? h.getPointer() : null);
}
public HKEY getValue() {
Pointer p = getPointer().getPointer(0);
if (p == null) {
return null;
}
if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p)) {
return (HKEY) WinBase.INVALID_HANDLE_VALUE;
}
HKEY h = new HKEY();
h.setPointer(p);
return h;
}
}
HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
HKEY HKEY_CURRENT_USER = new HKEY(0x80000001);
HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002);
HKEY HKEY_USERS = new HKEY(0x80000003);
HKEY HKEY_PERFORMANCE_DATA = new HKEY(0x80000004);
HKEY HKEY_PERFORMANCE_TEXT = new HKEY(0x80000050);
HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060);
HKEY HKEY_CURRENT_CONFIG = new HKEY(0x80000005);
HKEY HKEY_DYN_DATA = new HKEY(0x80000006);
}
+894
View File
@@ -0,0 +1,894 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Callback;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
import com.sun.jna.platform.win32.WinDef.HBRUSH;
import com.sun.jna.platform.win32.WinDef.HCURSOR;
import com.sun.jna.platform.win32.WinDef.HICON;
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.LRESULT;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
import java.util.Arrays;
import java.util.List;
/**
* Ported from WinUser.h Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface WinUser extends StdCallLibrary, WinDef {
HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF));
HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3));
/* RegisterDeviceNotification stuff */
public static class HDEVNOTIFY extends PVOID {
public HDEVNOTIFY() {
}
public HDEVNOTIFY(Pointer p) {
super(p);
}
}
int FLASHW_STOP = 0;
int FLASHW_CAPTION = 1;
int FLASHW_TRAY = 2;
int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
int FLASHW_TIMER = 4;
int FLASHW_TIMERNOFG = 12;
int IMAGE_BITMAP = 0;
int IMAGE_ICON = 1;
int IMAGE_CURSOR = 2;
int IMAGE_ENHMETAFILE = 3;
int LR_DEFAULTCOLOR = 0x0000;
int LR_MONOCHROME = 0x0001;
int LR_COLOR = 0x0002;
int LR_COPYRETURNORG = 0x0004;
int LR_COPYDELETEORG = 0x0008;
int LR_LOADFROMFILE = 0x0010;
int LR_LOADTRANSPARENT = 0x0020;
int LR_DEFAULTSIZE = 0x0040;
int LR_VGACOLOR = 0x0080;
int LR_LOADMAP3DCOLORS = 0x1000;
int LR_CREATEDIBSECTION = 0x2000;
int LR_COPYFROMRESOURCE = 0x4000;
int LR_SHARED = 0x8000;
public class GUITHREADINFO extends Structure {
public int cbSize = size();
public int flags;
public HWND hwndActive;
public HWND hwndFocus;
public HWND hwndCapture;
public HWND hwndMenuOwner;
public HWND hwndMoveSize;
public HWND hwndCaret;
public RECT rcCaret;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "flags",
"hwndActive", "hwndFocus", "hwndCapture", "hwndMenuOwner",
"hwndMoveSize", "hwndCaret", "rcCaret"});
}
}
public class WINDOWINFO extends Structure {
public int cbSize = size();
public RECT rcWindow;
public RECT rcClient;
public int dwStyle;
public int dwExStyle;
public int dwWindowStatus;
public int cxWindowBorders;
public int cyWindowBorders;
public short atomWindowType;
public short wCreatorVersion;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "rcWindow",
"rcClient", "dwStyle", "dwExStyle", "dwWindowStatus",
"cxWindowBorders", "cyWindowBorders", "atomWindowType",
"wCreatorVersion"});
}
}
int GWL_EXSTYLE = -20;
int GWL_STYLE = -16;
int GWL_WNDPROC = -4;
int GWL_HINSTANCE = -6;
int GWL_ID = -12;
int GWL_USERDATA = -21;
int DWL_DLGPROC = 4;
int DWL_MSGRESULT = 0;
int DWL_USER = 8;
int WS_MAXIMIZE = 0x01000000;
int WS_VISIBLE = 0x10000000;
int WS_MINIMIZE = 0x20000000;
int WS_CHILD = 0x40000000;
int WS_POPUP = 0x80000000;
int WS_EX_COMPOSITED = 0x20000000;
int WS_EX_LAYERED = 0x80000;
int WS_EX_TRANSPARENT = 32;
int LWA_COLORKEY = 1;
int LWA_ALPHA = 2;
int ULW_COLORKEY = 1;
int ULW_ALPHA = 2;
int ULW_OPAQUE = 4;
/**
* Defines the x- and y-coordinates of a point.
*/
public class POINT extends Structure {
public int x, y;
public POINT() {
}
public POINT(int x, int y) {
this.x = x;
this.y = y;
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"x", "y"});
}
}
public class MSG extends Structure {
public HWND hWnd;
public int message;
public WPARAM wParam;
public LPARAM lParam;
public int time;
public POINT pt;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"hWnd", "message", "wParam",
"lParam", "time", "pt"});
}
}
public class FLASHWINFO extends Structure {
public int cbSize;
public HANDLE hWnd;
public int dwFlags;
public int uCount;
public int dwTimeout;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "hWnd", "dwFlags",
"uCount", "dwTimeout"});
}
}
public interface WNDENUMPROC extends StdCallCallback {
/**
* Return whether to continue enumeration.
*
* @param hWnd
* @param data
* @return
*/
boolean callback(HWND hWnd, Pointer data);
}
public interface LowLevelKeyboardProc extends HOOKPROC {
LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam);
}
/**
* Specifies the width and height of a rectangle.
*/
public class SIZE extends Structure {
public int cx, cy;
public SIZE() {
}
public SIZE(int w, int h) {
this.cx = w;
this.cy = h;
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cx", "cy"});
}
}
int AC_SRC_OVER = 0x00;
int AC_SRC_ALPHA = 0x01;
int AC_SRC_NO_PREMULT_ALPHA = 0x01;
int AC_SRC_NO_ALPHA = 0x02;
public class BLENDFUNCTION extends Structure {
public byte BlendOp = AC_SRC_OVER; // only valid value
public byte BlendFlags = 0; // only valid value
public byte SourceConstantAlpha;
public byte AlphaFormat;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"BlendOp", "BlendFlags",
"SourceConstantAlpha", "AlphaFormat"});
}
}
int VK_SHIFT = 16;
int VK_LSHIFT = 0xA0;
int VK_RSHIFT = 0xA1;
int VK_CONTROL = 17;
int VK_LCONTROL = 0xA2;
int VK_RCONTROL = 0xA3;
int VK_MENU = 18;
int VK_LMENU = 0xA4;
int VK_RMENU = 0xA5;
int MOD_ALT = 0x0001;
int MOD_CONTROL = 0x0002;
int MOD_NOREPEAT = 0x4000;
int MOD_SHIFT = 0x0004;
int MOD_WIN = 0x0008;
int WH_KEYBOARD = 2;
int WH_MOUSE = 7;
int WH_KEYBOARD_LL = 13;
int WH_MOUSE_LL = 14;
public class HHOOK extends HANDLE {
}
public interface HOOKPROC extends StdCallCallback {
}
/**
* The WM_PAINT message is sent when the system or another application makes
* a request to paint a portion of an \ application's window.
*/
int WM_PAINT = 0x000F;
/**
* Sent as a signal that a window or an application should terminate.
*/
int WM_CLOSE = 0x0010;
/**
* Indicates a request to terminate an application, and is generated when
* the application calls the PostQuitMessage function.
*/
int WM_QUIT = 0x0012;
/**
* Sent to a window when the window is about to be hidden or shown.
*/
int WM_SHOWWINDOW = 0x0018;
/**
* Sent to the parent window of an owner-drawn button, combo box, list box,
* or menu when a visual aspect of the button, combo box, list box, or menu
* has changed.
*/
int WM_DRAWITEM = 0x002B;
/**
* Posted to the window with the keyboard focus when a nonsystem key is
* pressed. A nonsystem key is a key that is pressed when the ALT key is not
* pressed.
*/
int WM_KEYDOWN = 0x0100;
/**
* Posted to the window with the keyboard focus when a WM_KEYDOWN message is
* translated by the TranslateMessage function. The WM_CHAR message contains
* the character code of the key that was pressed.
*/
int WM_CHAR = 0x0102;
/**
* A window receives this message when the user chooses a command from the
* Window menu (formerly known as the system or control menu) or when the
* user chooses the maximize button, minimize button, restore button, or
* close button.
*/
int WM_SYSCOMMAND = 0x0112;
/**
* An application sends the WM_MDIMAXIMIZE message to a multiple-document
* interface (MDI) client window to maximize an MDI child window.
*/
int WM_MDIMAXIMIZE = 0x0225;
/**
* Posted when the user presses a hot key registered by the RegisterHotKey
* function. The message is placed at the top of the message queue
* associated with the thread that registered the hot key.
*/
int WM_HOTKEY = 0x0312;
int WM_KEYUP = 257;
int WM_SYSKEYDOWN = 260;
int WM_SYSKEYUP = 261;
int WM_SESSION_CHANGE = 0x2b1;
int WM_CREATE = 0x0001;
int WM_SIZE = 0x0005;
int WM_DESTROY = 0x0002;
public static final int WM_DEVICECHANGE = 0x0219;
public class KBDLLHOOKSTRUCT extends Structure {
public int vkCode;
public int scanCode;
public int flags;
public int time;
public ULONG_PTR dwExtraInfo;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"vkCode", "scanCode", "flags",
"time", "dwExtraInfo"});
}
}
int SM_CXSCREEN = 0;
int SM_CYSCREEN = 1;
int SM_CXVSCROLL = 2;
int SM_CYHSCROLL = 3;
int SM_CYCAPTION = 4;
int SM_CXBORDER = 5;
int SM_CYBORDER = 6;
int SM_CXDLGFRAME = 7;
int SM_CYDLGFRAME = 8;
int SM_CYVTHUMB = 9;
int SM_CXHTHUMB = 10;
int SM_CXICON = 11;
int SM_CYICON = 12;
int SM_CXCURSOR = 13;
int SM_CYCURSOR = 14;
int SM_CYMENU = 15;
int SM_CXFULLSCREEN = 16;
int SM_CYFULLSCREEN = 17;
int SM_CYKANJIWINDOW = 18;
int SM_MOUSEPRESENT = 19;
int SM_CYVSCROLL = 20;
int SM_CXHSCROLL = 21;
int SM_DEBUG = 22;
int SM_SWAPBUTTON = 23;
int SM_RESERVED1 = 24;
int SM_RESERVED2 = 25;
int SM_RESERVED3 = 26;
int SM_RESERVED4 = 27;
int SM_CXMIN = 28;
int SM_CYMIN = 29;
int SM_CXSIZE = 30;
int SM_CYSIZE = 31;
int SM_CXFRAME = 32;
int SM_CYFRAME = 33;
int SM_CXMINTRACK = 34;
int SM_CYMINTRACK = 35;
int SM_CXDOUBLECLK = 36;
int SM_CYDOUBLECLK = 37;
int SM_CXICONSPACING = 38;
int SM_CYICONSPACING = 39;
int SM_MENUDROPALIGNMENT = 40;
int SM_PENWINDOWS = 41;
int SM_DBCSENABLED = 42;
int SM_CMOUSEBUTTONS = 43;
int SM_CXFIXEDFRAME = SM_CXDLGFRAME; /* ;win40 name change */
int SM_CYFIXEDFRAME = SM_CYDLGFRAME; /* ;win40 name change */
int SM_CXSIZEFRAME = SM_CXFRAME; /* ;win40 name change */
int SM_CYSIZEFRAME = SM_CYFRAME; /* ;win40 name change */
int SM_SECURE = 44;
int SM_CXEDGE = 45;
int SM_CYEDGE = 46;
int SM_CXMINSPACING = 47;
int SM_CYMINSPACING = 48;
int SM_CXSMICON = 49;
int SM_CYSMICON = 50;
int SM_CYSMCAPTION = 51;
int SM_CXSMSIZE = 52;
int SM_CYSMSIZE = 53;
int SM_CXMENUSIZE = 54;
int SM_CYMENUSIZE = 55;
int SM_ARRANGE = 56;
int SM_CXMINIMIZED = 57;
int SM_CYMINIMIZED = 58;
int SM_CXMAXTRACK = 59;
int SM_CYMAXTRACK = 60;
int SM_CXMAXIMIZED = 61;
int SM_CYMAXIMIZED = 62;
int SM_NETWORK = 63;
int SM_CLEANBOOT = 67;
int SM_CXDRAG = 68;
int SM_CYDRAG = 69;
int SM_SHOWSOUNDS = 70;
int SM_CXMENUCHECK = 71;
int SM_CYMENUCHECK = 72;
int SM_SLOWMACHINE = 73;
int SM_MIDEASTENABLED = 74;
int SM_MOUSEWHEELPRESENT = 75;
int SM_XVIRTUALSCREEN = 76;
int SM_YVIRTUALSCREEN = 77;
int SM_CXVIRTUALSCREEN = 78;
int SM_CYVIRTUALSCREEN = 79;
int SM_CMONITORS = 80;
int SM_SAMEDISPLAYFORMAT = 81;
int SM_IMMENABLED = 82;
int SM_CXFOCUSBORDER = 83;
int SM_CYFOCUSBORDER = 84;
int SM_TABLETPC = 86;
int SM_MEDIACENTER = 87;
int SM_STARTER = 88;
int SM_SERVERR2 = 89;
int SM_MOUSEHORIZONTALWHEELPRESENT = 91;
int SM_CXPADDEDBORDER = 92;
int SM_REMOTESESSION = 0x1000;
int SM_SHUTTINGDOWN = 0x2000;
int SM_REMOTECONTROL = 0x2001;
int SM_CARETBLINKINGENABLED = 0x2002;
int SW_HIDE = 0;
int SW_SHOWNORMAL = 1;
int SW_NORMAL = 1;
int SW_SHOWMINIMIZED = 2;
int SW_SHOWMAXIMIZED = 3;
int SW_MAXIMIZE = 3;
int SW_SHOWNOACTIVATE = 4;
int SW_SHOW = 5;
int SW_MINIMIZE = 6;
int SW_SHOWMINNOACTIVE = 7;
int SW_SHOWNA = 8;
int SW_RESTORE = 9;
int SW_SHOWDEFAULT = 10;
int SW_FORCEMINIMIZE = 11;
int SW_MAX = 11;
int RDW_INVALIDATE = 0x0001;
int RDW_INTERNALPAINT = 0x0002;
int RDW_ERASE = 0x0004;
int RDW_VALIDATE = 0x0008;
int RDW_NOINTERNALPAINT = 0x0010;
int RDW_NOERASE = 0x0020;
int RDW_NOCHILDREN = 0x0040;
int RDW_ALLCHILDREN = 0x0080;
int RDW_UPDATENOW = 0x0100;
int RDW_ERASENOW = 0x0200;
int RDW_FRAME = 0x0400;
int RDW_NOFRAME = 0x0800;
/**
* The retrieved handle identifies the window of the same type that is
* highest in the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDFIRST = 0;
/**
* The retrieved handle identifies the window of the same type that is
* lowest in the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDLAST = 1;
/**
* The retrieved handle identifies the window below the specified window in
* the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDNEXT = 2;
/**
* The retrieved handle identifies the window above the specified window in
* the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDPREV = 3;
/**
* The retrieved handle identifies the specified window's owner window, if
* any. For more information, see Owned Windows.
*/
int GW_OWNER = 4;
/**
* The retrieved handle identifies the child window at the top of the Z
* order, if the specified window is a parent window; otherwise, the
* retrieved handle is NULL. The function examines only child windows of the
* specified window. It does not examine descendant windows.
*/
int GW_CHILD = 5;
/**
* The retrieved handle identifies the enabled popup window owned by the
* specified window (the search uses the first such window found using
* GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the
* retrieved handle is that of the specified window.
*/
int GW_ENABLEDPOPUP = 6;
/**
* Retains the current Z order (ignores the hWndInsertAfter parameter).
*/
int SWP_NOZORDER = 0x0004;
/**
* Minimizes the window.
*/
int SC_MINIMIZE = 0xF020;
/**
* Maximizes the window.
*/
int SC_MAXIMIZE = 0xF030;
/**
* Contains information about a simulated message generated by an input
* device other than a keyboard or mouse.
*/
public static class HARDWAREINPUT extends Structure {
public static class ByReference extends HARDWAREINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public HARDWAREINPUT() {
}
public HARDWAREINPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.DWORD uMsg;
public WinDef.WORD wParamL;
public WinDef.WORD wParamH;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"uMsg", "wParamL", "wParamH"});
}
}
/**
* Used by SendInput to store information for synthesizing input events such
* as keystrokes, mouse movement, and mouse clicks.
*/
public static class INPUT extends Structure {
public static final int INPUT_MOUSE = 0;
public static final int INPUT_KEYBOARD = 1;
public static final int INPUT_HARDWARE = 2;
public static class ByReference extends INPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public INPUT() {
}
public INPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.DWORD type;
public INPUT_UNION input = new INPUT_UNION();
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"type", "input"});
}
public static class INPUT_UNION extends Union {
public INPUT_UNION() {
}
public INPUT_UNION(Pointer memory) {
super(memory);
read();
}
public MOUSEINPUT mi;
public KEYBDINPUT ki;
public HARDWAREINPUT hi;
}
}
/**
* Contains information about a simulated keyboard event.
*/
public static class KEYBDINPUT extends Structure {
/**
* If specified, the scan code was preceded by a prefix byte that has
* the value 0xE0 (224).
*/
public static final int KEYEVENTF_EXTENDEDKEY = 0x0001;
/**
* If specified, the key is being released. If not specified, the key is
* being pressed.
*/
public static final int KEYEVENTF_KEYUP = 0x0002;
/**
* If specified, the system synthesizes a VK_PACKET keystroke. The wVk
* parameter must be zero. This flag can only be combined with the
* KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
*/
public static final int KEYEVENTF_UNICODE = 0x0004;
/**
* If specified, wScan identifies the key and wVk is ignored.
*/
public static final int KEYEVENTF_SCANCODE = 0x0008;
public static class ByReference extends KEYBDINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public KEYBDINPUT() {
}
public KEYBDINPUT(Pointer memory) {
super(memory);
read();
}
/**
* A virtual-key code. The code must be a value in the range 1 to 254.
* If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.
*/
public WinDef.WORD wVk;
/**
* A hardware scan code for the key. If dwFlags specifies
* KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be
* sent to the foreground application.
*/
public WinDef.WORD wScan;
/**
* Specifies various aspects of a keystroke. This member can be certain
* combinations of the following values.
*/
public WinDef.DWORD dwFlags;
/**
* The time stamp for the event, in milliseconds. If this parameter is
* zero, the system will provide its own time stamp.
*/
public WinDef.DWORD time;
/**
* An additional value associated with the keystroke. Use the
* GetMessageExtraInfo function to obtain this information.
*/
public BaseTSD.ULONG_PTR dwExtraInfo;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"wVk", "wScan", "dwFlags",
"time", "dwExtraInfo"});
}
}
/**
* Contains information about a simulated mouse event.
*/
public static class MOUSEINPUT extends Structure {
public static class ByReference extends MOUSEINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public MOUSEINPUT() {
}
public MOUSEINPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.LONG dx;
public WinDef.LONG dy;
public WinDef.DWORD mouseData;
public WinDef.DWORD dwFlags;
public WinDef.DWORD time;
public BaseTSD.ULONG_PTR dwExtraInfo;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"dx", "dy", "mouseData",
"dwFlags", "time", "dwExtraInfo"});
}
}
/**
* Contains the time of the last input.
*/
public static class LASTINPUTINFO extends Structure {
public int cbSize = size();
// Tick count of when the last input event was received.
public int dwTime;
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "dwTime"});
}
}
/**
* Contains window class information. It is used with the RegisterClassEx
* and GetClassInfoEx functions.
*
* The WNDCLASSEX structure is similar to the WNDCLASS structure. There are
* two differences. WNDCLASSEX includes the cbSize member, which specifies
* the size of the structure, and the hIconSm member, which contains a
* handle to a small icon associated with the window class.
*/
public class WNDCLASSEX extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends WNDCLASSEX implements
Structure.ByReference {
}
/**
* Instantiates a new wndclassex.
*/
public WNDCLASSEX() {
}
/**
* Instantiates a new wndclassex.
*
* @param memory the memory
*/
public WNDCLASSEX(Pointer memory) {
super(memory);
read();
}
/**
* The cb size.
*/
public int cbSize = this.size();
/**
* The style.
*/
public int style;
/**
* The lpfn wnd proc.
*/
public Callback lpfnWndProc;
/**
* The cb cls extra.
*/
public int cbClsExtra;
/**
* The cb wnd extra.
*/
public int cbWndExtra;
/**
* The h instance.
*/
public HINSTANCE hInstance;
/**
* The h icon.
*/
public HICON hIcon;
/**
* The h cursor.
*/
public HCURSOR hCursor;
/**
* The hbr background.
*/
public HBRUSH hbrBackground;
/**
* The lpsz menu name.
*/
public String lpszMenuName;
/**
* The lpsz class name.
*/
public WString lpszClassName;
/**
* The h icon sm.
*/
public HICON hIconSm;
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "style",
"lpfnWndProc", "cbClsExtra", "cbWndExtra", "hInstance",
"hIcon", "hCursor", "hbrBackground", "lpszMenuName",
"lpszClassName", "hIconSm"});
}
}
/**
* An application-defined function that processes messages sent to a window.
* The WNDPROC type defines a pointer to this callback function.
*
* WindowProc is a placeholder for the application-defined function name.
*/
public interface WindowProc extends Callback {
/**
* @param hwnd [in] Type: HWND
*
* A handle to the window.
*
* @param uMsg [in] Type: UINT
*
* The message.
*
* For lists of the system-provided messages, see System-Defined
* Messages.
*
* @param wParam [in] Type: WPARAM
*
* Additional message information. The contents of this parameter depend
* on the value of the uMsg parameter.
*
* @param lParam [in] Type: LPARAM
*
* Additional message information. The contents of this parameter depend
* on the value of the uMsg parameter.
*
* @return the lresult
*/
LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam);
}
}