当前位置: 首页>>代码示例>>Java>>正文


Java NativeLongByReference类代码示例

本文整理汇总了Java中com.sun.jna.ptr.NativeLongByReference的典型用法代码示例。如果您正苦于以下问题:Java NativeLongByReference类的具体用法?Java NativeLongByReference怎么用?Java NativeLongByReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NativeLongByReference类属于com.sun.jna.ptr包,在下文中一共展示了NativeLongByReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Capstone

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public Capstone(int arch, int mode) {
   cs = (CS)Native.loadLibrary("capstone", CS.class);
   int version = cs.cs_version(null, null);
   if (version != (CS_API_MAJOR << 8) + CS_API_MINOR) {
     throw new RuntimeException("Different API version between core & binding (CS_ERR_VERSION)");
   }

   this.arch = arch;
   this.mode = mode;
   ns = new NativeStruct();
   ns.handleRef = new NativeLongByReference();
   if (cs.cs_open(arch, mode, ns.handleRef) != CS_ERR_OK) {
     throw new RuntimeException("ERROR: Wrong arch or mode");
   }
   ns.csh = ns.handleRef.getValue();
   this.detail = CS_OPT_OFF;
this.diet = cs.cs_support(CS_SUPPORT_DIET);
 }
 
开发者ID:binarybird,项目名称:Redress-Disassembler,代码行数:19,代码来源:Capstone.java

示例2: getPrivateKeyHandle

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public NativeLong getPrivateKeyHandle(RtPkcs11 pkcs11, NativeLong session)
        throws Pkcs11CallerException {
    CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);

    final NativeLongByReference keyClass =
            new NativeLongByReference(Pkcs11Constants.CKO_PRIVATE_KEY);
    template[0].type = Pkcs11Constants.CKA_CLASS;
    template[0].pValue = keyClass.getPointer();
    template[0].ulValueLen = new NativeLong(NativeLong.SIZE);

    ByteBuffer idBuffer = ByteBuffer.allocateDirect(mKeyPairId.length);
    idBuffer.put(mKeyPairId);
    template[1].type = Pkcs11Constants.CKA_ID;
    template[1].pValue = Native.getDirectBufferPointer(idBuffer);
    template[1].ulValueLen = new NativeLong(mKeyPairId.length);

    return findObject(pkcs11, session, template);
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:19,代码来源:Certificate.java

示例3: findObject

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
private NativeLong findObject(RtPkcs11 pkcs11, NativeLong session, CK_ATTRIBUTE[] template)
    throws Pkcs11CallerException {
    NativeLong rv = pkcs11.C_FindObjectsInit(session,
            template, new NativeLong(template.length));
    if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);

    NativeLong objects[] = new NativeLong[1];
    NativeLongByReference count =
            new NativeLongByReference(new NativeLong(objects.length));
    rv = pkcs11.C_FindObjects(session, objects, new NativeLong(objects.length),
            count);

    NativeLong rv2 = pkcs11.C_FindObjectsFinal(session);
    if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
    else if (!rv2.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv2);
    else if (count.getValue().intValue() <= 0) return null;

    return objects[0];
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:20,代码来源:Certificate.java

示例4: Token

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
Token(NativeLong slotId) throws Pkcs11CallerException {
    RtPkcs11 pkcs11 = RtPkcs11Library.getInstance();
    synchronized (pkcs11) {
        mId = slotId;
        initTokenInfo();

        NativeLongByReference session = new NativeLongByReference();
        NativeLong rv = RtPkcs11Library.getInstance().C_OpenSession(mId,
                Pkcs11Constants.CKF_SERIAL_SESSION, null, null, session);

        if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
        mSession = session.getValue();

        try {
            initCertificatesList(pkcs11);
        } catch (Pkcs11CallerException exception) {
            try {
                close();
            } catch (Pkcs11CallerException exception2) {
            }
            throw exception;
        }
    }
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:25,代码来源:Token.java

示例5: readHeader

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
@Override
public AudioFormat readHeader() throws IOException {
    NativeLongByReference sr = new NativeLongByReference();
    IntByReference ch = new IntByReference(),
            en = new IntByReference();
    throwOnError(mpg123_getformat(h, sr, ch, en));
    safeBuffer = mpg123_safe_buffer();

    format.setBitDepth(AudioFormat.bitDepthFromNumber(mpg123_samplesize(en.getValue()) * 8));
    format.setChannels(ch.getValue());
    format.setSampleRate(sr.getValue().intValue());

    long ret2 = mpg123_length(h).longValue();
    if(ret2 != MPG123_ERR)
        format.setSamples(ret2);
    tmpBuff = MemoryUtils.createByteBuffer(safeBuffer);

    return format;
}
 
开发者ID:melchor629,项目名称:Java-GLEngine,代码行数:20,代码来源:Mpg123Decoder.java

示例6: setUp

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    // Create client
    ID clientName = Foundation.cfString("Client");
    MIDINotifyProc notifyProc = new CoreMidiLibrary.MIDINotifyProc() {

        @Override
        public void apply(MIDINotification message, Pointer refCon) {
        }
    };
    NativeLongByReference nativeLongByReference =
            new NativeLongByReference();
    LOGGER.info(nativeLongByReference.getValue().longValue());
    int midiClientCreate =
            CoreMidiLibrary.INSTANCE.MIDIClientCreate(clientName,
                    notifyProc, null, nativeLongByReference);
    LOGGER.info(nativeLongByReference.getValue().longValue());
    LOGGER.info(midiClientCreate);
}
 
