I'd rewrite this as

```d
while (true)
{
  auto len = GetModuleFileNameW(null, buffer.ptr, cast(DWORD) (buffer.length - 1));
  enforce(len, sysErrorString(GetLastError()));
  if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) break;
  buffer.length *= 2;
}
```

to avoid code duplication, but that might be a matter of personal preference.