Jump to content

Recommended Posts

Posted

hi all...

1st to all i sorry for my english

now... i want to make a antihacking sistem for a game,

i make a program to verify all files on size after if all files is ok, run the game (game.exe)

problem is : other people can open from game.exe without to test files

now i want to do something like this:

i want to compile my program with game.exe (something like FileInstall) and when i want to runit, i run it without extracting.

other ideas is welcome.

Thanks in advance!

ps. again sorry for my english

Posted (edited)

Maybe...

Dim $s_TempFile, $s_FileName, $s_Path
; remove all files and folder when Autoit exits
OnAutoItExitRegister("CleanUp")
; generate unique filename in @TempDir
$s_TempFile = __TempFile()
; get the folder/path
$s_Path = _FileGetPath($s_TempFile)
; create a unique folder to remove later
DirCreate($s_Path & "\My_Removable_Dir")
; reset the path to the removable folder
$s_Path = $s_Path & "\My_Removable_Dir\"
; set the folder as "Hidden"
FileSetAttrib($s_Path, "H", 1)
; generate unique filename in given directory and starting with tst_ for your files
$s_FileName = __TempFile($s_Path, "tst_", ".txt", 7)
; export the installed files (as needed)
FileInstall("C:\Programs\My_Files_I_Want\To_Install.txt.", $s_FileName)
;FileInstall("C:\Programs\My_Files_I_Want\To_Install.txt.", $s_FileName2)
MsgBox(4096, "Info", "Names for new temporary file : " & @LF & $s_TempFile & @LF & $s_FileName & @LF & "Path = " & $s_Path & @LF & "Attribue : " & FileGetAttrib($s_Path))

; ------------- FUNCTIONS ----------------
Func __TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7) ; AKA _TempFile
 ; Check parameters
 If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir ; First reset to default temp dir
 If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir ; Still wrong then set to Scriptdir
 ; add trailing \ for directory name
 If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\"
 ;
 Local $s_TempName
 Do
  $s_TempName = ""
  While StringLen($s_TempName) < $i_RandomLength
   $s_TempName = $s_TempName & Chr(Random(97, 122, 1))
  WEnd
  $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension
 Until Not FileExists($s_TempName)
 Return $s_TempName
EndFunc   ;==>__TempFile
Func _FileGetPath($szPath)
 Local $pos = StringInStr($szPath, "\", 0, -1)
 Local $dir = StringLeft($szPath, $pos)
 Return $dir
EndFunc   ;==>_FileGetPath
Func CleanUp()
 DirRemove($s_Path,1)
 Exit
EndFunc   ;==>CleanUp

8)

EDIT: Added a removeable directory

Edited by Valuater

NEWHeader1.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...