开发者ID:locurasoft,项目名称:osxmidi4j,代码行数:21,代码来源:CoreMidiLibraryMacOsXTest.java

示例7: readProcessMemory

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
/**
 * readProcessMemory to memory.
 */
long readProcessMemory(Pointer baseAddress, Memory goal)
{
	NativeLong sizeAvalaible = new NativeLong(goal.size());
	NativeLongByReference bytesReadRefernce = new NativeLongByReference();
	boolean ret = MyKernel32.INSTANCE.ReadProcessMemory(
			_processInformation.hProcess.getPointer(), baseAddress, goal,
			sizeAvalaible, bytesReadRefernce);
	if (!ret)
		log("pid " + _pid + " ReadProcessMemory returns " + ret);
	long bytesRead = bytesReadRefernce.getValue().longValue();
	return bytesRead;

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:17,代码来源:WindowsXPProcess.java

示例8: getCertificatesWithCategory

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
private Map<NativeLong, Certificate> getCertificatesWithCategory(RtPkcs11 pkcs11, CertificateCategory category) throws Pkcs11CallerException {
    CK_ATTRIBUTE[] template = (CK_ATTRIBUTE[]) (new CK_ATTRIBUTE()).toArray(2);

    NativeLongByReference certClass =
            new NativeLongByReference(Pkcs11Constants.CKO_CERTIFICATE);
    template[0].type = Pkcs11Constants.CKA_CLASS;
    template[0].pValue = certClass.getPointer();
    template[0].ulValueLen = new NativeLong(NativeLong.SIZE);

    NativeLongByReference certCategory = new NativeLongByReference(new NativeLong(category.getValue()));
    template[1].type = Pkcs11Constants.CKA_CERTIFICATE_CATEGORY;
    template[1].pValue = certCategory.getPointer();
    template[1].ulValueLen = new NativeLong(NativeLong.SIZE);

    NativeLong rv =
            pkcs11.C_FindObjectsInit(mSession, template, new NativeLong(template.length));
    if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);

    NativeLong[] objects = new NativeLong[30];
    NativeLongByReference count = new NativeLongByReference(new NativeLong(objects.length));
    ArrayList<NativeLong> certs = new ArrayList<NativeLong>();
    do {
        rv = pkcs11.C_FindObjects(mSession, objects, new NativeLong(objects.length), count);
        if (!rv.equals(Pkcs11Constants.CKR_OK)) break;
        certs.addAll(Arrays.asList(objects).subList(0, count.getValue().intValue()));
    } while (count.getValue().intValue() == objects.length);

    NativeLong rv2 = pkcs11.C_FindObjectsFinal(mSession);
    if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);
    else if (!rv2.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv2);

    HashMap<NativeLong, Certificate> certificateMap = new HashMap<NativeLong, Certificate>();
    for (NativeLong c : certs) {
        certificateMap.put(c, new Certificate(pkcs11, mSession, c));
    }

    return certificateMap;
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:39,代码来源:Token.java

示例9: sign

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public void sign(final NativeLong certificate, final byte[] data,
        Pkcs11Callback callback) {
    new Pkcs11AsyncTask(callback) {
        @Override
        protected Pkcs11Result doWork() throws Pkcs11CallerException {
            Certificate cert = mCertificateMap.get(certificate);
            if (cert == null) throw new CertNotFoundException();

            NativeLong keyHandle = cert.getPrivateKeyHandle(mPkcs11, mSession);
            if (keyHandle == null) throw new KeyNotFoundException();

            NativeLongByReference count =
                    new NativeLongByReference(new NativeLong());

            final byte[] oid = {
                    0x06, 0x07, 0x2a, (byte) 0x85, 0x03, 0x02, 0x02, 0x1e, 0x01
            };
            ByteBuffer oidBuffer = ByteBuffer.allocateDirect(oid.length);
            oidBuffer.put(oid);
            CK_MECHANISM mechanism =
                    new CK_MECHANISM(RtPkcs11Constants.CKM_GOSTR3410_WITH_GOSTR3411,
                            Native.getDirectBufferPointer(oidBuffer),
                            new NativeLong(oid.length));
            NativeLong rv = mPkcs11.C_SignInit(mSession, mechanism, keyHandle);
            if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);

            rv = mPkcs11.C_Sign(mSession, data, new NativeLong(data.length), null, count);
            if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);

            byte signature[] = new byte[count.getValue().intValue()];
            rv = mPkcs11.C_Sign(mSession, data, new NativeLong(data.length), signature, count);
            if (!rv.equals(Pkcs11Constants.CKR_OK)) throw Pkcs11Exception.exceptionWithCode(rv);

            return new Pkcs11Result(signature);
        }
    }.execute();
}
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:38,代码来源:Token.java

