Merging two DLL files

  • Thread starter n o s p a m p l e a s e
  • Start date
N

n o s p a m p l e a s e

Is it possible to merge two DLL files into one? If so, how?

Thanx/NSP
 
R

Richard Bos

n o s p a m p l e a s e said:
Is it possible to merge two DLL files into one? If so, how?

Sure. Use fopen() one one file in binary append mode, fopen() on the
other file in binary read mode, and continue to fgetc() from the second
stream and fputc()ing the result into the first, until the result is
EOF. The result may not be what you expect; if you want something
Micro$oft-safe, ask in a Micro$oft-specific newsgroup.

Richard
 
R

Richard Heathfield

n o s p a m p l e a s e said:
Is it possible to merge two DLL files into one?
Yes.

If so, how?

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
int rc = EXIT_FAILURE;
if(argc > 3)
{
FILE *fpout = fopen(argv[1], "wb");
if(fpout != NULL)
{
FILE *fpa = fopen(argv[2], "rb");
if(fpa != NULL)
{
FILE *fpb = fopen(argv[3], "rb");
if(fpb != NULL)
{
int ch = 0;
while((ch = getc(fpa)) != EOF)
{
putc(ch, fpout);
}
while((ch = getc(fpb)) != EOF)
{
putc(ch, fpout);
}
if(!ferror(fpa) && !ferror(fpb) && !ferror(fpout))
{
rc = EXIT_SUCCESS;
}
fclose(fpb);
}
fclose(fpa);
}
if(fclose(fpout))
{
rc = EXIT_FAILURE;
}
}
}
return rc;
}

That will do it, if I haven't made any mistakes.

As a bonus, it will merge any two files, not just DLLs.
 
M

Mark McIntyre

Is it possible to merge two DLL files into one? If so, how?

DLLs are not part of the C language. Y ou need to ask the experts in a
Windows system group.

The answer by the way is likely to be the same as to the question "is
it possible to merge two EXE files into one?"
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
J

jacob navia

n said:
Is it possible to merge two DLL files into one? If so, how?

Thanx/NSP
In each dll you have a different NAME space. If you merge
them, you will have to take care of the possible name
conflicts between them.

For instance if both dlls define a procedure called
"DoCalculations()"
then you have to rename one of them into something else or else
the linker will fail.
 
M

Mark McIntyre

In each dll you have a different NAME space. If you merge
them, you will have to take care of the possible name
conflicts between them.

I think this is going to be the least of his problems - how will you
merge two binary executables usefully?

to the OP: you need to be clearer about what you mean. If you want to
combine two actual DLL files into a single file, and you do not have
the source code from which they were built, you probably can't do it,
and its not a C problem anyway. If you mean you have hte source for
two DLLs, then Jacob's point is relevant and all you have to do is
resolve any overlap or conflicts between the source, then build a new
DLL (how you do this is again not a C question).
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
J

jacob navia

Mark said:
I think this is going to be the least of his problems - how will you
merge two binary executables usefully?

Actually... I never even thought about that possibility. Rereading
the question maybe the OP means literally merging the dlls like
the AVI files, that can be merged by just catenating them one
after the other...

In that case... he should first learn something :)
 
W

Walter Roberson

On Mon, 18 Jun 2007 04:33:17 -0700, in comp.lang.c , n o s p a m p l e
DLLs are not part of the C language. Y ou need to ask the experts in a
Windows system group.

Very true.
The answer by the way is likely to be the same as to the question "is
it possible to merge two EXE files into one?"

I believe that Windows DLLs and Unix shared objects (e.g., DSOs)
have symbol tables, and that access to the objects (data, functions)
within them are mediated by the symbol table accesses (though possibly
only for the first call, with some systems patching the code to make the
call direct instead of through the mediation code).

These leads us to the possibility of having several DLLs or shared
objects that one wishes to combine into a single object (less to
distribute for example), with the symbol table layer being merged
so that the calling code still only has to know the symbol name and
the appropriate section of the combined object is accessed.

This is, I would say, considerably more plausible, in theory, than
merging two arbitrary EXE (executable) files into one, since executable
files might no longer have symbol tables (other than references to
unresolved symbols that are found in DLLs/shared objects).

I don't have any idea how -practical- this would be for DLLs;
I have, in my readings, occasionally encountered shared object mergers
for various Unices.
 
B

Barry

jacob navia said:
Actually... I never even thought about that possibility. Rereading
the question maybe the OP means literally merging the dlls like
the AVI files, that can be merged by just catenating them one
after the other...

In that case... he should first learn something :)

Jacob, you often make incorrect comments abouts Windows
programming. Why do you even attempt to make them, when
you know the correct thing to do is direct them to a Windows
newsgroup?
 
J

jacob navia

Barry said:
Jacob, you often make incorrect comments abouts Windows
programming. Why do you even attempt to make them, when
you know the correct thing to do is direct them to a Windows
newsgroup?

???? What incorrect comments?

Maybe my introduction to windows programming in the tutorial
of lcc-win32 is incorrect somewhere?

I am not a "guru" and I can be wrong but I have been doing
windows/dos programming since 1991.
 
C

CBFalconer

jacob said:
???? What incorrect comments?

Maybe my introduction to windows programming in the tutorial
of lcc-win32 is incorrect somewhere?

I am not a "guru" and I can be wrong but I have been doing
windows/dos programming since 1991.

Fine, but that is not suitable for c.l.c discussion.
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top