Write data to EXE file
#1
How to attach data (sound, image, etc.) to EXE files has been shown here several times.
My only question is, can the actual program also write itself, or is that only possible with a separate program?

If a program is running, you can still open it for reading, but writing is denied.
So the system, with me Windows denied the write access when a program is running.
Here's the question, is there a way to bypass the system lock?


Example program, even started as an administrator does not work. ( Regtest.bas )
Code: (Select All)
'====================Declarirung fr die Registrirung==========================================================================================
Declare Dynamic Library "kernel32"
FUNCTION GetVolumeInformationA& (lpRootPathName$, lpVolumeNameBuffer$, BYVAL nVolumeNameSize~&, _
    lpVolumeSerialNumber~&, lpMaximumComponentLength~&, lpFileSystemFlags~&, lpFileSystemNameBuffer$, BYVAL nFileSystemNameSize&)
End Declare

Declare Library: Function GetDriveType& (d$): End Declare
Dim Shared DriveType As String, SERIALFOUND As String
Dim As _Float Regist
Dim As _Float FileSize
'========================Ende der Registrirung=================================================================================================

MyAppName$ = Mid$(Command$(0), _InStrRev(Command$(0), "\") + 1)
'If MyAppName$ <> "Register-3.exe" Then System

'Open ".\Register-3.exe" For Input As #1
'FileSize = LOF(1)
'Close #1
'If FileSize = 592187 Then Else System






'===========================Code fr die Registrirung==========================================================================================
Test% = 0
SERIALSSHOW:
For q = 1 To 26: X = GetFileInfo(q): 'If SERIALFOUND <> "!!!-!!!" Then Print " "; Chr$(64 + q) + ":    "; SERIALFOUND
    If SERIALFOUND <> "!!!-!!!" And Test% = 0 Then
        Temp$ = SERIALFOUND
        Test% = 1
    End If

Next q
'Print Temp$


'file$ = _OpenFileDialog$("Datei Öffnen", "", "*.EXE", "Programdatei", 0)
file$ = ".\Regtest.exe"
Open file$ For Binary As #1
FileSize = LOF(1)
t$ = "NR"
check$ = "  "
Color 3, 5
'Print FileSize

Get #1, FileSize - 1, check$
'check$ = _MK$(_Float, Regist)
'check$ = Left$(check$, 3)
'check$ = Right$(check$, 2)

'Print check1$

'Print check$
Regist = 0




Select Case UCase$(check$)
    Case "VC" 'verified copy.  All is good
        Get #1, FileSize - 10, Regist
        String1$ = _MK$(_Float, Regist)
        String1$ = Left$(String1$, 9)

        'Print String1$
        'Print Temp$
        If UCase$(String1$) = UCase$(Temp$) Then
            Print "You have a paid copy of this software.  All is good."
        Else
            Print " Illegaler Programm Aufruf !!!!!!!"
            _Delay 5
            Close #1
            System
        End If
    Case "NR" 'already has a timestamp, is a limited time test version.  Toss NAG Screen.

        Print "This is a trial version of the program."
        Registrierung$ = _InputBox$("Regtest Registrierung", "Geben sie bitte den Registrierungs Code ein:", "Demo")
        If Registrierung$ = Chr$(36) + Chr$(82) + Chr$(101) + Chr$(103) + Chr$(105) + Chr$(115) + Chr$(116) + Chr$(101) + Chr$(114) + Chr$(64) Then '$Register@

            Get #1, FileSize - 10, Regist
            String1$ = _MK$(_Float, Regist)
            Color 3, 6
            String1$ = Left$(String1$, 9)
            If UCase$(String1$) = UCase$(Temp$) Then
                Print "Programm wurde manipuliert"
            Else
                Print "Schreibe VC in Datei"
                Sleep 5
                Temp$ = Temp$ + "VC"
                Put #1, FileSize - 1, Temp$
                Print "Programm wurde Registriert "
                _NotifyPopup "Regtest", "Ihre Registrierung war Erfolgreich", "info" ' "info" , "warning" oder "error"
                Close #1
                _Delay .5
                'Open file$ For Binary As #1
                'FileSize = LOF(1)
                'Get #1, FileSize - 10, Regist
                'String1$ = _MK$(_Float, Regist)
                'Color 3, 6
                'String1$ = Left$(String1$, 9)
                'Print "RegTest " + String1$

                Sleep
                Close #1
            End If
        Else
            Print " Ihr Code ist Falsch "
            _NotifyPopup "Regtest", "Ihre Registrierung ist Fehlgeschlagen", "warning"
        End If

    Case Else 'first run.
        Print "Illegal copy of software!  Terminating Now!"
        Print " Schreibe NR in Datei"
        Sleep 5
        'Print check$
        Put #1, FileSize + 1, t$
        'Print t$
        Sleep
        Close #1
        End
End Select
Close #1

'=======================================Code ende Registrirung ====================================================================


'==================================Funtionen fr die Registrirung =================================================
Function GetFileInfo (D)
    SERIALFOUND = "!!!-!!!":
    If DRIVEEXISTS(D) <> 1 Then GetFileInfo = 0: Exit Function
    Dname$ = Chr$(D + 64) + ":\": Sname$ = Space$(260)
    R = GetVolumeInformationA(Dname$ + Chr$(0), Vname$, 260, serial~&, empty1~&, empty2~&, Sname$, 260)
    If R = 0 Then Exit Function
    Sname$ = Left$(Hex$(serial~&), 4) + "-" + Right$(Hex$(serial~&), 4)
    SERIALFOUND = "" + Sname$ + ""
    GetFileInfo = -1
End Function
'---
Function DRIVEEXISTS (V)
    DRIVEEXISTS = 0: varX$ = Chr$(V + 64) + ":\" + Chr$(0): VarX = GetDriveType(varX$): If VarX > 1 Then DRIVEEXISTS = 1
End Function
'===========================================Ende der Registrirung==========================
Reply


Messages In This Thread
Write data to EXE file - by Steffan-68 - 05-14-2023, 05:18 PM
RE: Write data to EXE file - by SMcNeill - 05-14-2023, 05:41 PM
RE: Write data to EXE file - by Steffan-68 - 05-14-2023, 08:37 PM
RE: Write data to EXE file - by mnrvovrfc - 05-14-2023, 10:31 PM
RE: Write data to EXE file - by Steffan-68 - 05-15-2023, 09:58 AM
RE: Write data to EXE file - by euklides - 05-15-2023, 03:00 PM
RE: Write data to EXE file - by Steffan-68 - 05-15-2023, 04:23 PM
RE: Write data to EXE file - by Kernelpanic - 05-15-2023, 05:21 PM
RE: Write data to EXE file - by Steffan-68 - 05-15-2023, 06:41 PM



Users browsing this thread: 3 Guest(s)