private long getDiskSize(Disk disk) { long result = -1l; Kernel32 kernel32 = Kernel32.INSTANCE; HANDLE diskHandle = kernel32.CreateFile(disk.path, WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ, null, WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null); if (WinBase.INVALID_HANDLE_VALUE.equals(diskHandle)) { return result; } try { Memory output = new Memory(Native.getNativeSize(LARGE_INTEGER.class)); IntByReference lpBytes = new IntByReference(); boolean success = kernel32.DeviceIoControl(diskHandle, WinioctlUtil.CTL_CODE(Winioctl.FILE_DEVICE_DISK, 0x17, Winioctl.METHOD_BUFFERED, Winioctl.FILE_READ_ACCESS), null, 0, output, Native.getNativeSize(LARGE_INTEGER.class), lpBytes, null); // TODO: Check success? result = output.getLong(0); } finally { Kernel32Util.closeHandle(diskHandle); } return result; }
/** * @param modelId * @param size * @return */ public Set<RenderEngineClash> finalizeClashesByEI(Pointer modelId, int size) { Set<RenderEngineClash> clashes = new HashSet<RenderEngineClash>(); Memory pG1 = new Memory(size * 4 * getPlatformMultiplier()); Memory pG2 = new Memory(size * 4 * getPlatformMultiplier()); engine.finalizeClashesByEI(modelId, pG1, pG2); for (int i = 0; i < size; i++) { Long eid1 = null; Long eid2 = null; if (getPlatformMultiplier() == 1) { eid1 = (long)pG1.getInt(i * 4 * getPlatformMultiplier()); eid2 = (long)pG2.getInt(i * 4 * getPlatformMultiplier()); } else { eid1 = pG1.getLong(i * 4 * getPlatformMultiplier()); eid2 = pG2.getLong(i * 4 * getPlatformMultiplier()); } RenderEngineClash clash = new RenderEngineClash(); clash.setEid1(eid1); clash.setEid2(eid2); clashes.add(clash); } return clashes; }
/** * @param modelId * @param size * @return */ public Set<RenderEngineClash> finalizeClashesByGuid(Pointer modelId, int size) { Set<RenderEngineClash> clashes = new HashSet<RenderEngineClash>(); Memory pG1 = new Memory(size * 4 * getPlatformMultiplier()); Memory pG2 = new Memory(size * 4 * getPlatformMultiplier()); engine.finalizeClashesByGuid(modelId, pG1, pG2); for (int i = 0; i < size; i++) { Pointer memory1 = pG1.getPointer(i * 4 * getPlatformMultiplier()); String pG1Str = memory1.getString(0); Pointer memory2 = pG2.getPointer(i * 4 * getPlatformMultiplier()); String pG2Str = memory2.getString(0); RenderEngineClash clash = new RenderEngineClash(); clash.setGuid1(pG1Str); clash.setGuid2(pG2Str); clashes.add(clash); } return clashes; }
public float[] owlGetMappedItem(Pointer model, Pointer instance, long owlInstance) { Memory memory = new Memory(16 * 4 * getPlatformMultiplier()); LongByReference owlInstanceReference = new LongByReference(); owlInstanceReference.setValue(owlInstance); engine.owlGetMappedItem(model, instance, owlInstanceReference, memory); if (getPlatformMultiplier() == 2) { double[] doubleArray = memory.getDoubleArray(0, 16); float[] floatArray = new float[16]; for (int i=0; i<16; i++) { floatArray[i] = (float)doubleArray[i]; } return floatArray; } else { return memory.getFloatArray(0, 16); } }
public native short NSFSearchExtended3 (int hDB, int hFormula, int hFilter, int FilterFlags, Memory ViewTitle, int SearchFlags, int SearchFlags1, int SearchFlags2, int SearchFlags3, int SearchFlags4, short NoteClassMask, NotesTimeDateStruct Since, NotesCallbacks.b32_NsfSearchProc EnumRoutine, Pointer EnumRoutineParameter, NotesTimeDateStruct retUntil, int namelist);
public native short NSFSearchExtended3 (long hDB, long hFormula, long hFilter, int filterFlags, Memory ViewTitle, int SearchFlags, int SearchFlags1, int SearchFlags2, int SearchFlags3, int SearchFlags4, short NoteClassMask, NotesTimeDateStruct Since, NotesCallbacks.b64_NsfSearchProc EnumRoutine, Pointer EnumRoutineParameter, NotesTimeDateStruct retUntil, long namelist);
/** * Retrieves a message from a message queue, provided the queue is not in a QUIT state. * The message will be stored in the buffer specified in the Buffer argument.<br> * Note: The error code {@link INotesErrorConstants#ERR_MQ_QUITTING} indicates that the * message queue is in the QUIT state, denoting that applications that are reading * the message queue should terminate. For instance, a server addin's message queue * will be placed in the QUIT state when a "tell <addin> quit" command is input at the console. * @param buffer buffer used to read data * @param waitForMessage if the specified message queue is empty, wait for a message to appear in the queue. The timeout argument specifies the amount of time to wait for a message. * @param timeoutMillis if waitForMessage is set to <code>true</code>, the number of milliseconds to wait for a message before timing out. Specify 0 to wait forever. If the message queue goes into a QUIT state before the Timeout expires, MQGet will return immediately. * @param offset the offset in the buffer where to start writing the message * @param length the max length of the message in the buffer * @return Number of bytes written to the buffer */ public int get(Memory buffer, boolean waitForMessage, int timeoutMillis, int offset, int length) { checkHandle(); if (length > NotesConstants.MQ_MAX_MSGSIZE) { throw new IllegalArgumentException("Max size for the buffer is "+NotesConstants.MQ_MAX_MSGSIZE+" bytes. You specified one with "+length+" bytes."); } ShortByReference retMsgLength = new ShortByReference(); short result = NotesNativeAPI.get().MQGet(m_queue, buffer, (short) (length & 0xffff), waitForMessage ? NotesConstants.MQ_WAIT_FOR_MSG : 0, timeoutMillis, retMsgLength); NotesErrorUtils.checkResult(result); return retMsgLength.getValue(); }
@Override protected FileAttributes getAttributes(@NotNull String path) throws Exception { Memory buffer = new Memory(256); int res = SystemInfo.isLinux ? myLibC.__lxstat64(STAT_VER, path, buffer) : myLibC.lstat(path, buffer); if (res != 0) return null; int mode = getModeFlags(buffer) & LibC.S_MASK; boolean isSymlink = (mode & LibC.S_IFMT) == LibC.S_IFLNK; if (isSymlink) { if (!loadFileStatus(path, buffer)) { return FileAttributes.BROKEN_SYMLINK; } mode = getModeFlags(buffer) & LibC.S_MASK; } boolean isDirectory = (mode & LibC.S_IFMT) == LibC.S_IFDIR; boolean isSpecial = !isDirectory && (mode & LibC.S_IFMT) != LibC.S_IFREG; long size = buffer.getLong(myOffsets[OFF_SIZE]); long mTime1 = SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME]) : buffer.getLong(myOffsets[OFF_TIME]); long mTime2 = myCoarseTs ? 0 : SystemInfo.is32Bit ? buffer.getInt(myOffsets[OFF_TIME] + 4) : buffer.getLong(myOffsets[OFF_TIME] + 8); long mTime = mTime1 * 1000 + mTime2 / 1000000; boolean writable = ownFile(buffer) ? (mode & LibC.WRITE_MASK) != 0 : myLibC.access(path, LibC.W_OK) == 0; return new FileAttributes(isDirectory, isSpecial, isSymlink, false, size, mTime, writable); }
/** * This function returns the path specification of the local Domino or Notes * executable / data / temp directory.<br> * <br> * Author: Ulrich Krause * * @param osDirectory * {@link OSDirectory} * @return path */ public static String getOsDirectory(OSDirectory osDirectory) { Memory retPathName = new Memory(NotesConstants.MAXPATH); switch (osDirectory) { case EXECUTABLE: NotesNativeAPI.get().OSGetExecutableDirectory(retPathName); break; case DATA: NotesNativeAPI.get().OSGetDataDirectory(retPathName); break; case TEMP: NotesNativeAPI.get().OSGetSystemTempDirectory(retPathName, NotesConstants.MAXPATH); break; case VIEWREBUILD: NotesNativeAPI.get().NIFGetViewRebuildDir(retPathName, NotesConstants.MAXPATH); break; case DAOS: NotesNativeAPI.get().DAOSGetBaseStoragePath(retPathName, NotesConstants.MAXPATH); break; default: throw new IllegalArgumentException("Unsupported directory type: "+osDirectory); } NotesNativeAPI.get().OSPathAddTrailingPathSep(retPathName); return NotesStringUtils.fromLMBCS(retPathName, -1); }
/** * Gets the icon that corresponds to a given icon handler. * * @param hIcon * Handler to the icon to get * @return The icon that corresponds to a given icon handler */ public static BufferedImage getIcon(final HICON hIcon) { final int width = ICON_SIZE; final int height = ICON_SIZE; final short depth = ICON_DEPTH; final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); final Memory lpBitsColor = new Memory(width * height * depth / ICON_BYTE_SIZE); final Memory lpBitsMask = new Memory(width * height * depth / ICON_BYTE_SIZE); final BITMAPINFO info = new BITMAPINFO(); final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER(); info.bmiHeader = hdr; hdr.biWidth = width; hdr.biHeight = height; hdr.biPlanes = 1; hdr.biBitCount = depth; hdr.biCompression = WinGDI.BI_RGB; final HDC hDC = User32.INSTANCE.GetDC(null); final ICONINFO piconinfo = new ICONINFO(); User32.INSTANCE.GetIconInfo(hIcon, piconinfo); GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmColor, 0, height, lpBitsColor, info, WinGDI.DIB_RGB_COLORS); GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmMask, 0, height, lpBitsMask, info, WinGDI.DIB_RGB_COLORS); int r, g, b, a, argb; int x = 0, y = height - 1; for (int i = 0; i < lpBitsColor.size(); i = i + 3) { b = lpBitsColor.getByte(i) & 0xFF; g = lpBitsColor.getByte(i + 1) & 0xFF; r = lpBitsColor.getByte(i + 2) & 0xFF; a = 0xFF - lpBitsMask.getByte(i) & 0xFF; argb = a << 24 | r << 16 | g << 8 | b; image.setRGB(x, y, argb); x = (x + 1) % width; if (x == 0) { y--; } } User32.INSTANCE.ReleaseDC(null, hDC); GDI32.INSTANCE.DeleteObject(piconinfo.hbmColor); GDI32.INSTANCE.DeleteObject(piconinfo.hbmMask); return image; }
/** * Reads the note flags (e.g. {@link NotesConstants#NOTE_FLAG_READONLY}) * * @return flags */ private short getFlags() { checkHandle(); Memory retFlags = new Memory(2); retFlags.clear(); if (PlatformUtils.is64Bit()) { NotesNativeAPI64.get().NSFNoteGetInfo(m_hNote64, NotesConstants._NOTE_FLAGS, retFlags); } else { NotesNativeAPI32.get().NSFNoteGetInfo(m_hNote32, NotesConstants._NOTE_FLAGS, retFlags); } short flags = retFlags.getShort(0); return flags; }
/** * Converts a C API error code to an error message * * @param err error code * @return error message */ public static String errToString(short err) { if (err==0) return ""; Memory retBuffer = new Memory(256); short outStrLength = NotesNativeAPI.get().OSLoadString(0, err, retBuffer, (short) 255); if (outStrLength==0) { return ""; } Memory newRetBuffer = new Memory(outStrLength); for (int i=0; i<outStrLength; i++) { newRetBuffer.setByte(i, retBuffer.getByte(i)); } String message = NotesStringUtils.fromLMBCS(newRetBuffer, outStrLength); return message; }
public short NSFSearchExtended3 (long hDB, long hFormula, long hFilter, int filterFlags, Memory ViewTitle, int SearchFlags, int SearchFlags1, int SearchFlags2, int SearchFlags3, int SearchFlags4, short NoteClassMask, NotesTimeDateStruct Since, NotesCallbacks.b64_NsfSearchProc EnumRoutine, Pointer EnumRoutineParameter, NotesTimeDateStruct retUntil, long namelist);
/** * Method to remove an item from a note * * @param itemName item name */ public void removeItem(String itemName) { checkHandle(); Memory itemNameMem = NotesStringUtils.toLMBCS(itemName, false); short result; if (PlatformUtils.is64Bit()) { result = NotesNativeAPI64.get().NSFItemDelete(m_hNote64, itemNameMem, (short) (itemNameMem.size() & 0xffff)); } else { result = NotesNativeAPI32.get().NSFItemDelete(m_hNote32, itemNameMem, (short) (itemNameMem.size() & 0xffff)); } if (result==INotesErrorConstants.ERR_ITEM_NOT_FOUND) { return; } NotesErrorUtils.checkResult(result); }
/** * Stores the values from {@code array} allocating memory as needed. * * @param array the array of {@link E}s to write to the referenced memory. * The array size must be the same as defined for this * {@link FixedArrayByReference}. */ public void setArray(E[] array) { if (array == null) { throw new NullPointerException("array cannot be null"); } if (array.length != size) { throw new IllegalArgumentException("array size must be " + size); } if (size < 1) { super.setPointer(Pointer.NULL); return; } else if (getPointer() == null) { // Allocate new memory super.setPointer(new Memory(getElementSize() * size)); } setElements(array); }
/** * Returns the note class of the note * * @return note class */ public EnumSet<NoteClass> getNoteClass() { if (m_noteClass==null) { checkHandle(); Memory retNoteClass = new Memory(2); retNoteClass.clear(); if (PlatformUtils.is64Bit()) { NotesNativeAPI64.get().NSFNoteGetInfo(m_hNote64, NotesConstants._NOTE_CLASS, retNoteClass); } else { NotesNativeAPI32.get().NSFNoteGetInfo(m_hNote32, NotesConstants._NOTE_CLASS, retNoteClass); } int noteClassMask = retNoteClass.getShort(0); m_noteClass = NoteClass.toNoteClasses(noteClassMask); } return m_noteClass; }
/** * Converts CFString object to String. * * @param cfStringPointer Pointer to CFString object * @return String from CFString */ private String getStringFromCFStringRef(Pointer cfStringPointer) { if (cfStringPointer != null) { long lenght = cfLibrary.CFStringGetLength(cfStringPointer); long maxSize = cfLibrary.CFStringGetMaximumSizeForEncoding(lenght, 0x08000100); // 0x08000100 = UTF-8 Pointer buffer = new Memory(maxSize); if (cfLibrary.CFStringGetCString(cfStringPointer, buffer, maxSize, 0x08000100)) { // 0x08000100 = UTF-8 return buffer.getString(0L); } } return null; }
/** * Converts CFNumber to int. * * @param cfNumberPointer pointer to CFNumber object * @return int from CFNumber */ private int getIntFromCFNumberRef(Pointer cfNumberPointer) { if (cfNumberPointer != null) { Pointer cfNumberType = cfLibrary.CFNumberGetType(cfNumberPointer); long numberSize = cfLibrary.CFNumberGetByteSize(cfNumberPointer); Pointer numberValue = new Memory(numberSize); if (cfLibrary.CFNumberGetValue(cfNumberPointer, cfNumberType, numberValue)) { return numberValue.getInt(0L); } } return 0; }
/** * Converts CFNumber to String. * * @param cfNumberPointer pointer to CFNumber object * @return String from CFNumber */ private String getStringFromCFNumberRef(Pointer cfNumberPointer) { if (cfNumberPointer != null) { Pointer cfNumberType = cfLibrary.CFNumberGetType(cfNumberPointer); long numberSize = cfLibrary.CFNumberGetByteSize(cfNumberPointer); Pointer numberValue = new Memory(numberSize); if (cfLibrary.CFNumberGetValue(cfNumberPointer, cfNumberType, numberValue)) { return String.valueOf(numberValue.getInt(0L)); } } return null; }
public static boolean inject(int processID, String dllName) { DWORD_PTR processAccess = new DWORD_PTR(0x43A); HANDLE hProcess = kernel32.OpenProcess(processAccess, new BOOL(false), new DWORD_PTR(processID)); if(hProcess == null) { System.out.println("Handle was NULL! Error: " + kernel32.GetLastError()); return false; } DWORD_PTR loadLibraryAddress = kernel32.GetProcAddress(kernel32.GetModuleHandle("KERNEL32"), "LoadLibraryA"); if(loadLibraryAddress.intValue() == 0) { System.out.println("Could not find LoadLibrary! Error: " + kernel32.GetLastError()); return false; } LPVOID dllNameAddress = kernel32.VirtualAllocEx(hProcess, null, (dllName.length() + 1), new DWORD_PTR(0x3000), new DWORD_PTR(0x4)); if(dllNameAddress == null) { System.out.println("dllNameAddress was NULL! Error: " + kernel32.GetLastError()); return false; } Pointer m = new Memory(dllName.length() + 1); m.setString(0, dllName); boolean wpmSuccess = kernel32.WriteProcessMemory(hProcess, dllNameAddress, m, dllName.length(), null).booleanValue(); if(!wpmSuccess) { System.out.println("WriteProcessMemory failed! Error: " + kernel32.GetLastError()); return false; } DWORD_PTR threadHandle = kernel32.CreateRemoteThread(hProcess, 0, 0, loadLibraryAddress, dllNameAddress, 0, 0); if(threadHandle.intValue() == 0) { System.out.println("threadHandle was invalid! Error: " + kernel32.GetLastError()); return false; } kernel32.CloseHandle(hProcess); return true; }
SockFProg(SockFilter filters[]) { len = (short) filters.length; // serialize struct sock_filter * explicitly, its less confusing than the JNA magic we would need Memory filter = new Memory(len * 8); ByteBuffer bbuf = filter.getByteBuffer(0, len * 8); bbuf.order(ByteOrder.nativeOrder()); // little endian for (SockFilter f : filters) { bbuf.putShort(f.code); bbuf.put(f.jt); bbuf.put(f.jf); bbuf.putInt(f.k); } this.filter = filter; }
@Override public void apply(Pointer voidPtr1, int levelID, Pointer formatPtr, Pointer args) { Level level; switch(levelID) { // SEE FFmpeg libavutil/log.h case AV_LOG_QUIET: case AV_LOG_TRACE: level = Level.TRACE; break; case AV_LOG_PANIC: case AV_LOG_FATAL: level = Level.FATAL; break; case AV_LOG_ERROR: level = Level.ERROR; break; case AV_LOG_WARNING: level = Level.WARN; break; case AV_LOG_INFO: level = Level.INFO; break; case AV_LOG_VERBOSE: case AV_LOG_DEBUG: level = Level.DEBUG; break; default: level = Level.DEBUG; } Memory line = new Memory(128L); Avutil55Library.INSTANCE.av_log_format_line(voidPtr1, levelID, formatPtr, args, line.share(0), 128, prefix); String message = String.format(line.getString(0), args).trim(); logger.log(level, message); }
public SockFProg(SockFilter filters[]) { len = (short) filters.length; // serialize struct sock_filter * explicitly, its less confusing than the JNA magic we would need Memory filter = new Memory(len * 8); ByteBuffer bbuf = filter.getByteBuffer(0, len * 8); bbuf.order(ByteOrder.nativeOrder()); // little endian for (SockFilter f : filters) { bbuf.putShort(f.code); bbuf.put(f.jt); bbuf.put(f.jf); bbuf.putInt(f.k); } this.filter = filter; }
@SuppressWarnings("unused") private static int[] getVersionInfo(String path) { if (installedBrowsers == null) { findInstalledBrowsers(); } IntByReference dwDummy = new IntByReference(); dwDummy.setValue(0); int versionlength = com.sun.jna.platform.win32.Version.INSTANCE .GetFileVersionInfoSize(path, dwDummy); byte[] bufferarray = new byte[versionlength]; Pointer lpData = new Memory(bufferarray.length); PointerByReference lplpBuffer = new PointerByReference(); IntByReference puLen = new IntByReference(); boolean fileInfoResult = com.sun.jna.platform.win32.Version.INSTANCE .GetFileVersionInfo(path, 0, versionlength, lpData); boolean verQueryVal = com.sun.jna.platform.win32.Version.INSTANCE .VerQueryValue(lpData, "\\", lplpBuffer, puLen); VS_FIXEDFILEINFO lplpBufStructure = new VS_FIXEDFILEINFO( lplpBuffer.getValue()); lplpBufStructure.read(); int v1 = (lplpBufStructure.dwFileVersionMS).intValue() >> 16; int v2 = (lplpBufStructure.dwFileVersionMS).intValue() & 0xffff; int v3 = (lplpBufStructure.dwFileVersionLS).intValue() >> 16; int v4 = (lplpBufStructure.dwFileVersionLS).intValue() & 0xffff; return new int[] { v1, v2, v3, v4 }; }
public String getCurrentDesktopWallpaper() { char[] chars = new char[User32Ext.MAX_PATH]; String currentWallpaper = new String(chars); Pointer m = new Memory(Native.WCHAR_SIZE * (currentWallpaper.length())); User32Ext.INSTANCE.SystemParametersInfo(SPI.SPI_GETDESKWALLPAPER, currentWallpaper.length(), m, 0); currentWallpaper = m.getWideString(0); return currentWallpaper; }
/** * Returns the database title * * @return title */ public String getTitle() { checkHandle(); Memory infoBuf = getDbInfoBuffer(); Memory titleMem = new Memory(NotesConstants.NSF_INFO_SIZE - 1); NotesNativeAPI.get().NSFDbInfoParse(infoBuf, NotesConstants.INFOPARSE_TITLE, titleMem, (short) (titleMem.size() & 0xffff)); return NotesStringUtils.fromLMBCS(titleMem, -1); }
public static Stubber answerStringByReference(String value) { return doAnswer((Answer<Integer>) invocation -> { Object[] args = invocation.getArguments(); PointerByReference reference = (PointerByReference)args[0]; Pointer pointer = new Memory(Native.WCHAR_SIZE * (value.length() +1)); pointer.setWideString(0, value); reference.setValue(pointer); return 0; }); }
public short FTSearch( long hDB, LongByReference phSearch, long hColl, Memory query, int options, short limit, long hIDTable, IntByReference retNumDocs, Memory reserved, LongByReference rethResults);
/** * Converts the {@link TextStyle} to a style id, reusing already defined * styles if all attributes are matching * * @param style text style * @return style id */ private int getStyleId(TextStyle style) { int styleHash = style.hashCode(); Integer styleId = m_definedStyleId.get(styleHash); if (styleId==null) { checkHandle(); if (isClosed()) throw new NotesError(0, "CompoundText already closed"); IntByReference retStyleId = new IntByReference(); NotesCompoundStyleStruct styleStruct = style.getAdapter(NotesCompoundStyleStruct.class); if (styleStruct==null) throw new NotesError(0, "Unable to get style struct from TextStyle"); Memory styleNameMem = NotesStringUtils.toLMBCS(style.getName(), true); short result; if (PlatformUtils.is64Bit()) { result = NotesNativeAPI64.get().CompoundTextDefineStyle(m_handle64, styleNameMem, styleStruct, retStyleId); } else { result = NotesNativeAPI32.get().CompoundTextDefineStyle(m_handle32, styleNameMem, styleStruct, retStyleId); } NotesErrorUtils.checkResult(result); styleId = retStyleId.getValue(); m_definedStyleId.put(styleHash, styleId); m_hasData=true; } return styleId; }
/** * This function creates a new Domino database. * * @param serverName server name, either canonical, abbreviated or common name * @param filePath filepath to database * @param dbClass specifies the class of the database created. See {@link DBClass} for classes that may be specified. * @param forceCreation controls whether the call will overwrite an existing database of the same name. Set to TRUE to overwrite, set to FALSE not to overwrite. * @param options database creation option flags. See {@link CreateDatabase} * @param encryption encryption strength * @param maxFileSize optional. Maximum file size of the database, in bytes. In order to specify a maximum file size, use the database class, {@link DBClass#BY_EXTENSION} and use the option, {@link CreateDatabase#MAX_SPECIFIED}. */ public static void createDatabase(String serverName, String filePath, DBClass dbClass, boolean forceCreation, EnumSet<CreateDatabase> options, Encryption encryption, long maxFileSize) { String fullPath = NotesStringUtils.osPathNetConstruct(null, serverName, filePath); Memory fullPathMem = NotesStringUtils.toLMBCS(fullPath, true); byte encryptStrengthByte; switch (encryption) { case None: encryptStrengthByte = NotesConstants.DBCREATE_ENCRYPT_NONE; break; case Simple: encryptStrengthByte = NotesConstants.DBCREATE_ENCRYPT_SIMPLE; break; case Medium: encryptStrengthByte = NotesConstants.DBCREATE_ENCRYPT_MEDIUM; break; case Strong: encryptStrengthByte = NotesConstants.DBCREATE_ENCRYPT_STRONG; break; default: encryptStrengthByte = NotesConstants.DBCREATE_ENCRYPT_NONE; } short dbClassShort = dbClass.getValue(); short optionsShort = CreateDatabase.toBitMask(options); short result = NotesNativeAPI.get().NSFDbCreateExtended(fullPathMem, dbClassShort, forceCreation, optionsShort, encryptStrengthByte, maxFileSize); NotesErrorUtils.checkResult(result); }
/** * Writes data for a string search key * * @param itemOut output stream for ITEM structure * @param valueDataOut output stream for search key value * @param currKey search key * @throws Exception in case of errors */ private static void addStringKey(OutputStream itemOut, OutputStream valueDataOut, String currKey) throws Exception { Memory strValueMem = NotesStringUtils.toLMBCS(currKey, false); Memory itemMem = new Memory(NotesConstants.tableItemSize); NotesTableItemStruct item = NotesTableItemStruct.newInstance(itemMem); item.NameLength = 0; item.ValueLength = (short) ((strValueMem.size() + 2) & 0xffff); item.write(); for (int i=0; i<NotesConstants.tableItemSize; i++) { itemOut.write(itemMem.getByte(i)); } Memory valueMem = new Memory(strValueMem.size() + 2); short txtType = (short) NotesItem.TYPE_TEXT; valueMem.setShort(0, txtType); Pointer strValuePtr = valueMem.share(2); for (int i=0; i<strValueMem.size(); i++) { strValuePtr.setByte(i, strValueMem.getByte(i)); } for (int i=0; i<valueMem.size(); i++) { valueDataOut.write(valueMem.getByte(i)); } }
public native short NSFItemInfoNext( long note_handle, NotesBlockIdStruct.ByValue NextItem, Memory item_name, short name_len, NotesBlockIdStruct retbhItem, ShortByReference retDataType, NotesBlockIdStruct retbhValue, IntByReference retValueLength);
public native short NIFFindByKeyExtended2 (int hCollection, Memory keyBuffer, int findFlags, int returnFlags, NotesCollectionPositionStruct retIndexPos, IntByReference retNumMatches, ShortByReference retSignalFlags, IntByReference rethBuffer, IntByReference retSequence);
/** * Change the name of the administration server for the access control list. * * @param server server, either in abbreviated or canonical format */ public void setAdminServer(String server) { checkHandle(); Memory serverCanonicalMem = NotesStringUtils.toLMBCS(NotesNamingUtils.toCanonicalName(server), true); short result; if (PlatformUtils.is64Bit()) { result = NotesNativeAPI64.get().ACLSetAdminServer(m_hACL64, serverCanonicalMem); } else { result = NotesNativeAPI32.get().ACLSetAdminServer(m_hACL32, serverCanonicalMem); } NotesErrorUtils.checkResult(result); }
public short SECTokenValidate( Memory ServerName, Memory OrgName, Memory ConfigName, Memory TokenData, Memory retUsername, NotesTimeDateStruct retCreation, NotesTimeDateStruct retExpiration, int dwReserved, Pointer vpReserved);
public short NSFNoteAttachFile( long note_handle, Memory item_name, short item_name_length, Memory file_name, Memory orig_path_name, short encoding_type);
public CDRecordMemory(Memory recordBuf, CDRecordType type, short typeAsShort, int dataSize, int cdRecordLength) { m_cdRecordBuf = recordBuf; m_type = type; m_typeAsShort = typeAsShort; m_dataSize = dataSize; m_cdRecordLength = cdRecordLength; }
/** * This function converts a distinguished name in abbreviated format to canonical format. * A fully distinguished name is in canonical format - it contains all possible naming components. * The abbreviated format of a distinguished name removes the labels from the naming components. * * @param name name to convert * @param templateName name to be used when the input name is in common name format * @return canonical name */ public static String toCanonicalName(String name, String templateName) { if (name==null) return null; if (name.length()==0) return name; String cacheKey = name + ((templateName!=null && templateName.length()>0) ? ("|" + templateName) : ""); String abbrName = m_nameCanonicalCache.get(cacheKey); if (abbrName!=null) { return abbrName; } Memory templateNameMem = templateName==null ? null : NotesStringUtils.toLMBCS(templateName, true); //used when abbrName is only a common name Memory inNameMem = NotesStringUtils.toLMBCS(name, true); Memory outNameMem = new Memory(NotesConstants.MAXUSERNAME); ShortByReference outLength = new ShortByReference(); short result = NotesNativeAPI.get().DNCanonicalize(0, templateNameMem, inNameMem, outNameMem, NotesConstants.MAXUSERNAME, outLength); NotesErrorUtils.checkResult(result); String sOutName = NotesStringUtils.fromLMBCS(outNameMem, (int) (outLength.getValue() & 0xffff)); m_nameCanonicalCache.put(cacheKey, sOutName); return sOutName; }
public MemoryBuffer(int buffSize, Pointer process) { this.buffSize = buffSize; this.process = process; memory = new Memory(buffSize); startPoint = -1; endPoint = -1; }
public native short NIFFindByKeyExtended3 (int hCollection, Memory keyBuffer, int findFlags, int returnFlags, NotesCollectionPositionStruct retIndexPos, IntByReference retNumMatches, ShortByReference retSignalFlags, IntByReference rethBuffer, IntByReference retSequence, NotesCallbacks.NIFFindByKeyProc NIFFindByKeyCallback, NIFFindByKeyContextStruct Ctx);