• Welcome to Valhalla Legends Archive.
 

Disassembling VB Programs

Started by Telos, February 11, 2004, 03:11 PM

Previous topic - Next topic

Telos

TheMinistered and I have been documenting some of the functions inside of VB programs to understand exactly what is going on.  The first thing we noticed is that if you write VB programs with strict type checking and use type specific functions like Mid$, Left$, Right$ instead of variant accepting functions like Mid, Left, and Right, there is a serious decrease in the amount of code that VB generates.  It may seem fairly obvious but its a good reminder to use type specific functions whenever possible.  Lastly for people interested in working with VB disassembly the documentation on the functions we have done is available at http://www.freewebs.com/telosx

Grok

#1
That's a well documented fact, which you could have deduced without disassembly.

When using the Variant type functions Mid(), Left(), Right(), Trim(), etc, VB must first determine the vartype of the operands.

In fact it is one of the first things you learn when reading about VB code optimization.

Telos

Hence the statement:

Quote
It may seem fairly obvious but its a good reminder to user type specific functions whenever possible.

It should be common sense that when using indetermine forms of variables that extra code will be required to determine the data type.  The disassembly simply allows you to see the sheer volume of extra code that Visual Basic has to execute to do this.

Grok

By the way, why are you two disassembling a dead language?

Newby

Quote from: Grok on February 11, 2004, 05:52 PM
By the way, why are you two disassembling a dead language?

* Newby looks at how many posts in the Visual basic section there are compared to any other programming sections (Besides General =P)

* Newby laughs :P

It's not dead for Battle.net :P
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Adron

Quote from: Grok on February 11, 2004, 05:04 PM
That's a well documented fact, which you could have deduced without disassembly.

When using the Variant type functions Mid(), Left(), Right(), Trim(), etc, VB must first determine the vartype of the operands.

In fact it is one of the first things you learn when reading about VB code optimization.

That is strange. I see VB functions getting turned into other calls when compiling to native code. VB should be able to do static selections of what function to use when you call Mid, Left, etc, if they are passed string variable arguments.

Maddox

#6
Should be
BSTR __fastcall __vbaStrCopy(BSTR destination, BSTR source);

This isn't like like strcpy. It copies source and destination to a new buffer which it returns.
asdf.