Page 1 of 1

PDF-Tools DLLs base address optimization suggestion

Posted: Mon Oct 05, 2009 11:26 am
by tieto_hc
Hi!

I noticed that all PDF-Tools 4 DLLs have a default Visual C preferred load address of 0x10000000. Since many other DLLs also use this base address, loading a application which uses PDF-Tools dlls causes these dlls to be relocated to another address. Included is a Process Explorer screenshot which highlights the relocated dlls of a example application.

DLL relocation has two drawbacks:

1. Due to the relocation process, the application startup is slower than it could be.
2. In multi-user environments such as Terminal Services, the relocated dll cannot be shared by other sessions. This increases the memory requirements of an application, since every instance of a application has to have separate copies of the PDF-Tools dlls.

The second point in particular is a real issue to us in Terminal Server / Citrix environments, where our application has several dozens of simultaneous users in any given application server, and any memory optimization would be more than welcome.

It is quite easy to specify the base address in the C compiler and because this increases the performance of the PDF-Tools in general without any risks, it would be a really good addition to a further release.

Available and good memory ranges in general would be 0x12000000 to 0x1FFFFFFF or 0x30000000 to 0x5FFFFFFF, since these ranges aren't used by many other applications.

Another good way to do this is to use the editbin tool included in the MS Platform SDK. For example, rebasing dscrt40.dll and xccdx40.dll to a staring address of 0x40000000 would be done

Code: Select all

EDITBIN /REBASE:0x40000000 dscrt40.dll xccdx40.dll 
Of course, this would have to happen before the code signing of the dlls.

For more information on the DLL rebase process, please see

http://msdn.microsoft.com/en-us/library/ms810432.aspx
http://www.ddj.com/windows/184416272;js ... stid=20593

Best regards,
--
Timo Multanen

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Mon Oct 05, 2009 3:12 pm
by Tracker Supp-Stefan
Thanks Timo,

We take all suggestions in consideration here so I will pass yours to our development team but as you say any way to save memory and reduce load times is a plus for everybody :)

Regards,
Stefan

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Tue Oct 06, 2009 6:17 pm
by Ivan - Tracker Software
The Load address is dependant on the enviroment and the application which loads.

So, if you need to have an optimized system - by all means - rebase our dlls for your system.

HTH

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Tue Oct 06, 2009 7:33 pm
by Tracker - Clarion Support
Hi Timo!

For the Clarion environment especially, your suggestion is a good one!

As Ivan points out, our DLLs are written generically to support a wide range of development environments, and what might be a good rebase for one might cause trouble in another. So we'll continue to release our libraries using the default Visual C preferred load address of 0x10000000.

However there is nothing to prevent you, or any other developer, from rebasing as desired. I suggest maintaining archive copies of our DLLs that you can copy and rebase as desired.

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Wed Oct 07, 2009 12:12 pm
by tieto_hc
Hi Craig and Ivan,

And thanks for your replies!

I'm aware that I can manually rebase even 3rd party dlls, and I'd gladly do this, but this breaks your digital signatures on the dlls. Since it is a requirement to have signed executables on Vista / Windows 2008 / Windows 7 to eventually fulfill the requirements of the various Windows Logo programs, we'd then have to code sign those with our own Authenticode certificate. That would then imply that we are the original supplier of the PDF-Tools executables, which is not exactly the case.

Using default load address of 0x10000000 for all PDF-Tools / PDF-XChange dlls is the worst case scenario, since there's most likely another Visual C dll already loaded in the system occupying this default address. Therefore this always causes the relocation procedure to be done on application load and for every PDF-Tools dll used.

Having a less used base address as a starting point for the first PDF-Tools dll and configuring other PDF-Tools dlls to have sequentially a preferred load address (which doesn't overlap with the previous addresses, and which can be easily done with editbin tool) should always be a better approach. Even if all the load addresses would overlap with other dlls in use, this would be no worse than the current situation.

Note that it one thing to have a preferred address vs. having a fixed address - latter would cause the dll not to be loaded at all if couldn't load at its fixed address.

Best regards,
--
Timo Multanen

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Wed Oct 07, 2009 3:08 pm
by Ivan - Tracker Software
Ok. Will try to rebase our dlls to addresses starting from 0x12000000

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Thu Oct 08, 2009 7:07 am
by tieto_hc
Thank you!

That is excellent news! I'm sure that this change will benefit all your customers.

BR,
--
Timo

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Thu Oct 08, 2009 12:39 pm
by Tracker Supp-Stefan
Our pleasure Timo :)

Best,
Stefan

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Mon Sep 08, 2014 10:04 am
by Nardus
Hi

Seems like this never happened as the current base address is still 1000 0000h on the Clarion version of PDF tools in any case. (Still can't rebase a signed dll)

xccdx40.dll
xcpro40.dll
pxclib40.dll
fm40base.dll
fm40tiff.dll
ixclib40.dll
dscrt40.dll

Please see attached file for list of your dlls as well as CapeSoft's dlls in my app.

Thanks

Nardus

Re: PDF-Tools DLLs base address optimization suggestion

Posted: Mon Sep 08, 2014 3:42 pm
by Tracker - Clarion Support
Hi Nardus!

I'm not sure which direction this went - I'll alert Ivan. :)