sijms / PowerBuilder-decompile

Python module that parse power builder file (PBD) and analyze code (Incomplete)
MIT License
16 stars 7 forks source link

unpack requires a buffer of 8 bytes #1

Closed Sp0Q1 closed 2 years ago

Sp0Q1 commented 2 years ago
 File "pbd/definitions.py", line 389, in __init__
    length1, length2 = struct.unpack("<II", file.read(8))
  File "pbd/definitions.py", line 260, in __init__
    self.const_ = ConstData(file)
  File "pbd/definitions.py", line 1149, in __init__
    temp = Lookup(file)
  File "analyse_folder.py", line 22, in <module>
    group = definitions.Group(os.path.join(sys.argv[1], file))

on command python3 analyse_folder.py <output-folder-of-pbd_dump>

I cannot share the file that I am investigating, but I am investigating this issue.

sijms commented 2 years ago

can you tell me the extension of the file that make the problem know the decompiler is support the following format ("win", "fun", "udo")

Sp0Q1 commented 2 years ago

it's an udo file, which came out of the pbd_dump.py command.

sijms commented 2 years ago

the error occur at line which read the group name (at the beginning of reading operation)

temp = Lookup(file)
    if len(temp) > 0:
        self.group_name = temp[0].name

and according to the error the file is end! there will be 2 possible cause for this 1- the file version is different from the version I test against = PowerBuilder 11.5 2- the problem is related to the file to solve the issue I need to ask you does the tool make a successful decompilation for other files especially (udo) in your pbd library? if the answer is yes this means that the problem is related to this file only otherwise I suggest the version difference

dcsnetlink commented 2 years ago

Greetings. I am facing the same issue when I use this to decompile a fun file. I can successfully decompile the fun files from the pbd. The same occurs with all fun files. Can you suggest a work around? If needed, I can send you the file(s).

Thank you.

sijms commented 2 years ago

ok send and I will test

dcsnetlink commented 2 years ago

That would be great if you can help. I will share it via Google Drive.

Thank you so much!

Bob Scheff

Network Administrator / Programmer

@.***

Toll Free: 877-327-6385 | Fax: 715-201-4811

DCS Netlink

101 E. South Street

Rice Lake, WI 54868

Making I.T. Easy …as it should be!

On Tue, Aug 23, 2022 at 4:01 PM Samy Sultan @.***> wrote:

ok send and I will test

— Reply to this email directly, view it on GitHub https://github.com/sijms/PowerBuilder-decompile/issues/1#issuecomment-1224882640, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2S6SXTCSPEUJZPT3Z3VDT3V2U33RANCNFSM5KEVRDZA . You are receiving this because you commented.Message ID: @.***>

sijms commented 2 years ago

I find the problem by comparing your file and another file with me your file header:

00000000 | 4f 01 03 00 7d 40 01 00 | 10 00 00 00 24 51 d5 59 
00000010 | 00 00 00 00 15 f3 a6 5a | 00 00 00 00 08 00 00 00

and my file

00000000 | 41 01 03 00 77 40 01 00 | 10 00 00 00 83 91 0e 5b 
00000010 | 5e de bc 61 08 00 00 00

as you see the difference is as follow: 1- header 1 your file = 0x14F. my file 0x141 2- system class id your file = 0x407d my file = 0x4077 3- time of creation: your file = 8 bytes. my file = 4 bytes 4- time of modification: your file = 8 bytes. my file = 4 bytes

the 2 item 4 + 4 bytes difference make the error

sijms commented 2 years ago

what I will do to solve the problem is hardcode values like this

if self.h1 == 0x14f:
    c_date_id, m_date_id, self.h5 = struct.unpack("<QQI", file.read(0x14))
else:
    c_date_id, m_date_id, self.h5 = struct.unpack("<III", file.read(0xC))
sijms commented 2 years ago

now this code will raise exception:

        if class_type == 0x4000:
            if pcode.args[1] not in (0x40CF, 0x40D0):
                raise Exception("unknown module no.: {}".format(hex(pcode.args[1])))
Exception: unknown module no.: 0x40d5

this means your power builder virtual machine is more updated that what I have so I need these files: PBVM115.DLL and PBVM115.DLL.PBD

sijms commented 2 years ago

I fix the package you can test it now

dcsnetlink commented 2 years ago

Your update has resolved my issue! Thank you!