Handle dwCreationDisposition in CreateFileA to fix PSYLINK #60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this change,
dwCreationDisposition
parameter ofCreateFileA
was ignored by wibo. However, it turns out thatPSYLINK.EXE
in PsyQ 4.4 sometimes depends on correct handling of that parameter.When building overlays with
PSYLINK.EXE
, it sometimes opens the resulting overlay file the second time, withOPEN_EXISTING
creation disposition (as opposed toTRUNCATE_EXISTING
). Before the change, wibo opened that file withfopen(..., "wb+")
which truncated the file even thoughOPEN_EXISTING
(non-truncating) was requested. This affected mgs_reversing, where one of the overlays (camera.bin
) was built incorrectly when using wibo (worked correctly on Windows or with wine).This PR adds proper handling of
dwCreationDisposition
parameter. The file now can be opened in truncating or non-truncating mode. Additionally, the implementation now reacts correctly to file existing/non-existing as specified by the requested creation disposition parameter. For example, ifCreateFileA
is called withOPEN_EXISTING
and the file does not exist it will set an error and not create a new file (the previous behavior). If the file exists, it's opened in non-truncating mode, asTRUNCATE_EXISTING
orCREATE_ALWAYS
is required for truncation.After the fix you can correctly build the whole mgs_reversing project with wibo - tools running under wibo:
ASMPSX
,ASPSX
,CC1PSX
4.0 & 4.4,PSYLINK
. I have NOT tested other executables apart from those.