Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:34:35+00:00 2026-06-15T17:34:35+00:00

There are other questions about the same message, but I specifically seem to run

  • 0

There are other questions about the same message, but I specifically seem to run into this when I try to execute a string of machine code that invokes certain functions. In my case I make a call to exit(0) which works fine when called as typical in C in the same program. If, however, as an exercise I set the EIP to the address of some machine code (you might call it “shellcode”), e.g.

const char code[] = 
"\x6A\x00"      // push        0"
"\xFF\x15\x00\x00\x00\x00"  //system call, 'read access violation':   call dword ptr [__imp__exit]
"\x5D"  //pop ebp    
"\xC3"; //ret

I will get the message “Access violation reading location 0x00000000.”. The “\x6A\x00” instruction will run, but the call to exit(0) will throw this exception.

This is C compiled in VS2010 with /GS-, and also running the “shellcode” with execute rights, but is there still some sort of nonexecutable memory or stack protection going on? Why is this instruction causing an error?

    int main() 
{ 

    void *exec = VirtualAlloc(0, sizeof(code), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    memcpy(exec, code, sizeof(code));
//EIP = exec in debug->immediate
    exit(0);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:34:35+00:00Added an answer on June 15, 2026 at 5:34 pm

    If you disassemble your shellcode, you’ll get something like this (AT&T syntax):

    00000000 <_code>:
       0:   6a 00                   push   $0x0
       2:   ff 15 00 00 00 00       call   *0x0
       8:   5d                      pop    %ebp
       9:   c3                      ret
    

    The call instruction is doing a memory-indirect jump through address 0: it’s loading the target from memory address 0 and jumping to that location. Since memory address 0 is invalid (in rare exceptions it can be valid, but this is no exception), an access violation results.

    Ordinarily, when you compile C code, the jumps to external functions get replaced by placeholders, and those placeholders get filled in by the linker at link time. When you’re generating shellcode at runtime, you don’t have the assistance of the linker, so you have to do it yourself. You need to figure out what your desired target address is and fill that in directly in the shellcode, possibly using some position-independent tricks if you don’t know exactly what address the shellcode is going to execute at.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are several other questions about this topic that I have gone through, but
There a bunch of other questions like this, but the only substantial answer I've
I know there are other questions with that same title, but none of them
I have seen some other questions about this but the errors were related to
There are a couple of questions about tail-recursive function e.g. this and this but
I realize there are a few other questions about why Cygwin is apparently slow,
Given my previous questions about the the usage of AMPL. Are there any other
There are other questions on here that sound similar but are not. I have
I know there are other questions that have similar issues, but I have read
There are other SO questions on speeding up jQuery Mobile for Android, but does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.