Didn't want to write here, but okay, I'm trying to load the hex code into memory and execute it. c++, windows. The code itself:

# include <
iostream >
# include <
Windows.h >
#Pragma warning (disable: 4996)
int main () {
    int size= 0;
    FILE * fp;
    fp= fopen ("source.b", "rb");
    fseek (fp, 0, SEEK_END);
    size= ftell (fp);
    fseek (fp, 0, SEEK_SET);
    unsigned char * code= new unsigned char [size];
    fread (code, size, 1, fp);
    fclose (fp);
    code [size]= '\ 0';
    std :: cout <
"Size:" <
 size <
 "\ nCode:" <
 code <
 '\ n';
    if (! mcd) return -1;
    CopyMemory (mcd, code, size);
    mcd ();
    VirtualFree (mcd, size, MEM_RELEASE);
    return 0;

I get the error "The frame is not in the module, The current stack frame was not found in the loaded module." How can you fix it? There is one NOP in source.b, 0x90.

First, think about what in the end you are trying to cram into the allocated area of ​​virtual memory; secondly, VirtualProtect is sufficient for shellcode.

greg zakharov2022-01-03 15:38:56

I'm trying to stuff the bytes in there, everything is correct. My guess is that the compiler has placed the memory in a non-executable area that is read-only but not executable.

Тимур Крамар2022-01-03 17:01:54