Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Main/Obfuscate/Obfuscate App
Required plugins for this example:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/Obfuscate/Obfuscate App
This example is the version from Fri, 18th Sep 2014.
Project "Obfuscate App.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub OpenDocument(item As FolderItem) if item<>Nil then dic = new Dictionary LibCount = 0 ProcessLibraries Item processApps item MsgBox str(dic.Count)+" files renamed and "+str(LibCount)+" files modified." end if End EventHandler
Function Untitled() As Boolean Return True End Function
Protected Sub ProcessFile(f as FolderItem) if f.Length = 0 then Return // empty file dim b as BinaryStream = BinaryStream.Open(f, false) dim changed as Boolean = false dim oldData as string = b.Read(b.Length) b.Close if lenb(oldData) = 0 then Break Return end if dim NewData as string = oldData dim c as integer = dic.Count-1 for i as integer = 0 to c dim key as Variant = dic.Key(i) dim oldName as string = key dim newName as string = dic.Value(key) dim p as integer = instrb(NewData, oldName) while p > 0 changed = true NewData = leftb(NewData, p-1) + newName + midb(NewData, p+lenb(oldName)) p = instrb(NewData, oldName) wend next if lenb(NewData) <> lenb(oldData) then Break end if if changed then LibCount = LibCount + 1 b = BinaryStream.open(f, true) b.Write NewData b.Close end if End Sub
Protected Sub ProcessLib(f as FolderItem) if Right(f.name, 3) = ".so" then processLib f, ".so" Return end if if Right(f.name,4) = ".dll" then if left(f.name,4) <> "MSVC" then // MSVC*.dll don't like to be renamed processLib f, ".dll" end if end if if Right(f.name, 6) = ".dylib" then processLib f, ".dylib" end if End Sub
Protected Sub ProcessLib(f as FolderItem, extension as string) dim NewName as string dim OldName as string = f.name if dic.HasKey(OldName) then NewName = dic.Value(OldName) f.name = NewName Return end if NewName = extension while lenb(NewName) < lenb(OldName) dim r as integer = Rnd*26 + 65 NewName = Encodings.ASCII.Chr(r) + NewName wend f.Name = NewName dic.Value(OldName) = NewName End Sub
Protected Sub ProcessLibraries(item as FolderItem) dim c as integer = item.Count dim files() as FolderItem for i as integer = 1 to c dim f as FolderItem = item.TrueItem(i) if f = nil then // ignore elseif f.Directory then ProcessLibraries f elseif f.Visible then files.append f end if next for each f as FolderItem in files ProcessLib f next End Sub
Protected Sub processApps(item as FolderItem) dim files() as FolderItem dim c as integer = item.Count for i as integer = 1 to c dim f as FolderItem = item.TrueItem(i) if f = nil then // ignore elseif f.Directory then if f.Name = "XojoFramework.framework" then // ignore else processApps f end if elseif f.Visible then files.Append f end if next for each f as FolderItem in files ProcessFile f next End Sub
Property Protected LibCount As Integer
Property Protected dic As Dictionary
End Class
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim f as FolderItem = SelectFolder 'GetOpenFolderItem(FileTypes1.SpecialAny) if f<>Nil then app.OpenDocument f end if End EventHandler
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Filetype special/any
Filetype special/folder
End FileTypes1
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Main Plugin.

MBS Xojo Plugins