WaxfordSqueers
November 4th, 2005, 18:16
Quote:
[Originally Posted by dELTA]Each DLL will execute its DLLMain as soon as it is loaded, i.e. in the case with statically linked imports, before the program hits its exe entrypoint. |
I have no problem with what you're saying with respect to these dll's being loaded before the main app executes. I'm scratching my head a bit over them executing their own code. I'm no expert, however. A dll is a library to me, hence must be static (i.e. can't execute by itself). My understanding is that certain dll's can be run by a module like rundll32.exe, but I've never heard of them running on their own. In fact, when you come down to it, even executables don't run themselves.
I have some excellent books on win 32 systems by Matt Pietrek, Jeffrey Richter and Mark Russinovich (with Solomon) and I've only read enough to make myself dangerous. The loading process, from the time you click on an exe file, till it is up and running, is becoming exceedingly complex, especially in Win 2000/XP. It's amazing to me that all this can be accomplished in the bat of an eye. In fact, the speed is many orders faster than the bat of an eye.
Being (or having been) an electronics/computer technician (I've downgraded to 'electrician')

it amuses me how programmers talk about programs as if they have a life of their own. That's taken to an absurd level by OOP programmers who talk about programming 'objects' being representative of the real world. Some will condescend to grudgingly admit that an object is a piece of code. When did we stop talking about code being code and start refering to it as objects, containers, etc. Was that necessary?
Anyway, the processor is the heart of code execution...always has been, always will be. It starts itself through a bootstrap process, which obviously depends on a voltage being present. In fact, the entire notion of 1's and 0's is represented in the real world by +5 volts and 0 volts, although the +5 is now down to about 3 volts. Once started, the processor depends on an external clock, which is a crystal shocked into oscillation by a voltage. It's by sub-dividing the gigahertz frequency of this self-oscillating clock that the time-slicing computer operates.
From that standpoint, no code ever executes on its own, it is the processor executing it. We all know that the code is represented in memory as 1's and 0's, which is represented in RAM by +5(3)/0 volts held in cells. These bits are clocked in and out of the registers of the processor, and the codes represented by the bytes, give direction to the processor. But, the program is essentially inert.
I try to imagine from time to time which is which. I do that partly because I'm a wierdo, and partly because it interests me (which makes me even more of a wierdo). It's amazing to me that on an Intel chip, the paging is actually a function of the chip. I'm sure Microsoft would like people to think it is the code doing it, but it was built into the processor by Intel. What I'm trying to say in this long-winded diatribe, is that technically, even executables don't execute themselves.
I'm not trying to make a big deal out of this, I'm just trying to understand the process. it wasn't till you mentioned dll's executing themselves, that I started thinking it through. Even at that, I'm still mightily confused.
Quote:
[Originally Posted by dELTA]The "code between the MZ header and the PE header" has nothing to do with normal 32 bit execution, but will rather only be seen (and executed) by operating systems that only recognize 16-bit MZ-only executables and don't not know what a PE header is at all. In short, it's for backward compatibility only. |
I know there's a tiny bit of code in there for the MZ portion, but I've heard of additional code being inserted into the blank spaces of the MZ header.