title: Inline ASM jmp to new memory
body: <p>So I would like to load a set of assembly instructions from a file, and execute those instructions. </p>
  
  <p>OR</p>
  
  <p>I would like to load already compiled machine code again from a file (non-exe) </p>
  
  <p><strong>My Thoughts:</strong></p>
  
  <p>So far I've learned enough inline asm to work with c/c++ variables easily. </p>
  
  <pre><code>  asm volatile (
      "mov     %1, %%ecx;" // yes unnecessary, I know
      "add     %2, %%ecx;" // I know they're already loaded in a register
      "mov     %%ecx ,%0 ;"// just demonstrating what I've learned
      :"=r"(address)
      :"r"(address),"r"(offset)
      :"%ecx"
    );
  </code></pre>
  
  <p>I've begun to learn about op-codes, and I've gotten some x86 manuals. I understand (somewhat) how the hardware works at a basic level.</p>
  
  <p>I know that I can load the file into memory with c++ with fstream, and I'm wondering if there's a way to execute memory from that space, or if it's in a non-executable portion of memory or something..</p>
  
  <p><strong>Reason:</strong></p>
  
  <p>Currently there are several reasons I'd like to do this. I have a desire to create a <em>basic</em> encyption for my program, for a simple key to run the program. And while I can easily encrypt and decrypt the actual code, I want the program to be unencrypted every run and never stored on the harddrive. I am aware of several problems, however I'm very interested in doing so. </p>
  
  <p><strong>Final Questions:</strong></p>
  
  <p>Can I execute machine code from memory space in a program from c++ in asm?</p>
  
  <p>Is asm necessary?</p>
  
  <p>Are there other ways to accomplish this task more efficiently, if so, what are those methods?</p>
  
  <p>I'm also reading up on some DLL injection for a mouse sharing program that I'm making (two computers next to each other, both have monitors, however you only have one mouse/keyboard. And I'm wondering where I can find some good resources on the topic? Google has been helpful, however I'm interested in perhaps some IRC channels or something similar. Anyways, thanks for reading!</p>