Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decompile to recover lost .bas module?

Status
Not open for further replies.

ghardenb

Programmer
Oct 24, 2004
28
US
I cannot access and work on my source code because I inadvertently over-wrote the .bas module containing my record fields (type/end type) and my global variables.

Is there a decompiler that will get that back for me from the compiled exe file? Any other ideas?

 
Yes there is one called Free VB Decompiler which is I think is about 5.39 MB. But the Program is slow but it does decompile most of the Files. You can also get a commercial one from the same author(s) which I have read somewhere is more accurate.

Just google it.
 
I'll repeat: this is, I'm afraid, arrant nonsense. There has been no effective native code decompilers for Classic VB5 or VB6 (VB3 had a reasonably good decompiler, and VB4 had one or two that worked a bit, but both of those languages only compiled to p-code, so it was much, much easier to decompile). And if you investigate how the native code compilation works (in summary, an intermediate language version of your program is passed to the same highly efficient optimising compiler used by Microsoft's C/C++, languages) you'd understand why.

The "Free VB Decompiler" you mention is almost certainly limited to 'decompiling' p-code, which practically no-one has compiled to for about a decade, and even then has numerous limitations.

Most of the 'decompilers' on the market (free or otherwise) attempt to disassemble native code instead, which is not the same thing as decompilation at all, and given the nature of an optimising compiler, cannot properly recover even the structure of your original program, let alone individual lines of code
 
I've already mentioned that the decompiler will surely not be accurate.


LONG STORY SHORT:
The download page has a description written about the program and
in the middle of the description is the line:

If a program was compiled into the native code, restoring full source code from machine instructions is not possible.

Which means it afterall may be helpful to someone by extracting some part of the real sourcecode, may be it'll help him recode the file faster.

Most of all, someone asked for a program which would help him extract and regain something he worked hard to make.
So, I mentioned what I knew and don't care whether it is pseudo code or not and I don't care about it's accuracy and limitations.
 
>Which means it afterall may be helpful

And I'll repeat that, in relation to native code compilation, they are a waste of money and, frankly, a con. And often use carefully worded sentences to hide their limitations ...

> by extracting some part of the real sourcecode

No, they can't do this. Really (or at least not in any meaningful sense). The nature of the optimizing compiler is such that there is no one-to-one correspondence between the compiled code and the original source. At best they take a guess at what the source code may have been (and earlier versions of VB Decompiler were more honest about this and pretty much state as much in the documentation)

Here, for example, is the full code of a simple VB program:
Code:
[blue]Option Explicit

Private Sub Command1_Click()
    Text1.Text = "Hello World"
End Sub[/blue]

and here is (part of) VB Decompiler 8.1's decompilation of that code (or rather, as previously stated, a disassembly):
Code:
Private Sub Command1_Click() '401AF0
  loc_00401AF0: push ebp
  loc_00401AF1: mov ebp, esp
  loc_00401AF3: sub esp, 0000000Ch
  loc_00401AF6: push 00401096h
  loc_00401AFB: mov eax, fs:[00h]
  loc_00401B01: push eax
  loc_00401B02: mov fs:[00000000h], esp
  loc_00401B09: sub esp, 00000014h
  loc_00401B0C: push ebx
  loc_00401B0D: push esi
  loc_00401B0E: push edi
  loc_00401B0F: mov var_C, esp
  loc_00401B12: mov var_8, 00401080h
  loc_00401B19: mov esi, arg_8
  loc_00401B1C: mov eax, esi
  loc_00401B1E: and eax, 00000001h
  loc_00401B21: mov var_4, eax
  loc_00401B24: and esi, FFFFFFFEh
  loc_00401B27: push esi
  loc_00401B28: mov arg_8, esi
  loc_00401B2B: mov ecx, [esi]
  loc_00401B2D: call [ecx+04h]
  loc_00401B30: mov edx, [esi]
  loc_00401B32: xor edi, edi
  loc_00401B34: push esi
  loc_00401B35: mov var_18, edi
  loc_00401B38: call [edx+00000300h]
  loc_00401B3E: push eax
  loc_00401B3F: lea eax, var_18
  loc_00401B42: push eax
  loc_00401B43: call [00401018h] [magenta]; Set (object)[/magenta]
  loc_00401B49: mov esi, eax
  loc_00401B4B: push 00401524h [/magenta]; "Hello World"[/magenta]
  loc_00401B50: push esi
  loc_00401B51: mov ecx, [esi]
  loc_00401B53: call [ecx+000000A4h]
  loc_00401B59: cmp eax, edi
  loc_00401B5B: fclex
  loc_00401B5D: jnl 401B71h
  loc_00401B5F: push 000000A4h
  loc_00401B64: push 0040153Ch
  loc_00401B69: push esi
  loc_00401B6A: push eax
  loc_00401B6B: call [00401010h]
  loc_00401B71: lea ecx, var_18
  loc_00401B74: call [00401078h]
  loc_00401B7A: mov var_4, edi
  loc_00401B7D: push 00401B8Fh
  loc_00401B82: jmp 401B8Eh
  loc_00401B84: lea ecx, var_18
  loc_00401B87: call [00401078h]
  loc_00401B8D: ret

Good luck in extracting your source from that ...
 
OKAY I'm completely unfamilier with ASM and I'm just asking myself why I even posted the reply with the name of the program.

But, I repeat I DON'T CARE. Topic Closed for ME...

THX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top