/** * Dial a phone book entry by name (Asynchronously - callback type 2) * @param entryName The phone book entry name * @param func2 * @return the HRASCONN for this connection * @throws Ras32Exception errors */ public static HANDLE dialEntry(String entryName, RasDialFunc2 func2) throws Ras32Exception { // get the RAS Credentials RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference(); synchronized (phoneBookMutex) { credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain; int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials); if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err); } // set the dialing parameters RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference(); System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length()); System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length); System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length); System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length); // dial HANDLEByReference hrasConn = new HANDLEByReference(); int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 2, func2, hrasConn); if (err != WinError.ERROR_SUCCESS) { if (hrasConn.getValue() != null) Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue()); throw new Ras32Exception(err); } return hrasConn.getValue(); }
/** * Dial a phone book entry by name (Synchronously) * @param entryName The phone book entry name * @return result reference * @throws Ras32Exception errors */ public static HANDLE dialEntry(String entryName) throws Ras32Exception { // get the RAS Credentials RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference(); synchronized (phoneBookMutex) { credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain; int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials); if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err); } // set the dialing parameters RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference(); System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length()); System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length); System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length); System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length); // dial HANDLEByReference hrasConn = new HANDLEByReference(); int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 0, null, hrasConn); if (err != WinError.ERROR_SUCCESS) { if (hrasConn.getValue() != null) Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue()); throw new Ras32Exception(err); } return hrasConn.getValue(); }
WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, new HANDLEByReference().getValue());
Pointer spawnCfg = null; Pointer winpty = null; WinNT.HANDLEByReference processHandle = new WinNT.HANDLEByReference(); NamedPipe coninPipe = null; NamedPipe conoutPipe = null;
Memory securityDescriptorMemoryPointer = getSecurityDescriptorForFile(file.getAbsolutePath().replace('/', '\\')); HANDLEByReference openedAccessToken = new HANDLEByReference(); HANDLEByReference duplicatedToken = new HANDLEByReference(); Win32Exception err = null; try{
final WinNT.HANDLE accessToken; final WinNT.HANDLEByReference tokenReference = new WinNT.HANDLEByReference(); final boolean success = advapi32.OpenProcessToken( kernel32.GetCurrentProcess(),
final HANDLEByReference phThreadToken = new HANDLEByReference();
final HANDLEByReference phThreadToken = new HANDLEByReference(); final HANDLEByReference phProcessToken = new HANDLEByReference();
HANDLEByReference phToken = new HANDLEByReference(); Win32Exception err = null; try {
WinNT.FILE_SHARE_READ, new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, new HANDLEByReference().getValue());
public static PRINTER_INFO_2 getPrinterInfo2(String printerName) { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference(); HANDLEByReference pHandle = new HANDLEByReference();
final HANDLEByReference phThreadToken = new HANDLEByReference();
HANDLEByReference phToken = new HANDLEByReference(); try {
@Override public IWindowsIdentity getIdentity() { final HANDLEByReference phContextToken = new HANDLEByReference(); final int rc = Secur32.INSTANCE.QuerySecurityContextToken(this.ctx, phContextToken); if (WinError.SEC_E_OK != rc) { throw new Win32Exception(rc); } return new WindowsIdentityImpl(phContextToken.getValue()); }
@Override public IWindowsIdentity logonDomainUserEx(final String username, final String domain, final String password, final int logonType, final int logonProvider) { final HANDLEByReference phUser = new HANDLEByReference(); if (!Advapi32.INSTANCE.LogonUser(username, domain, password, logonType, logonProvider, phUser)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return new WindowsIdentityImpl(phUser.getValue()); }
@Override public IWindowsIdentity getIdentity() { final HANDLEByReference phContextToken = new HANDLEByReference(); final int rc = Secur32.INSTANCE.QuerySecurityContextToken(this.ctx, phContextToken); if (WinError.SEC_E_OK != rc) { throw new Win32Exception(rc); } return new WindowsIdentityImpl(phContextToken.getValue()); }
@Override public IWindowsIdentity logonDomainUserEx(final String username, final String domain, final String password, final int logonType, final int logonProvider) { final HANDLEByReference phUser = new HANDLEByReference(); if (!Advapi32.INSTANCE.LogonUser(username, domain, password, logonType, logonProvider, phUser)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return new WindowsIdentityImpl(phUser.getValue()); }
@Override public IWindowsIdentity logonDomainUserEx(final String username, final String domain, final String password, final int logonType, final int logonProvider) { final HANDLEByReference phUser = new HANDLEByReference(); if (!Advapi32.INSTANCE.LogonUser(username, domain, password, logonType, logonProvider, phUser)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return new WindowsIdentityImpl(phUser.getValue()); }
private void addShutdownPrivilegeToProcess() { HANDLEByReference hToken = new HANDLEByReference(); LUID luid = new LUID(); Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(), WinNT.TOKEN_ADJUST_PRIVILEGES, hToken); Advapi32.INSTANCE.LookupPrivilegeValue("", WinNT.SE_SHUTDOWN_NAME, luid); TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES(1); tp.Privileges[0] = new LUID_AND_ATTRIBUTES(luid, new DWORD(WinNT.SE_PRIVILEGE_ENABLED)); Advapi32.INSTANCE.AdjustTokenPrivileges(hToken.getValue(), false, tp, tp.size(), null, new IntByReference()); }
@Override public IWindowsIdentity getIdentity() { final HANDLEByReference phContextToken = new HANDLEByReference(); final int rc = Secur32.INSTANCE.QuerySecurityContextToken(this.ctx, phContextToken); if (WinError.SEC_E_OK != rc) { throw new Win32Exception(rc); } return new WindowsIdentityImpl(phContextToken.getValue()); }