/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Win32 and library calls.
*/
class WindowsNativeDispatcher {
private WindowsNativeDispatcher() { }
/**
* HANDLE CreateFile(
* LPCTSTR lpFileName,
* DWORD dwDesiredAccess,
* DWORD dwShareMode,
* LPSECURITY_ATTRIBUTES lpSecurityAttributes,
* DWORD dwCreationDisposition,
* DWORD dwFlagsAndAttributes,
* HANDLE hTemplateFile
* )
*/
int dwDesiredAccess,
int dwShareMode,
long lpSecurityAttributes,
int dwFlagsAndAttributes)
throws WindowsException
{
try {
} finally {
}
}
int dwDesiredAccess,
int dwShareMode,
int dwFlagsAndAttributes)
throws WindowsException
{
}
int dwDesiredAccess,
int dwShareMode,
long lpSecurityAttributes,
int dwFlagsAndAttributes)
throws WindowsException;
/**
* CloseHandle(
* HANDLE hObject
* )
*/
/**
* DeleteFile(
* LPCTSTR lpFileName
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* CreateDirectory(
* LPCTSTR lpPathName,
* LPSECURITY_ATTRIBUTES lpSecurityAttributes
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* RemoveDirectory(
* LPCTSTR lpPathName
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* Marks a file as a sparse file.
*
* DeviceIoControl(
* FSCTL_SET_SPARSE
* )
*/
throws WindowsException;
/**
* Retrieves the reparse point data associated with the file or directory.
*
* DeviceIoControl(
* FSCTL_GET_REPARSE_POINT
* )
*/
/**
* HANDLE FindFirstFile(
* LPCTSTR lpFileName,
* LPWIN32_FIND_DATA lpFindFileData
* )
*/
try {
return data;
} finally {
}
}
static class FirstFile {
private long handle;
private int attributes;
private FirstFile() { }
}
throws WindowsException;
/**
* HANDLE FindFirstFile(
* LPCTSTR lpFileName,
* LPWIN32_FIND_DATA lpFindFileData
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* FindNextFile(
* HANDLE hFindFile,
* LPWIN32_FIND_DATA lpFindFileData
* )
*
* @return lpFindFileData->cFileName or null
*/
throws WindowsException;
/**
* HANDLE FindFirstStreamW(
* LPCWSTR lpFileName,
* STREAM_INFO_LEVELS InfoLevel,
* LPVOID lpFindStreamData,
* DWORD dwFlags
* )
*/
try {
return null;
return data;
} finally {
}
}
static class FirstStream {
private long handle;
private FirstStream() { }
}
throws WindowsException;
/*
* FindNextStreamW(
* HANDLE hFindStream,
* LPVOID lpFindStreamData
* )
*/
/**
* FindClose(
* HANDLE hFindFile
* )
*/
/**
* GetFileInformationByHandle(
* HANDLE hFile,
* LPBY_HANDLE_FILE_INFORMATION lpFileInformation
* )
*/
throws WindowsException;
/**
* CopyFileEx(
* LPCWSTR lpExistingFileName
* LPCWSTR lpNewFileName,
* LPPROGRESS_ROUTINE lpProgressRoutine
* LPVOID lpData,
* LPBOOL pbCancel,
* DWORD dwCopyFlags
* )
*/
long addressToPollForCancel)
throws WindowsException
{
try {
} finally {
}
}
/**
* MoveFileEx(
* LPCTSTR lpExistingFileName,
* LPCTSTR lpNewFileName,
* DWORD dwFlags
* )
*/
throws WindowsException
{
try {
} finally {
}
}
int flags) throws WindowsException;
/**
* DWORD GetFileAttributes(
* LPCTSTR lpFileName
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* SetFileAttributes(
* LPCTSTR lpFileName,
* DWORD dwFileAttributes
*/
throws WindowsException
{
try {
} finally {
}
}
int dwFileAttributes) throws WindowsException;
/**
* GetFileAttributesEx(
* LPCTSTR lpFileName,
* GET_FILEEX_INFO_LEVELS fInfoLevelId,
* LPVOID lpFileInformation
* );
*/
try {
} finally {
}
}
throws WindowsException;
/**
* SetFileTime(
* HANDLE hFile,
* CONST FILETIME *lpCreationTime,
* CONST FILETIME *lpLastAccessTime,
* CONST FILETIME *lpLastWriteTime
* )
*/
long createTime,
long lastAccessTime,
long lastWriteTime)
throws WindowsException;
/**
* SetEndOfFile(
* HANDLE hFile
* )
*/
/**
* DWORD GetLogicalDrives(VOID)
*/
/**
* GetVolumeInformation(
* LPCTSTR lpRootPathName,
* LPTSTR lpVolumeNameBuffer,
* DWORD nVolumeNameSize,
* LPDWORD lpVolumeSerialNumber,
* LPDWORD lpMaximumComponentLength,
* LPDWORD lpFileSystemFlags,
* LPTSTR lpFileSystemNameBuffer,
* DWORD nFileSystemNameSize
* )
*/
throws WindowsException
{
try {
return info;
} finally {
}
}
static class VolumeInformation {
private int volumeSerialNumber;
private int flags;
private VolumeInformation() { }
}
throws WindowsException;
/**
* UINT GetDriveType(
* LPCTSTR lpRootPathName
* )
*/
try {
} finally {
}
}
/**
* GetDiskFreeSpaceEx(
* LPCTSTR lpDirectoryName,
* PULARGE_INTEGER lpFreeBytesAvailableToCaller,
* PULARGE_INTEGER lpTotalNumberOfBytes,
* PULARGE_INTEGER lpTotalNumberOfFreeBytes
* )
*/
throws WindowsException
{
try {
return space;
} finally {
}
}
static class DiskFreeSpace {
private long freeBytesAvailable;
private long totalNumberOfBytes;
private long totalNumberOfFreeBytes;
private DiskFreeSpace() { }
}
throws WindowsException;
/**
* GetVolumePathName(
* LPCTSTR lpszFileName,
* LPTSTR lpszVolumePathName,
* DWORD cchBufferLength
* )
*
* @return lpFileName
*/
try {
} finally {
}
}
throws WindowsException;
/**
* InitializeSecurityDescriptor(
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* DWORD dwRevision
* )
*/
throws WindowsException;
/**
* InitializeAcl(
* PACL pAcl,
* DWORD nAclLength,
* DWORD dwAclRevision
* )
*/
throws WindowsException;
/**
* GetFileSecurity(
* LPCTSTR lpFileName,
* SECURITY_INFORMATION RequestedInformation,
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* DWORD nLength,
* LPDWORD lpnLengthNeeded
* )
*/
int requestedInformation,
long pSecurityDescriptor,
int nLength) throws WindowsException
{
try {
} finally {
}
}
int requestedInformation,
long pSecurityDescriptor,
int nLength) throws WindowsException;
/**
* SetFileSecurity(
* LPCTSTR lpFileName,
* SECURITY_INFORMATION SecurityInformation,
* PSECURITY_DESCRIPTOR pSecurityDescriptor
* )
*/
int securityInformation,
long pSecurityDescriptor)
throws WindowsException
{
try {
} finally {
}
}
long pSecurityDescriptor) throws WindowsException;
/**
* GetSecurityDescriptorOwner(
* PSECURITY_DESCRIPTOR pSecurityDescriptor
* PSID *pOwner,
* LPBOOL lpbOwnerDefaulted
* )
*
* @return pOwner
*/
throws WindowsException;
/**
* SetSecurityDescriptorOwner(
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* PSID pOwner,
* BOOL bOwnerDefaulted
* )
*/
long pOwner)
throws WindowsException;
/**
* GetSecurityDescriptorDacl(
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* LPBOOL lpbDaclPresent,
* PACL *pDacl,
* LPBOOL lpbDaclDefaulted
* )
*/
/**
* SetSecurityDescriptorDacl(
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* BOOL bDaclPresent,
* PACL pDacl,
* BOOL bDaclDefaulted
* )
*/
throws WindowsException;
/**
* GetAclInformation(
* PACL pAcl,
* LPVOID pAclInformation,
* DWORD nAclInformationLength,
* ACL_INFORMATION_CLASS dwAclInformationClass
* )
*/
return info;
}
static class AclInformation {
private int aceCount;
private AclInformation() { }
}
/**
* GetAce(
* PACL pAcl,
* DWORD dwAceIndex,
* LPVOID *pAce
* )
*/
/**
* AddAccessAllowedAceEx(
* PACL pAcl,
* DWORD dwAceRevision,
* DWORD AceFlags,
* DWORD AccessMask,
* PSID pSid
* )
*/
/**
* AddAccessDeniedAceEx(
* PACL pAcl,
* DWORD dwAceRevision,
* DWORD AceFlags,
* DWORD AccessMask,
* PSID pSid
* )
*/
/**
* LookupAccountSid(
* LPCTSTR lpSystemName,
* PSID Sid,
* LPTSTR Name,
* LPDWORD cbName,
* LPTSTR ReferencedDomainName,
* LPDWORD cbReferencedDomainName,
* PSID_NAME_USE peUse
* )
*/
return acc;
}
static class Account {
private int use;
private Account() { }
}
throws WindowsException;
/**
* LookupAccountName(
* LPCTSTR lpSystemName,
* LPCTSTR lpAccountName,
* PSID Sid,
* LPDWORD cbSid,
* LPTSTR ReferencedDomainName,
* LPDWORD cbReferencedDomainName,
* PSID_NAME_USE peUse
* )
*
* @return cbSid
*/
long pSid,
int cbSid) throws WindowsException
{
try {
} finally {
}
}
int cbSid) throws WindowsException;
/**
* DWORD GetLengthSid(
* PSID pSid
* )
*/
/**
* ConvertSidToStringSid(
* PSID Sid,
* LPTSTR* StringSid
* )
*
* @return StringSid
*/
throws WindowsException;
/**
* ConvertStringSidToSid(
* LPCTSTR StringSid,
* PSID* pSid
* )
*
* @return pSid
*/
throws WindowsException
{
try {
} finally {
}
}
throws WindowsException;
/**
* HANDLE GetCurrentProcess(VOID)
*/
static native long GetCurrentProcess();
/**
* HANDLE GetCurrentThread(VOID)
*/
static native long GetCurrentThread();
/**
* OpenProcessToken(
* HANDLE ProcessHandle,
* DWORD DesiredAccess,
* PHANDLE TokenHandle
* )
*/
throws WindowsException;
/**
* OpenThreadToken(
* HANDLE ThreadHandle,
* DWORD DesiredAccess,
* BOOL OpenAsSelf,
* PHANDLE TokenHandle
* )
*/
boolean openAsSelf) throws WindowsException;
/**
*/
throws WindowsException;
/**
* SetThreadToken(
* PHANDLE Thread,
* HANDLE Token
* )
*/
throws WindowsException;
/**
* GetTokenInformation(
* HANDLE TokenHandle,
* TOKEN_INFORMATION_CLASS TokenInformationClass,
* LPVOID TokenInformation,
* DWORD TokenInformationLength,
* PDWORD ReturnLength
* )
*/
/**
* AdjustTokenPrivileges(
* HANDLE TokenHandle,
* BOOL DisableAllPrivileges
* PTOKEN_PRIVILEGES NewState
* DWORD BufferLength
* PTOKEN_PRIVILEGES
* PDWORD ReturnLength
* )
*/
throws WindowsException;
/**
* AccessCheck(
* PSECURITY_DESCRIPTOR pSecurityDescriptor,
* HANDLE ClientToken,
* DWORD DesiredAccess,
* PGENERIC_MAPPING GenericMapping,
* PPRIVILEGE_SET PrivilegeSet,
* LPDWORD PrivilegeSetLength,
* LPDWORD GrantedAccess,
* LPBOOL AccessStatus
* )
*/
throws WindowsException;
/**
*/
try {
} finally {
}
}
throws WindowsException;
/**
* CreateSymbolicLink(
* LPCWSTR lpSymlinkFileName,
* LPCWSTR lpTargetFileName,
* DWORD dwFlags
* )
*/
throws WindowsException
{
try {
flags);
} finally {
}
}
/**
* CreateHardLink(
* LPCTSTR lpFileName,
* LPCTSTR lpExistingFileName,
* LPSECURITY_ATTRIBUTES lpSecurityAttributes
* )
*/
throws WindowsException
{
try {
} finally {
}
}
long existingFiletBuffer) throws WindowsException;
/**
* GetFullPathName(
* LPCTSTR lpFileName,
* DWORD nBufferLength,
* LPTSTR lpBuffer,
* LPTSTR *lpFilePart
* )
*/
try {
} finally {
}
}
throws WindowsException;
/**
* GetFinalPathNameByHandle(
* HANDLE hFile,
* LPTSTR lpszFilePath,
* DWORD cchFilePath,
* DWORD dwFlags
* )
*/
throws WindowsException;
/**
* FormatMessage(
* DWORD dwFlags,
* LPCVOID lpSource,
* DWORD dwMessageId,
* DWORD dwLanguageId,
* LPTSTR lpBuffer,
* DWORD nSize,
* va_list *Arguments
* )
*/
/**
* LocalFree(
* HLOCAL hMem
* )
*/
/**
* HANDLE CreateIoCompletionPort (
* HANDLE FileHandle,
* HANDLE ExistingCompletionPort,
* DWORD CompletionKey,
* DWORD NumberOfConcurrentThreads
* )
*/
int completionKey) throws WindowsException;
/**
* GetQueuedCompletionStatus(
* HANDLE CompletionPort,
* LPDWORD lpNumberOfBytesTransferred,
* LPDWORD lpCompletionKey,
* LPOVERLAPPED *lpOverlapped,
* DWORD dwMilliseconds
*/
throws WindowsException
{
return status;
}
static class CompletionStatus {
private int error;
private int bytesTransferred;
private int completionKey;
private CompletionStatus() { }
}
/**
* PostQueuedCompletionStatus(
* HANDLE CompletionPort,
* DWORD dwNumberOfBytesTransferred,
* DWORD dwCompletionKey,
* LPOVERLAPPED lpOverlapped
* )
*/
int completionKey) throws WindowsException;
/**
* ReadDirectoryChangesW(
* HANDLE hDirectory,
* LPVOID lpBuffer,
* DWORD nBufferLength,
* BOOL bWatchSubtree,
* DWORD dwNotifyFilter,
* LPDWORD lpBytesReturned,
* LPOVERLAPPED lpOverlapped,
* LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
* )
*/
long bufferAddress,
int bufferLength,
boolean watchSubTree,
int filter,
long bytesReturnedAddress,
long pOverlapped)
throws WindowsException;
/**
* BackupRead(
* HANDLE hFile,
* LPBYTE lpBuffer,
* DWORD nNumberOfBytesToRead,
* LPDWORD lpNumberOfBytesRead,
* BOOL bAbort,
* BOOL bProcessSecurity,
* LPVOID* lpContext
* )
*/
long bufferAddress,
int bufferSize,
boolean abort,
long context)
throws WindowsException
{
return result;
}
static class BackupResult {
private int bytesTransferred;
private long context;
private BackupResult() { }
}
throws WindowsException;
/**
* BackupSeek(
* HANDLE hFile,
* DWORD dwLowBytesToSeek,
* DWORD dwHighBytesToSeek,
* LPDWORD lpdwLowByteSeeked,
* LPDWORD lpdwHighByteSeeked,
* LPVOID* lpContext
* )
*/
throws WindowsException;
// -- support for copying String with a NativeBuffer --
// get a native buffer of sufficient size
} else {
// buffer already contains the string contents
return buffer;
}
// copy into buffer and zero terminate
char[] chars = s.toCharArray();
return buffer;
}
// -- native library initialization --
private static native void initIDs();
static {
// nio.dll has dependency on net.dll
return null;
}});
initIDs();
}
}