Mechaflash Posted September 19, 2012 Share Posted September 19, 2012 (edited) using DllCall() and ran into a function that defines a parameter as 'char'. I'm using 'str' right now in its place, and the DllCall() completes, but the function itself is giving errors. Just want to make sure... is 'str' is the correct replacement for 'char' type? Edited September 20, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 Try BYTE AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mechaflash Posted September 19, 2012 Author Share Posted September 19, 2012 Try BYTE Using 'BYTE', DllCall() also completes (but having same problems with the function). 'BYTE' and 'str' have some type of correlation? I'm beginning to think the problem is with the DLL itself. I don't think the documentation on the return values are correct. Using the 'Connexion' function, and it keeps returning 1... meaning the environment variable for ExtraPuTTY hasn't been set. Yet I've quadrouple checked, and it does exist (it gets created upon installation). I also added it to the local user's environment but it still returns the same value. $sDll = "C:Program FilesExtraPuTTYBinExtraPuTTY.dll" $i = DllCall($sDll, "int", "Connexion", "BYTE", "192.168.1.5", "ULONG", "1001", "BYTE", "root", "BYTE", "password", "BOOL", "TRUE", "long", "1", "ULONG", "22", "long", "0", "int", "1", "ULONG", "2^1") msgbox(0,"",@error & @CRLF & $i[0]) $i = DllCall($sDll, "int", "CloseConnexion", "ULONG", "1001") msgbox(0,"",@error & @CRLF & $i[0]) Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 Looks like a char pointer to me, as do most of those parameters. try prepending you autoit types with * that is of course after you have used dllstructcreate and dllstructgetptr AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 for example, for ;unsigned long *ConnectionId $ConnectionId = 1001 $dllstruct = DllStructCreate("ulong") DllStructSetData($dllstruct,1,$ConnectionId) $ConnectionIdptr = DllStructGetPtr($dllstruct) ;"ulong*", $ConnectionIdptryour second parameter AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mechaflash Posted September 19, 2012 Author Share Posted September 19, 2012 for example, for ;unsigned long *ConnectionId $ConnectionId = 1001 $dllstruct = DllStructCreate("ulong") DllStructSetData($dllstruct,1,$ConnectionId) $ConnectionIdptr = DllStructGetPtr($dllstruct) ;"ulong*", $ConnectionIdptryour second parameter Ohhhhh... so any of the parameters that have '*' have to be built into a struct first because they are required to be a pointer? Even if you say "yes" to the above, I still don't understand how structs/pointers work, but I'll figure it out in due time XD Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 You should look through some of the WinAPI UDF's to see how they are used. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted September 19, 2012 Share Posted September 19, 2012 As well as WinAPIEx too. Both UDFs will give you an idea of where to start. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Mechaflash Posted September 20, 2012 Author Share Posted September 20, 2012 Hmm... looking at WinAPIEx line 1651, there's this: DllCall('advapi32.dll', 'int', 'LookupPrivilegeNameW', 'ptr', 0, 'ptr', DllStructGetPtr($tTP2, 2) + 12 * $i, 'ptr', DllStructGetPtr($tData), 'dword*', 128) I notice dword has an * (to specify that it's a pointer?) but the value given is a direct integer. for example, for ;unsigned long *ConnectionId $ConnectionId = 1001 $dllstruct = DllStructCreate("ulong") DllStructSetData($dllstruct,1,$ConnectionId) $ConnectionIdptr = DllStructGetPtr($dllstruct) ;"ulong*", $ConnectionIdptryour second parameter What I get from the above quote is that I'm supposed to build the struct/pointer for it? However the example doesn't show this. Can someone explain what I'm missing from this? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2012 Share Posted September 20, 2012 $dllstruct = DllStructCreate("ulong") ; creates a ulong structDllStructSetData($dllstruct,1,$ConnectionId) ; sets value of the ulong$ConnectionIdptr = DllStructGetPtr($dllstruct) ; retrieves the pointer , pointer to a ulong AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted September 20, 2012 Share Posted September 20, 2012 using DllCall() and ran into a function that defines a parameter as 'char'. I'm using 'str' right now in its place, and the DllCall() completes, but the function itself is giving errors. Just want to make sure... is 'str' is the correct replacement for 'char' type? No it's not. Your types are (respectively): str, ulong*, str, str, bool, long, ulong, long, int*, ulong. Here: $aArray = DllCall($sDll, "int", "Connexion", _ "str", "192.168.1.5", _ "ulong*", 1001, _ "str", "root", _ "str", "password", _ "bool", 1, _ "long", 1, _ "ulong", 22, _ "long", 0, _ "int*", 1, _ "ulong", 2) JohnOne is overthinking. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2012 Share Posted September 20, 2012 That does not surprise me. Does Autoit automagically pass the pointer then, when you prepend * to type? And does it just automagically pass the first element address of a string and null terminate it? And would that mean you never have to prepend str type? Sorry for the array of questions. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mechaflash Posted September 20, 2012 Author Share Posted September 20, 2012 (edited) Sorry for the array of questions. Local $aQs[4] Local $aAs[3] Local $sTitle = "JohnOne" $aQs[0] = 3 $aQs[1] = "Does Autoit automagically pass the pointer then, when you prepend * to type?" $aQs[2] = "And does it just automagically pass the first element address of a string and null terminate it?" $aQs[3] = "And would that mean you never have to prepend str type?" For $i = 1 To $aQs[0] $aAs[$i -1] = msgbox(4 + 32, "JohnOne's Question", $aQs[$i]) If $aAs[$i - 1] = 6 Then $sA = _YesAnswers() Else $sA = _NoAnswers() EndIf msgbox(48, "Trancexx's Answers", $sA) Next Func _YesAnswers() Local $sY[3] $sY[0] = "Yes" $sY[1] = "Of course..." $sY[2] = "You didn't know that?" Return $sY[Random(0, 2, 1)] EndFunc Func _NoAnswers() Local $sN[3] $sN[0] = "No" $sN[1] = "That's not what I said..." $sN[2] = "Don't be silly." Return $sN[Random(0, 2, 1)] EndFunc Now there's an array of questions with a msgbox answering system XD Sorry. I come up with weird stuff all the time XD Edited September 20, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2012 Share Posted September 20, 2012 What a delightful answer, thank's. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted September 20, 2012 Share Posted September 20, 2012 (edited) That does not surprise me.Does Autoit automagically pass the pointer then, when you prepend * to type?And does it just automagically pass the first element address of a string and null terminate it?And would that mean you never have to prepend str type?Sorry for the array of questions.Since the questions are on the table (you will see what I mean here when new version of AutoIt is out), the answers are...Yes, if you add asterisk AutoIt internally makes memory buffer in size of specified type and passes its pointer.str is memory buffer filled with string; array of characters + null terminator, whose pointer is then passed. Address of the buffer is the address of the first character, obviously.str* is also a valid type, but that's not the same as str. It's pointer to str pointer. Edited September 20, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2012 Share Posted September 20, 2012 Thank you trancexx.So if I pass str*, could dll type be something like char** ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted September 20, 2012 Share Posted September 20, 2012 (edited) Yes. ...Can be very dangerous, you see that right? Edited September 20, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2012 Share Posted September 20, 2012 Oh yes!, but it won't blow the computer machine up or anything. well not in this universe anyway. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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