Also this patch has a minor bug fix (wasn't actually responding with the
number of bytes in the output, but just synce_tracing the value).

On Tue, Jul 7, 2009 at 12:53 PM, David Richardson <docgra...@gmail.com>wrote:

> The first step is to get it detected by ActiveSync.  If you're using a VM
> like I am, you're unlikely to get RNDIS to connect, so disable advanced
> networking.  Once it is detected fire up VS and Tools > Device Security
> Manager... > Connect to a device...
>
> Platform: Windows Mobile 5.0 Pocket PC SDK
> Devices: Windows Mobile 5.0 Pocket PC Device R2
>
> Hit connect and be ready to hit "Yes" to about 5 dialog boxes on the
> device.  Afterwards click "Security Off" and then "Deploy to Device".
>
> You probably need the WM SDK to do this (maybe included, depending on your
> trial).
>
> Installing SdkCerts.cab may do the trick, too.  I'm also a Linux developer
> and would love to cut the Visual Studio step out of my development.
>
>
> On Tue, Jul 7, 2009 at 12:42 PM, Mark Ellis <m...@mpellis.org.uk> wrote:
>
>> On Mon, 2009-06-29 at 23:02 +0200, David Richardson wrote:
>> > I implemented reading of the output_size and output_buffer too.  I
>> > couldn't figure out how to actually run the CeRapiInvoke tests (my
>> > automake experience is lacking) but I did create a separate executable
>> > that does the same thing as those tests.  It should pass
>> > test_ping_result and test_ping_buffer now, but not the stream test
>> > (will still return E_NOTIMPL).  I didn't check test_last_error yet.
>> >
>>
>> Hi David, thanks for the patch. I'd like to do some work on the rest of
>> it, but I do linux programming, not MS :) I've got a trial version of
>> Visual Studio around somewhere, can you explain how to disable the
>> device's security from there ?
>>
>> Ta
>> Mark
>>
>>
>
Index: src/rapi2/rapi2_api.h
===================================================================
--- src/rapi2/rapi2_api.h	(revision 3786)
+++ src/rapi2/rapi2_api.h	(working copy)
@@ -342,7 +342,7 @@
         ULONG cb,
         ULONG *pcbWritten);
 
