On Fri Sep 22 15:55:16 2023 +0000, Aidan Khoury wrote:
> You're right, I checked again and this exception is captured and
> gracefully fails with the last error code set to 0xE0000001. So, I will
> remove this and just set the last error 0xE0000001 with a failing return
> value. I'll add some tests for this case.
this can also be done by setting an exception handler inside some functions
(in badly written pseudo code):
```
try {
// do the expected stuff
// setting ret & last error in case of error
} catch (exception e) {
throw exception(0xE0000001);
ret = FALSE;
SetLastError(0xE0000001);
}
return ret;
```
but that doesn't prevent from releasing the resources between the throw and this handler (we're not using RAEII and the current exception handling even for C code requires compiler support that we don't have)
so perhaps the safest solution is to return error codes internally (no exception) and throw the exception on top level functions
that's not nice for sure, but I fear we don't have many other options
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3870#note_46367
On Thu Sep 21 22:33:18 2023 +0000, Aidan Khoury wrote:
> This `rebase_image` implementation could still be adapted as an imghelp
> internal function, could it not? Though that would be better to be done
> as a separate MR, I think.
I gave ReBaseImage a quick look at how it behaves in windows and it has some likely unwanted behavior (like hard to really force a new rebase address), so it's fine to leave it aside for now
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3870#note_46359
On Fri Sep 22 15:46:59 2023 +0000, Aidan Khoury wrote:
> The native RtlImageHeader does not have boundary checks. I cannot do
> this check on RtlImageHeader's return value safely since that would be
> after RtlImageHeader has already potentially accessed an invalid address.
it has an exception handler around it, so
* either the field is not on a readable page and the exception will be fired, and you'll get a NULL pointer (SAFE)
* or the field is on a readable page but with a wrong magic value, and you'll get a NULL pointer (SAFE)
* or the field is on a readable page, with the expected magic value, and you'll a non NULL pointer, that you can check if it fits or not in mapped view before reading into it (SAFE)
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3870#note_46358
On Fri Sep 22 06:40:36 2023 +0000, eric pouech wrote:
> (my question was unclear: I meant does native throw this exception?)
> what does native do if the exception is continued? (I doubt this helper
> can be DECLSPEC_NOTRETURN)
You're right, I checked again and this exception is captured and gracefully fails with the last error code set to 0xE0000001. So, I will remove this and just set the last error 0xE0000001 with a failing return value. I'll add some tests for this case.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3870#note_46356
On Fri Sep 22 06:50:36 2023 +0000, eric pouech wrote:
> this raises the questions does native ntdll.RtlImageHeader check for
> e_lfanew being within image boundary? if so, it builtin implementation
> has to be fixed (with test case please)
> and if it doesn't you can still add the check on RtlImageHeader's
> returned value
The native RtlImageHeader does not have boundary checks. I cannot do this check on RtlImageHeader's return value safely since that would be after RtlImageHeader has already potentially accessed an invalid address.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3870#note_46353