Hi Regis

Thanx a lot for ur reply.

I had tried that earlier too after reading the docs.
e.g. What i did was 
{
        long a,b;
        long *tptr = MemPtrNew(8); //space for 2 pointers.

        *tptr = &a;
        *(tptr +1)=&b;
        userdatap = tptr;
        PceNativeCall();
}

Then In my dll

i extracted the 2 pointers, byte swapped them and tried to access the
locations.
But no, it crashes.

Dont know the problem

Regards
Salil


Regis Nicolas wrote:
> 
> You are facing a byte ordering problem.
> 
> s1.v1 has been initialized by PalmOS 68K so the address is stored in big
> endian.
> PceNativeCall does not know anything about the pointer you pass to the
> native code and can't adjust pointers in it.
> 
> On the Windows native side, you need to byte swap the pointer to put it in
> the windows native format before using it. You should be able to find 100 of
> functions to do that, including ntohl or steal one from Palm headers...
> 
> WARNING: THIS IS NOT ENOUGH. You will also face to alignment/padding issues.
> The 68K compiler will not layout structures the same way than Windows
> compiler. The safest way is to manually put things in a memory area and pass
> a pointer to it to Windows, read manually knowing how you stored things. Do
> not rely on the compiler since they are different.
> 
> Cordially,
> Regis.
> 
> ------------------------------------------------------------------------
> Regis NICOLAS - Engineering Director, Montpellier Site
> Palm Computing Europe, a PalmSource, Inc. subsidiary
> 
> When the finger points to the sky, the idiot looks at the finger.
> 
> -----Original Message-----
> From: Salil Gokhale [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 13, 2002 8:31 AM
> To: Palm Developer Forum
> Subject: wierd problem
> 
> Hello
> 
> Has anyone tried native programming on simulator?
> 
> Now we can pass a structure of parameters to the native code as
> userdata.
> 
> I want to pass a number of buffers to the code.
> So I declare
> 
> struct s1
> {
>         long *v1;
>         long *v2;
> };
> 
> in my palm program.
> 
> Also I have to access this structure in my dll, so i use this
> declaration.
> But if i try to access *v1 in dll then simulator crashes.
> 
> If i declare it
> struct s1
> {
>         long v1[5];
>         long v2[1];
> };
> 
> Then I can acess v1[0], v1[1] etc.
> 
> Does that mean I have to declare all my buffers as arrays?
> 
> But I have huge buffers so can be declared on stack.
> 
> Can anyone help?
> 
> Regards
> Salil
> 
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/support/forums/
> 
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see 
>http://www.palmos.com/dev/support/forums/

-- 
Der lagii aane me tum ko shukar hai phir bhii aaye to
Aas ne dil kaa saath na chhoDa vaise ham ghabaraaye to

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to