Zebediah Figura zfigura@codeweavers.com writes:
- file = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
- if (file == INVALID_HANDLE_VALUE)
- {
ERR( "failed to open %s, error %u\n", debugstr_w( path ), GetLastError() );
return NULL;
- }
- size = GetFileSize( file, NULL );
- mapping = CreateFileMappingW( file, NULL, PAGE_READONLY, 0, size, NULL );
- CloseHandle( file );
- if (!mapping)
- {
ERR( "failed to create mapping, error %u\n", GetLastError() );
return NULL;
- }
- view = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, size );
- CloseHandle( mapping );
- if (!view)
ERR( "failed to map file, error %u\n", GetLastError() );
I'd suggest malloc+read instead of a file mapping, so that we don't waste 64K of address space to load a 400-byte file.