What does this mean?

P

prabu

Hi all,

I want to know, what does the value of the array in the following
statement mean and How to print the content of the array SMB_Negotiate
using printf?

unsigned char SMB_Negotiate[] =

"\x00\x00\x00\x85\xFF\x53\x4D\x42\x72\x00\x00\x00\x00\x18\x53\xC8"

"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"

"\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4E\x45\x54\x57\x4F"

"\x52\x4B\x20\x50\x52\x4F\x47\x52\x41\x4D\x20\x31\x2E\x30\x00\x02"

"\x4C\x41\x4E\x4D\x41\x4E\x31\x2E\x30\x00\x02\x57\x69\x6E\x64\x6F"

"\x77\x73\x20\x66\x6F\x72\x20\x57\x6F\x72\x6B\x67\x72\x6F\x75\x70"

"\x73\x20\x33\x2E\x31\x61\x00\x02\x4C\x4D\x31\x2E\x32\x58\x30\x30"

"\x32\x00\x02\x4C\x41\x4E\x4D\x41\x4E\x32\x2E\x31\x00\x02\x4E\x54"
"\x20\x4C\x4D\x20\x30\x2E\x31\x32\x00";

Regards,
Prabu.K
 
S

santosh

prabu said:
Hi all,

I want to know, what does the value of the array in the following
statement mean

It depends on the program and what it's trying to do.
and How to print the content of the array SMB_Negotiate
using printf?

Take the size of the array using the sizeof operator. Then use a loop
to print each byte of the array as an hexadecimal value with a
statement like:
printf("%x ", SMB_Negotiate[BYTE_NUM]);

Don't forget to call fflush() after printing all the bytes.
 
N

Nick Keighley

prabu said:
I want to know, what does the value of the array in the following
statement mean

well its an array of unsigned char, initialised with a string. The
string
contains hex values. It includes nul characters ('\0') so you can't
manipulate it using str* functions.

I'm not sure what you mean by "what does the value of the array
"mean"".
How can a value "mean" anything? Some of it could be ASCII try
translating it.
and How to print the content of the array SMB_Negotiate
using printf?

a for loop and %x format specification?

unsigned char SMB_Negotiate[] =

"\x00\x00\x00\x85\xFF\x53\x4D\x42\x72\x00\x00\x00\x00\x18\x53\xC8"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
"\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4E\x45\x54\x57\x4F"

<snip>


--
Nick Keighley

A ruby trembled. Two tourmaline nets failed to rectify the laser beam.
A diamond noted the error. Both the error and the correction went into
the general computer.
Corwainer Smith "The Dead Lady of Clown Town"
 
J

John Turner

prabu said:
Hi all,

I want to know, what does the value of the array in the following
statement mean and How to print the content of the array SMB_Negotiate
using printf?

unsigned char SMB_Negotiate[] =

"\x00\x00\x00\x85\xFF\x53\x4D\x42\x72\x00\x00\x00\x00\x18\x53\xC8"

"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"

"\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4E\x45\x54\x57\x4F"

"\x52\x4B\x20\x50\x52\x4F\x47\x52\x41\x4D\x20\x31\x2E\x30\x00\x02"

"\x4C\x41\x4E\x4D\x41\x4E\x31\x2E\x30\x00\x02\x57\x69\x6E\x64\x6F"

"\x77\x73\x20\x66\x6F\x72\x20\x57\x6F\x72\x6B\x67\x72\x6F\x75\x70"

"\x73\x20\x33\x2E\x31\x61\x00\x02\x4C\x4D\x31\x2E\x32\x58\x30\x30"

"\x32\x00\x02\x4C\x41\x4E\x4D\x41\x4E\x32\x2E\x31\x00\x02\x4E\x54"
"\x20\x4C\x4D\x20\x30\x2E\x31\x32\x00";

Regards,
Prabu.K

Ignoring unprintable characters it's:

"SMBrS bPC NETWORK PROGRAM 1.0LANMAN1.0Windows for Workgroups
3.1aLM1.2X002LANMAN2.1NT LM 0.12"

To display with printf in a nice and hacky and unrecommended way:

int i;
for (i=0; i < sizeof(SMB_Negotiate); i++)
{
if (SMB_Negotiate == 0) {
SMB_Negotiate++;
}
}
printf(SMB_Negotiate);
 
R

Richard Bos

John Turner said:
prabu said:
I want to know, what does the value of the array in the following
statement mean and How to print the content of the array SMB_Negotiate
using printf?

unsigned char SMB_Negotiate[] =
"\x00\x00\x00\x85\xFF\x53\x4D\x42\x72\x00\x00\x00\x00\x18\x53\xC8"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
"\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4E\x45\x54\x57\x4F"
"\x52\x4B\x20\x50\x52\x4F\x47\x52\x41\x4D\x20\x31\x2E\x30\x00\x02"
"\x4C\x41\x4E\x4D\x41\x4E\x31\x2E\x30\x00\x02\x57\x69\x6E\x64\x6F"
"\x77\x73\x20\x66\x6F\x72\x20\x57\x6F\x72\x6B\x67\x72\x6F\x75\x70"
"\x73\x20\x33\x2E\x31\x61\x00\x02\x4C\x4D\x31\x2E\x32\x58\x30\x30"
"\x32\x00\x02\x4C\x41\x4E\x4D\x41\x4E\x32\x2E\x31\x00\x02\x4E\x54"
"\x20\x4C\x4D\x20\x30\x2E\x31\x32\x00";

Ignoring unprintable characters it's:

"SMBrS bPC NETWORK PROGRAM 1.0LANMAN1.0Windows for Workgroups
3.1aLM1.2X002LANMAN2.1NT LM 0.12"

Presuming ASCII. In this case the presumption appears correct, but
that's not guaranteed by C. These days, it's not even guaranteed under
M$ Windows.
To display with printf in a nice and hacky and unrecommended way:

int i;
for (i=0; i < sizeof(SMB_Negotiate); i++)
{
if (SMB_Negotiate == 0) {
SMB_Negotiate++;


That's dangerous. It assumes that '\x01' is a printable character which
won't, e.g., cause your printer to do a pagefeed. Safer, and probably
clearer, would be

SMB_Negotiate=' '; /* or ='?', for extra obviousness. */

Of course, after any of these solutions, the array will most likely no
longer be useable for its previous purpose. Better mangle a copy
instead.

Richard
 
B

Ben Bacarisse

Ignoring unprintable characters it's:

"SMBrS bPC NETWORK PROGRAM 1.0LANMAN1.0Windows for Workgroups
3.1aLM1.2X002LANMAN2.1NT LM 0.12"

To display with printf in a nice and hacky and unrecommended way:

int i;
for (i=0; i < sizeof(SMB_Negotiate); i++)
{
if (SMB_Negotiate == 0) {
SMB_Negotiate++;
}
}
printf(SMB_Negotiate);


Dangerous! printf("%s", SMB_Negotiate); works when the data contains
%. Obviously, puts is an option as well.
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top