StringCaseSense On Chars = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ gui, add, button, w100 gOpen,Open File gui, add, text, x+10,var name: gui, add, edit, x+10 w100 vName,File gui, add, text, x+10,extract to: gui, add, edit, x+10 w100 vwriteto,file.ext gui, add, edit, r40 w510 vOutput xm gui, show return Open: gui, submit, nohide fileselectFile,file BinRead(file,data) Bin2Hex(h,data,0) output = count = 0 loop, { if not h break stringleft, peice%A_index%,h,16000 stringtrimright,h, h,16000 output := output "`n" name "_peice" A_index " = " peice%A_index% count ++ } output := output "`n`nWriteFile(""" writeto """,""" loop, %count% output := output name "_peice" A_index "|" stringtrimright,output,output,1 output := output """) `n`n" function = (join`n WriteFile(file,peices) { global local Handle,data,hex Handle := DllCall("CreateFile","str",file,"Uint",0x40000000 ,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0) Loop,parse,peices,| { peice := `%A_loopfield`% data := data peice } Loop, { if strlen(data) = 0 break StringLeft, Hex, data, 2 StringTrimLeft, data, data, 2 Hex = 0x`%hex`% DllCall("WriteFile","UInt", Handle,"UChar *", Hex ,"UInt",1,"UInt *",UnusedVariable,"UInt",0) } DllCall("CloseHandle", "Uint", Handle) return } ) output := output function guicontrol,,output,%output% return Bin2Hex(ByRef h, ByRef b, n=0) ; n bytes binary data -> stream of 2-digit hex { ; n = 0: all (SetCapacity can be larger than used!) format = %A_FormatInteger% ; save original integer format SetFormat Integer, Hex ; for converting bytes to hex m := VarSetCapacity(b) If (n < 1 or n > m) n := m Address := &b h = Loop %n% { x := *Address ; get byte in hex StringTrimLeft x, x, 2 ; remove 0x x = 0%x% ; pad left StringRight x, x, 2 ; 2 hex digits h = %h%%x% Address++ } SetFormat Integer, %format% ; restore original format } BinRead(file, ByRef data, n=0, offset=0) { h := DllCall("CreateFile","Str",file,"Uint",0x80000000,"Uint",3,"UInt",0,"UInt",3,"Uint",0,"UInt",0) IfEqual h,-1, SetEnv, ErrorLevel, -1 IfNotEqual ErrorLevel,0,Return,0 ; couldn't open the file m = 0 ; seek to offset IfLess offset,0, SetEnv,m,2 r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m) IfEqual r,0, SetEnv, ErrorLevel, -3 IfNotEqual ErrorLevel,0, { t = %ErrorLevel% ; save ErrorLevel to be returned DllCall("CloseHandle", "Uint", h) ErrorLevel = %t% ; return seek error Return 0 } m := DllCall("GetFileSize","UInt",h,"Int64 *",r) If (n < 1 or n > m) n := m Granted := VarSetCapacity(data, n, 0) IfLess Granted,%n%, { ErrorLevel = Mem=%Granted% Return 0 } result := DllCall("ReadFile","UInt",h,"Str",data,"UInt",n,"UInt *",Read,"UInt",0) if (!result or Read < n) t = -3 IfNotEqual ErrorLevel,0, SetEnv,t,%ErrorLevel% h := DllCall("CloseHandle", "Uint", h) IfEqual h,-1, SetEnv, ErrorLevel, -2 IfNotEqual t,,SetEnv, ErrorLevel, %t%-%ErrorLevel% Return Read }