NO

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

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • 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: 790
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: 179
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.

Grincheux

  • Guest
Re: Preview #2 of PE/COFF Viewer
« Reply #3 on: June 11, 2021, 06:18:47 PM »
Super,
Very useful.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • 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: 2096
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.  ;)
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • 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: 175
    • 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!
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline algernon_77

  • Member
  • *
  • Posts: 33
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: 2266
    • 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: 2266
    • 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: 33
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: 2091
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: 2266
    • 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

Grincheux

  • Guest
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!