Link to home
Start Free TrialLog in
Avatar of msjammu
msjammuFlag for United States of America

asked on

VB Application Source Code: Win32 API equivalent source code for VB Application

Experts:

Hi,

My observation: Vb is a higher level interface, So every call is acually implemented as a Win32 Api function call.

I am wondering to see the Win32 API equivalent surce code of my VB generated application. Please let me know any way out/tools to view Win32 API equivalent surce code of the application written in vb. How can I Import it in VC++ project.

:)

Regards,
msjammu



Avatar of RanjeetRain
RanjeetRain

Sorry to disappoint you, but the correct answer to your question is: No, you can't do it.

I have not come across any tool till date that can translate VB code to equivalent Windows API code, or for that matter import a VB project and open it as a VC++ project.

Even there is no chance of decompilation. Even if you get hold of a decompiler, it will spit out Assembly code, which would be almost unreadable.
Avatar of msjammu

ASKER


Thanks for Comments,
but I am still Optimistic,

I don't want any decompilation but only I want is something between my VB source code and actual object code.

If this is not possible I wuld like to know the complete process of VB compiler  translating the VB proram to object code/executable code. That may help in this.

Thanks and Regards,

SOLUTION
Avatar of cookre
cookre
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msjammu

ASKER

cookre:

Can you plz elaborate more?

Many Thanks,
We'll use the field level I/O (reading/writing a series of variously typed field).  There are no Win32 APIs that let you do this.  Your program code instead calls the VB runtime library that, in turn, uses the APIs to load chunks of the file in question, interprets what it read from the file, then passes back to you individual field values.

This is also one way to make it easier to move a program between versions of Windows.  If your code had explicit API references in it, it would fail if it referenced an API that was OS specific.  Since the VB runtime libraries are OS specific or OS aware, your generated code is less dependant on OS version.
Avatar of msjammu

ASKER

Thank You cookre,

At last

>>>If this is not possible I wuld like to know the *COMPLETE* process of VB compiler  translating the VB program to object code/executable code. That may help in this

You may help in this also

Any links will also help

Regards,
Hi,
vb is not opensource, and i don't think microsoft will give you the code (or as you call it: "the complete process") of translating vbcode into w32 api calls.

Belthazor


>> If this is not possible I wuld like to know the complete process of VB compiler  translating the VB proram to object code/executable code. That may help in this.

Not sure how will that help you. Anyway, there is no such documentation available. Yes, experts may use thier personal experience to explain you a few things in brief, but certainly not the "complete process".

I'd suggest go thru some documentation on compiler design etc. Because, at the core all compilers are same. They all work on similar lines. May be that can help you.

If you want I can tell you a few things,, but at the moment you are expecting way too much.
I just took a look at a VB6 executable.  I saw no direct calls to any Win32 APIs.  There were, however, plenty of calls to the VB runtime libraries.

That also explains why there is no static link option for VB.
Avatar of msjammu

ASKER

RanjeetRain:

>>>Yes, experts may use thier personal experience to explain you a few things in brief,

Plz, If you or anybody can

>>>I'd suggest go thru some documentation on compiler design etc. Because, at the core all compilers are same. They all work on similar lines. May be that can help you.

You are right. Architecturally all compilers work similarly. but I want only in terms of VB. What I need is not general compiler design process.

>>>If you want I can tell you a few things,, but at the moment you are expecting way too much.

I will appriciate any type of help specific to VB compile process as I know little about core of VB compiler.

cookre :

>>>I just took a look at a VB6 executable.  I saw no direct calls to any Win32 APIs.  There were, however, plenty of calls to the VB runtime libraries. That also explains why there is no static link option for VB.

Thanks for the Help.


Regards,
msjammu




SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops, I missed a bit on my cut and paste, here is the complete code for the msgbox

4:    MsgBox "Hi There"
0040160C   mov         ecx,80020004h
00401611   mov         eax,0Ah
00401616   mov         dword ptr [ebp-48h],ecx
00401619   mov         dword ptr [ebp-38h],ecx
0040161C   mov         dword ptr [ebp-28h],ecx
0040161F   lea         edx,[unnamed_var1]
00401622   lea         ecx,[unnamed_var1]
00401625   mov         dword ptr [unnamed_var1],0
0040162C   mov         dword ptr [unnamed_var1],eax
0040162F   mov         dword ptr [unnamed_var1],eax
00401632   mov         dword ptr [unnamed_var1],eax
00401635   mov         dword ptr [ebp-58h],offset ___vba@001BD378 (0040131c)
0040163C   mov         dword ptr [unnamed_var1],8
00401643   call        dword ptr [__imp____vbaVarDup (0040105c)]
00401649   lea         eax,[unnamed_var1]
0040164C   lea         ecx,[unnamed_var1]
0040164F   push        eax
00401650   lea         edx,[unnamed_var1]
00401653   push        ecx
00401654   push        edx
00401655   lea         eax,[unnamed_var1]
00401658   push        0
0040165A   push        eax
0040165B   call        dword ptr [__imp____vba@001BD43C (00401018)]
00401661   lea         ecx,[unnamed_var1]
00401664   lea         edx,[unnamed_var1]
00401667   push        ecx
00401668   lea         eax,[unnamed_var1]
0040166B   push        edx
0040166C   lea         ecx,[unnamed_var1]
0040166F   push        eax
00401670   push        ecx
00401671   push        4
00401673   call        dword ptr [__imp____vbaFreeVarList (00401008)]
00401679   add         esp,14h
0040167C   push        offset $L47 (004016a0)
00401681   jmp         $L42 (0040169f)
5:
6:    End Sub
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Being a Assembly programmer can help. No, understanding Assembly wont help a lot. Not atleast upto an extent where you can import it or debug it.

For your learning Windows API purpose, you should give up on idea of importing or seeing the equivalent API code translated from VB. For that my recommendation would be to read an Windows API book.

THere are many sites on Net that have excellent reference material. YOu can see several implemntation of VB's built-in controls and other poular controls. Most of them have been implemented using C/C++ and Windows API. I guess that would be your best bet.
Now, if we tweak your original statement a bit, you are right on.

"My observation: Vb is a higher level interface, So every STATEMENT is acually implemented as a VB RUNTIME function call."

And about sums up the "complete process of the [VB] compiler".
Avatar of msjammu

ASKER

JohnBPrice:

"My observation: Vb is a higher level interface, So every STATEMENT is acually implemented as a VB RUNTIME function call." - Approved

:)

This is a nice discussion.
I am Extremely Thankful to all the experts for their contributions.

Regards,
Manpreet S Jammu