GetDllBitness()
GetDllBitness()
GetDllBitness()
whipped it up quick, placed here for reference..
Re: GetDllBitness()
Updated the API call as it was incorrect.
Re: GetDllBitness()
You can do it without imagehlp.dll
Code: Select all
oFile := FileOpen(DllPath, "r")
oFile.Seek(0x3c)
oFile.Seek(oFile.ReadInt()+4)
machineType := oFile.ReadUShort()
oFile.Close()
if (machineType = 0x14c)
msgbox 32 bit
if (machineType = 0x8664) or (machineType = 0x200)
msgbox 64 bit
Re: GetDllBitness()
yah I was aware but figured using the api call would be somehow "cleaner" lol
also wouldn't oFile.ReadInt()+A_PtrSize be more compliant? *wonderin
also wouldn't oFile.ReadInt()+A_PtrSize be more compliant? *wonderin
Re: GetDllBitness()
No. Because
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#signature-image-onlyAfter the MS-DOS stub, at the file offset specified at offset 0x3c, is a 4-byte signature that identifies the file as a PE format image file.
- Delta Pythagorean
- Posts: 627
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: GetDllBitness()
What exactly does this do and what is it for?
[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat
Re: GetDllBitness()
Based on the function's name, the example and the description (scroll down in the code window), I would suppose that it determines, if a specific dll-file is a 64 or a 32 bit library. ("It gets the bitness of a DLL").
Application case: As you might know, you can't use 64 bit DLLs on 32 bit Windows operating systems - so how do you determine programmatically, for example, if the user downloaded the right DLL version for a certain task?
Description: Returns a dll's bitness.
Parameters:
dll: The full path of the dll whose bitness is to be determined.
warn (optional): Displays a message if the dll is invalid then exits.
Return value: The return value is a nonzero number.
Re: GetDllBitness()
Hi, if the else branch is executed you do not free the loaded dll. In any case, it is not necessary to load it manually as dllcall will do it for you automatically if needed. See dllcall - performance.
Thanks for sharing, cheers.
Thanks for sharing, cheers.
Re: GetDllBitness()
Thanks @Helgef
By `load it` do you mean explicit load of the imagehlp library? If so, my script crashes without it.
By `load it` do you mean explicit load of the imagehlp library? If so, my script crashes without it.
Re: GetDllBitness()
arent u also supposed to eventually UnMapAndLoad if ure gonna use this dllcall?
Re: GetDllBitness()
Sorry, I see you do a double numget, which means that you dereference something allocated by the dll, so indeed you need to load it explicitly and cannot rely on dllcall to do it for you.
Re: GetDllBitness()
I really did rush through this one.
Thanks guys, updated.
Thanks guys, updated.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 80 guests