static data structs in win32 DLL, hex editor

K

Kendall Bailey

A shot in the dark. I have a C++ DLL that I'd prefer not to recompile.
It's compiled also on a Unix platform as a shared object. It has
static variables holding time zone Daylight Saving rules. I thought I
might try to use a hex editor to update the rules for the change coming
up in March. There's a pair of structs, each with 4 ints which
describe the start/end of DST. It's clear as day in the Unix shared
object, but I can not find it in the Windows DLL. It was compiled with
msvc++.net 2003. Taking endianess into account, and alignment I search
through a hex dump and the structs don't show up in any form. For
example

struct A { int a,b,c,d; };
struct B { struct A x,y; };

static struct B tz = { {3,1,0,120},{10,0,0,120} };

I expect to find bytes like this 03000000 01000000 00000000 78000000
which is a hex string of the first four ints above in little endian
byte order. Any clue why I don't find it?

Thanks,
Kendall
 
J

Jack Klein

A shot in the dark. I have a C++ DLL that I'd prefer not to recompile.
It's compiled also on a Unix platform as a shared object. It has
static variables holding time zone Daylight Saving rules. I thought I
might try to use a hex editor to update the rules for the change coming
up in March. There's a pair of structs, each with 4 ints which
describe the start/end of DST. It's clear as day in the Unix shared
object, but I can not find it in the Windows DLL. It was compiled with
msvc++.net 2003. Taking endianess into account, and alignment I search
through a hex dump and the structs don't show up in any form. For
example

struct A { int a,b,c,d; };
struct B { struct A x,y; };

static struct B tz = { {3,1,0,120},{10,0,0,120} };

I expect to find bytes like this 03000000 01000000 00000000 78000000
which is a hex string of the first four ints above in little endian
byte order. Any clue why I don't find it?

Each and every one of the following items in your post is off-topic
here, having nothing to do with the C language:

1. C++
2. DLL
3. UNIX
4. shared object
5. hex editor
6. msvc++.net 2003
7. hex dump

If you want to know how to find things in DLLs, ask in a Microsoft
programming group.
 
K

Kendall Bailey

Each and every one of the following items in your post is off-topic
here, having nothing to do with the C language:

OK, ok. More theoretically... is a questions about static data
structures defined in a compilation unit being represented in a binary
execution format more on topic? Across all implementations of the C
language, how varied are the final binaries which hold the static data
that is used to initialize a static struct? Are there compilers that
generate executable code which sets the fields one by one? Is there a
general taxonomy of C compiler implementations with respect to static
initializers?

Sorry about so many specifics the first time around. I'm curious about
the theoretical mapping of C language constructs to binary code. My
expectations proved false for one platform, but true for another.
Consider it background info and look at the broader question. I asked
for any speculations, and I'm happy to hear any open ended,
non-specific, answers.
 
S

santosh

Kendall said:
OK, ok. More theoretically... is a questions about static data
structures defined in a compilation unit being represented in a binary
execution format more on topic? Across all implementations of the C
language, how varied are the final binaries which hold the static data
that is used to initialize a static struct? Are there compilers that
generate executable code which sets the fields one by one? Is there a
general taxonomy of C compiler implementations with respect to static
initializers?

Sorry about so many specifics the first time around. I'm curious about
the theoretical mapping of C language constructs to binary code. My
expectations proved false for one platform, but true for another.
Consider it background info and look at the broader question. I asked
for any speculations, and I'm happy to hear any open ended,
non-specific, answers.

Yes, as you note, code and data generation is implementation specific
and varies according to the machine, operating system, compiler etc.

This question is better posted to comp.compilers or to a specific
compiler group like gnu.gcc.help etc.
 
W

Walter Roberson

I have a C++ DLL that I'd prefer not to recompile.
There's a pair of structs, each with 4 ints which
describe the start/end of DST. It's clear as day in the Unix shared
object, but I can not find it in the Windows DLL.

struct A { int a,b,c,d; };
struct B { struct A x,y; };
static struct B tz = { {3,1,0,120},{10,0,0,120} };
I expect to find bytes like this 03000000 01000000 00000000 78000000
which is a hex string of the first four ints above in little endian
byte order. Any clue why I don't find it?

Construct a sample case and compile it with the appropriate compiler
and disassemble the result to see how that particular compiler handles
such things.

Note, by the way, that "little-endian" includes the byte order
2143 (e.g., 00000300), not just 4321; you should test to
confirm that the byte order is what you were expecting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top