Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Well now, here's something pretty useless-Binary File Editor


  • Please log in to reply
No replies to this topic
User2009
  • Guests
  • Last active:
  • Joined: --
It edits Binary Files, well anyway I tested it and it works, so I thought that I should give a post..
Simple, just select file to be edited, and it reads the file data, replaces all binary 0s to "|" , all binary 10s to "|n" and all |s to "||" ...
Press save button to save as the same file selected...
The purpose for the |s is to have an EscChar for characters that dont display in edits..
So if you edit a "| ", "|n", or "||", then make sure you edit it all correctly or it doesnt work, the | is used as the Escape Char for 3 characters
The Purpose for the script?...pff..Make use of it yourself ^^
I've only used it to edit some swf texts in uncompressed format..other than that..I don't see much use for it..
but I saw that they offered hex editors online, so it has to be useful for something
Feel free to edit
SetBatchLines -1

FileSelectFile,File
If(ErrorLevel==1)
	ExitApp
FileGetSize,Size,% File
FileRead,Data,% File

Pointer:=&Data

Gui,Add,Edit,x5 y5 w50 h20 vname,0`%
Gui,Show
Data:=Mem2Hex(Pointer,Size)
Gui,Destroy
Gui,Font,s9,Arial Unicode MS
Gui,Add,Edit,x5 y5 w800 h500 vname,
Gui,Add,Button,x5 y510 w50 h20 gSave,Save
Gui,Show
GuiControl,,name,% Data
Return

Mem2Hex(Pointer,Size){
     pn:=1
     Loop % Size{
          pt:=Round(a_index*100/Size)
          If(pt>pn)
               GuiControl,,name,% pn++ "`%"
          N:=NumGet(Pointer+a_index-1,0,"UChar")
          if(N>0 && N!=10 && N!=124)
	Hex.=Chr(N)
          else if(N==0)
	Hex.="| "
          else if(N==10)
	Hex.="|n"
          else if(N==124)
	Hex.="||"
     }
     Return Hex
}

Esc::
GuiClose:
ExitApp

Save:
GuiControlGet,Data,,name
GoNum(Data, File, Size)
Return


GoNum(Dat,File, Size){
StringReplace,Data,Dat,||,-,All
StringReplace,Data,Data,|n,-,All
StringReplace,Data,Data,% "| ",-,All
Size:=StrLen(Data), Pointer:=&Data
StringSplit,D,Dat
mn:=1, pn:=1
     Loop % Size{
          pt:=Round(a_index*100/Size)
          If(pt>pn)
          	ToolTip % pn++ "`%"
          if(D%mn%=="|"){
               mn++
               if(D%mn%==" ")
	     NumPut(00,Pointer+a_index-1,0,"UChar")
               else if(D%mn%=="n")
	     NumPut(10,Pointer+a_index-1,0,"UChar")
               else NumPut(124,Pointer+a_index-1,0,"UChar")
          }
          mn++
     }
offset:=0, n:=0
FileDelete % File
   h := DllCall("CreateFile",Str,file,UInt,0x40000000,UInt,0,UInt,0,UInt,4,UInt,0,UInt,0)
   m:=0
   IfLess offset,0, SetEnv,m,2
   r := DllCall("SetFilePointerEx",UInt,h,Int64,offset,UIntP,&Data,Int,m)
   m := VarSetCapacity(Data)
   If (n < 1 or n > m)
       n := m
   DllCall("WriteFile",UInt,h,Str,Data,UInt,n,UIntP,W,UInt,0)
   DllCall("CloseHandle", UInt, h)

ToolTip
}
Some code from tips n tricks ^^