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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:17:45+00:00 2026-06-05T07:17:45+00:00

In my application I open a handle to shared memory that I read/write to/from.

  • 0

In my application I open a handle to shared memory that I read/write to/from. I open the handle like so:

//Map the shared memory
     d_to_mbx_mem_arr[idx] = reinterpret_cast<Byte*>(MapViewOfFile(to_mem_h,    // handle to map object
                                                       FILE_MAP_ALL_ACCESS, // read/write permission
                                                       0,
                                                       0,
                                                       MAILBOX_SIZE_e));

The variable getting set here is an array of Byte* (Byte is an alias for unsigned char), so I do a reinterpret cast so I can just use the handle like a standard Byte pointer.

Later I try to release the handle in the following way:

CloseHandle(d_to_mbx_mem_arr[p_tool_id]);
d_to_mbx_mem_arr[p_tool_id] = NULL;

Since the value is getting set to NULL after CloseHandle and the code calling this method is only single-threaded I know I’m only calling this once. However when I do call it I get the following warning:

“First-chance exception at 0x7c90e4ff (ntdll.dll) in FMLib_Comm_Layer.exe: 0xC0000008: An invalid handle was specified.”

When I break for the warning I see that the handle it is trying to close has a value of “0x01c90000”, which seems reasonable to me for a shared mem pointer. Does anyone see a problem with this implementation, or should I assume I’ve screwed something else up somewhere else?

  • 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-05T07:17:47+00:00Added an answer on June 5, 2026 at 7:17 am

    You need to call CloseHandle() on to_mem_h, not on the return value of MapViewOfFile() (See an example of using MapViewOfFile() here — that example is calling UnmapViewOfFile() on the return value of MapViewOfFile() and is calling CloseHandle() on the first parameter to MapViewOfFile())

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

Sidebar

Related Questions

I want to read status information that an application provides via shared memory. I
I was under the impression that if an application has an open handle and
var doc = w.document; doc.open('application/CSV','replace'); doc.charset = utf-8; doc.write(all,hello); doc.close(); if(doc.execCommand(SaveAs,null,file.csv)) { window.alert(saved );
When we open NUnit application it loads the assemblies that are loaded in it
I have built an open-source application from the source code. Unfortunately, the original executable
The PHP documentation states that php://input can only be read once. In my application
I have an Open GL application that renders a simulation animation and outputs several
I'm trying to write a C++ MFC application that uses the serial port (e.g.
Having the window handle for an open application, I'm able to use the GetWindowText
I have a Win32 application that I'm making, and it sends a string from

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.