Also als allererstes mal ein Frohes neues an alle...
So und gleich zu meinem eigentlichen Problem, ich versuche mir ein UDF zu schreiben mit dem ich Dateien Patchen kann...
Code
#include-once
$file = FileOpenDialog ("",@ScriptDir,"")
$a = "AAA"
_patchfile ($file,2,$a,0)
Func _patchfile ($file, $position, $data, $hex=0)
Local $AFO_h
Local $AFW_r, $AFW_n, $AFW_i
Local $AFW_ptr
Local $AFSP_r
Local $AFC_r
$AFO_h = DllCall( "kernel32.dll", "hwnd", "CreateFile","str", $file,"long", BitOR( 0x80000000,0x40000000),"long", 0,"ptr", 0,"long", 4,"long",0x00000080,"long", 0 )
$AFSP_r = DllCall( "kernel32.dll", "long", "SetFilePointer","hwnd",$AFO_h[0],"long",$position,"long*",0,"long",0 )
If $hex = 0 Then
$AFW_n = StringLen($data)+1
$AFW_ptr = DllStructCreate("char["&$AFW_n&"]")
DllStructSetData($AFW_ptr,1,String($data))
Else
$data = StringSplit($data,",")
$AFW_n = $data
$AFW_ptr = DllStructCreate("byte[" & $AFW_n & "]")
For $AFW_i = 1 to $AFW_n
DllStructSetData($AFW_ptr,1,Dec($data[$AFW_i]),$AFW_i)
Next
EndIf
$AFW_r = DllCall( "kernel32.dll", "int", "WriteFile","hwnd", $AFO_h[0],"ptr",DllStructGetPtr($AFW_ptr),"long",$AFW_n,"long*",0,"ptr",0 )
SetError($AFW_r[0])
Return $AFW_r[4]
$AFC_r = DllCall( "kernel32.dll", "int", "CloseHandle","hwnd", $AFO_h[0] )
EndFunc
Alles anzeigen
Das Problem das ich habe ist, an $data hängt er während dem Patchen immer ein "00" (in HEX) an... jemand eine Idee was ich falsch mache?
Grüßle AlkoholiX