From dc104853d825de4f9421921735ecc7582b468e28 Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Mon, 30 Jun 2008 11:12:44 +0000 Subject: [PATCH] [WinCE][api] Implement IRAPISession#CeRapiInvoke --- .../lib/os/win32/x86/jrapi.dll | Bin 15872 -> 16384 bytes .../native/RapiSession.cpp | 59 +++++++++++++++++- ...org_eclipse_tm_internal_rapi_RapiSession.h | 19 +++++- .../eclipse/tm/internal/rapi/RapiSession.java | 24 ++++++- .../src/org/eclipse/tm/rapi/IRapiSession.java | 19 +++++- 5 files changed, 116 insertions(+), 5 deletions(-) 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 da109aaf7778a76e79e5f0319b482783b0c8fcf2..983e6b8253b5502b2c4937d0d129636f8a53f63b 100644 GIT binary patch delta 4029 zcmc&%eQ;A%7QgS&w4p5~g{Fj3XbS-Xg_@cclDvErYyh!9n$o1zN~mo#4gK0SVe8tN z7SmYjqb_h+7hPG!GOjvZm!%y=S1?etvQ`#Q!C76W?&55m!ipawj3RG;H!T$SZ~xjm z^SdACoO|x?oO9pHOGjHr2e-q_6Kg49|4=2(s++|&wVcHX*17?v}A z6A%ZO`(Nap+^)De-1Bs9oIQTOjwr<_l~UFHkH;l*oP$!CHh)7YQA%gTDQxt0w}9SnFBq1kip@JRuZx} zXidB`ot@$+bxEhi4Vq-9r0Qc7*DFO;B|R0dQg31;?hv~N;J`U%=T?hLcGI8Z)m#lt zOIS!%2~*2G8y~2+$$iLDgncBa2mjS=Zst90EV4sj>*!t0ygtSPb4jOqi?JG#u^o&h zc*Kd15llr@F?~6qj!#de)8%XUlhbImd=;NMllIAH^1f;Ggk0crruD~9E{^BwXsJS* z-vl2lQEc>m!V>ct%VYq{TQfOfaDhIlNK2YnU!{Liq$N+RlkcLZ6{<0VSZ&nw8%5fJ zm_aP{8F%4?ZMU7!yB&fdSsh)kOv|jpoRo@{8fBT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`-UKLEc5{sHjd{de1!MKp&qlHzWEcCinby1~EcLtL)! zrv0tgZ>2x*tgke+Vfk()dwJCh+uMC@UU$9NvHh_&UsFeWUA?_}^+yo{In0}@Wz(Inqv;C}}ZAozW z8OS>4$kHG?09pPVnI2gw&Bwm~?^>+*-)lji&n~1_vlHn^c4C*CtZS>R>uB2KZn@9r zc9S)nUGz1!Hr(fHYgt!r|Mq&)*6c1=o#$$9CJ&aEt*xq@oe&@Abhp;Gx!lh7w#HV` z?IV=-qk1)vH&xe*WV#Jce)xMMSY3Wxvsr^Ykj+TUt=?K!OpS0vB4w$h6cCK z>1k_gBIHT>!SW>;pUrdnTj5<3c^2ysP+M!n>|Wj(k!I8M6X?{+2R~8s9pda`c$Px%~14n@|V38ST z95@Pm1Y{Hw@(6GO_!wAfA!H{o09*rdtOyc#0hj=?O9*KIjssyJuM{r;U;y~Al&DDD zT0+*+PjWU4=I5?e4c;i|=g*kRd3^3~65fe2t~TZw4XbIo`QYFw^L&oWr>_>T>e_91 z!tk`=sNsa+SB49QF+}tulUEsFBku!IL)HBtgz%;ES8OyDvQtZTT96D wp5-e`ly!l1p>>J%9;@BD&AQXtZ1q`pS@&3btdAq1?A|LEqkm;^+!D|K2Zf|{Q~&?~ 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; }