Euler G. Posted March 26, 2011 Share Posted March 26, 2011 Folks, Tsunami Record Manager is a Btrieve like database manager. Developed in PowerBasic by Timm Motl it may be used by many languages by making calls to its ~66KB DLL. It used to be hosted in http://www.trm-ug.com/ but website was shutdown (don't know the reasons). TRM v2.x is free to any use though it had a commercial v3.x with some extras like a toolbox to help with things like browsing databases, etc (never used). One can reach my TRM packages and documentation through http://www.4shared.com/file/ixKDMfQr/TRMPB.html and http://www.4shared.com/file/lR2ElA6A/trm.html links. TRMPB.zip contains documentation and examples for PowerBasic while trmVB.zip is Visual Basic. Latter is the one I'm using as example. Anyway, I'm trying to access TRM databases using AutiIt3 and even started to write an #include file (TRM.AU3) to accommodate global variables, functions, error messages and so. TRM.dll can be called either by a String API or by Pointer-based API (2 methods). String API is the easiest to use and recommended for use with Visual Basic, thus my choice for this method. Despite the syntax seems quite right, calling a function like trm_Open crashes AutoIt3 (I used a valid database furnished in package). Other functions like trm_Create returned an error (#28) not mentioned in docs. Alas, I don't have a Visual Basic environment to check the source code provided. Below the open function that crashes AutoIt. Func trm_Open($sFile, $iOpenFlag = 0) Local $oRet = -1 If Not IsKeyword($sFile) Or $sFile <> "" Or $sFile <> -1 Then $oRet = DllCall($g_hDll_TRM, "long", "trm_Open", "str", $sFile, "long", $iOpenFlag) EndIf Return $oRet EndFunc ;==>_trm_Open I have to find what's wrong before going any further. Any help much appreciated. Best, Euler Link to comment Share on other sites More sharing options...
ProgAndy Posted March 26, 2011 Share Posted March 26, 2011 Maybe the DLL uses cdecl calling convention and not stdcall. So try to use long:cdecl as return parameter. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Euler G. Posted March 26, 2011 Author Share Posted March 26, 2011 Been there, done that. No joy. It's supposedly to work on string mode right out of the box. This is what they use in VB:hFile& = trm_Open(File$, 0)and VB wrapper has this calling procedure:Declare Function trm_Open Lib "TRM.DLL" _ (PathFileName As String, MultiUser As Long) As LongWhat bugs me is that it seems to start right and then it blows out. Does it ring a bell? Best, Euler Link to comment Share on other sites More sharing options...
trancexx Posted March 27, 2011 Share Posted March 27, 2011 There is nothing wrong on AutoIt's side of your code. Calling convention is ok, that's not the problem either. The problem is executable compressor used on that module, Aspack. It makes dynamically calling functions hazardous action. If you can find uncompressed trm.dll you will see that all works fine with only just a touch more. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Euler G. Posted March 27, 2011 Author Share Posted March 27, 2011 Hmm, this compressor thing crossed my mind but didn't go that way because it seemed to work for others. Let me try to find a de-compressor. I had problems in the past trying to decompress Aspack. Thanks for the hint, trancexx Best, Euler Link to comment Share on other sites More sharing options...
ProgAndy Posted March 27, 2011 Share Posted March 27, 2011 Hmm, this compressor thing crossed my mind but didn't go that way because it seemed to work for others. Let me try to find a de-compressor. I had problems in the past trying to decompress Aspack. Maybe one of those unpackers will help: http://www.exetools.com/unpackers.htm *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Euler G. Posted March 27, 2011 Author Share Posted March 27, 2011 I just used aspackdie13d and unaspack211c tools to uncompress Tsunami Record Manager DLL (TRM.DLL). Unfortunately, unpacking it results in an unloadable DLL despite both tools produced a very clean output. Looks like DLL checks its status on loading (file size, CRC, etc). Best, Euler Link to comment Share on other sites More sharing options...
Euler G. Posted March 28, 2011 Author Share Posted March 28, 2011 While TRM author doesn't return my message I did some research in the Net about TRM.dll usage with other languages. A PureBasic user had problems using it's string API (as I am) but was successful using pointer API. Below, String and Pointer API constructs for trm_Open command: String API (PowerBasic syntax) hFile& = trm_Open(File$, 0) … where File$ represents a string variable holding the name of the file to be opened, optionally including a valid path. If you do specify a path, it must be a complete path, including the drive letter. Pointer-based API #1 (7 parameters … 4-byte signed integers, PowerBasic syntax) Op& = %Tsu_Open KeyPtr& = STRPTR(File$) KeyLen& = LEN(File$) KeyNo& = 0 ‘ single-user Result& = trm(Op&, hFile&, 0, 0, KeyPtr&, KeyLen&, KeyNo&) If successful, a file handle is returned in the hFile& parameter. Pointer-based API #2 (1 parameter … a User Defined Type, PowerBasic syntax) Tsu.op = %Tsu_Open Tsu.keyptr = STRPTR(File$) Tsu.keylen = LEN(File$) Tsu.keyno = 0 ‘ single-user Result& = trm_udt(Tsu) If successful, a file handle is returned in the Tsu.file element. Is it possible to use such pointer construct in AutoIt3? BTW, I'm no more than a noob when it comes to dll calls, so please, be patient. Best, Euler Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now