本文整理汇总了Java中com.sun.jna.Memory.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java Memory.getInt方法的具体用法?Java Memory.getInt怎么用?Java Memory.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.Memory
的用法示例。
在下文中一共展示了Memory.getInt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finalizeClashesByEI
import com.sun.jna.Memory; //导入方法依赖的package包/类
/**
* @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;
}
示例2: findDynAddress
import com.sun.jna.Memory; //导入方法依赖的package包/类
/**
* Finds a dynamic address given by its offsets from the given starting
* address. It is assumed that the value stored at the base address is a
* pointer. It is also assumed that the pointer received by this stored
* pointer plus the first offset stores another pointer. The same principle
* must hold for all offsets. The resulting dynamic address is the pointer
* stored at this location.
*
* @param offsets
* Offsets that need to be followed
* @param startingAddress
* Address from which to start following the offsets
* @return The dynamic address received by following all offsets starting at
* the given starting address
*/
public long findDynAddress(final int[] offsets, final long startingAddress) {
final int size = Pointer.SIZE;
Memory pTemp = new Memory(size);
long pointerAddress = -1;
for (int i = 0; i < offsets.length; i++) {
if (i == 0) {
pTemp = Kernel32Util.readMemory(this.mProcess.getHandle(), startingAddress, size);
}
pointerAddress = pTemp.getInt(0) + offsets[i];
if (i != offsets.length - 1) {
pTemp = Kernel32Util.readMemory(this.mProcess.getHandle(), pointerAddress, size);
}
}
return pointerAddress;
}
示例3: getAttributes
import com.sun.jna.Memory; //导入方法依赖的package包/类
@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);
}
示例4: getNoteId
import com.sun.jna.Memory; //导入方法依赖的package包/类
/**
* Returns the note id of the note
*
* @return note id
*/
public int getNoteId() {
checkHandle();
Memory retNoteId = new Memory(4);
retNoteId.clear();
if (PlatformUtils.is64Bit()) {
NotesNativeAPI64.get().NSFNoteGetInfo(m_hNote64, NotesConstants._NOTE_ID, retNoteId);
}
else {
NotesNativeAPI32.get().NSFNoteGetInfo(m_hNote32, NotesConstants._NOTE_ID, retNoteId);
}
return retNoteId.getInt(0);
}
示例5: getValue
import com.sun.jna.Memory; //导入方法依赖的package包/类
/**
* @return The value of this {@link CFNumberRef} as a {@link Number}.
*/
public Number getValue() {
if (this.getPointer() == null) {
return null;
}
CFNumberType numberType = INSTANCE.CFNumberGetType(this);
Memory value = new Memory(8);
INSTANCE.CFNumberGetValue(this, numberType, value);
switch (numberType) {
case kCFNumberCFIndexType:
case kCFNumberSInt32Type:
return value.getInt(0);
case kCFNumberCGFloatType:
case kCFNumberMaxType:
if (NativeLong.SIZE == 8) {
return value.getDouble(0);
}
return value.getFloat(0);
case kCFNumberCharType:
return (int) value.getChar(0);
case kCFNumberDoubleType:
case kCFNumberFloat64Type:
return value.getDouble(0);
case kCFNumberFloatType:
case kCFNumberFloat32Type:
return value.getFloat(0);
case kCFNumberLongLongType:
case kCFNumberSInt64Type:
return value.getLong(0);
case kCFNumberIntType:
case kCFNumberLongType:
case kCFNumberNSIntegerType:
return value.getNativeLong(0);
case kCFNumberSInt16Type:
case kCFNumberShortType:
return value.getShort(0);
case kCFNumberSInt8Type:
return value.getByte(0);
default:
throw new IllegalStateException("Unimplemented value " + numberType);
}
}
示例6: getModeFlags
import com.sun.jna.Memory; //导入方法依赖的package包/类
private int getModeFlags(Memory buffer) {
return SystemInfo.isLinux ? buffer.getInt(myOffsets[OFF_MODE]) : buffer.getShort(myOffsets[OFF_MODE]);
}
示例7: ownFile
import com.sun.jna.Memory; //导入方法依赖的package包/类
private boolean ownFile(Memory buffer) {
return buffer.getInt(myOffsets[OFF_UID]) == myUid && buffer.getInt(myOffsets[OFF_GID]) == myGid;
}
示例8: readInt
import com.sun.jna.Memory; //导入方法依赖的package包/类
/**
* Reads an integer from the given address.
*
* @param address
* Address to start reading from
* @return The integer read from the given address.
*/
public int readInt(final long address) {
final Memory value = readMemory(address, MemSize.getIntSize());
return value.getInt(0);
}