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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:13:00+00:00 2026-06-19T04:13:00+00:00

I start to make code in 32 platform and code work great, but in

  • 0

I start to make code in 32 platform and code work great, but in 64 bit can’t even start, what i’m searching for is where problem start, and why think don’t work under 64?

The error is:

Unhandled exception at 0x00FF1230 in “MyApp.exe”: 0xC0000005: Access violation executing location 0x00FF1230

Actual code is:

    // win.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

/* Keymapper v1.1
 *
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */

// Make a really small executable
#pragma comment(linker,"/ENTRY:main") // Set entry point

// Merge all default sections into the .text (code) section.
#pragma comment(linker,"/MERGE:.rdata=.data")
#pragma comment(linker,"/MERGE:.text=.data")

#pragma comment(lib, "msvcrt.lib")

#if (_MSC_VER < 1300)
    #pragma comment(linker,"/IGNORE:4078")
    #pragma comment(linker,"/OPT:NOWIN98")
#endif

#pragma comment(linker, "/FILEALIGN:0x200")

#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#define WH_KEYBOARD_LL 13

#include <windows.h>

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL WINAPI ConsoleEventHandler(DWORD dwCtrlType); // for graceful exit
DWORD dwMainThread = 0; // because apparently the console event handler thread for Ctrl+C is different from the main thread

int main(int args, char* argv[])
{
    const char message[] =
        "Caps Lock Remapper\n"
        "Remaps Caps Lock to Backspace on the fly without rebooting.\n"
        "Written by Petrus Theron http://freshcode.co/\n"
        "Fork this on GitHub: http://github.com/pate/keymapper\n"
        "\nPress Ctrl+C or close window to exit.\n";

    DWORD count = 0;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    WriteConsoleA(hStdOut, message, sizeof(message)-2, &count, NULL);

    if (!SetConsoleCtrlHandler(ConsoleEventHandler, TRUE))
        return -1;

    dwMainThread = GetCurrentThreadId();

    // Retrieve the applications instance
    HINSTANCE appInstance = GetModuleHandle(NULL);

    // Attach global keyboard hook to capture keystrokes
    HHOOK hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, appInstance, 0);
    if (!hHook)
        return -2;

    MSG msg;

    while(GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // Clean up
    UnhookWindowsHookEx(hHook);
    SetConsoleCtrlHandler(ConsoleEventHandler, FALSE);

    return 0;
}

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    KBDLLHOOKSTRUCT *pKeyBoard = (KBDLLHOOKSTRUCT *)lParam;

    switch( pKeyBoard->vkCode )
    {
    case VK_CAPITAL:
        {
            switch (wParam)
            {
            case WM_KEYDOWN:
                keybd_event(VK_BACK, 0x8e, 0, 0);
                return 1;
            case WM_KEYUP:
                keybd_event(VK_BACK, 0x8e, KEYEVENTF_KEYUP, 0);
                return 1;
            }
        }

        default:
            return CallNextHookEx( NULL, nCode, wParam, lParam );
    }

    return 0;
}


BOOL WINAPI ConsoleEventHandler(DWORD dwCtrlType)
{
    switch(dwCtrlType)
    {
        case CTRL_C_EVENT:
        case CTRL_CLOSE_EVENT:
            PostThreadMessage(dwMainThread, WM_QUIT, NULL, NULL);
            return TRUE;

        default:
            return FALSE;
    }
}
  • 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-19T04:13:02+00:00Added an answer on June 19, 2026 at 4:13 am

    Text and data sections are merged.

    #pragma comment(linker,"/MERGE:.text=.data")

    Attempt to execute non-executable address 0000000000111ee6
    (1078.1080): Access violation - code c0000005 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    *** WARNING: Unable to verify checksum for test.exe
    test!ILT+225(_main):
    00111ee6 e955010000      jmp     test!main (00112040)
    

    00111ee6 address belongs to .data section and has PAGE_WRITECOPY memory protection which not allowed execute code.

    0:000:x86> !address 00111ee6 
    Usage:                  Image
    Allocation Base:        00100000
    Base Address:           00111000
    End Address:            00114000
    Region Size:            00003000
    Type:                   01000000    MEM_IMAGE
    State:                  00001000    MEM_COMMIT
    Protect:                00000008    PAGE_WRITECOPY
    
    0:000:x86> !dh test
    [...]
         ----- new -----
    0000000000100000 image base
    [...]
    SECTION HEADER #2
       .data name
        2E3A virtual size
       11000 virtual address
        2C00 size of raw data
    [..]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i make such code working? public void start() { ThreadPoolManager.getInstance().scheduleWithFixedDelay(new Thread(), 1000,
Before I start, I want to make it clear that my code is working
Title probably doesn't make a lot of sense, so I'll start with some code:
How can i make mysql start every time the system boot ? I need
How can I make a quick start on Windows Phone 7 in working with
I want to start to make a chat client that runs in web browsers,
I am about to start to make the interface for a game in WPF
Is there a way to make Timeline start recording EXACTLY at the time where
I want to make regular expression that start with only 4 and 5 and
I want to make my own Start Menu replacement and I am trying to

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.