For learning reasons I wonder if someone has a tutorials, simple examples on how to inject functions located in DLL into an already executable so the the executable starts executing functions injected then returns to normal execution.
I don't have a tutorial nor examples but, I can point you in the right direction.
You mentioned you want to statically (that is not at run time) inject code into a dll (it doesn't make much, if any, difference whether dll or exe.)
Three ways to do it come to mind.
The first way and, the simplest one is, if there is enough padding space in the dll/exe code segment(s) then, you can simply add the code into the padding space. The one problem to be aware of is that, the code _may_ need to have additional relocation entries added into the relocation table. This depends on how the injected code is written.
The second way is not hard but it's very "delicate" and, takes a fair amount of work. Basically, you extend the code segment to make it as large as you need it to be to accommodate the code you want to inject. Doing it that way means the program that is injecting the code has to re-link the executable because the injected code causes the offsets to other segments in the PE file to no longer be correct. If the PE file does not have a relocation table, this method cannot/shouldn't be used because there is no list of all the adjustments that must be made to ensure a valid resulting executable.
The third way, likely safest way and most flexible way, is to add a code segment that follows existing code and some of the data segments, that way, the most important offsets in the PE file remain valid and only a subset of the offsets have to be recalculated (those that reference areas after the added/injected code segment.) This makes re-linking much simpler and possible even if the PE file does not contain a relocations section.
Lastly but, extremely important, you have to have _solid_ knowledge of the PE file format. As far as an example, search for the source of a "PE rebase" utility. Rebasing without injecting code is very simple but, that would give you a good idea of what's involved. Matt Pietrek published a "rebase" utility along with a few others in his book "Windows 95 system programming secrets" and he makes the original disk available for download on his website. His is written in C, maybe someone knows of a rebase utility written in Pascal they might want to mention.
HTH.