Link to home
Start Free TrialLog in
Avatar of gringogordo
gringogordo

asked on

converting LPBYTE to LPSTR (whats happening and is it efficient!?)

Hi,

I'm writing a wildcard ISAPI extension.

I want to point to the EXTEnSION_CONTROL_BLOCK data structure element lpbData.  To make it easy for me, as a C++ idiot, I am hoping to store it in a local LPSTR variable (this will mean I can use 'inbuilt' functions I am already comfortable with and local functions that I already have.

Basically this means I am using the line

pDataBody = (LPSTR) pecb->lpbData; // pecb->lpbData is a LPBYTE.

I realised as I was doing it that I don't know what this is really doing.  As pecb->lpbData  can potentially be very large I was hoping someone could and would tell me whether this is a reasonable (not necessarily perfect!) and efficient thing to do.  And if possible what is going on in the background.  i.e. As they are both pointer types is the same memory just being interpreted in a different way, or is the memory being copied to different locations for the 2 different types?

I hope this makes some sense ...

Thanks,

Ben.
ASKER CERTIFIED SOLUTION
Avatar of novitiate
novitiate

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of novitiate
novitiate

sorry for typos

What do you mean by, I can use built-in functions, if its LPSTR?

if your built-in functions are doing any string manipulation then it won't work, remember its still data not string, though you cast it to LPSTR.

_novi_
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gringogordo

ASKER

Hi,

I hope the point split is acceptable!  

I felt novitiate  got there first but AlexFM was a little clearer on what was going on under the hood.


Thanks,

Ben.