-HRESULT _NotImplementedCeRapiInvoke2(
+HRESULT _CeRapiInvoke2(
         LPCWSTR pDllPath,
         LPCWSTR pFunctionName,
         DWORD cbInput,
@@ -352,7 +352,7 @@
         IRAPIStream **ppIRAPIStream,
         DWORD dwReserved);
 
-HRESULT _NotImplementedCeRapiInvokeA2(
+HRESULT _CeRapiInvokeA2(
         LPCSTR pDllPath,
         LPCSTR pFunctionName,
         DWORD cbInput,
Index: src/rapi2/invoke2.c
===================================================================
--- src/rapi2/invoke2.c	(revision 3786)
+++ src/rapi2/invoke2.c	(working copy)
@@ -35,24 +35,120 @@
   return hr;
 }/*}}}*/
 
+static HRESULT CeRapiInvokeCommon2(
+    RapiContext* context,
+    LPCWSTR pDllPath,
+    LPCWSTR pFunctionName,
+    DWORD cbInput,
+    const BYTE *pInput,
+    DWORD dwReserved,
+    BOOL inRapiStream
+    )
+{
+  if (cbInput)
+    if (!pInput)
+      return E_INVALIDARG;
 
-HRESULT _NotImplementedCeRapiInvoke2( /*{{{*/
+  rapi_context_begin_command(context, 0x4c);
+  rapi_buffer_write_uint32(context->send_buffer, dwReserved);
+  rapi2_buffer_write_string(context->send_buffer, pDllPath);
+  rapi2_buffer_write_string(context->send_buffer, pFunctionName);
+  rapi_buffer_write_uint32(context->send_buffer, cbInput);
+  if (cbInput)
+    rapi_buffer_write_data  (context->send_buffer, pInput, cbInput);
+  rapi_buffer_write_uint32(context->send_buffer, inRapiStream);
+
+  return S_OK;
+}
+
+static HRESULT CeRapiInvokeBuffers(
     LPCWSTR pDllPath,
     LPCWSTR pFunctionName,
     DWORD cbInput,
     const BYTE *pInput,
     DWORD *pcbOutput,
     BYTE **ppOutput,
+    DWORD dwReserved)
+{
+  RapiContext* context = rapi_context_current();
+  HRESULT return_value = E_UNEXPECTED;
+  HRESULT hr;
+
+  synce_trace("begin");
+  
+  hr = CeRapiInvokeCommon2(
+      context,
+      pDllPath,
+      pFunctionName,
+      cbInput,
+      pInput,
+      dwReserved,
+      FALSE);
+  if (FAILED(hr))
+  {
+    synce_error("CeRapiInvokeCommon2 failed");
+    return hr;
+  }
+
+  if ( !rapi2_context_call(context) )
+  {
+    synce_error("rapi2_context_call failed");
+    hr = E_FAIL;
+    return hr;
+  }
+
+  synce_trace("pInput: 0x%08x", pInput);
+  rapi_buffer_read_uint32(context->recv_buffer, &context->last_error);
+  synce_trace("last error: 0x%08x", context->last_error);
+  rapi_buffer_read_uint32(context->recv_buffer, &return_value);
+  synce_trace("return_value: 0x%08x", return_value);
+  rapi_buffer_read_uint32(context->recv_buffer, pcbOutput);
+  synce_trace("output_size: 0x%08x", *pcbOutput);
+  if (*pcbOutput > 0 && ppOutput)
+  {
+    *ppOutput = malloc(*pcbOutput);
+    if(!*ppOutput)
+    {
+      return E_OUTOFMEMORY;
+    }
+    if (!rapi_buffer_read_data(context->recv_buffer, *ppOutput, *pcbOutput))
+    {
+      synce_error("Failed to read output data");
+      hr = E_FAIL;
+    }
+    else
+    {
+      synce_trace("output_buffer: 0x%0x", ppOutput);
+    }
+  }
+
+  if (SUCCEEDED(hr))
+    return return_value;
+  else
+    return hr;
+}
+
+HRESULT _CeRapiInvoke2( /*{{{*/
+    LPCWSTR pDllPath,
+    LPCWSTR pFunctionName,
+    DWORD cbInput,
+    const BYTE *pInput,
+    DWORD *pcbOutput,
+    BYTE **ppOutput,
     IRAPIStream **ppIRAPIStream,
     DWORD dwReserved)
 {
-  RapiContext* context = rapi_context_current();
-  context->rapi_error = E_NOTIMPL;
-  context->last_error = ERROR_CALL_NOT_IMPLEMENTED;
-  return E_NOTIMPL;
+  if (ppIRAPIStream)
+  {
+    synce_error("Stream mode is not implemented");
+    return E_NOTIMPL;
+  }
+  else
+    return CeRapiInvokeBuffers(pDllPath, pFunctionName, cbInput, pInput,
+        pcbOutput, ppOutput, dwReserved);
 }/*}}}*/
 
-HRESULT _NotImplementedCeRapiInvokeA2( /*{{{*/
+HRESULT _CeRapiInvokeA2( /*{{{*/
     LPCSTR pDllPath,
     LPCSTR pFunctionName,
     DWORD cbInput,
@@ -62,9 +158,21 @@
     IRAPIStream **ppIRAPIStream,
     DWORD dwReserved)
 {
-  RapiContext* context = rapi_context_current();
-  context->rapi_error = E_NOTIMPL;
-  context->last_error = ERROR_CALL_NOT_IMPLEMENTED;
-  return E_NOTIMPL;
+  HRESULT hr;
+  WCHAR* wide_dll_path      = wstr_from_current(pDllPath);
+  WCHAR* wide_function_name = wstr_from_current(pFunctionName);
+
+  if ((!wide_dll_path) || (!wide_function_name)) {
+          wstr_free_string(wide_dll_path);
+          wstr_free_string(wide_function_name);
+          return E_INVALIDARG;
+  }
+
+  hr = CeRapiInvoke( wide_dll_path, wide_function_name, cbInput, pInput,
+      pcbOutput, ppOutput, ppIRAPIStream, dwReserved);
+
+  wstr_free_string(wide_dll_path);
+  wstr_free_string(wide_function_name);
+
+  return hr;
 }
-
Index: src/rapi2.c
===================================================================
--- src/rapi2.c	(revision 3786)
+++ src/rapi2.c	(working copy)
@@ -105,7 +105,7 @@
         _NotImplementedIRAPIStream_Read2,  /* IRAPIStream_Read */
         _NotImplementedIRAPIStream_Write2, /* IRAPIStream_Write */
         /* IRAPIStream_GetRawSocket, */   /* IRAPIStream_GetRawSocket */
-        _NotImplementedCeRapiInvoke2,     /* CeRapiInvoke */
-        _NotImplementedCeRapiInvokeA2,    /* CeRapiInvokeA */
+        _CeRapiInvoke2,     /* CeRapiInvoke */
+        _CeRapiInvokeA2,    /* CeRapiInvokeA */
 #endif /* SWIG */
 };
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
SynCE-Devel mailing list
SynCE-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synce-devel

Reply via email to