rodrigocfd / windigo

Windows API and GUI in idiomatic Go.
https://pkg.go.dev/github.com/rodrigocfd/windigo
MIT License
405 stars 22 forks source link

MapViewOfFile fails when arch is 386 #24

Closed Hoto-Cocoa closed 1 year ago

Hoto-Cocoa commented 1 year ago

When I used win.IniLoad, It fails with error: [5 0x05] Access is denied., but not with amd64.

I tried to fix this issue but failed.

How can I fix this? INI file size is just 1,536 bytes.

Thanks.

rodrigocfd commented 1 year ago

I made two commits to stricten the behavior of MapViewOfFile, but I'm unsure it would make any difference in x86 architectures. The behavior of the C implementation is the same for any architecture.

What's the latest Windows to support x86? I can try downloading an ISO and installing it in a VirtualBox machine to test.

Hoto-Cocoa commented 1 year ago

I updated windigo but fail as same. The last Windows that supports x86 is Windows 10. However, just build with GOARCH=386 and running it on x64 Windows also fails as same.

rodrigocfd commented 1 year ago

I made a search and there seems to be a number of issues with MapViewOfFile in x86 architectures. As a solution, I simply reimplemented the loading routine in the Ini, which will not use FileMapped in x86.

Please let me know if this solves your issue.

Hoto-Cocoa commented 1 year ago

It seems new version not published, Should I wait?

rodrigocfd commented 1 year ago

The pkg.go.dev may take some time to deploy the documentation, but the code is already commited. You can use it right away.

Hoto-Cocoa commented 1 year ago

Thanks for let me know, I just tried update and got new version.

However, now [87 0x57] The parameter is incorrect. error occurred.

rodrigocfd commented 1 year ago

This error is coming from which function call?

Hoto-Cocoa commented 1 year ago

It is abst_File.go file, ReadAll function, and first call of me.Seek().

rodrigocfd commented 1 year ago

I found that SetFilePointerEx doesn't work in x86 architectures, so SetFilePointer must be used instead. This is an undocumented behavior, apparently.

Let me know if this works for you.

Hoto-Cocoa commented 1 year ago

Now WriteFile: %!w(<nil>) error occurred. It seems to changes in c71c216 caused make err != nil always true.

However, the file saved successfully.

rodrigocfd commented 1 year ago

I missed an error check, please try again.

Hoto-Cocoa commented 1 year ago

It now works perfectly! Thanks a lot for the support.