Es gibt also keine Möglichkeit nur eine einzelne Grafik über eine Funktion "anzusprechen" und diese dann an anderer Stelle zu zeichnen. Das sehe ich doch richtig so oder?
Verstehe dich nicht - wie meinst du das?
UEZ
Es gibt also keine Möglichkeit nur eine einzelne Grafik über eine Funktion "anzusprechen" und diese dann an anderer Stelle zu zeichnen. Das sehe ich doch richtig so oder?
Verstehe dich nicht - wie meinst du das?
UEZ
Danke an Greenhorn für die Links und RR04 für sein C++ Beispiel!
Gruß,
UEZ
Was auf die Schnelle um die Uhrzeit!
;Coded by UEZ 2009.12.11
#include <GDIplus.au3>
Opt("GUIOnEventMode", 1)
_GDIPlus_Startup()
Global $load_background = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Background.png")
Global $load_foreground = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Smiley.png")
Global $width = _GDIPlus_ImageGetWidth($load_background)
Global $height = _GDIPlus_ImageGetHeight($load_background)
Global $dx = _GDIPlus_ImageGetWidth($load_foreground)
Global $dy = _GDIPlus_ImageGetHeight($load_foreground)
Global Const $pi_div_180 = 4 * ATan(1) / 180
Global $radius = 60
Global $i
Global $hwnd = GUICreate("GDI+: Example by UEZ", $width, $height, -1, -1, Default)
GUISetOnEvent(-3, "_Exit")
GUISetState()
Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
;~ _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)
[/autoit] [autoit][/autoit] [autoit]Global $size_x = $dx / 4, $size_y = $dy / 4
Global $coordinate[4][2]
$coordinate[0][0] = $size_x
$coordinate[0][1] = 0
$coordinate[1][0] = 3 * $size_x
$coordinate[1][1] = 0
$coordinate[2][0] = 5 * $size_x
$coordinate[2][1] = 0
$coordinate[3][0] = 7 * $size_x
$coordinate[3][1] = 0
$i = 0
While Sleep(30)
_GDIPlus_GraphicsDrawImage($backbuffer, $load_background, 0, 0) ;draw background
_GDIPlus_GraphicsDrawImageRect($backbuffer, $load_foreground, $coordinate[0][0], $coordinate[0][1] + $i, $size_x, $size_y)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $load_foreground, $coordinate[1][0], $coordinate[1][1], $size_x, $size_y)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $load_foreground, $coordinate[2][0], $coordinate[2][1], $size_x, $size_y)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $load_foreground, $coordinate[3][0], $coordinate[3][1] + $i, $size_x, $size_y)
$i += 2
If $coordinate[0][1] + $i >= $height Then $i = -$size_y
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
WEnd
Func _Exit()
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()
Exit
EndFunc
Gruß,
UEZ
Ich hab gleich mit C++ angefangen und erstmal das Tutorial gemacht. Damit bin ich gut klargekommen und kann inzwischen schon einfache Sachen, wie Tic Tac Toe ohne Hilfe selbst programmieren.
Ich würde gerne das objektorientierte Programmieren lernen und dachte mir C++ wäre ein guter Einstieg. Mal sehen...
Danke für den Link, werde ich mir auf jeden Fall auch anschauen. Zur Zeit gehe ich das Buch durch, um mich überhaupt mal mit C++ vertraut zu machen. Wird wohl einige Wochen dauern, bis ich ein eigenständiges Programm erstellen kann.
Ich würde das so machen:Spoiler anzeigen
Code Alles anzeigen#include <iostream> using namespace std; int produkt_berechnen(int z1, int z2) { return z1 * z2; } double mittelwert_berechnen(int z1, int z2) { return ( static_cast<double>(z1 + z2) / 2.0 ); } int main() { //Variablen deklarieren int zahl1, zahl2; //Zahlenwerte einlesen cout <<("Geben Sie eine Zahlen zwischen 1 und 100 ein: "); cin >> zahl1; cout <<("noch eine Zahl: "); cin >> zahl2; //Ergebnis berechnen int produkt = produkt_berechnen(zahl1, zahl2); int mittelwert = mittelwert_berechnen(zahl1, zahl2); //Ergebnis ausgeben cout << "\n1. Zahl = " << zahl1 << "\n"; cout << "2. Zahl = " << zahl2 << "\n\n"; cout << "Produkt = " << produkt << "\n"; cout << "Mittelwert = " << mittelwert << "\n"; return 0; }
Damit das Fenster am Ende offen bleibt solltest du am Ende vor dem return ein paar cin.get(); einfügen.
EDIT: #include <stdio.h> brauchst du hier nicht und was steht in der stdafx.h?
Übrigends gehen alle C-Befehle auch unter C++.
Ich benutze den MS Visual C++ 2008 für den C++ Code, und wenn ich eine Consolen App. bauen will, wird automatisch
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
erstellt. Ich vermute, dass ist so was wie die $cmdline unter AutoIt.
An dem Code kann man vieles vielleicht besser machen, aber ich muss erstmal mich mit dem Editor und den Befehlen auseinander setzen! C und C++ will ich auch nicht mischen...
Gruß,
UEZ
Ich habe mir das C/C++ Buch von M+T (C/C++ Die Referenz) geholt und habe mich entschlossen direkt mit C++ anzufangen.
Darum bewusst die C++ Syntax.
Ich weiß nicht, ob ich doch lieber vorher mit C anfangen sollte!
Gruß,
UEZ
PS: Das auf dem Foto ist Salvatore Dali
Irgendwie war mit dem Compiler was los, denn jede Änderung die ich gemacht hatte, wurde ignoriert.
So wollte ich es haben:
// Product_Calc.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
int produkt_berechnen(int z1, int z2)
{
int ergebnis;
ergebnis = z1 * z2;
return ergebnis;
}
double mittelwert_berechnen(int z1, int z2)
{
double ergebnis;
ergebnis = (z1 + z2) / 2.0;
return ergebnis;
}
int main(int argc, char **argv)
{
//Variablen deklarieren
int zahl1, zahl2;
int produkt;
double mittelwert;
//Zahlenwerte einlesen
cout <<("\nGeben Sie zwei Zahlen zwischen 1 und 100 ein: ");
cin >> zahl1 >> zahl2;
//Ergebnis berechnen
produkt = produkt_berechnen(zahl1, zahl2);
mittelwert = mittelwert_berechnen(zahl1, zahl2);
//Ergebnis ausgeben
cout << "\n1. Zahl = " << zahl1 << "\n";
cout << "2. Zahl = " << zahl2 << "\n\n";
cout << "Produkt = " << produkt << "\n";
cout << "Mittelwert = " << mittelwert << "\n";
return 0;
}
Und so sieht der Output aus:
Geben Sie zwei Zahlen zwischen 1 und 100 ein: 235 23523
1. Zahl = 235
2. Zahl = 23523
Produkt = 5527905
Mittelwert = 11879
Der Fehler lag sehr wahrscheinlich an der Person vor der Tastatur! So sind die 1. Schritte
UEZ
Ja, viel Spass dabei^^. Das ist jetzt Ernst gemeint, es gibt wunderschöne Seiten zu diesem Thema! Wenn du dich auf die Befehlssätze vom 8088 beschränkst, ist das für den Anfang absolut ausreichend, 80286 und 80386 erweitern die Befehle nur um 16- bzw 32 Bitbefehle.
Als Referenz für die Befehle hab ich hier noch einen uralten Schinken in Papierform, allerdings ist u.a. HIER eine sehr gute Online-Referenz. Passend dazu das sehr treffend geschriebene TUTORIALFür den, der eine in Assembler geschriebene dll zur Grafikbearbeitung und auch die passende AutoIt-Implementation sucht, ist HIER ein weiteres Highlight. UNBEDINGT die AutoIt Megademo ansehen!! Ist vergraben im Verzeichnis Demos und Scources (AutoIt) und dort im Verzeichnis Megademo. Eine der schönsten AutoIt-Demos, die ich bisher gesehen habe, der Code zeigt auch, wie einfach die Funktionen anzusprechen sind.
VIELEN DANK!
UEZ
Da ich mich entschlossen habe C++ zu lernen, habe ich gleich in der 1. Lektion
probleme:
// Product_Calc.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
int produkt_berechnen(int z1, int z2)
{
int ergebnis;
ergebnis = z1 * z2;
return ergebnis;
}
double mittelwert_berechnen(int z1, int z2)
{
double ergebnis;
ergebnis = (z1 + z2) / 2.0;
return ergebnis;
}
int main(int argc, char **argv)
{
//Variablen deklarieren
int zahl1, zahl2;
int produkt;
double mittelwert;
//Zahlenwerte einlesen
cout <<("Geben Sie zwei Zahlen zwischen 1 und 100 ein: ");
cin >> zahl1 >> zahl2;
//Ergebnis berechnen
produkt = produkt_berechnen(zahl1, zahl2);
mittelwert = mittelwert_berechnen(zahl1, zahl2);
//Ergebnis ausgeben
cout << "1. Zahl = " << zahl1 << "\n";
cout << "2. Zahl = " << zahl2;
cout << "Produkt = " << produkt;
cout << "Mittelwert = " << mittelwert;
return 0;
}
Irgendwie sieht der Ouput nicht so aus, wie ich es will ->
Geben Sie zwei Zahlen zwischen 0 und 100 ein: 12 55
1. Zahl = 122. Zahl = 55
Produkt = %d
660Mittelwert = %f
33.5
Ich benuzte den MS Visual C++ Kompiler!
Danke,
UEZ
Nein, aber 0/8/15-"Cracker" bekommen das nicht ohne Hilfe/Whatever hin.
0-8-15 Cracker würde ich auch nicht als Cracker bezeichnen, eher Script Kiddies oder s.ä.
Egal, sonst diskutieren wir über die Definition Cracker.
UEZ
Beispiel:
...
Sodass die potenzielen "Cracker" erstmal an C++ vorbeimüssen (sprich den ganzen Assemlber-Kram), und dann vielleicht noch Schwierigkeiten damit haben, die AutoIT Exe auszulesen. ...Gruß
Glaubst du wirklich daran, dass C++ Exe Dateien (oder ASM Code) Cracker aufhalten?
Gruß,
UEZ
Alles anzeigenSpoiler anzeigen
[autoit][/autoit] [autoit][/autoit] [autoit]
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>#Region StartUp
[/autoit] [autoit][/autoit] [autoit]
Opt("GUIOnEventMode", 1)
_GDIPlus_Startup()
$Rot = _GDIPlus_PenCreate(0xFFFF0000)
$Gruen = _GDIPlus_PenCreate(0xFF00FF00)
$Blau = _GDIPlus_PenCreate(0xFF0000FF)
#EndRegion StartUp#Region GUI
[/autoit] [autoit][/autoit] [autoit]
$hGUI = GUICreate("RandomDraw", 640, 480, -1, -1)
$Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
GUISetState(@SW_SHOW)
#EndRegion GUI#Region Loop
[/autoit] [autoit][/autoit] [autoit]
For $y = 1 To 479
For $x = 0 To 639
$Random = Random(1, 3, 1)
Switch $Random
Case 1
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Rot)
Case 2
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Gruen)
Case 3
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Blau)
EndSwitch
Next
If GUIGetMsg() = -3 Then ExitFunc()
NextWhile 1
[/autoit] [autoit][/autoit] [autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitFunc()
EndSwitch
WEnd
#EndRegion Loop#Region Func's
[/autoit]
Func ExitFunc()
_GDIPlus_PenDispose($Rot)
_GDIPlus_PenDispose($Blau)
_GDIPlus_PenDispose($Gruen)
_GDIPlus_GraphicsDispose($Graphic)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>ExitFunc
#EndRegion Func'sSchneller + übersichtlicher
Da fehlt der Eintrag GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunc").
Am besten vor GUISetState(@SW_SHOW) plazieren
Ach ja, und If GUIGetMsg() = -3 Then ExitFunc() benötigst du somit nicht mehr!
D.h. auch der Inhalt der While Schleife ist überflüssig ->
While Sleep(50)
WEnd
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region StartUp
Opt("GUIOnEventMode", 1)
_GDIPlus_Startup()
$Rot = _GDIPlus_PenCreate(0xFFFF0000)
$Gruen = _GDIPlus_PenCreate(0xFF00FF00)
$Blau = _GDIPlus_PenCreate(0xFF0000FF)
#EndRegion StartUp
#Region GUI
$hGUI = GUICreate("RandomDraw", 640, 480, -1, -1)
$Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunc")
GUISetState(@SW_SHOW)
#EndRegion GUI
#Region Loop
For $y = 1 To 479
For $x = 0 To 639
$Random = Random(1, 3, 1)
Switch $Random
Case 1
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Rot)
Case 2
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Gruen)
Case 3
_GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Blau)
EndSwitch
Next
Next
While Sleep(50)
WEnd
#EndRegion Loop
#Region Func's
Func ExitFunc()
_GDIPlus_PenDispose($Rot)
_GDIPlus_PenDispose($Blau)
_GDIPlus_PenDispose($Gruen)
_GDIPlus_GraphicsDispose($Graphic)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>ExitFunc
#EndRegion Func's
Gruß,
UEZ
Hier ein Beispiel von trancexx:
#include <GUIConstantsEx.au3>
#include <Memory.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global Const $STM_SETIMAGE = 370
[/autoit] [autoit][/autoit] [autoit]Global Const $iWidth = 810
Global Const $iHeight = 470
GUICreate("", $iWidth, $iHeight)
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0)
Global $hPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
[/autoit] [autoit][/autoit] [autoit]Global $iSize = $iWidth * $iHeight
Global $tBits = DllStructCreate("int[" & $iSize & "]")
Global $pBits = DllStructGetPtr($tBits)
Global $hBitmap, $aCall, $iHMsg
Global $hPicHandle = GUICtrlGetHandle($hPic)
Global $tRandom = DllStructCreate("dword")
Global $pRandom = DllStructGetPtr($tRandom)
GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $aRtlRandomEx = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("ntdll.dll"), "str", "RtlRandomEx")
Global $pRtlRandomEx = $aRtlRandomEx[0]
Global $aRtlMoveMemory = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("kernel32.dll"), "str", "RtlMoveMemory")
Global $pRtlMoveMemory = $aRtlMoveMemory[0]
Global $aSendMessageW = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("user32.dll"), "str", "SendMessageW")
Global $pSendMessageW = $aSendMessageW[0]
Global $aDeleteObject = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "DeleteObject")
Global $pDeleteObject = $aDeleteObject[0]
Global $aCreateBitmap = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "CreateBitmap")
Global $pCreateBitmap = $aCreateBitmap[0]
Global $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)
[/autoit] [autoit][/autoit] [autoit]Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode)
[/autoit] [autoit][/autoit] [autoit]#Region Assemply
DllStructSetData($tCodeBuffer, 1, _
"0x" & _
"33DB" & _ ; xor ebx, ebx
"68" & SwapEndian($pRandom) & _ ; push $pRandom
"B8" & SwapEndian($pRtlRandomEx) & _ ; mov eax, RtlRandomEx
"FFD0" & _ ; call eax
"8BCB" & _ ; mov ecx, ebx
"69C9" & SwapEndian(4) & _ ; imul ecx, 4
"81C1" & SwapEndian($pBits) & _ ; add ecx, $pBits
"68" & SwapEndian(3) & _ ; push 3 bytes
"68" & SwapEndian($pRandom) & _ ; push $pRandom
"51" & _ ; push ecx
"B8" & SwapEndian($pRtlMoveMemory) & _ ; mov eax, RtlMoveMemory
"FFD0" & _ ; call eax
"43" & _ ; inc ebx
"81FB" & SwapEndian($iSize) & _ ; cmp ebx, $iSize; <- compare ebx with $iSize
"75" & Hex(256 - 53, 2) & _ ; jne -53 bytes; <- this is saying go back and do it again if not equal
"68" & SwapEndian($pBits) & _ ; push $pBits
"68" & SwapEndian(32) & _ ; push BitsPerPel
"68" & SwapEndian(1) & _ ; push Planes
"68" & SwapEndian($iHeight) & _ ; push $iHeight
"68" & SwapEndian($iWidth) & _ ; push $iWidth
"B8" & SwapEndian($pCreateBitmap) & _ ; mov eax, CreateBitmap
"FFD0" & _ ; call eax
"50" & _ ; push eax
"68" & SwapEndian(0) & _ ; push IMAGE_BITMAP
"68" & SwapEndian($STM_SETIMAGE) & _ ; push STM_SETIMAGE
"68" & SwapEndian($hPicHandle) & _ ; push $hPicHandle
"B8" & SwapEndian($pSendMessageW) & _ ; mov eax, SendMessageW
"FFD0" & _ ; call eax
"50" & _ ; push eax
"B8" & SwapEndian($pDeleteObject) & _ ; mov eax, DeleteObject
"FFD0" & _ ; call eax
"C3" _ ; ret
)
#EndRegion Assembly
While 1
[/autoit] [autoit][/autoit] [autoit]#region Assembly
[/autoit] [autoit][/autoit] [autoit]DllCall("user32.dll", "int", "CallWindowProcW", _
"ptr", $pRemoteCode, _
"int", 0, _
"int", 0, _
"int", 0, _
"int", 0)
#endregion Assembly
[/autoit] [autoit][/autoit] [autoit]Sleep(10)
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit]Func SwapEndian($iValue)
Return Hex(Binary($iValue))
EndFunc ;==>SwapEndian
Func _Quit()
Exit
EndFunc ;==>_Quit
Mit Inline Assembler
Sprenger120: Benutze Opt("GUIOnEventMode", 1), damit dein Code schneller läuft!
Gruß,
UEZ
PS: wenn man das Ding lang genug laufen lässt, besteht die Wahrscheinlichkeit ein Bild aus dem Universum der Bilder dargestellt zu bekommen, jedenfalls für einen Augenblick
Sieht super aus!
Kannst ja mal _GDIPlus_StringFormatSetAlign() dir näher anschauen, um den Text einfacher zu plazieren.
Gruß,
UEZ
Alles anzeigenes gibt 2 Möglichkeiten der Einbindung von Assemblercode:
- trancexx (wie sollte es anders sein) hält es mit dem Motto der Frauen, je härter, je besser. Sie codet "zu Fuß", benutzt also keinen Assemblercode, sondern schreibt die Prozessorbefehle direkt per Bits und Bytes in den Speicher und setzt dann den Programmpointer auf diesen Code...crazy!Spoiler anzeigen
[autoit]; by trancexx
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstantsEx.au3>
#include <Memory.au3>Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global Const $STM_SETIMAGE = 370
[/autoit] [autoit][/autoit] [autoit]Global Const $iWidth = 800
[/autoit] [autoit][/autoit] [autoit]
Global Const $iHeight = 470GUICreate("", $iWidth, $iHeight)
[/autoit] [autoit][/autoit] [autoit]
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0)Global $hPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
[/autoit] [autoit][/autoit] [autoit]Global $iSize = $iWidth * $iHeight
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Global $tBits = DllStructCreate("int[" & $iSize & "]")
Global $pBits = DllStructGetPtr($tBits)Global $hBitmap, $aCall, $iHMsg
[/autoit] [autoit][/autoit] [autoit]
Global $hPicHandle = GUICtrlGetHandle($hPic)Global $tRandom = DllStructCreate("dword")
[/autoit] [autoit][/autoit] [autoit]
Global $pRandom = DllStructGetPtr($tRandom)GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $aRtlRandomEx = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("ntdll.dll"), "str", "RtlRandomEx")
[/autoit] [autoit][/autoit] [autoit]
Global $pRtlRandomEx = $aRtlRandomEx[0]Global $aRtlMoveMemory = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("kernel32.dll"), "str", "RtlMoveMemory")
[/autoit] [autoit][/autoit] [autoit]
Global $pRtlMoveMemory = $aRtlMoveMemory[0]Global $aSendMessageW = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("user32.dll"), "str", "SendMessageW")
[/autoit] [autoit][/autoit] [autoit]
Global $pSendMessageW = $aSendMessageW[0]Global $aDeleteObject = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "DeleteObject")
[/autoit] [autoit][/autoit] [autoit]
Global $pDeleteObject = $aDeleteObject[0]Global $aCreateBitmap = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "CreateBitmap")
[/autoit] [autoit][/autoit] [autoit]
Global $pCreateBitmap = $aCreateBitmap[0]Global $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)
[/autoit] [autoit][/autoit] [autoit]Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode)
[/autoit] [autoit][/autoit] [autoit]#Region Assemply
[/autoit] [autoit][/autoit] [autoit]
DllStructSetData($tCodeBuffer, 1, _
"0x" & _
"33DB" & _ ; xor ebx, ebx
"68" & SwapEndian($pRandom) & _ ; push $pRandom
"B8" & SwapEndian($pRtlRandomEx) & _ ; mov eax, RtlRandomEx
"FFD0" & _ ; call eax
"8BCB" & _ ; mov ecx, ebx
"69C9" & SwapEndian(4) & _ ; imul ecx, 4
"81C1" & SwapEndian($pBits) & _ ; add ecx, $pBits
"68" & SwapEndian(3) & _ ; push 3 bytes
"68" & SwapEndian($pRandom) & _ ; push $pRandom
"51" & _ ; push ecx
"B8" & SwapEndian($pRtlMoveMemory) & _ ; mov eax, RtlMoveMemory
"FFD0" & _ ; call eax
"43" & _ ; inc ebx
"81FB" & SwapEndian($iSize) & _ ; cmp ebx, $iSize; <- compare ebx with $iSize
"75" & Hex(256 - 53, 2) & _ ; jne -53 bytes; <- this is saying go back and do it again if not equal
"68" & SwapEndian($pBits) & _ ; push $pBits
"68" & SwapEndian(32) & _ ; push BitsPerPel
"68" & SwapEndian(1) & _ ; push Planes
"68" & SwapEndian($iHeight) & _ ; push $iHeight
"68" & SwapEndian($iWidth) & _ ; push $iWidth
"B8" & SwapEndian($pCreateBitmap) & _ ; mov eax, CreateBitmap
"FFD0" & _ ; call eax
"50" & _ ; push eax
"68" & SwapEndian(0) & _ ; push IMAGE_BITMAP
"68" & SwapEndian($STM_SETIMAGE) & _ ; push STM_SETIMAGE
"68" & SwapEndian($hPicHandle) & _ ; push $hPicHandle
"B8" & SwapEndian($pSendMessageW) & _ ; mov eax, SendMessageW
"FFD0" & _ ; call eax
"50" & _ ; push eax
"B8" & SwapEndian($pDeleteObject) & _ ; mov eax, DeleteObject
"FFD0" & _ ; call eax
"C3" _ ; ret
)
#EndRegion Assembly;While 1
[/autoit] [autoit][/autoit] [autoit]#region Assembly
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$t=timerinit()
for $i=1 to 10
DllCall("user32.dll", "int", "CallWindowProcW", _
"ptr", $pRemoteCode, _
"int", 0, _
"int", 0, _
"int", 0, _
"int", 0)
next
#endregion Assembly
$x=timerdiff($t)
msgbox(0,0,$x)
Sleep(10)
while 1
WEndFunc SwapEndian($iValue)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Return Hex(Binary($iValue))
EndFunc ;==>SwapEndianFunc _Quit()
[/autoit]
Exit
EndFunc ;==>_Quit- die zweite Möglichkeit ist "schön"
Sprungmarken, eine "richtige" Assemblersyntax und andere feine Features sind in eine fertige Assembler-UDF eingebaut.Spoiler anzeigen
[autoit]#include <ASM.au3>
[/autoit] [autoit][/autoit] [autoit]; Initial an asm object
[/autoit] [autoit][/autoit] [autoit]
Global $Asm = AsmInit()Demo1()
[/autoit] [autoit][/autoit] [autoit]
Demo2()
Demo3()
Demo4()Func Demo1()
[/autoit] [autoit][/autoit] [autoit]
; Demo 1: Using Parameters
AsmReset($Asm)
AsmAdd($Asm, "push ebp")
AsmAdd($Asm, "mov ebp, esp")
AsmAdd($Asm, "mov eax, [ebp + 08]")
AsmAdd($Asm, "add eax, [ebp + 0c]")
AsmAdd($Asm, "pop ebp")
AsmAdd($Asm, "retn 8")
ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
$Ret = MemoryFuncCall("int", AsmGetPtr($Asm), "int", 1, "int", 2)
MsgBox(0, "Demo 1: Using Parameters", "1 + 2 = " & $Ret[0])
EndFuncFunc Demo2()
[/autoit] [autoit][/autoit] [autoit]
; Demo 2: Read Time-Stamp Counter
AsmReset($Asm)
AsmAdd($Asm, "push ebp")
AsmAdd($Asm, "mov ebp, esp")
AsmAdd($Asm, "rdtsc")
AsmAdd($Asm, "mov ecx, [ebp + 08]")
AsmAdd($Asm, "mov [ecx], edx")
AsmAdd($Asm, "pop ebp")
AsmAdd($Asm, "retn 4")
ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
$start=timerinit()
$Ret = MemoryFuncCall("uint", AsmGetPtr($Asm), "uint*", 0)
MsgBox(0, "Demo 2: Read Time-Stamp Counter",timerdiff($start)& " RDTSC = " & Hex($Ret[1]) & Hex($Ret[0], 8))
Return Hex($Ret[1]) & Hex($Ret[0],
EndFuncFunc Demo3()
[/autoit] [autoit][/autoit] [autoit]
; Demo 3: Using Label
AsmReset($Asm)
AsmAdd($Asm, "mov eax, 0")
AsmAdd($Asm, "mov ecx, 10")
AsmAdd($Asm, "label:")
AsmAdd($Asm, "inc eax")
AsmAdd($Asm, "loop @label")
AsmAdd($Asm, "ret")
ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
$Ret = MemoryFuncCall("int", AsmGetPtr($Asm))
MsgBox(0, "Demo 3: Using Label", "loop label for " & $Ret[0] & " times")
EndFuncFunc Demo4()
[/autoit] [autoit][/autoit] [autoit]
; Demo 4: Call AutoIt Func From Assembly
$AutoItFunc = DllCallbackRegister("AutoItFunc", "int", "")
AsmReset($Asm)
AsmAdd($Asm, "call " & DllCallbackGetPtr($AutoItFunc))
;AsmAdd($Asm, "shl eax, 1")
AsmAdd($Asm, "ret")
ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
$Ret = MemoryFuncCall("int", AsmGetPtr($Asm))
MsgBox(0, "Demo 4: AutoIt Function", "BitShift return value of AutoItFunc: " & $Ret[0])
DllCallbackFree($AutoItFunc)
EndFuncFunc AutoItFunc()
[/autoit] [autoit][/autoit] [autoit]
MsgBox(0, "AutoItFunc", "Called by Inline Assembly")
Return 1230
EndFunc; Release the asm object
[/autoit] [autoit][/autoit] [autoit][/autoit]
AsmExit($Asm)
Exit
Welche man letztendlich nutzt, bleibt jedem selbst überlassen, aber die ASM.au3 wäre mein Favorit.
Danke für die Info (ASM.au3 und die Demo dazu kenne ich bereits). Ich dachte er daran, wie man in ASM programmiert, aber ich werde mal googeln!
Danke,
UEZ
Allerdings, ich hatte den Wink schon richtig verstanden
Das schöne an der Arbeit mit den structs ist, daß man die prospeed.dll ohne weiteres sofort einsetzen kann, das ist auch der einzige Grund, warum ich bisher den AutoIt-"Inlineassembler" nicht aktiviere. Gerade was den richtig schnellen Grafikkram betrifft, ist es besser, hier im Forum "den Ball ein wenig flach zu halten".
Sonst werden die Jungs und Mädelz im "bösen" Forum wieder aufmerksam 8o, und ich bekomme wieder haufenweise PN´s nach Pixelsearch in "hiden fenstas"
AutoIt-"Inlineassembler" - klingt interessant! Hast du was für mich (Tutorials), womit ich einige Sachen in GDI+ beschleunigen kann? trancexx hat ja schon einige sehr interessante Beispiele mit Inline ASM gezeigt, nur mir fehlt ein wenig der Einstieg.
Für Bots habe ich ehrlich gesagt auch kein Bock was zu machen - einfach uninteressant für mich!
Danke,
UEZ
Bedenke, dass die Kollisionsabfrage von Rechtecken ausgeht. Wenn du komplexere Objekte hast, wird die Kollisionsabfrage ungenauer!
Gruß,
UEZ
Du solltest die Funktion nicht ändern, sondern mit den Koordinaten der beiden Objekte füttern, so dass du ein Wert zurück bekommst, ob beide Objekte eine Kollision haben oder nicht!
Gruß,
UEZ
#include<GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
$hGUI = GUICreate("Form1", 625, 443, 192, 124)
$Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
GUISetState(@SW_SHOW)
$Rot = _GDIPlus_PenCreate (0xFFFF0000)
$Gruen = _GDIPlus_PenCreate (0xFF00FF00)
$Blau = _GDIPlus_PenCreate (0xFF0000FF)
_GDIPlus_GraphicsClear($Graphic, 0xFF000000)
_GDIPlus_GraphicsDrawLine ($Graphic,100,10,2,200, $Rot)
_GDIPlus_GraphicsDrawLine ($Graphic,100,100,2,200, $Gruen)
_GDIPlus_GraphicsDrawLine ($Graphic,200,200,2,200, $Blau)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_GDIPlus_PenDispose($Rot)
_GDIPlus_PenDispose($Blau)
_GDIPlus_PenDispose($Gruen)
_GDIPlus_GraphicsDispose($Graphic)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd
UEZ