Page 1 of 1

Load DLL with Python - Solved

Posted: Thu Mar 12, 2020 11:48 pm
by jayn23

I am currently researching .gr2 format and want to import granny2.dll in order to decompress the files, but i am having issues with implementing it python since every example i have managed to find was written in c++.
any help would be very much appreciated

for loading the DLL i tried 2 approaches using ctypes:

Code: Select all

MyDllObject = ctypes.cdll.LoadLibrary("granny2.dll")
MyFunctionObject = MyDllObject._GrannyDecompressData@32

but this is an instant fail since it reads the function name up to "@" and stops so it never finds the wanted function

Code: Select all

lib = ctypes.WinDLL("granny2.dll")
func = lib['_GrannyDecompressData@32']
value = func(section.compression,0,section.data_size,ComperesedData,section.first16bit,section.first8bit,section.decompressed_size,DecompressedData)
it does seem to find the function, but i am un-share how to send the parameters needed for the decompression, since i keep getting errors no matter what combo i try.

Thanks in advance

Re: Load DLL with Python

Posted: Fri Mar 13, 2020 3:50 pm
by jayn23
I got it working it seems the syntax for my second try was actually correct the problem was with the parameters i was sending didn't fit what the function was expecting to receive, ill just note for anyone who might wonder here in the future if your sending a bytes object/bytesarray make sure its the correct size or program will crash with a debug error.