BigDaddyO Posted August 11, 2020 Posted August 11, 2020 I've been asked to try and automate testing of a mainframe app. I've found that it comes with the whlapi32.dll loaded into the install folder and this appears to be a pretty standard mainframe emulator automation app as doing some google searches returned multiple apps using the same dll. I've got to the point where I can connect to the session, get session status, Send strings, Send Enter, Get the cursor location, but I'm stuck on any of the functions that update a Buffer with a return string. Local $rBuffer, $pBuffer Local $rSize, $pSize $rBuffer = DllStructCreate("char String[" & $iSessionSize & "]") $pBuffer = DllStructGetPtr($rBuffer) $rSize = DllStructCreate("int") $pSize = DllStructGetPtr($rSize) ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "str", Null, "int", 4096) ;Crashes ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", Null, "int", Null) ;Returns -2, ATM_INVALIDPARAMETER but no crash... ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", Null, "int", 4096) ;Crashes ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", $pBuffer, "ptr", $pSize) ;Crashes $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", $pBuffer, "int", $iSessionSize) ;Returns -2, ATM_INVALIDPARAMETER but no crash... ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", $pBuffer, "int", 5) ;Returns -7, ATM_INVALIDPOSITION but no crash... ;~ $aReturn = DllCall($hBZ, "int", "ATMGetString", "hwnd", $hBlueZone, "int", 0, "int", 0, "ptr", $pBuffer, "int", Null) ;Returns -2, ATM_INVALIDPARAMETER but no crash... If Ubound($aReturn) > 0 Then ConsoleWrite("DLL Call returned " & $aReturn[0] & @CRLF) ConsoleWrite("DLLStructGetData = " & DllStructGetData($rBuffer, "String") & @CRLF) _ArrayDisplay($aReturn) Else ConsoleWrite("Failed to get text" & @CRLF) Exit EndIf I'm confused by the -2 Invalid Parameter and the -7 Invalid Position errors that I get above. Do you think I have the options wrong in the DLLCall, or is the DLLStruct setup wrong? Any help you can offer would be greatly appreciated. Below is from a document that isn't actually for the emulator I'm using but everything seems to be matching up from the Function Names I exported from "DLL Export Viewer" and it's the only Doc I have access to: The ATMGetString function copies a string from the connected session into a string provided by the application program. Prerequisites A successful call to ATMConnectSession must have been made prior to using this function. Syntax rc = ATMGetString ( hWnd, row,column, buffer, bufferLength) Call parameters Each call parameter of the ATMGetString function is described below. Parameter Description rc = The integer return value. hWnd = This integer indicates the window handle of your application. row = This integer indicates the starting row position of the string to copy from the host session. column = This integer indicates the starting column position of the string to copy from the host session. buffer = The destination string that receives the copied string from the target session. It must be large enough to handle the number of characters specified in the bufferLength parameter. bufferLength = An integer that defines the number of characters to copy, beginning from the position specified in the row and column parameters. The function stops copying when it reaches the last character specified in the bufferLength parameter.
TheXman Posted August 11, 2020 Posted August 11, 2020 (edited) You are referring to the ATMAPI32.DLL (Attachmate's Enterprise Access Library), not the WHLAPI32.DLL (Attachmate's Windows High Level API Library). They are separate and distinct automation API libraries. Both API libraries are 32-bit and expect 32-bit pointers. Are you forcing your script to run as 32-bit (#AutoIt3Wrapper_UseX64=N)? If not, passing a 64-bit pointer for the string buffer, when it is expecting a 32-bit pointer, would probably cause an invalid parameter error. Looks like you have access to the API doc, but just in case you don't have the official docs, the links are below: https://docs.attachmate.com/extra/x-treme/apis/eal.pdf http://docs.attachmate.com/extra/x-treme/apis/whllapi.pdf Edited August 11, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
BigDaddyO Posted August 12, 2020 Author Posted August 12, 2020 Yep, I'm using the _UseX64=N I couldn't even connect without that. The DLL i'm accessing: $hBZ = DllOpen("C:\Program Files (x86)\BlueZone\7.1\whlapi32.dll") I exported all the functions from that DLL and it has all the eal.pdf functions so I have been using that for my reference. It also has all the functions mentioned in here: https://docs.attachmate.com/extra/x-treme/apis/wd_api.pdf so I think i'm going to switch gears and try to see if I can get any further with them since the WD_CopyPSToString uses a szDataStr instead of a buffer.
TheXman Posted August 12, 2020 Posted August 12, 2020 Well, it was worth a shot. I lost count how many times over the decades that the most obvious issue causing a problem, which was basically staring me in the face, temporarily eluded me. I downloaded a copy of BlueZone's v7.1.9 and see what you are saying about all of the different automation lib (EAL, WinHLLAPI, HLLAPI) functions that are exported in their custom WHLAPI32.DLL. Seeing how it is a custom DLL, they may have changed the ATMGetString's implementation a little from Attachmate's ATMAPI32.DLL version. I used to use Attachmate's apps a lot, back in the day. BlueZone's API documentation only references using the WinHLLAPI, COM, and DDE. I have to assume that is for a reason. If you installed the full version of BlueZone, have you tried using their COM interface? Unfortunately, I haven't messed with mainframes since the 80's in my ALC/CICS/COBOL/RPG days. So I don't have a way to do help test or trouble shooting the issue. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
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