myrkraverk
25.11.2010, 00:44 |
HX fails at anonymous memory mapping (DOSX) |
Dear HX users,
HX 2.17 runs into an infinite loop or hangs with the following code. I did not bother to find out where it stops though. I am running on Freedos in VirtualBox. It works fine in Wine.
Mappings to actual files work.
#include <windows.h>
#include <iostream>
#include <cstdlib>
int main( int, char *[] )
{
// Note: hardcoded size.
HANDLE map = CreateFileMapping( 0, NULL, PAGE_READWRITE, 0, 6, NULL );
void *buffer = MapViewOfFile( map, FILE_MAP_WRITE, 0, 0, 0 );
std::memcpy( buffer, "hello", 6 );
std::cout << static_cast< char * >( buffer ) << std::endl;
return 0;
}
This is currently my showstopper at supporting DOS (though I don't think anyone will want to use my application, much less in DOS).
This is a practice/demonstration at using memory mappings so "just using new[]" isn't going to "help." In practice I'd probably use something else, honest!
If there is a memory mapper in some other DOS extender I may play with it as well.
Johann |
Japheth
Germany (South), 25.11.2010, 08:30
@ myrkraverk
|
HX fails at anonymous memory mapping |
> HX fails at anonymous memory mapping
[snip]
> // Note: hardcoded size.
> HANDLE map = CreateFileMapping( 0, NULL, PAGE_READWRITE, 0, 6, NULL );
I don't think that 0 as first parameter will trigger "anonymous" memory mapping. Actually, 0 is a valid file handle. Please make yourself familiar with the Win32 API! --- MS-DOS forever! |
myrkraverk
25.11.2010, 10:07
@ Japheth
|
HX fails at anonymous memory mapping |
> > HX fails at anonymous memory mapping
>
> [snip]
>
> > // Note: hardcoded size.
> > HANDLE map = CreateFileMapping( 0, NULL, PAGE_READWRITE, 0, 6, NULL );
>
> I don't think that 0 as first parameter will trigger "anonymous" memory
> mapping. Actually, 0 is a valid file handle. Please make yourself familiar
> with the Win32 API!
You're right, I need to pass in INVALID_HANDLE_VALUE. Shame on me. Note to self: Never assume a 0 void * is an invalid value.
Johann |