flat assembler
Message board for the users of flat assembler.

Index > Windows > Direct access to video memory

Author
Thread Post new topic Reply to topic
A$M



Joined: 29 Feb 2012
Posts: 94
A$M 17 Feb 2014, 19:44
Hello.

Yes, I know it's impossible to do like this:
Code:
mov [0xA0000+X*(Y*W)], COLOR    

I want to know how can I write a driver or something that let me to draw directly on screen. Please, tell me what you know about or documentations about GPUs.

Thanks, LHLaurini.
Post 17 Feb 2014, 19:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 18 Feb 2014, 00:22
A$M wrote:
Yes, I know it's impossible to do like this:
Code:
mov [0xA0000+X*(Y*W)], COLOR    

I want to know how can I write a driver or something that let me to draw directly on screen. Please, tell me what you know about or documentations about GPUs.
Here is my experience with GPUs: There is no documentation. Read about the problems the Linux folk have with getting anything. Perhaps your best option is to learn CUDA or OpenCL? If you can find some proper documentation please post it so others can benefit also. I would also imagine that all the different makes and models of GPUs will have very different internal subsystems and each will require different driver code.
Post 18 Feb 2014, 00:22
View user's profile Send private message Visit poster's website Reply with quote
A$M



Joined: 29 Feb 2012
Posts: 94
A$M 18 Feb 2014, 00:30
revolution wrote:
A$M wrote:
Yes, I know it's impossible to do like this:
Code:
mov [0xA0000+X*(Y*W)], COLOR    

I want to know how can I write a driver or something that let me to draw directly on screen. Please, tell me what you know about or documentations about GPUs.
Here is my experience with GPUs: There is no documentation. Read about the problems the Linux folk have with getting anything. Perhaps your best option is to learn CUDA or OpenCL? If you can find some proper documentation please post it so others can benefit also. I would also imagine that all the different makes and models of GPUs will have very different internal subsystems and each will require different driver code.
Well, it's not good. So my best option is to use GDI? It's fast?
Post 18 Feb 2014, 00:30
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 18 Feb 2014, 01:25
Wouldn't hurt debugging a Windows graphics driver in VMware Wink Then try to make your own. But exposing your hardware like that could lead to system instability.

What makes your program so special that you need DMA?

There have been successful video games that use DirectX and never did they complain of the "lack" of DMA.
Post 18 Feb 2014, 01:25
View user's profile Send private message Reply with quote
A$M



Joined: 29 Feb 2012
Posts: 94
A$M 18 Feb 2014, 02:27
Well, I think GDI is easier.
Code:
format PE GUI 4.0
entry start

XRES = 800
YRES = 600

include "win32ax.inc"

section '.text' code readable executable
 start:
    invoke GetModuleHandle, 0
    mov [wc.hInstance], eax
    invoke LoadIcon, 0, IDI_APPLICATION
    mov [wc.hIcon], eax
    mov [wc.hIconSm], eax
    invoke LoadCursor, 0, IDC_ARROW
    mov [wc.hCursor], eax
    invoke GetStockObject, GRAY_BRUSH
    mov [wc.hbrBackground], eax

    invoke RegisterClassEx, wc
    invoke AdjustWindowRect, winrect, WS_POPUP + WS_CAPTION + WS_SYSMENU + WS_MINIMIZEBOX + WS_VISIBLE, FALSE
    mov eax, [winrect.left]
    sub [winrect.right], eax
    mov eax, [winrect.top]
    sub [winrect.bottom], eax
    invoke CreateWindowEx, NULL, class, title, WS_POPUP + WS_CAPTION + WS_SYSMENU + WS_MINIMIZEBOX + WS_VISIBLE, 100, 50, [winrect.right], [winrect.bottom], 0, 0, [wc.hInstance], 0
    test eax, eax
    jz winerror
 msg_loop:
    invoke GetMessage, wMsg, 0, 0, 0
    cmp eax, 1
    jb exit
    jne msg_loop
    invoke TranslateMessage, wMsg
    invoke DispatchMessage, wMsg
 jmp msg_loop

 winerror:
    invoke MessageBox, 0, WinError, 0, MB_ICONERROR+MB_OK
 exit:
    mov eax, [wMsg.wParam]
    invoke ExitProcess, [wMsg.wParam]

 proc WindowProc uses ebx esi edi ecx, hWnd, uMsg, wParam, lParam
    mov eax, [uMsg]
    cmp eax, WM_CREATE
    je wmCreate
    cmp eax, WM_TIMER
    je wmTimer
    cmp eax, WM_PAINT
    je wmPaint
    cmp eax, WM_CLOSE
    je wmClose
    cmp eax, WM_DESTROY
    je wmDestroy
    invoke DefWindowProcA, [hWnd], [uMsg], [wParam], [lParam]
    ret

 wmCreate:
    invoke malloc, XRES*YRES*4
    mov [pSCREEN], eax
    invoke SetTimer, [hWnd], 1, 1000/60, NULL
    ret

 wmTimer:
    invoke GetTickCount
    mov ecx, XRES*YRES
    mov edi, [pSCREEN]
    rep stosd
    invoke sprintf, title, title_format, eax
    invoke SetWindowText, [hWnd], title
    invoke InvalidateRect, [hWnd], NULL, FALSE
    ret

 wmPaint:
    invoke BeginPaint, [hWnd], psPaint
    mov [hDC], eax

    invoke SetDIBitsToDevice, [hDC], 0, 0, XRES, YRES, 0, 0, 0, YRES, [pSCREEN], BITMAPINFO, 0 ;DIB_RGB_COLORS

    invoke EndPaint, [hWnd], psPaint
    ret

 wmClose:
    invoke free, [pSCREEN]
    invoke DestroyWindow, [hWnd]
    ret

 wmDestroy:
    invoke PostQuitMessage, WM_QUIT
    ret
 endp


