asar icon indicating copy to clipboard operation
asar copied to clipboard

`stdincludes.txt` not loaded when called through `PATH`

Open exodustx0 opened this issue 1 year ago • 7 comments

The manual (for both v1.90 and v2) states:

When a file with [the name stdincludes.txt] exists next to the Asar executable, Asar automatically opens it and adds every line in it as an include search path [...]

This is not true if asar is called through PATH, due to argv[0] just being asar.

exodustx0 avatar Aug 09 '24 21:08 exodustx0

ugh, that's true. is there a better way to do this? anything more portable than readlink(/proc/self/exe)?

trillllian avatar Aug 09 '24 21:08 trillllian

does #ifdef count as portable?

Note that, for the Windows implementation, the path may not fit in MAX_PATH-length buffer when long path support is enabled. Also, I'm not sure what you're doing with the first argument to GetModuleFileNameA, but the documentation suggests passing in NULL to get the current process's executable path.

exodustx0 avatar Aug 09 '24 22:08 exodustx0

Yes, passing NULL gets the current EXE's path.

That is not necessarily the path Asar is in, if it's compiled as a DLL. That's what that first argument does.

MAX_PATH, however, is a valid objection.

Alcaro avatar Aug 09 '24 22:08 Alcaro

I wasn't aware DLLs have inconsistent path reporting through GetModuleFileName.

exodustx0 avatar Aug 09 '24 22:08 exodustx0

what are you talking about. there's nothing inconsistent there, GetModuleFileName returns the exe's path just fine if called from a dll with hmodule=null

it's just that that's not the path the dll is looking for. dlls don't need to be beside the exe, go look up where kernel32.dll is located

Alcaro avatar Aug 09 '24 22:08 Alcaro

I misinterpreted your earlier message.

exodustx0 avatar Aug 09 '24 22:08 exodustx0