Discussion:
dll problem
(too old to reply)
Mark Weinberg
2008-07-24 14:52:28 UTC
Permalink
Hi,
I'm not sure if I missed something or what, but in attempting to port a dll
from c++builder 4 to 7, the dll appeared to break. The application which
called the dll could no longer identify it, but if I used the one generated
in 4 things worked fine. I looked at the PE header and noticed that the low
and high byte reversed flags were different between the 2 (set in 4, not set
in 7) in the image characteristics section. I used the wizards in each tool
to generate empty dlls (no outside code at all), and the headers also
differed in these flags, so I know it's not my code. Is there a way to set
these flags through a switch or define? I have not been able to find a
mention in the documentation.

Thanks,
Mark
Mark Weinberg
2008-08-01 19:27:52 UTC
Permalink
Doesn't anybody write dlls in C++ out there? This seems like a fundamental
problem.

--Mark
Post by Mark Weinberg
Hi,
I'm not sure if I missed something or what, but in attempting to port a dll
from c++builder 4 to 7, the dll appeared to break. The application which
called the dll could no longer identify it, but if I used the one generated
in 4 things worked fine. I looked at the PE header and noticed that the low
and high byte reversed flags were different between the 2 (set in 4, not set
in 7) in the image characteristics section. I used the wizards in each tool
to generate empty dlls (no outside code at all), and the headers also
differed in these flags, so I know it's not my code. Is there a way to set
these flags through a switch or define? I have not been able to find a
mention in the documentation.
Thanks,
Mark
Bob Gonder
2008-08-01 23:27:40 UTC
Permalink
Post by Mark Weinberg
Doesn't anybody write dlls in C++ out there?
I'm sure many people do, with success.
Though nobody uses c++builder 7 because it doesn't exist.
Post by Mark Weinberg
Post by Mark Weinberg
I looked at the PE header and noticed that the low
and high byte reversed flags were different between
the 2 (set in 4, not set in 7) in the
image characteristics section.
Whatever that means?
You asked a specific esoteric question that probably no one understood.
Post by Mark Weinberg
Post by Mark Weinberg
Is there a way to set these flags through a switch or define?
PE settings are set in the PE section of the Linker Options.
But I have no idea what to look for as I don't understand your problem.

If you twiddle those bits in the non-working dll, does it start working?
Mark Weinberg
2008-08-04 02:23:02 UTC
Permalink
Sorry, I meant c++builder 2007, sorry for the shorthand.

I don't think that this is particularly esoteric. I examine the PE header,
using the GExpert tools, and I get
the following with 2007:

Executable format Standard PE
Machine Intel 80386 or later
Number of sections $7
Time/Date stamp $4893714F (8/1/2008 8:25:51 PM UTC)
Address of symbol table $0
Number of symbols $0
Size of optional header $E0
Characteristics $210E
Characteristic File is valid and can be run
Characteristic COFF line numbers have been removed
Characteristic COFF symbol table entries have been removed
Characteristic Machine based on 32-bit word architecture
Characteristic Image is a DLL

while using C++Builder 4 and the same source files I get:



Executable format Standard PE
Machine Intel 80386 or later
Number of sections $7
Time/Date stamp $46E5A794 (9/10/2007 8:22:44 PM UTC)
Address of symbol table $0
Number of symbols $0
Size of optional header $E0
Characteristics $FFFFA18E
Characteristic File is valid and can be run
Characteristic COFF line numbers have been removed
Characteristic COFF symbol table entries have been removed
Characteristic Low bytes of machine word are reversed
Characteristic Machine based on 32-bit word architecture
Characteristic Image is a DLL
Characteristic High bytes of machine word are reversed



This one works, while the 2007 one doesn't. The difference between the two
seems to only be in the machine word flags. None of the linker flags seems
to affect
this, so I was wondering if anyone knew how to do it. Delphi appears to
have a $setPEflags command but I can't find the equivalent in C++ builder.
I can find the
flag bits defined in winnt.h, but I can't find where they are set or how to
set them. As I said, if I just generate an empty dll using the wizard in
both tools I get the same
difference in the PE headers, so it appears that my code has nothing to do
with it.

--Mark
Post by Bob Gonder
Post by Mark Weinberg
Doesn't anybody write dlls in C++ out there?
I'm sure many people do, with success.
Though nobody uses c++builder 7 because it doesn't exist.
Post by Mark Weinberg
Post by Mark Weinberg
I looked at the PE header and noticed that the low
and high byte reversed flags were different between
the 2 (set in 4, not set in 7) in the
image characteristics section.I
Whatever that means?
You asked a specific esoteric question that probably no one understood.
Post by Mark Weinberg
Post by Mark Weinberg
Is there a way to set these flags through a switch or define?
PE settings are set in the PE section of the Linker Options.
But I have no idea what to look for as I don't understand your problem.
If you twiddle those bits in the non-working dll, does it start working?
Bob Gonder
2008-08-04 15:10:39 UTC
Permalink
Post by Mark Weinberg
Sorry, I meant c++builder 2007, sorry for the shorthand.
I don't think that this is particularly esoteric. I examine the PE header,
using the GExpert tools, and I get
For most people, including myself, that is esoteric.
Post by Mark Weinberg
Characteristic Low bytes of machine word are reversed
The first Google hit for that entire line shows a
table that includes "App can handle >2Gb addresses".

I recognize that as an earlier question which was
resolved by setting the GF switch in the PE section
of the Linker section of the Options for the Project:
-GF:LARGEADDRESSAWARE
Unfortunately the Help doesn't show options for your settings.
Fortunately (?) Microsoft says it isn't an issue:
http://msdn.microsoft.com/en-us/library/ms680313(VS.85).aspx

Have you tried manually setting those 0x8080 bits in the DLL?
Frhed (FRee Hex EDitor) can do the job.
I would be surprised if it fixed your problem.

Continue reading on narkive:
Loading...