Jump to content

trancexx

Active Members
  • Posts

    6,848
  • Joined

  • Last visited

  • Days Won

    58

trancexx last won the day on September 7 2019

trancexx had the most liked content!

About trancexx

  • Birthday 02/18/1987

Profile Information

  • Member Title
    something something something
  • Location
    Split, HR

Recent Profile Visitors

13,620 profile views

trancexx's Achievements

  1. It could be something like this: #include <WinHttp.au3> $url = "https://slack.com/api/files.upload" $token = "abc-123-456-abc123" $args = "#random" $file = "c:\Users\Public\catloloz.jpg" ; example curl command -- curl -F file=@c:\Users\Public\catloloz.jpg -F channels=#random -F token=abc-123-456-abc123 https://slack.com/api/files.upload $sForm = _ '<form action="' & $url & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="file"/>' & _ ; ' <input name="channels" />' & _ ' <input name="token" />' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen() $hConnect = $sForm ; will pass form as string so this is for coding correctness because $hConnect goes in byref ; Fill form $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:file", $file, _ "name:channels", $args, _ "name:token", $token) If @error Then MsgBox(4096, "Error", "Error number = " & @error) Else ConsoleWrite("!" & $sHTML & @CRLF) EndIf ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
  2. That last line. ;... _WinHttpSendRequest($hRequest, -1, "action=fetch_number_1")
  3. Actually it's pretty straightforward. An object is created that has a pointer to the original object as its property, and all the calls to methods of this new object are simply translated to the original one. Obviously GetIDsOfNames and Invoke of the new object checks for call to the new methods and alters the parameters array accordingly before calling the original. The only thing that was truly a challenge was how to free dynamically allocated memory from within itself. Doing it from x64 code is easy due to specific calling convention and execution algorithm, but from x86 it's nightmare until you figure out that it is not the spoon that bends, lol. There is no spoon. The code is super interesting, I wish I had a chance to see something like that ten years ago, and be able to learn from it. I would have asked thousands of questions. Who knows... maybe I'd be ruling the world now, and not that fuc*ker. This way I had to do it all by myself with little chance of ruling. The. World.
  4. You could also use some sort of wrapper object that allows something like that, on top of the original one. This method would be the simplest to use. Unfortunately no one ever shared the code that would do that because writing sensible implementation requires extended knowledge of the memory management, COM Idispatch handling and whatnot. I remember one user writing it in AutoIt but it has different issues. I would do it like this (added __propget__, __propset__ and __call__ for every object): ObjectExtend.au3 #include-once ; ExtendObj.au3 ;.......script written by trancexx (trancexx at yahoo dot com) - yea it's PayPal address too Func ObjectExtend($oObject) ; This function adds three methods to original $oObject: __propget__, __propset__ and __call__ ; Resulting object doesn't require any special memory managment. It frees and deallocates itself when reference count reaches 0, like any other object in AutoIt Local $tIntfc If @AutoItX64 Then $tIntfc = DllStructCreate("ptr Object;ptr Original;ulong refCount;ptr pFree;ptr pQueryInterface;ptr pAddRef;ptr pRelease;ptr pGetTypeInfoCount;ptr pGetTypeInfo;ptr pGetIDsOfNames;ptr pInvoke;byte QueryInterface[12];byte AddRef[36];byte Release[44];byte GetTypeInfoCount[12];byte GetTypeInfo[12];byte GetIDsOfNames[148];byte Invoke[536];", __Extend_VirtualAlloc(0, 888, 0x1000, 64)) DllStructSetData($tIntfc, "QueryInterface", "0x488B4908488B0148FF20") DllStructSetData($tIntfc, "AddRef", "0x40534883EC20488BD9488B4908488B01FF50088B4310FFC08943104883C4205BC3") DllStructSetData($tIntfc, "Release", "0xFF4910514883EC20488B4908488B11FF52104883C420598B411085C0750B31D241B800800000FF6118C3") DllStructSetData($tIntfc, "GetTypeInfoCount", "0x488B4908488B0148FF6018") DllStructSetData($tIntfc, "GetTypeInfo", "0x488B4908488B0148FF6020") DllStructSetData($tIntfc, "GetIDsOfNames", "0x48895C2408574883EC304C8B5C2468418BF94D85C074544D85DB744F498B1841BA05150000440FB70B4585C9743D4183E1DF456BD221488D5B024503D1440FB70B4585C975E84181FABDAC0A5A74124181FA62ECB77D74094181FA6E12917E750A41F7DA45891333C0EB1B488B4908448BCF8B4424604C895C2428894424204C8B1141FF5228488B5C24404883C4305FC3") DllStructSetData($tIntfc, "Invoke", "0x488BC4488958084889701848897820895010554154415541564157488BEC4883EC60488B5D58418BF9498BF04C8BF181FA92ED6E810F85DD0000008B4310488B4908FFC84C8B11488D1440488B03488D52014C8D04D0488BD6488D4538488944242844894C242041B90100000041FF5228FF4B10488D45F04C8B7D70BA040000004C8B6568448BCF4C8B6D604C8BC64C897C244048894308C7431401000000498B4E084C89642438C745F0FDFFFFFF4C896C2430488B0148895C242866895424208B5538FF50303D030002800F8527010000498B4E08BA080000004C897C2440448BCF4C896424384C8BC64C896C2430488B0148895C242866895424208B5538FF50303D030002800F85EB000000B806000280E9E100000081FA9E13488275518B431033D289553885C0743A488B4908FFC88BD041B9010000004C8B114C8D044501000000488B034C03C2488BD64E8D04C0488D45384889442428897C242041FF52288B5538FF4B1041B802000000EB5181FA4353F5A575448B431085C0748E488B4908FFC88BD041B9010000004C8B114C8D044501000000488B034C03C2488BD64E8D04C0488D45384889442428897C242041FF5228FF4B108B5538440FB74550488B4570448BCF498B4E084889442440488B45684889442438488B45604C8B11488944243048895C24286644894424204C8BC641FF52304C8D5C2460498B5B30498B7340498B7B48498BE3415F415E415D415C5DC3") Else $tIntfc = DllStructCreate("ptr Object;ptr Original;ulong refCount;ptr pFree;ptr pQueryInterface;ptr pAddRef;ptr pRelease;ptr pGetTypeInfoCount;ptr pGetTypeInfo;ptr pGetIDsOfNames;ptr pInvoke;byte QueryInterface[16];byte AddRef[24];byte Release[48];byte GetTypeInfoCount[16];byte GetTypeInfo[16];byte GetIDsOfNames[108];byte Invoke[356];", __Extend_VirtualAlloc(0, 628, 0x1000, 64)) DllStructSetData($tIntfc, "QueryInterface", "0x8B4424048B40048B0889442404FF21") DllStructSetData($tIntfc, "AddRef", "0x8B5424048B4204508B08FF5104FF42088B4208C20400") DllStructSetData($tIntfc, "Release", "0x8B5424048B5204528B12FF52085A5952FF49088B410885C07515680080000050518B510C40803C02C375F901D05052C3") DllStructSetData($tIntfc, "GetTypeInfoCount", "0x8B4424048B40048B0889442404FF610C") DllStructSetData($tIntfc, "GetTypeInfo", "0x8B4424048B40048B0889442404FF6110") DllStructSetData($tIntfc, "GetIDsOfNames", "0x837C24180074498B44240C85C074418B10B8051500000FB70A85C974336BC0218D520283E1DF01C80FB70A85C975EE3DBDAC0A5A740E3D62ECB77D74073D6E12917E750CF7D88B542418890231C0EB168B4424046A0559FF742418E2FA8B4004508B00FF5014C21800") DllStructSetData($tIntfc, "Invoke", "0x8B542408538B5C2408558B6C2418565781FA92ED6E810F85A20000008B7C24288D4424188B730450558B4F088B078B1683C0F86A01C1E10403C150FF74242C56FF5214FF742434FF4F088D442418FF7424348B742424FF742434C7470C01000000576A048947048B43045556FF742434C7442434FDFFFFFF8B0850FF51183D030002800F85D3000000FF7424348B4304FF742434FF7424348B08576A085556FF74243450FF51183D030002800F85AA0000005F5E5DB8060002805BC224008B74242881FA9E134882753B8B7E0833D28954241885FF74248B4B048D442418508B06558B1183C0F86A01C1E70403C750FF74242C51FF52148B542418FF4E08BF02000000EB3A81FA4353F5A5752E8B7E0885FF749E8B4B048D442418508B06558B1183C0F86A01C1E70403C750FF74242C51FF5214FF4E088B5424188B7C2424FF7424348B4304FF742434FF7424348B08565755FF7424345250FF51185F5E5D5BC22400") EndIf DllStructSetData($tIntfc, "Object", DllStructGetPtr($tIntfc, "pQueryInterface")) DllStructSetData($tIntfc, "Original", Ptr($oObject)) DllStructSetData($tIntfc, "refCount", 1) DllStructSetData($tIntfc, "pFree", __Extend_GetProcAddress(__Extend_GetModuleHandle("kernel32.dll"), "VirtualFree")) DllStructSetData($tIntfc, "pQueryInterface", DllStructGetPtr($tIntfc, "QueryInterface")) DllStructSetData($tIntfc, "pAddRef", DllStructGetPtr($tIntfc, "AddRef")) DllStructSetData($tIntfc, "pRelease", DllStructGetPtr($tIntfc, "Release")) DllStructSetData($tIntfc, "pGetTypeInfoCount", DllStructGetPtr($tIntfc, "GetTypeInfoCount")) DllStructSetData($tIntfc, "pGetTypeInfo", DllStructGetPtr($tIntfc, "GetTypeInfo")) DllStructSetData($tIntfc, "pGetIDsOfNames", DllStructGetPtr($tIntfc, "GetIDsOfNames")) DllStructSetData($tIntfc, "pInvoke", DllStructGetPtr($tIntfc, "Invoke")) ; Call AddRef on original object DllCallAddress("ulong", DllStructGetData(DllStructCreate("ptr pQueryInterface;ptr pAddRef;ptr pRelease;", DllStructGetData(DllStructCreate("ptr Object", Ptr($oObject)), 1)), "pAddRef"), "ptr", Ptr($oObject)) Return ObjCreateInterface(DllStructGetPtr($tIntfc), Default, Default, False) EndFunc Func __Extend_VirtualAlloc($pAddress, $iSize, $iAllocationType, $iProtect) Local $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iAllocationType, "dword", $iProtect) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func __Extend_GetModuleHandle($vModule) Local $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", "wstr", $vModule) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func __Extend_GetProcAddress($hHandle, $sFunc) Local $aCall = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hHandle, "str", $sFunc) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ...and then (modified Chimp's): #include <ie.au3> #include "ExtendObj.au3" $oMyObject = ObjectExtend(_IECreate()) ; just to have a "guinea pig" to experiment with Global $aDesiredProperties[] = ['Left=10', 'Top=10', 'Width=260', 'Height=350', 'AddressBar=0', 'MenuBar=0', 'StatusBar=0', 'ToolBar=0'] For $i = 0 To UBound($aDesiredProperties) - 1 $aSet = StringSplit($aDesiredProperties[$i], "=", 2) ; 2 -> $STR_NOCOUNT) $oMyObject.__propset__($aSet[0], $aSet[1]) Next Local $sHTML = '0x3C21444F43545950452068746D6C3E3C68746D6C3E3C686561643E3C2F68656' & _ '1643E3C626F64793E3C696D67207372633D2268747470733A2F2F636F6F6C6D617465726' & _ '9616C2E636F6D2F77702D636F6E74656E742F75706C6F6164732F323031332F30322F737' & _ '472697065732E676966222077696474683D2232323022206865696768743D22323930223' & _ 'E3C2F626F64793E3C2F68746D6C3E' $oMyObject.document.Write(BinaryToString($sHTML)) $oMyObject.document.close() $oMyObject.document.execCommand("Refresh") MsgBox(0, "Info", "Press OK to exit") $oMyObject.quit
  5. I prefer leaving last three parameters undocumented for forward compatibility reasons. They're used internally.
  6. If you think what I think you're thinking, then no.
  7. But that's not true. You can check my code again
  8. Could you write a reproducer for me to run?
  9. It's hard to figure out what user wants to send. It should be up to you to feed the function with data properly formatted. In your case this should work correctly: $sPostData = "Hello پک و چیز Hello" $sPostData = BinaryToString(StringToBinary($sPostData, 4)) ;...
  10. Add one more argument for upload function. Like this: ;... ; Fill form $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _ Default, _ "name:upload", $sFileToUpload, _ "name:someparam", "Candy", _ "[IGNORE_CERT_ERRORS]") ;...
  11. Maybe besause it shoud be like in your original code unlike your AutoIt one: "https://api.betfair.com/exchange/betting/rest/v1.0/"
  12. Maybe like this: #include "WinHttp.au3" $sAddress = 'https://api.betfair.com/exchange/betting/json-rpc/v1/' $sAppKey = '4YpsEhdsgtedjd' $sSession_key = 'BhKl7Ijdu4E3pzHhKu7K5fQrvzf9p3wq/diRMt7bZka7' $sjson_req = '{"filter":{ }}' $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, $sAddress) $sReturned = _WinHttpSimpleSSLRequest($hConnect, "POST", "listEventTypes/", Default, $sjson_req, 'X-Application: ' & $sAppKey & @CRLF & 'X-Authentication: ' & $sSession_key & @CRLF & 'Content-Type: application/json', Default, Default, Default, Default, 1) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ConsoleWrite($sReturned & @CRLF)
  13. "Hvala vam" is too formal, "Hvala ti" would be more appropriate. Both would be "thank you" in English, because "thee", "thou", "ye" and whatnot all died with Shakespeare.
×
×
  • Create New...