section '.data' data readable writeable
 winrect RECT 0,0,XRES,YRES
 wc WNDCLASSEX wcend-wc, 0, WindowProc, 0, 0, 0, 0, 0, 0, 0, class, 0
 wcend:
 class db "MAIN",0
 title db "This is your computer's tick count (...)",0,0,0,0,0,0
 title_format db "This is your computer's tick count (%08x)",0
 WinError db "Could not create window.",0
 BITMAPINFO    BITMAPINFOHEADER sizeof.BITMAPINFOHEADER,\     ; biSize
                                   XRES,\                     ; biWidth
                                   -YRES,\                    ; biHeight
                                   1,\                        ; biPlanes
                                   32,\                       ; biBitCount
                                   BI_RGB,\                   ; biCompression
                                   0,\                        ; biSizeImage
                                   0, \                       ; biXPelsPerMeter
                                   0, \                       ; biYPelsPerMeter
                                   0, \                       ; biClrUsed
                                   0                          ; biClrImportant

section '.bss' data readable writeable
 wMsg MSG
 psPaint PAINTSTRUCT
 hDC dd ?
 pSCREEN dd ?

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL',\
          gdi32,'GDI32.DLL',\
          crtdll,'CRTDLL.DLL'

  include 'api\kernel32.inc'
  include 'api\user32.inc'
  include 'api\gdi32.inc'

  import crtdll,\
         malloc,'malloc',\
         sprintf,'sprintf',\
         free,'free'
                                           

PS:
revolution wrote:
www: http://justfuckinggoogleit.com/
Ha, ha, ha. Very funny...

EDIT: Well, but if I get access to Ring 1 and I get where Windows places the VESA screen buffer, I could do this?
Post 18 Feb 2014, 02:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 18 Feb 2014, 13:30
A$M wrote:
EDIT: Well, but if I get access to Ring 1 and I get where Windows places the VESA screen buffer, I could do this?
I expect you mean Ring 0. But even so there are many complications with what you ask there. The system might not be using a VESA mode. The display driver might do something completely different. Plus the 64-bit/32-bit thing could well make your life difficult. And the latest versions of Windows only allows signed code to run with such privileges.
A$M wrote:
PS:
revolution wrote:
www: http://justfuckinggoogleit.com/
Ha, ha, ha. Very funny...
I was also considering making this my home page.
Post 18 Feb 2014, 13:30
View user's profile Send private message Visit poster's website Reply with quote
Melissa



Joined: 12 Apr 2012
Posts: 125
Melissa 18 Feb 2014, 15:14
You have open source nvidia,amd,intel drivers for Linux. Just download
Linux kernel source and look up how they did it.
Post 18 Feb 2014, 15:14
View user's profile Send private message Reply with quote
A$M



Joined: 29 Feb 2012
Posts: 94
A$M 18 Feb 2014, 18:06
Thanks.
Post 18 Feb 2014, 18:06
View user's profile Send private message Reply with quote
nmaps



Joined: 26 Oct 2012
Posts: 8
nmaps 16 Apr 2014, 03:27
You can use a DIB window (CreateDIBSection() WinAPI).
Post 16 Apr 2014, 03:27
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.