NetVision-Technik

Zur?ck   NetVision-Technik > Forum > Programmierung > C / C++

C / C++ Hier findet ihr Code-Schnipsel zu C & C++

Antwort
 
Themen-Optionen Ansicht
Alt 09.02.2009, 19:59   #1
scannt EXE-Dateien auf Key-Strings
Bluesteel Bluesteel ist offline 09.02.2009, 19:59

hier hätte ich noch einen
er scannt exe dateien auf Key strings

Code:
#include <io.h>

#include <fcntl.h>



int LoadConfig()

{

    int file;

    long size;

    long pos;

    long cfgpos;

    char *buffer;

    char cfgheader[20];

    CString cfgdata;



    file = _open(GetEXEFile(), _O_BINARY | _O_RDONLY);

    if (file == -1)

    {

        DEBUGMSG("CApp::LoadConfig() can't open EXE file");

        return 0;  // if we can't read config, we also can't enter stealth mode!

    }



    _lseek(file, 0, SEEK_END);

    size = _tell(file);

    buffer = (char *) malloc(size + 1);

    if (!buffer)

    {

        DEBUGMSG("CApp::LoadConfig() can't malloc() memory for EXE file");

        return 0;  // if we can't read config, we also can't enter stealth mode!

    }

    _lseek(file, 0, SEEK_SET);

    _read(file, buffer, size);

    _close(file);



    strcpy(cfgheader, "#####");  // configure this to match your desired data key

    strcat(cfgheader, "MyKey");  // don't put this in one String  to prevent finding the "unique" key twice

    strcat(cfgheader, "#####");

    for (pos = 0; pos < size - 15; pos++)

    {

        if (!memcmp(buffer + pos, cfgheader, 15)) break;

    }



    if (pos == size - 15)              //if no data attached, do nothing

    {

        return 1;

    }



    cfgpos = pos + 15;                 //calculate where the config data begins



    buffer[size] = 0;

    cfgdata = buffer + cfgpos;



    free(buffer);



    m_strConfig = cfgdata;



    //DEBUGMSG(STR(cfgdata));



    return 1;

}
oder der hier er startet aplikationen und wartetauf ein return
Code:
int RunApplication(CString strPath, CString strArgs)

{

    BOOL                rc;

    STARTUPINFO   si;

    PROCESS_INFORMATION pi;

    CString    strCmdLine;



    strCmdLine.Format("%s %s", strPath, strArgs);  // why don't we use CreateProcess' 1st parameter?

    ZeroMemory(&si, sizeof(si));

    si.CB  = sizeof(si);

    ZeroMemory(&pi, sizeof(pi));

    rc = CreateProcess(NULL,

                strCmdLine.GetBuffer(strCmdLine.GetLength() + 1),

                NULL,

                NULL,

                FALSE,

                0,

                NULL,

                NULL,

                &si,

                &pi);

    if (rc)

    {

        WaitForSingleObject(pi.hProcess, INFINITE); // Wait until child process exits.

        CloseHandle(pi.hProcess);               // Close process and thread handles.

        CloseHandle(pi.hThread);

    }

    return rc;

}
einen hab ich noch und zwar nen extension zum splitten von strings
Code:
CString StringPart(CString str, char cDelimiter, int nIndex)

{

    if (str.Find(cDelimiter) == -1) return str;



    int iPos = 0;

    int iEnd;

    CString str2;



    while (nIndex--)

    {

        iPos = str.Find(cDelimiter, iPos) + 1;

        if (!iPos) return str2;

    }



    iEnd = str.Find(cDelimiter, iPos);

    if (iEnd == -1) iEnd = str.GetLength();



    str2 = str.Mid(iPos, iEnd - iPos);



    return str2;

}



int StringPartCount(CString str, char cDelimiter)

{

    if (str.IsEmpty()) return 0;

    return str.Remove(cDelimiter) + 1;

}



int StringPartBegin(CString str, char cDelimiter, int nIndex)

{

    if (str.Find(cDelimiter) == -1) return 0;

    if (str.IsEmpty()) return 0;

    if (nIndex == 0) return 0;



    int iPos = 0;

    while (nIndex--)

    {

        iPos = str.Find(cDelimiter, iPos) + 1;

        if (!iPos) return iPos;

    }



    return iPos;

}
so das soll es erstmal gewesen sein
__________________




Ge?ndert von Bluesteel (09.02.2009 um 20:05 Uhr).

 
Benutzerbild von Bluesteel
Bluesteel
Super-Moderator
Letzte Erfolge
Registriert seit: 27.05.2008
Ort: zu hause
Beitr?ge: 2.029
Abgegebene Danke: 510
Erhielt 302 Danke für 52 Beiträge
Downloads: 48
Uploads: 2
Nachrichten: 1565
Hits: 9625
Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, G?ste: 1)
 
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beitr?ge zu antworten.
Es ist Ihnen nicht erlaubt, Anh?nge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beitr?ge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:10 Uhr.


Powered by vBulletin® Version 3.8.9 (Deutsch)
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Template-Modifikationen durch TMS