Pelles C forum

Pelles C => Announcements => Topic started by: Pelle on June 05, 2021, 11:22:29 am

Title: Preview #2 of PE/COFF Viewer
Post by: Pelle 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)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: John Z on June 05, 2021, 12:19:46 pm
Got it - gonna try it....

John Z
Title: Re: Preview #2 of PE/COFF Viewer
Post by: bitcoin on June 11, 2021, 05:45:09 pm
Very good, thank you Pelle!
Try it with some exe and obj files, works well.
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Grincheux on June 11, 2021, 06:18:47 pm
Super,
Very useful.
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle 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!
Title: Re: Preview #2 of PE/COFF Viewer
Post by: frankie on June 12, 2021, 05:29:47 pm
It seems to work great for me!
Good job.  ;)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle on June 12, 2021, 08:28:57 pm
so... 3-0... starting to sound like maybe not a total failure, then... cool...  8)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: MrBcx 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!
Title: Re: Preview #2 of PE/COFF Viewer
Post by: algernon_77 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
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle 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
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle 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
Title: Re: Preview #2 of PE/COFF Viewer
Post by: algernon_77 on June 13, 2021, 03:19:20 pm
:) Good stuff, thanks very much!
Title: Re: Preview #2 of PE/COFF Viewer
Post by: TimoVJL on June 14, 2021, 09:28:35 am
Nice, a fresh view for files 8)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle 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! :)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Grincheux on June 14, 2021, 05:48:18 pm
Where is it?
I downloaded an old version!
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Marco on June 15, 2021, 11:12:02 am
I also tried it with several files. It does work great. Very well done!  :)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Grincheux on June 15, 2021, 01:13:09 pm

Version 0.99 is the last version.
Would be a good idea to copy into the clipboard only one line rather than all the code.
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle on June 15, 2021, 08:06:08 pm
I also tried it with several files. It does work great. Very well done!  :)
Thanks!  :)
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Pelle on June 15, 2021, 08:09:03 pm
Version 0.99 is the last version.
Would be a good idea to copy into the clipboard only one line rather than all the code.
Something to consider for a later version, I think.
Title: Re: Preview #2 of PE/COFF Viewer
Post by: John Z on June 16, 2021, 02:40:50 pm
Question 1:

It seems every DLL file I look at, even old 32 bit from PellesC 9, show under the "Image_File_Header" section item "Machine" they all show "IMAGE_FILE_MACHINE_AMD64".  So I checked the flags of the LineCount.DLL and see a macro ASFLAGS -AAMD64 -Gr now I'm on a I7 10th gen so probably my mistake.  However every PellesC 9 Add-in DLL showed the same AMD64 machine.

Is it right?

Question 2:
I use the version control in the LineCount.dll in explorer right click on properties shows the version under details.  Using PE/COFF viewer on the DLL under the '.rsrc' section, IMAGE_RESOURCE_DIRECTORY (types) I see Major and Minor version entries but they don't show the version information.

Is it different version from somewhere else?

-------
You can probably tell I'm a novice at using a tool like this  :)

John Z
Title: Re: Preview #2 of PE/COFF Viewer
Post by: Grincheux on June 16, 2021, 04:51:53 pm
Q1:AMD64 rather than INTEL is because they were the first to implement that instruction set.
If you have a CPU INTEL that works, this is a generic name.

Quote
You can probably tell I'm a novice at using a tool like this

That is better that misunderstanding.

They are people that say they have understood to hide the fact they don't know.
I hope you will have more questions like this.