pH wrote: Why write functions in machine code and store them as strings, why not just write the functions as c++ functions and call them. Unless you are a machine code guru, you need to learn to handle the stack, passing parameters and return values, this will lead to a lot of learning about intel assembly language but little about c++. Error handling will also be tricky.
grasshopa wrote: Well yesterday I found out that Win32 apps can be coded in C!
RazorEdge wrote: This will not work. You cannot execute this executable code from your own process memory space like this. Have a read about the virtual address spaces of processes if you want to look into it a bit more.
Its definately possible but is probably more work that you want to be doing. You would effectively simulate what the kernel does -> load the PE, fixup and load dependancies, read entry point address and spawn a thread at that address.
I think what Razoredge was trying to say was that it would be only able to copy the code within its own memory page (or whatever you kids are calling it these day), and then the kernel wouldn't be able to give that process a memory page because it would be stored in memory that is already allocated to another program, yes?
Argh. I have some issues though, I'm trying to do a simple write to a file. I include <windows.h> and <stdio.h> and I write in the C code (file *ifp etc etc). When I have it set to a Win32 Application in Visual C++ it doesn't actually write to the file. When I copy this code into a command-line program though it works just fine. Help?!?!
RazorEdge wrote: Interesting. I was thinking this afterwards as well. Probably not a road that grasshoppa should go down though
grasshopa wrote: Cool, I finally finished the program... Not bad for an absolute programming noob. I went with the append-to-EXE approach, it's pretty small and simple and if anyone's curious for source code PM me or ask me to put it up here. One thing though... This is windows. And my program creates no window. And therefore I can not declare a handle for the window and have no hwnd variable as this is usually returned from CreateProcess. Therefore I cannot close my window because DestroyWindow requires a window handle. So the program stays open forever....