Skip to content

DPMI function 0800h crashes when trying to map more than 8Mb #4

@viti95

Description

@viti95

While testing VESA modes on FastDoom I've discovered that DPMI function 0800h crashes if you try to map more than 8Mb. This issue also happens on other games, and it's why the NOLFB utility was created. This is the code I use (modified to avoid crashes).

#define MEMORY_LIMIT (128*64*1024)

void *DPMI_MAP_PHYSICAL(void *p, unsigned long size)
{
  // Limit memory to 8Mb, mapping 16Mb crashes
  if (size > MEMORY_LIMIT)
    size = MEMORY_LIMIT;

  /* DPMI call 800h map physical memory*/
  PrepareRegisters();
  regs.w.ax = 0x0800;
  regs.w.bx = (unsigned short)(((unsigned long)p) >> 16);
  regs.w.cx = (unsigned short)(((unsigned long)p) & 0xffff);
  regs.w.si = (unsigned short)(size >> 16);
  regs.w.di = (unsigned short)(size & 0xffff);
  int386x(0x31, &regs, &regs, &sregs);
  return (void *)(((unsigned long)regs.w.bx << 16) | regs.w.cx);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions