Dllcall problem @error = 1

05/18/2015 18:19 FacePalmMan#1
Da ich einen Videostream in AutoIt möglich machen will in dem man nicht einzelne Frames verschickt, sondern echtes Video, habe ich sehr lange nach einer Methode gesucht einen Videostream zu erstellen. Als ich aber die Methode gefunden habe einen Videostream zu erstellen und ihn beim Schließen zu speichern, dachte ich mir: Wieso nicht einfach zwischenspeichern und die hinzugekommenen/geänderten Bytes zum Empfänger senden?
Tja. Ich bin nicht so der DllCall Experte da ich nicht so der C++ Profi bin, und in C# auch erst recht neu bin, habe ich etwas gebraucht bis ich den DllCall erstmal mit den richtigen Parametern & Datentypen vollständig hatte.
Aber da die AVI Datei nicht zwischendurch gespeichert wurde habe ich eine MsgBox ans Ende der Funktion gepackt, damit ich sehen kann was zurückgegeben wird.
Resultat: @error = 1, der Rest 0
Die AutoIt Hilfe sagt natürlich: @error 1 = unable to use the DLL file
Aber das Problem ist: Die DllCalls rufen ALLE die selbe DLL auf. D.h sowohl die Funktion die ich einfügen will, als auch die um den Stream zu erstellen und zu schließen.

Also was denkt ihr ist da falsch?

Downloadlink zu den Dateien (Problematische Funktion: AVISave):
[Only registered and activated users can see links. Click Here To Register...]
05/19/2015 14:46 elmarcia#2
Hi, there have u tried turning it off and on?.
So the other functions of the dll are working fine?, then are u sure u have to use stdcall method instead of cdecl.
I'm sorry don't speak german :c. I'm also afraid that i looked at your code and looks complicated, keep it up you will solve it soon!
05/19/2015 15:46 FacePalmMan#3
Quote:
Originally Posted by elmarcia View Post
Hi, there have u tried turning it off and on?.
So the other functions of the dll are working fine?, then are u sure u have to use stdcall method instead of cdecl.
I'm sorry don't speak german :c. I'm also afraid that i looked at your code and looks complicated, keep it up you will solve it soon!
I tried it too, but the @error is still 1
05/20/2015 02:12 elmarcia#4
Mmm, maybe its a problem with the dll, if its a x64 dll then u can't run it with scite, you should first compile the script x64 then run it, that worked for me with a test i made...
05/20/2015 19:49 FacePalmMan#5
Quote:
Originally Posted by elmarcia View Post
Mmm, maybe its a problem with the dll, if its a x64 dll then u can't run it with scite, you should first compile the script x64 then run it, that worked for me with a test i made...
Its a x86 dll, and my OS runs on 32 bit.
05/21/2015 15:45 elmarcia#6
Alright, u should:
1º-> Have u checked with pe explorer or something if your dll is exporting AVISave, maybe u missed it in your def file.
2º-> Check that every parameter that u are using is the equivalent to autoit.
3º-> Use a debugger to find out what it is happening with those parameters, (ollydbg should work) setting a breakpoint in AVISave call.
4º-> if still don't get it. Is autoit the best language for your project?. Translating those functions to C++ won't be so hard.
(if olly isn't working try using some plugins since autoit will check for debuggers)

Good Luck and Have fun doing your research!
05/21/2015 16:35 FacePalmMan#7
Quote:
Originally Posted by elmarcia View Post
Alright, u should:
1º-> Have u checked with pe explorer or something if your dll is exporting AVISave, maybe u missed it in your def file.
2º-> Check that every parameter that u are using is the equivalent to autoit.
3º-> Use a debugger to find out what it is happening with those parameters, (ollydbg should work) setting a breakpoint in AVISave call.
4º-> if still don't get it. Is autoit the best language for your project?. Translating those functions to C++ won't be so hard.
(if olly isn't working try using some plugins since autoit will check for debuggers)

Good Luck and Have fun doing your research!
The thing is that I want to show the world that you can do videostreaming using autoit.
To your other arguments: @error 1 means that the file can't be used. That means: the parameters don't have anything to do with it. Only the ":cdecl" could also cause this error, but it isn't because I tried it too.
05/21/2015 21:56 elmarcia#8
Find the solution i think looking again at your code->
Code:
$ret = DllCall($Avi32_Dll, "long", "AVISave", "str", $sFilename, "none", 0, "ptr", DllCallbackGetPtr($Emptycallback), "int", 1, "ptr", $Avi_Handle[1], "ptr", DllStructGetPtr($asi))
-none no value (only valid for return type - equivalent to void in C)
Why the hell u put none there :c
05/22/2015 05:37 YatoDev#9
hatte das problem auch mal in autoit das eine dll mit den autoit funktionen nicht ansprechbar war.
Meine lösung:
PHP Code:
;Example of using DllCallAddress
Func _CallFunction
($pointer$returntype)
    
Local $hResult DllCallAddress($returntype$pointer"int",0,"int",0,"int",@DesktopWidth,"int",@DesktopHeight,"str",@DesktopDir "\imgsrc.bmp")
    If 
Not IsArray($hResultThen Return False
    
Return $hResult[0]
EndFunc

;Gets the address of the fucntionparam1 module handle param2 "Function"
Func _GetFunctionPointer($hDll$name)
    
Local $hOpen DllOpen("kernel32.dll")
    
$hResult DllCall($hOpen"DWORD""GetProcAddress""HANDLE"$hDll"STR"$name)
    
DllClose($hOpen)
    If 
$hResult[0] = null Then Return False
    
Return $hResult[0]
EndFunc

;Returns the module handle
Func _LoadLibrary
($path)
    
Local $hOpen DllOpen("Kernel32.dll")
    
$hResult DllCall($hOpen"HANDLE","LoadLibrary""STR"$path)
    
DllClose($hOpen)
    If 
$hResult[0] = Null Then Return False
    
Return $hResult[0]
EndFunc

;closes the module
Func _FreeLibrary
($hModule)
    
Local $hOpen DllOpen("Kernel32.dll")
    
$hResult DllCall($hOpen"BOOL","FreeLibrary""HANDLE"$hModule)
    
DllClose($hResult)
    If 
$hResult[0] = 0 Then Return False
    
Return True
EndFunc 
#Edit:
Für DllCallAddress gibts auch api funktionen falls autoit nicht will
#Edit2:
Bei dem beispiel funktionsaufruf handelte es sich um eine von mir geschriebene IMG search dll die leider doch keinen geschwindigkeitsvorteil brachte dank autoshit^^
Edit3:
Wohl zu früh am morgen...
Die mühe mit den return hab ich mir gemacht um autoshit beizubringen True als sting auszugeben und keine 1. Ich hasse den autoit variant