News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Understand this code

Started by ragdog, December 03, 2011, 12:16:42 PM

Previous topic - Next topic

ragdog

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

qWord

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)
FPU in a trice: SmplMath
It's that simple!

clive

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.
It could be a random act of randomness. Those happen a lot as well.

ragdog

Thanks for you reply  :U

but can you send an example?

qWord

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
FPU in a trice: SmplMath
It's that simple!

ragdog

#5
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


jj2007

Looks like corrupted ANSI. The original text is "From Dawson's Creek".

ragdog

YEs i know

but what is this for charracters?

it is not unicode or ascii

clive

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.
It could be a random act of randomness. Those happen a lot as well.

dedndave

i vote for metadata   :P
it's probably part of a media file header

Tedd

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
No snowflake in an avalanche feels responsible.