Pages

duminică, 4 august 2024

FASM : writing on the screen with assembly programming language.

I haven't worked in assembly language for a long time. My favorite is FASM.
Here is an example of older source code that randomly displays some colored pixels.
If you change this line of source code, you will see that it is written directly on the screen from Windows 10:
invoke FindWindow,NULL,<'Random Pixels Screen'>
this is the result:
... using this you cannot be able to take a screenshot with Windows shortkeys:
invoke FindWindow,NULL,<'Random Pixels ...'>
This is the source code, if you want to test it:
format pe console
entry start

include 'INCLUDE/WIN32AX.INC'

section '.code' code readable writeable executable 

start:   
     invoke GetStdHandle,STD_OUTPUT_HANDLE
     mov [stdout],eax
          
     mov [rect.Left],0
     mov [rect.Top],0
     mov [rect.Right],79
     mov [rect.Bottom],44
     mov [coord.x],8
     mov [coord.y],40
     mov [cinfo.dwSize],25
     mov [cinfo.bVisible],FALSE
     
     cinvoke system,<'cls'>
     cinvoke srand,<cinvoke time,NULL>
     invoke SetConsoleTitle,<'Random Pixels Screen'>
     invoke SetConsoleWindowInfo,[stdout],1,rect
     invoke SetConsoleScreenBufferSize,[stdout],dword[coord]   
     invoke SetConsoleCursorInfo,[stdout],cinfo
     
     invoke FindWindow,NULL,<'Random Pixels ...'>
     mov [hWnd],eax
     invoke GetDC,[hWnd]
     mov [hdc],eax
                                     
@@:   
     cinvoke rand
     shl eax,9
     push eax
     cinvoke rand
     pop ecx
     add eax,ecx
     mov esi,eax
     invoke SetPixel,[hdc],<stdcall rnd,640>,<stdcall rnd,100>,esi
     cinvoke _kbhit
     test eax,eax
     jz @b
     invoke ExitProcess,0

proc rnd max
     cinvoke rand 
     shl eax,17
     mul [max]
     mov eax,edx            
     ret
endp    

section '.data' data readable writeable

struc COORD {
     .x dw ?
     .y dw ?
    } 

struc SMALL_RECT {
     .Left dw ?
     .Top dw ?
     .Right dw ?
     .Bottom dw ?
    } 

struc LPCONSOLE_CURSOR_INFO {
     .dwSize dd ?
     .bVisible db ?
    }      
     
     cinfo LPCONSOLE_CURSOR_INFO
     rect SMALL_RECT
     coord COORD     
          
     stdout dd ?
     hWnd dd ?
     hdc dd ?

     
section '.idata' import data readable writeable

     library kernel32,'kernel32.dll',\
        msvcrt,'msvcrt.dll',\
        user32,'user32.dll',\
        gdi32,'gdi32.dll'
         
     import gdi32,\
        SetPixel,'SetPixel'
                  
     import user32,\
        GetDC,'GetDC',\
        FindWindow,'FindWindowA'
             
     import kernel32,\     
        ExitProcess,'ExitProcess',\
        GetStdHandle,'GetStdHandle',\
        SetConsoleTitle,'SetConsoleTitleA',\
        SetConsoleCursorInfo,'SetConsoleCursorInfo',\
        SetConsoleWindowInfo,'SetConsoleWindowInfo',\
        SetConsoleCursorPosition,'SetConsoleCursorPosition',\
        SetConsoleScreenBufferSize,'SetConsoleScreenBufferSize'   
            
     import msvcrt,\
        _kbhit,'_kbhit',\
        system,'system',\      
        srand,'srand',\
        rand,'rand',\
        time,'time'

News : Inkscape Is About To Revolutionize The Shape Builder | v1.4 Beta Update

Inkscape : Create an extension for inkscape.

You can create your own extensions in inkscape with all features you need to improve the working area.
One extension can have minimum two file: the basic Python source code and another file with the graphic user interface ...
The source code of Python file can be link with the G.U.I. source code type file INX.
The source code for python can be customized and this is the main reason is no need to add it here.
Let's see the source code for the INX file:
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
    <name>Default extension example</name>
    <id>default.extensions.example</id>
    <param name="tab" type="notebook">
        <page name="Options" gui-text="Options">
            <param name="value_int" type="int" min="0" max="9" gui-text="INT type value from 0 up to 9 : ">10</param>
            <param name="value_bool" type="bool" gui-text="BOOL value set to false : ">false</param>
            <param name="value_space" type="float" gui-text="FLOAT value set to 0.1 custom range min 0.0 up max=99.0 : " min="0.0" max="99.0">0.1</param>
                <param name="option_group selection" type="optiongroup" appearance="combo" gui-text="Options :">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
            </param>
		<param name="grouppick" type="bool" gui-text="selection pick ..." gui-description="This is gui-description">false</param>
            <param name="pickmode" type="optiongroup" appearance="combo" gui-text="pick values group:">
                <option value="first">first</option>
                <option value="second">second</option>
            </param> 
	</page>
        <page name="Help" gui-text="Help for default extension example">
            <label xml:space="preserve">This is example of default extension example
	You can use this INX file and PY files type named 'default_extension_example'</label>
        </page>
    </param>
    <effect>
        <object-type>all</object-type>
        <effects-menu>
            <submenu name="catafest"/>
        </effects-menu>
    </effect>
    <script>
        <command location="inx" interpreter="python">default_extension_example.py</command>
    </script>
</inkscape-extension>
Bellow you can see some screenshots with these result