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 6116423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:12:15+00:00 2026-05-23T15:12:15+00:00

I allocated some space, wrote some asm and tried to start a thread at

  • 0

I allocated some space, wrote some asm and tried to start a thread at that point.
But I keep getting an access violation. Its suppose to push four 0s and call the messageboxa function. But right at the area address it gets a access violation.
How can I get it to run like normal code?

void test2()
{
    byte* area;
    HANDLE process;

    area = new byte[1024];

    for(int i = 0; i < 1024; i++)
        area[i] = 0;

    memmove((char*)area, "\x6a\x00\x6a\x00\x6a\x00\x6a\x00\xE8", 9);

    *(DWORD*)&area[9] = ((DWORD)GetProcAddress(GetModuleHandle("User32.dll"), "MessageBoxA") - (DWORD)&area[9] - 4);

    memmove((char*)&area[13], "\x33\xc0\xc3", 3);

    VirtualProtect(area, 17, PAGE_EXECUTE_READWRITE, 0);

    CreateThread(0, 0, (LPTHREAD_START_ROUTINE)area, 0, 0, 0);
}

here’s a screen shot of the disassembly
http://screensnapr.com/v/P33NsH.png

  • 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-05-23T15:12:16+00:00Added an answer on May 23, 2026 at 3:12 pm

    The VirtualProtect() call doesn’t do anything in this case: it just fails since it expects the 4th parameter to be a valid pointer to a memory area which receives the previous access protection flags (so you can restore it later). So, the CPU refuses to execute this page and you get the GPF at the very first instruction.

    You also need to use PAGE_EXECUTE_READ for the flag, otherwise the first heap operation (even read access to any other variable in the heap, which happens to touch the same page) will generate GPF. Alternatively, use VirtualAlloc(), instead of allocating on the heap.

    Note, I didn’t check the rest of the code, so there might be some other issues with it. Also note that this is not the way to write assembly, unless you’re writing an exploit (messing with VirtualProtect() is a sure sign of that). Here’s to hoping that I’m wrong in my assumption about the exploit.

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

Sidebar

Related Questions

I got a table where in got allocated space of 3gig but have no
Quick disclaimer: I saw some plugins that truncate text strings but they do not
I'm running into an issue with GDB and some buffers allocated in kernel space.
How memory is allocated in case of spawning a new thread, i.e how memory
I'm wrapping up user space linux socket functionality in some C++ for an embedded
I'm playing a little with memory dynamic allocation, but I don't get a point.
I'm doing some assignment and got stuck at one point here. I am trying
I have some code that I had to write to replace a function that
I'm adding some functionality to an existing code base that uses pure C functions
Is there any way to access the number of blocks allocated to a file

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.