Re: RosAsm injects extra bytes into your data



Betov wrote:
> "Alex McDonald" <alex_mcd@xxxxxxxxxxxxxxx> écrivait
> news:1114628472.109735.162400@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:
>
> > Thank you. You wrote;
> >
> >> > The point of my "idea" is rather than injecting all these
padding
> > bytes
> >> > to align things, why not rearrange all the declarations to
> > *minimize*
> >> > the wasted space while maintaining the alignment the user
requests.
> >
> >> Because this would be unusable, for the Programmer.
> >
> >> (The ones who have already written a bit of Assembly
> >> will probably understand without explanations... :)
> >
> > I still don't understand this statement. Can you explain?
>
> As the sense of humour might vary from culture
> to culture, and as, maybe, some beginner would
> also not understand, here is a trivial example:
>
> [MyFirstData: DwordData: D§ ?]
> ;...
> ;...
> [WordData: W§ ? ?]
> ;...
> ;...
> [ByteData: B§ ? ? ? ? ? ? ? MyLastData: D§ ?]
> ;...
> ;...
>
> ; Clear My Data from 'MyFirstData' to 'MyLastData':
>
> mov eax 0, edi MyFirstData
> While edi < MyLastData | stosd | End_While
>
> :)
>
> Betov.
>
> < http://rosasm.org >

As a coding style, this is pretty ropey. There are several assumptions
the novice programmer that wrote this has made in the above code. A
sense of humour is required when reading it, that's for sure.

In no particular order;

.. The label MyLastData points to the _start_ of 4 bytes at the end of
the structure, not the end. MyLastData - MyFirstData is 4 bytes short
of the length.

.. The while end_while depends on a less-than test. The last four bytes
will not be cleared.

.. OK, so fix the two problems above (and I'm not sure that you can in
RosAsm because of a lack of equate support). Now the structure must be
a multiple of dwords in length if you use stosd, otherwise you'll
overrun the structure. Unless I'm missing something, your structure is
a byte short of dword alignment; there are 7 bytes prior to MyLastData.
MyLastData is not dword aligned.

.. As this isn't properly a structure (it has no enforced coherence;
it's a collection of structures), moving anything out from between the
MyFirstData and MyLastData won't get cleared and the programmer will
not get a warning. Why would anyone do that? Because it's not clear
this is a single structure.

.. Clearing unrelated structures and values by blitting like this is bad
practise. Believe me, I've dug through enough cruddy code like this to
know. What if some of the labels in this mess of data were floats?
Initialisation is done infrequently. Do it properly.

.. All the data must be in a single section (or does RosAsm only support
a single data section?).

A lot of the problems in this code boil down to RosAsm not properly
supporting structures, a lack of an equate type statement (as in
MyLastData equ * ), a lack of an automatically calculated length for
the structure, and poor programming style.

You're right when you say "Because this would be unusable, for the
Programmer". If the programmer's using RosAsm it's difficult to see how
to make it usable. Beginners beware.

--
Regards
Alex McDonald

.



Relevant Pages

  • Re: Will HLA2.0 Support rosasm?
    ... it is Rene that always refers to me as "master". ... Flex, Bison, and Delphi programmer (and fairly decent at other languages, ... Maybe RosAsm will even be "auto-compiling" on ...
    (alt.lang.asm)
  • Re: .EXE -> .ASM -> .EXE
    ... RosAsm, I have to Cut&Paste the code. ... are developping a LibScanner, in Assembly form, without ... the associated Toys. ... own Binary, as long as you are an Assembly Programmer, ...
    (alt.lang.asm)
  • Re: Editors
    ... There are two ways to access content in your RosAsm ... pedantic, I could claim that your "protection" is, at best, 50% effective ... I don't think a programmer will miss such errors :-) ... This is why i recommend, above, to start RosAsm PEs ...
    (alt.lang.asm)
  • Re: Editors
    ... It seems you do not even understand the RosAsm ... When develoçping an App with RosAsm, ... executables. ... > from a PE if the programmer means to not go GPL. ...
    (alt.lang.asm)
  • Re: [Full-Disclosure] Windoze almost managed to 200x repeat 9/11
    ... > programmer, that eventually it has to do something other than increase. ... From the documentation, "The elapsed time is stored as a DWORD value. ... "If you need a higher resolution timer, use a multimedia timer or a ...
    (Full-Disclosure)