Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConEmu cause Windows API WriteFile to return set InvalidHandle error #415

Open
chossette opened this issue Nov 10, 2015 · 2 comments
Open

Comments

@chossette
Copy link

Hi,

The Windows API function WriteFile set LastError to 6 (InvalidHandle) when program is runned under ConEmu, but the data are well written.
The same program run from the same location does not get this error when run from cmd.exe or console2.

The compilation is done using Visual Studio 2008 SP1. Issue is present if built in 32 and 64bits, debug or release. OS is Windows 7 64bits professional, ConEmu is version 150707 [64]

Here is a minimal sample to reproduce the issue:

#include <windows.h>
#include <iostream>

const wchar_t *wfilename = L"F:\\temp\\writing_file.log";
const unsigned char buffer[2048] = { 0 };

int main(int argc, char* argv[])
{
  HANDLE handle = CreateFileW(wfilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  DWORD lastError = GetLastError();
  std::cout << "File created (le: " << lastError << "), handle: 0x" << std::hex << handle << std::endl;

  system("pause");
  DWORD written = 0;
  BOOL res = WriteFile(handle, buffer, 2048, &written, NULL);
  lastError = GetLastError();
  std::cout << "File write (le: " << std::dec << lastError << "), handle: 0x" << std::hex << handle << ", written: " << std::dec << written << std::endl;

  CloseHandle(handle);

  return 0;
}

Test have been done by adding an empty overlap structure, but issue is still present, and overlap structure content says that data have been written.

Tx !
Nicolas,

@Maximus5
Copy link
Owner

@chossette
Copy link
Author

Hi,

I just updated conemu to the last version : alpha 151109 (I thought that update was auto).

The issue is still present,

Nicolas,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants