c++ - Invalid handle exception on CloseHandle call? -
in application open handle shared memory read/write to/from. open handle so:
//map shared memory d_to_mbx_mem_arr[idx] = reinterpret_cast<byte*>(mapviewoffile(to_mem_h, // handle map object file_map_all_access, // read/write permission 0, 0, mailbox_size_e)); the variable getting set here array of byte* (byte alias unsigned char), reinterpret cast can use handle standard byte pointer.
later try release handle in following way:
closehandle(d_to_mbx_mem_arr[p_tool_id]); d_to_mbx_mem_arr[p_tool_id] = null; since value getting set null after closehandle , code calling method single-threaded know i'm calling once. when call following warning:
"first-chance exception @ 0x7c90e4ff (ntdll.dll) in fmlib_comm_layer.exe: 0xc0000008: invalid handle specified."
when break warning see handle trying close has value of "0x01c90000", seems reasonable me shared mem pointer. see problem implementation, or should assume i've screwed else somewhere else?
you need call closehandle() on to_mem_h, not on return value of mapviewoffile() (see example of using mapviewoffile() here -- example calling unmapviewoffile() on return value of mapviewoffile() , calling closehandle() on first parameter mapviewoffile())
Comments
Post a Comment