示例10:

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
NativeLong C_OpenSession
(
        NativeLong            slotID,        /* the slot's ID */
        NativeLong            flags,         /* from CK_SESSION_INFO */
        Pointer               pApplication,  /* passed to callback */
        Callback              Notify,        /* callback function */
        NativeLongByReference phSession      /* gets session handle */
);
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:9,代码来源:Pkcs11.java

示例11:

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
NativeLong C_EX_GetLicense
(
    NativeLong            hSession,     /* the session's handle */
    NativeLong            ulLicenseNum, /* the number of the license, can only be 1 or 2 */
    byte[]                pLicense,     /* receives the license */
    NativeLongByReference pulLicenseLen /* length of the license */
);
 
开发者ID:AktivCo,项目名称:rutoken-demobank-android,代码行数:8,代码来源:RtPkcs11.java

示例12: decodeAll

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
@Override
public AudioPCM decodeAll() throws IOException {
    NativeLongByReference decodedBytes = new NativeLongByReference();
    ByteBuffer pcm = null;
    if(format.getNumberOfSamples() != 0)
        pcm = MemoryUtils.createByteBuffer((int) format.getNumberOfSamples() * format.getChannels() * format.getBitDepth().bitDepth / 8);
    int ret = MPG123_OK;
    int bytesRead = 0;

    while(ret != MPG123_DONE) {
        ret = mpg123_read(h, tmpBuff, new NativeLong(tmpBuff.capacity()), decodedBytes);

        if(ret == MPG123_OK || ret == MPG123_NEW_FORMAT) {
            bytesRead += decodedBytes.getValue().intValue();

            if(ret == MPG123_NEW_FORMAT) {
                readHeader();
                if(pcm != null) {
                    pcm = MemoryUtils.realloc(pcm, (int) format.getNumberOfSamples() * format.getChannels() * format.getBitDepth().bitDepth / 8);
                }
            }

            if(format.getNumberOfSamples() != 0) {
                pcm.position(bytesRead);
                MemoryUtils.copy(tmpBuff, pcm, decodedBytes.getValue().intValue());
            } else {
                pcm = MemoryUtils.realloc(pcm, (pcm != null ? pcm.capacity() : 0) + decodedBytes.getValue().intValue());
                pcm.position(bytesRead);
                MemoryUtils.copy(tmpBuff, pcm, decodedBytes.getValue().intValue());
            }
        } else if(ret != MPG123_DONE) {
            MemoryUtils.free(pcm);
            delete();
            throw new AudioDecoderException(mpg123_plain_strerror(ret));
        }
    }

    delete();
    return new AudioPCM(format, pcm);
}
 
开发者ID:melchor629,项目名称:Java-GLEngine,代码行数:41,代码来源:Mpg123Decoder.java

示例13: MidiClient

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public MidiClient(final String string, final MIDINotifyProc notifyProc)
        throws CoreMidiException {
    final ID name = Foundation.cfString(string);
    final NativeLongByReference temp = new NativeLongByReference();

    final int midiClientCreate =
            CoreMidiLibrary.INSTANCE.MIDIClientCreate(name, notifyProc,
                    null, temp);
    if (midiClientCreate != 0) {
        throw new CoreMidiException(midiClientCreate);
    }
    LOGGER.info("MidiClientRef: " + temp.getValue().longValue());
    midiClientRef = temp.getValue();
}
 
开发者ID:locurasoft,项目名称:osxmidi4j,代码行数:15,代码来源:MidiClient.java

示例14: outputPortCreate

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public MidiOutputPort outputPortCreate(final String string)
        throws CoreMidiException {
    final NativeLongByReference temp = new NativeLongByReference();
    final ID name = Foundation.cfString(string);
    final int midiOutputPortCreate =
            CoreMidiLibrary.INSTANCE.MIDIOutputPortCreate(midiClientRef,
                    name, temp);
    if (midiOutputPortCreate != 0) {
        throw new CoreMidiException(midiOutputPortCreate);
    }
    return new MidiOutputPort(temp.getValue());
}
 
开发者ID:locurasoft,项目名称:osxmidi4j,代码行数:13,代码来源:MidiClient.java

示例15: inputPortCreate

import com.sun.jna.ptr.NativeLongByReference; //导入依赖的package包/类
public MidiInputPort inputPortCreate(final String name,
        final MIDIReadProc readProc) throws CoreMidiException {
    final NativeLongByReference temp = new NativeLongByReference();
    final int midiInputPortCreate =
            CoreMidiLibrary.INSTANCE.MIDIInputPortCreate(midiClientRef,
                    Foundation.cfString(name), readProc, null, temp);
    if (midiInputPortCreate != 0) {
        throw new CoreMidiException(midiInputPortCreate);
    }
    return new MidiInputPort(temp.getValue());
}
 
开发者ID:locurasoft,项目名称:osxmidi4j,代码行数:12,代码来源:MidiClient.java


注:本文中的com.sun.jna.ptr.NativeLongByReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。