Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetOverlappedResultEx could not be located in kernel32.dll

I am trying to create an application which uses a dll for pipe communication and run into this error, when I started using this function GetOverlappedResultEx. Whenever I run the executable that uses my dll, I get this error message ...Does anyone know what is the meaning of it? I am building 64 bit dlls! I am using C++ on visual studio 2012. Do I need to install any service pack? Edit: I am using Windows 7 Computer

enter image description here

like image 971
Samer Avatar asked Jan 08 '23 03:01

Samer


2 Answers

The message means that some part of the code depends on GetOverlappedResultEx, a function it expects exists in the system DLL kernel32.dll. (The 32 in kernel32.dll refers to the 32-bit version of the Windows API, which is the same even for 64-bit programs.)

To figure out what's going on, search MSDN for the function. On that page, you can see that GetOverlappedResultEx should indeed come from kernel32.dll, but it wasn't added to the API before Windows 8. You're likely trying to run the program on an older version of Windows.

Your options are to run the program on a newer version of Windows or to modify the code to not rely on this particular function.

like image 130
Adrian McCarthy Avatar answered Jan 21 '23 15:01

Adrian McCarthy


If you are targeting Windows 7 as your minimum, then you should set _WIN32_WINNT to 0x0601 as a Preprocessor Define. The Windows 8 SDK or later defaults to the 'newest' rather than the 'oldest' setting for this primary header control which with VS 2012 is 0x0602 (Windows 8). A number of API headers rely on this define to control platform-specific behavior to support 'down-level' versions of the OS. See Using Windows Headers.

GetOverlappedResultEx is only supported on Windows 8 or later. If you want to be compatible with Windows 7, then you need to stick with GetOverlappedResult.

For Windows 8 Store, Windows phone 8, and universal Windows apps you need to use GetOverlappedResultEx. Therefore, if you are writing code that is being reused for both these platforms, you go back to our friend _WIN32_WINNT. For example, in WaveBankReader.cpp in DirectX Tool Kit I used the following to support Windows Vista or later for Windows desktop, Windows 8 Store, Windows phone 8, and universal Windows apps:

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
    BOOL result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE );
#else
    if ( wait  )
        (void)WaitForSingleObject( m_event.get(), INFINITE );

    BOOL result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE );
#endif

I have the explicit call to WaitForSingleObject in the "down-level" case based on a variable that is set if the previous ReadFile failed with an ERROR_IO_PENDING. GetOverlappedResultEx handles this case.

See Dual-use Coding Techniques

like image 31
Chuck Walbourn Avatar answered Jan 21 '23 17:01

Chuck Walbourn