NO

Author Topic: Preview #2 of PE/COFF Viewer  (Read 1053 times)

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Preview #2 of PE/COFF Viewer
« on: June 05, 2021, 11:22:29 am »
This is a second preview of Pelles PE/COFF Viewer (pope.exe): a GUI program for looking into executable, archive (library), object, and debug files. It will be included in a future setup of Pelles C.

- Added X86/X64 disassembler (very basic, no symbolic names etc.)
- Added a few more bits of information
- Fixed a few problems

(compiled with new compiler and C runtime, so watch out...)

www.smorgasbordet.com/pellesc/extra/pope.zip  (this link will obviously go dead at some point in the future, but will stay there for now)
/Pelle

Offline John Z

  • Member
  • *
  • Posts: 331
Re: Preview #2 of PE/COFF Viewer
« Reply #1 on: June 05, 2021, 12:19:46 pm »
Got it - gonna try it....

John Z

Offline bitcoin

  • Member
  • *
  • Posts: 133
Re: Preview #2 of PE/COFF Viewer
« Reply #2 on: June 11, 2021, 05:45:09 pm »
Very good, thank you Pelle!
Try it with some exe and obj files, works well.

Offline Grincheux

  • Member
  • *
  • Posts: 321
  • Never be pleased, always improve
    • Arachne
Re: Preview #2 of PE/COFF Viewer
« Reply #3 on: June 11, 2021, 06:18:47 pm »
Super,
Very useful.
-------------------------
Kenavo / Bye

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Re: Preview #2 of PE/COFF Viewer
« Reply #4 on: June 12, 2021, 12:16:28 pm »
Very good, thank you Pelle!
Try it with some exe and obj files, works well.
Good news. Thanks!
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1839
Re: Preview #2 of PE/COFF Viewer
« Reply #5 on: June 12, 2021, 05:29:47 pm »
It seems to work great for me!
Good job.  ;)

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Re: Preview #2 of PE/COFF Viewer
« Reply #6 on: June 12, 2021, 08:28:57 pm »
so... 3-0... starting to sound like maybe not a total failure, then... cool...  8)
/Pelle

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 83
    • Bcx Basic to C/C++ Translator
Re: Preview #2 of PE/COFF Viewer
« Reply #7 on: June 12, 2021, 11:36:41 pm »
so... 3-0... starting to sound like maybe not a total failure, then... cool...  8)

Make that 4-0 ... you are approaching statistical significance.   ;D

Side note -- I routinely compile and test BCX using 5 different compilers.  I recently
re-enabled 'optimize speed' using your compiler and was stunned to learn
your code generation outperformed all the other compilers by as much as 30%.

It seems you have several super powers!

Offline algernon_77

  • Member
  • *
  • Posts: 31
Re: Preview #2 of PE/COFF Viewer
« Reply #8 on: June 13, 2021, 09:14:45 am »
Seems to be working very well on my end, too, I think it will make a nice addition to the compiler suite.

One question, though: how did you implement the splitter control? There are a few examples on the web (there's one on smorgasbordet, too), but in these the widths of the treeview/listview are being changed in realtime, which can generate a lot of flicker, especially with the treeview. Yours seems to work the "right way", i.e. it updates the controls on drag release only.

Regards,
Adrian

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Re: Preview #2 of PE/COFF Viewer
« Reply #9 on: June 13, 2021, 01:22:29 pm »
Side note -- I routinely compile and test BCX using 5 different compilers.  I recently
re-enabled 'optimize speed' using your compiler and was stunned to learn
your code generation outperformed all the other compilers by as much as 30%.

It seems you have several super powers!
Dumb luck, more likely...  :P

Over a wide range of applications I suspect GCC/LLVM will beat me on most of them. Sometimes the decision to call a runtime function vs using a compiler generated "inlined" version can make a big difference. Maybe even the best can get it slightly wrong at times...?

30% sounds like very much...  :o  Does this compiler have an option to disable the sleep() between statements?  ;D
/Pelle

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Re: Preview #2 of PE/COFF Viewer
« Reply #10 on: June 13, 2021, 01:30:12 pm »
One question, though: how did you implement the splitter control? There are a few examples on the web (there's one on smorgasbordet, too), but in these the widths of the treeview/listview are being changed in realtime, which can generate a lot of flicker, especially with the treeview. Yours seems to work the "right way", i.e. it updates the controls on drag release only.

It goes something like this:
Code: [Select]
In WM_LBUTTONDOWN handler:
SetCapture(hwnd);
g_xDivider = <start position>;
DrawResizeLine(hwnd, g_xDivider);

In WM_MOUSEMOVE handler:
if (hwnd == GetCapture()) {
  DrawResizeLine(hwnd, g_xDivider);
  g_xDivider = <new position>;
  DrawResizeLine(hwnd, g_xDivider);
}

In WM_LBUTTONUP handler:
if (hwnd == GetCapture()) {
  ReleaseCapture();
  DrawResizeLine(hwnd, g_xDivider);
  ResizeWorkspace();
}

static void DrawResizeLine(HWND hwnd, int x) {
    UpdateWindow(hwnd);
    HDC hdc = GetDC(hwnd);
    if (hdc) {
        PatBlt(hdc, x - CXDIVIDER/2, g_rcDivider.top, CXDIVIDER,
            g_rcDivider.bottom - g_rcDivider.top, DSTINVERT);
        ReleaseDC(hwnd, hdc);
    }
}

static void ResizeWorkspace(void) {
    HDWP hdwp = BeginDeferWindowPos(4 /* number of windows */);
    if (hdwp != NULL) {
        hdwp = DeferWindowPos(hdwp, <some window handle #1>, other params...);
        hdwp = DeferWindowPos(hdwp, <some window handle #2>, other params...);
        hdwp = DeferWindowPos(hdwp, <some window handle #3>, other params...);
        hdwp = DeferWindowPos(hdwp, <some window handle #4>, other params...);
        EndDeferWindowPos(hdwp);
    }
}

Using BeginDeferWindowPos(), DeferWindowPos(), EndDeferWindowPos() is the key to reduce flicker.
DrawResizeLine() is using DSTINVERT, which means the second time you call the function with the same coordinates it will cancel out the first call (removing the line from the screen).
Easy.  :P
/Pelle

Offline algernon_77

  • Member
  • *
  • Posts: 31
Re: Preview #2 of PE/COFF Viewer
« Reply #11 on: June 13, 2021, 03:19:20 pm »
:) Good stuff, thanks very much!

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1940
Re: Preview #2 of PE/COFF Viewer
« Reply #12 on: June 14, 2021, 09:28:35 am »
Nice, a fresh view for files 8)
May the source be with you

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2139
    • http://www.smorgasbordet.com
Re: Preview #2 of PE/COFF Viewer
« Reply #13 on: June 14, 2021, 11:50:48 am »
Nice, a fresh view for files 8)
Glad you think so, since you kicked off this project in the first place... thanks! :)
/Pelle

Offline Grincheux

  • Member
  • *
  • Posts: 321
  • Never be pleased, always improve
    • Arachne
Re: Preview #2 of PE/COFF Viewer
« Reply #14 on: June 14, 2021, 05:48:18 pm »
Where is it?
I downloaded an old version!
-------------------------
Kenavo / Bye