UCHAR problem

G

grubbymaster

Hello

The problem i have is this :
i want to use the following structure in a DLL that i created:

typedef struct _NDIS_802_11_SSID {
ULONG SsidLength;
UCHAR Ssid [32];
} NDIS_802_11_SSID, *PNDIS_802_11_SSID;

and i want to take the UCHAR Ssid[32] field and copy in it a certain
variable.I've tried the following ways :

NDIS_802_11_SSID Data;

_tcsncpy((TCHAR *)Data.Ssid, mySSID, 32);
strncpy((char *)pData.m_SSID.Ssid, mySSID, 32);

if i display it like this it works : MessageBox(NULL, Data.Ssid, L"",
MB_OK); and it displays ok : "EXAMPLE".

If i pass this as a parameter to a function like this : void X
(NDIS_802_11_SSID Data) and call this function from C# the recieved
string is "E\0X\0A\0\M\0P\0\L\0E\0".We solved this problem also by
using a for loop like this for (j=0; j<32 ; j=j+2) but if we have a
larger string that i want to put in UCHAR Ssid[32]; it will not retain
only 15chars because of the "\0" insertion after each char.I believe
that the problem is in the conversions i'm makeing above, and how i
store the data (with the TCHAR * and char * conversions). Is there a
function to copy from one UCHAR[32] to another UCHAR[32] without
conversions?

The mySSID parameter is taken as a parameter: void y(UCHAR mySSID[32])
,but in the body of the function it is seen as UCHAR[] and i can't use
this :

Data.Ssid = mySSID (error because UCHAR[32] <--->
UCHAR[])

That's it. Hope you can help me in some way.
Thank you.Bye
 
B

Ben Pope

grubbymaster said:

<snip> ULONG, UCHAR _tcsncpy, TCHAR, MessageBox, C#, DLL

You really should ask all this stuff in an appropriate place. This is
not it.

Check out the microsoft hierarchy.

Ben Pope
 
L

Lars Tetzlaff

grubbymaster said:
....
If i pass this as a parameter to a function like this : void X
(NDIS_802_11_SSID Data) and call this function from C# the recieved
string is "E\0X\0A\0\M\0P\0\L\0E\0".We solved this problem also by
using a for loop like this for (j=0; j<32 ; j=j+2) but if we have a
larger string that i want to put in UCHAR Ssid[32]; it will not retain
only 15chars because of the "\0" insertion after each char.I believe
that the problem is in the conversions i'm makeing above, and how i
store the data (with the TCHAR * and char * conversions). Is there a
function to copy from one UCHAR[32] to another UCHAR[32] without
conversions?

You are converting between different char sets. Your
"E\0X\0A\0\M\0P\0\L\0E\0" looks like an UTF-16 String diplayed as 8-bit
string.

You may have to set the character set in the properties of your vs-project.

Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Wrapper functions 1
std::min/max vs own functions 10
Java matrix problem 3
Function Identifier Not Found 1
Codeforces problem 0
Void problem 1
Timing problem 4
Member arrays and copy-construction 5

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top