diff --git a/wince/org.eclipse.tm.rapi/lib/os/win32/x86/jrapi.dll b/wince/org.eclipse.tm.rapi/lib/os/win32/x86/jrapi.dll index da109aaf777..983e6b8253b 100644 Binary files a/wince/org.eclipse.tm.rapi/lib/os/win32/x86/jrapi.dll and b/wince/org.eclipse.tm.rapi/lib/os/win32/x86/jrapi.dll differ diff --git a/wince/org.eclipse.tm.rapi/native/RapiSession.cpp b/wince/org.eclipse.tm.rapi/native/RapiSession.cpp index 21237b69fa7..e391cc4fe84 100644 --- a/wince/org.eclipse.tm.rapi/native/RapiSession.cpp +++ b/wince/org.eclipse.tm.rapi/native/RapiSession.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov + * Copyright (c) 2008 Radoslav Gerganov and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Radoslav Gerganov - initial API and implementation + * Radoslav Gerganov - [238773] [WinCE] Implement IRAPISession#CeRapiInvoke *******************************************************************************/ #include @@ -553,4 +554,58 @@ fail: if (arg1 && lparg1) env->ReleaseStringChars(arg1, lparg1); if (arg2 && lparg2) env->ReleaseStringChars(arg2, lparg2); return rc; -} \ No newline at end of file +} + +JNIEXPORT jint JNICALL RAPI_NATIVE(CeRapiInvoke) + (JNIEnv *env, jobject that, jint arg0, jstring arg1, jstring arg2, jbyteArray arg3, jintArray arg4) +{ + const jchar *lparg1 = NULL; + const jchar *lparg2 = NULL; + jbyte *lparg3 = NULL; + jint *lparg4 = NULL; + int res = -1; + jsize cbInput = 0; + + if (arg0 == 0) return -1; + if (arg1) { + lparg1 = env->GetStringChars(arg1, NULL); + if (lparg1 == NULL) goto fail; + } + if (arg2) { + lparg2 = env->GetStringChars(arg2, NULL); + if (lparg2 == NULL) goto fail; + } + if (arg3) { + lparg3 = env->GetByteArrayElements(arg3, NULL); + if (lparg3 == NULL) goto fail; + cbInput = env->GetArrayLength(arg3); + } + if (arg4) { + lparg4 = env->GetIntArrayElements(arg4, NULL); + if (lparg4 == NULL) goto fail; + } + IRAPISession *pSession = (IRAPISession*) arg0; + res = pSession->CeRapiInvoke((LPCWSTR)lparg1, (LPCWSTR)lparg2, cbInput, + (BYTE*)lparg3, (DWORD*) lparg4, (BYTE**) (lparg4 + 1), NULL, 0); + +fail: + if (arg1 && lparg1) env->ReleaseStringChars(arg1, lparg1); + if (arg2 && lparg2) env->ReleaseStringChars(arg2, lparg2); + if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0); + if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0); + return res; +} + +JNIEXPORT void JNICALL RAPI_NATIVE(CeRapiInvokeEx) + (JNIEnv *env, jobject that, jint arg0, jbyteArray arg1) +{ + jbyte *lparg1 = NULL; + jsize len = 0; + + if (arg1 == 0) return; + lparg1 = env->GetByteArrayElements(arg1, NULL); + if (lparg1 == NULL) return; + len = env->GetArrayLength(arg1); + memcpy(lparg1, (void*)arg0, len); + env->ReleaseByteArrayElements(arg1, lparg1, 0); +} diff --git a/wince/org.eclipse.tm.rapi/native/org_eclipse_tm_internal_rapi_RapiSession.h b/wince/org.eclipse.tm.rapi/native/org_eclipse_tm_internal_rapi_RapiSession.h index 115fc6346b1..cb8494d91bc 100644 --- a/wince/org.eclipse.tm.rapi/native/org_eclipse_tm_internal_rapi_RapiSession.h +++ b/wince/org.eclipse.tm.rapi/native/org_eclipse_tm_internal_rapi_RapiSession.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov + * Copyright (c) 2008 Radoslav Gerganov and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Radoslav Gerganov - initial API and implementation + * Radoslav Gerganov - [238773] [WinCE] Implement IRAPISession#CeRapiInvoke *******************************************************************************/ /* DO NOT EDIT THIS FILE - it is machine generated */ #include @@ -209,6 +210,22 @@ JNIEXPORT jboolean JNICALL Java_org_eclipse_tm_internal_rapi_RapiSession_CeSetFi JNIEXPORT jboolean JNICALL Java_org_eclipse_tm_internal_rapi_RapiSession_CeCreateProcess (JNIEnv *, jobject, jint, jstring, jstring, jint, jobject); +/* + * Class: org_eclipse_tm_internal_rapi_RapiSession + * Method: CeRapiInvoke + * Signature: (ILjava/lang/String;Ljava/lang/String;[B[I)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_tm_internal_rapi_RapiSession_CeRapiInvoke + (JNIEnv *, jobject, jint, jstring, jstring, jbyteArray, jintArray); + +/* + * Class: org_eclipse_tm_internal_rapi_RapiSession + * Method: CeRapiInvokeEx + * Signature: (I[B)V + */ +JNIEXPORT void JNICALL Java_org_eclipse_tm_internal_rapi_RapiSession_CeRapiInvokeEx + (JNIEnv *, jobject, jint, jbyteArray); + #ifdef __cplusplus } #endif diff --git a/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/internal/rapi/RapiSession.java b/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/internal/rapi/RapiSession.java index 5426a209d7c..31d21d850a9 100644 --- a/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/internal/rapi/RapiSession.java +++ b/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/internal/rapi/RapiSession.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov + * Copyright (c) 2008 Radoslav Gerganov and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Radoslav Gerganov - initial API and implementation + * Radoslav Gerganov - [238773] [WinCE] Implement IRAPISession#CeRapiInvoke *******************************************************************************/ package org.eclipse.tm.internal.rapi; @@ -275,6 +276,19 @@ public class RapiSession extends IRapiSession { } return pi; } + + public byte[] invoke(String dllPath, String funcName, byte[] input) throws RapiException { + int[] output = new int[2]; + int res = CeRapiInvoke(addr, dllPath, funcName, input, output); + if (res != 0) { + throw new RapiException("CeRapiInvoke failed", res); //$NON-NLS-1$ + } + int outputLength = output[0]; + int outputPtr = output[1]; + byte[] outputArr = new byte[outputLength]; + CeRapiInvokeEx(outputPtr, outputArr); + return outputArr; + } public String toString() { return "[RapiSession] addr: " + Integer.toHexString(addr); //$NON-NLS-1$ @@ -340,4 +354,12 @@ public class RapiSession extends IRapiSession { private final native boolean CeCreateProcess(int addr, String lpApplicationName, String lpCommandLine, int dwCreationFlags, ProcessInformation lpProcessInformation); + + private final native int CeRapiInvoke(int addr, String dllPath, String funcName, + byte[] input, int[] output); + + /** + * Initializes the outputArr with the memory pointed by outputPtr. + */ + private final native void CeRapiInvokeEx(int outputPtr, byte[] outputArr); } diff --git a/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/rapi/IRapiSession.java b/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/rapi/IRapiSession.java index 1c810d3e7b8..2c0491af185 100644 --- a/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/rapi/IRapiSession.java +++ b/wince/org.eclipse.tm.rapi/src/org/eclipse/tm/rapi/IRapiSession.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Radoslav Gerganov + * Copyright (c) 2008 Radoslav Gerganov and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Radoslav Gerganov - initial API and implementation + * Radoslav Gerganov - [238773] [WinCE] Implement IRAPISession#CeRapiInvoke *******************************************************************************/ package org.eclipse.tm.rapi; @@ -277,4 +278,20 @@ public abstract class IRapiSession extends IUnknown { */ public abstract ProcessInformation createProcess(String appName, String commandLine, int creationFlags) throws RapiException; + + /** + * Invokes the specified native function on the remote device passing the specified byte array as argument. + * The native function must have the following signature:

+ * HRESULT funcName(DWORD inpLen, BYTE *inp, DWORD *outLen, BYTE **out, IRAPIStream *stream)

+ * The native function must return 0 on success or non-zero value if an error occurs. + * @param dllPath the name of the dll on the remote device which contains the native function + * @param funcName the name of the native function that will be called + * @param input byte array which will be passed to the native function; inpLen is initialized with + * the length of input and inp points to a buffer with the same content as + * input + * @return byte array returned from the native function; the length and the content of the returned array + * corresponds to *outLen and *out respectively + * @throws RapiException if an error occurs. + */ + public abstract byte[] invoke(String dllPath, String funcName, byte[] input) throws RapiException; }