flat assembler
Message board for the users of flat assembler.
Index
> Windows > pointer to buffer Goto page 1, 2 Next |
Author |
|
LocoDelAssembly 28 Jun 2010, 23:35
Quote:
lea should be mov instead. |
|||
28 Jun 2010, 23:35 |
|
Teehee 28 Jun 2010, 23:39
still the same with mov..
[edit]at least it show a rectangle char symbol, but only one. |
|||
28 Jun 2010, 23:39 |
|
bitshifter 29 Jun 2010, 04:12
I would guess this rect is local to a procedure?
If so... Code: mov esi,[hTextBuff] mov byte[esi],'a' mov byte[esi+1],'b' mov byte[esi+2],0 lea edx,[rect] invoke DrawText,ebx,esi,-1,edx,DT_NOCLIP Also, what does DrawText return? |
|||
29 Jun 2010, 04:12 |
|
edemko 29 Jun 2010, 04:43
Should not "VirtualUnlock" be used - as i know "mov [hTextBuff],eax" is a pointer to a record the system takes care of? I must confess that always using HeapRe/Alloc/Free/ thus do not know sure in your case.
|
|||
29 Jun 2010, 04:43 |
|
revolution 29 Jun 2010, 05:25
Teehee: Post all your code. We can't help you with such limited information.
|
|||
29 Jun 2010, 05:25 |
|
Alphonso 29 Jun 2010, 07:22
Code: invoke VirtualAlloc,0,4*1024,MEM_RESERVE+MEM_COMMIT,PAGE_READWRITE mov [hTextBuff],eax ;check eax b4 this for error ... mov esi,[hTextBuff] ; lea esi,[hTextBuff] is wrong mov byte[esi],'a' ; or just mov dword[esi],'ab' ;equivalent to 'ab',0,0 mov byte[esi+1],'b' ; mov byte[esi+2],0 ; ... ; esi ebx and rect set correctly before call ; mov esi,[hTextBuff] ; mov ebx,[hDC] ; ? whatever your DC is called invoke DrawText,ebx,esi,-1,rect,DT_NOCLIP ; ... rect dd 0,0,40,20 ; Text area 40 long x 20 high from top left corner (0,0) |
|||
29 Jun 2010, 07:22 |
|
Tyler 29 Jun 2010, 07:43
bitshifter wrote:
http://msdn.microsoft.com/en-us/library/dd162498%28VS.85%29.aspx |
|||
29 Jun 2010, 07:43 |
|
ManOfSteel 29 Jun 2010, 08:51
^ I don't think bitshifter was asking Teehee about the API's return values in general, but rather he was asking Teehee to add a cmp after invoking the API to get the return value and check if the API is successful or not.
Last edited by ManOfSteel on 29 Jun 2010, 08:52; edited 1 time in total |
|||
29 Jun 2010, 08:51 |
|
bitshifter 29 Jun 2010, 08:52
LOL
no, i meant during runtime... |
|||
29 Jun 2010, 08:52 |
|
Teehee 29 Jun 2010, 12:54
here the entire code:
Code: format PE GUI 4.0 entry start include 'win32w.inc' section '.text' code readable executable start: ; main window regclass invoke GetModuleHandle,0 mov [hInstance],eax mov [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc test eax,eax jz error ; CodeBox regclass invoke LoadCursor,0,IDC_IBEAM mov [wc.hCursor],eax mov [wc.style],CS_GLOBALCLASS+CS_DBLCLKS mov [wc.lpfnWndProc],CodeBoxProc mov [wc.cbWndExtra],4 mov [wc.hbrBackground],1 mov [wc.lpszClassName],_codebox_class invoke RegisterClass,wc test eax,eax jz error ; center window invoke GetSystemMetrics,SM_CXSCREEN sub eax,600 shr eax,1 push eax invoke GetSystemMetrics,SM_CYSCREEN sub eax,700 shr eax,1 pop ebx ; create main window invoke CreateWindowEx,0,_mainWnd_class,_mainWnd_title,WS_VISIBLE+WS_SYSMENU,ebx,eax,600,700,NULL,NULL,[hInstance],NULL test eax,eax jz error ; main loop msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK end_loop: invoke ExitProcess,[msg.wParam] ; ===================== MainWindowProc =============================== proc MainWindowProc hwnd,wmsg,wparam,lparam push ebx esi edi mov eax,[wmsg] cmp eax,WM_SETFOCUS je .wm_setfocus cmp eax,WM_CREATE je .wm_create cmp eax,WM_DESTROY je .wm_destroy .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .ret1 .wm_setfocus: invoke SetFocus,[hCodeBox] jmp .ret0 .wm_create: ; create CodeBox font ;FF_DONTCARE invoke CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_MODERN,_CourierNewFont mov [hCodeFont],eax ; create CodeBox invoke CreateWindowEx,0,_codebox_class,NULL,WS_CHILD+WS_VISIBLE+WS_HSCROLL+WS_VSCROLL+ES_NOHIDESEL,0,0,400,450,[hwnd],NULL,[hInstance],NULL mov [hCodeBox],eax ; init text buffer invoke VirtualAlloc,0,4*1024,MEM_RESERVE+MEM_COMMIT,PAGE_READWRITE mov [hTextBuff],eax jmp .ret0 .wm_destroy: invoke VirtualFree,[hTextBuff],4*1024,MEM_RELEASE invoke PostQuitMessage,0 .ret0:xor eax, eax .ret1:pop edi esi ebx ret endp ; ===================== CodeBoxProc =============================== proc CodeBoxProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_PAINT je .cb_paint cmp [wmsg],WM_CHAR je .cb_char cmp [wmsg],WM_DESTROY je .cb_destroy .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .ret1 .cb_paint: invoke BeginPaint,[hwnd],codeBoxPS mov ebx,eax ; eax = hDC invoke SelectObject,ebx,[hCodeFont] mov esi,[hTextBuff] mov byte[esi],'a' mov byte[esi+1],'b' mov byte[esi+2],0 invoke DrawText,ebx,esi,-1,rect,DT_NOCLIP ;invoke TextOut,ebx, 0, 0, _mainWnd_title, 7 ; size invoke EndPaint,[hwnd],codeBoxPS jmp .ret0 .cb_char: mov eax,[wparam] ; char code ;lea edi,[hTextBuff] ;mov byte[edi],'a' ;mov byte[edi+1],'b' ;mov byte[edi+2],0 jmp .ret0 .cb_destroy: invoke PostQuitMessage,0 .ret0:xor eax, eax .ret1:pop edi esi ebx ret endp section '.data' data readable writeable wc WNDCLASS 0,MainWindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_mainWnd_class msg MSG codeBoxPS PAINTSTRUCT rect RECT 0,0,100,100 hInstance dd ? hCodeFont dd ? hCodeBox dd ? hTextBuff dd ? char_id dd 0 _mainWnd_class TCHAR 'FASMIDE',0 _mainWnd_title TCHAR 'fasmIDE',0 _codebox_class TCHAR 'CODEBOX',0 _CourierNewFont TCHAR 'Courier New',0 _error TCHAR 'Startup failed.',0 section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',gdi32,'GDI32.DLL',\ comctl32,'COMCTL32.DLL',shell32,'SHELL32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' include 'api\gdi32.inc' include 'api\comctl32.inc' include 'api\SHELL32.inc' _________________ Sorry if bad english. |
|||
29 Jun 2010, 12:54 |
|
revolution 29 Jun 2010, 13:13
Here is the problem:
Code: include 'win32w.inc' ;... mov byte[esi],'a' mov byte[esi+1],'b' mov byte[esi+2],0 |
|||
29 Jun 2010, 13:13 |
|
Teehee 29 Jun 2010, 14:55
thanks rev.
how that unicode code works? it uses different char values? |
|||
29 Jun 2010, 14:55 |
|
revolution 29 Jun 2010, 15:02
|
|||
29 Jun 2010, 15:02 |
|
Teehee 29 Jun 2010, 15:09
I'll take this topic to ask how can I map mouse X,Y position to character ID, since character buffer is linear, and not only this, the text is not displayed evenly.
|
|||
29 Jun 2010, 15:09 |
|
revolution 29 Jun 2010, 17:02
Read up on GetTextExtentPoint32
|
|||
29 Jun 2010, 17:02 |
|
Teehee 04 Jul 2010, 19:34
i don't know how that can help me, it only returns letter_width_in_pixels*string_size and letter_height_inpixels
|
|||
04 Jul 2010, 19:34 |
|
Teehee 04 Jul 2010, 22:35
The img below ilustrates what i need to do: map X,Y mouse click to character index. But i don't know how.
Legends:
*Clicking there must return the space char ' '.
_________________ Sorry if bad english. |
||||||||||
04 Jul 2010, 22:35 |
|
Tyler 04 Jul 2010, 23:42
Teehee wrote: I'm assuming each letter has 8x16 in pixels. Are you using a monospace font? If not, you can't even assume two different characters are the same size. |
|||
04 Jul 2010, 23:42 |
|
Teehee 04 Jul 2010, 23:54
yep, Courier New.
|
|||
04 Jul 2010, 23:54 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.