The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on December 03, 2011, 12:16:42 PM

Title: Understand this code
Post by: ragdog on December 03, 2011, 12:16:42 PM
Hi all

I try to understand this code

char Buffer[10000];
STRUCT_DATA* pData = (STRUCT_DATA*) Buffer;


STRUCT_DATA is a structur and pData pointer to this structur

But what make this code?
STRUCT_DATA * 1000 ? is this correct

Greets
Title: Re: Understand this code
Post by: qWord on December 03, 2011, 12:30:59 PM
The pointer to the char-array Buffer is typecasted to the structure-pointer pData.
This means, that the structure STRUCT_DATA, referenced by pData, is placed in the buffer Buffer. This also requires that sizeof(STRUCT_DATA) <= sizeof(Buffer)
Title: Re: Understand this code
Post by: clive on December 03, 2011, 10:30:52 PM
Quote from: ragdog on December 03, 2011, 12:16:42 PM
But what make this code?
STRUCT_DATA * 1000 ? is this correct

Well that would depend on the size of STRUCT_DATA, and on some architectures the alignment requirements.
But yes with a nominal 10 byte structure, 1000 would fit in 10000 bytes.
Title: Re: Understand this code
Post by: ragdog on December 04, 2011, 02:00:03 PM
Thanks for you reply  :U

but can you send an example?
Title: Re: Understand this code
Post by: qWord on December 04, 2011, 02:05:24 PM
STRUCT_DATA struct
    member1 DWORD ?
    member2 DWORD ?
    ;...
STRUCT_DATA ends

xyz PROC
LOCAL buffer[10000]:CHAR
...
lea esi,buffer
; esi = ptr STRUCT_DATA

mov [esi].STRUCT_DATA.member1,123
Title: Re: Understand this code
Post by: ragdog on December 04, 2011, 02:47:33 PM
Thanks guys i have solved it with your help :U

Now can i read out this struct and now have i the next problem
what is this for a text is this unicode or what?

46 72 6F 6D 20 44 C1 BD 80 00 02 0F 61 77 73 6F  From DÁ½€.awso
6E B4 73 20 43 72 65 65 C4 BC 80 00 03 0F 6B 20   n´s Creeļ€.k

Title: Re: Understand this code
Post by: jj2007 on December 04, 2011, 09:37:47 PM
Looks like corrupted ANSI. The original text is "From Dawson's Creek" (http://www.cduniverse.com/search/xx/music/pid/1090598/a/Songs+From+Dawson%27s+Creek.htm).
Title: Re: Understand this code
Post by: ragdog on December 05, 2011, 06:50:58 PM
YEs i know

but what is this for charracters?

it is not unicode or ascii
Title: Re: Understand this code
Post by: clive on December 05, 2011, 10:30:32 PM
Quote from: ragdogYes i know but what is this for characters? it is not unicode or ascii

It's ASCII data with other data interleaved periodically with it. Unfortunately you always seem to be hacking at things, and never provide enough context/information. It could be some compressed data, or some metadata, or if it's sub-titles some pacing/placement data.
Title: Re: Understand this code
Post by: dedndave on December 06, 2011, 01:08:59 AM
i vote for metadata   :P
it's probably part of a media file header
Title: Re: Understand this code
Post by: Tedd on December 06, 2011, 01:36:22 PM
Quote from: ragdog on December 04, 2011, 02:47:33 PM
46 72 6F 6D 20 44 C1 BD 80 00 02 0F 61 77 73 6F  From DÁ½€.awso
6E B4 73 20 43 72 65 65 C4 BC 80 00 03 0F 6B 20  n´s Creeļ€.k

"From D"         46 72 6F 6D 20 44
BDC1h            C1 BD
0080h            80 00
0F02h            02 0F
"awson´"         61 77 73 6F 6E B4
"s Cree"         73 20 43 72 65 65
BCC4h            C4 BC
0080h            80 00
0F03h            03 0F
"k "             6B 20


The binary values are probably for indexing and maybe flags, but it would help to know where it comes from.
Knowing the format means you can look for a description :wink