flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
semiono 05 Aug 2010, 04:41
Please help me the same!
![]() How To Get The Screen Resolution In Pixels? http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/ Fasm? --- And how to get $CmdLineRaw aka *% in batfiles in fasm/msdn valid mode? What's the api? |
|||
![]() |
|
typedef 05 Aug 2010, 05:10
Here
Code: format PE CONSOLE include 'win32ax.inc' entry start section '.text' data readable executable start: invoke GetHandle,0 ; Sorry i always use this invoke GetDesktop mov [hDesktop],eax invoke GetRect,[hDesktop],lpRect invoke printf,msg,[lpRect.right], [lpRect.bottom],[lpRect.top] ,[lpRect.left] invoke system,'pause>null' invoke Return,0 section '.data' data writable readable lpRect RECT ? msg DB 'Right %d, Bottom %d, Top %d, Left %d',0 hDesktop DD ? section '.idata' import data readable library kernel,\ 'KERNEL32.DLL',\ user,'USER32.DLL',\ msvcrt,'msvcrt.dll' import user,\ GetRect,'GetWindowRect',\ GetDesktop,'GetDesktopWindow' import msvcrt,\ system,'system',\ printf,'printf' import kernel,\ GetHandle,'GetModuleHandleA',\ Return,'ExitProcess' wrote that ontop of my head.... For me Output is Right 1152, Bottom 864, Top 0, Left 0 which is 1152 by 664 px |
|||
![]() |
|
Picnic 05 Aug 2010, 06:34
semiono wrote: Please help me the same! Hi semionio, Code: format PE CONSOLE include 'win32ax.inc' .data horizontal dd 0 vertical dd 0 buffer rb 256 .code main: stdcall GetDesktopResolution, horizontal, vertical cinvoke wsprintf, buffer, 'Resolution:%dx%d', [horizontal], [vertical] invoke MessageBox, HWND_DESKTOP, buffer, '', MB_OK ret proc GetDesktopResolution horizontal, vertical locals rc RECT endl pushad invoke GetDesktopWindow invoke GetWindowRect, eax, addr rc mov eax,[rc.right] mov ecx,[rc.bottom] mov esi,[horizontal] mov edi,[vertical] mov [esi], eax mov [edi], ecx popad ret endp .end main typedef wrote: Hello all. Hi, Don't forget, calling an API function changes registers eax ecx edx contents. Here's a simple FOR loop. Code: mov ecx, [count] @@: push ecx ; invoke SomeApiFunction pop ecx dec ecx jnz @B |
|||
![]() |
|
bitshifter 05 Aug 2010, 17:28
You can also save a byte by using loop instruction...
Also you can push all GPR at no extra cost (assuming use32) Code: mov ecx, [count] @@: pusha ; invoke SomeApiFunction popa loop @b |
|||
![]() |
|
LocoDelAssembly 05 Aug 2010, 20:02
Having this definition of for loop:
Code: for (expr1; expr2; expr3){ body } Code: ; Assembly code representing expr1 here (for instance mov [count], 0) .for_loop_check: ; Assembly code representing expr2 that jumps to .exit_for_loop when false (for instance cmp [count], TOP_VALUE / jae .exit_for_loop when expr2 is "count < TOP_VALUE"). Note that if expr2 is absent then so is the jump. ; body code here ; Assembly code representing expr3 here (for instance inc [count]) jmp .for_loop_check .exit_for_loop: Of course you are not forced to do this way always (in fact what the others suggested is OK, although I would use a non volatile register for count and the dec reg/jnz pair instead), but the pattern above should always work for arbitrary for loops (including those that are not behaving as Pascal-like for loops). |
|||
![]() |
|
ouadji 05 Aug 2010, 22:08
Code: push [count] ;count dd @@: invoke SomeApiFunction,A1,A2,...,Ax dec dword[esp] jnz @B add esp,4 |
|||
![]() |
|
semiono 06 Aug 2010, 09:48
typedef, big thanks! Picnic, big thanks!
Picnic, ; format PE CONSOLE ... ; ret invoke ExitProcess,0 ![]() Last edited by semiono on 09 Aug 2010, 13:40; edited 1 time in total |
|||
![]() |
|
semiono 09 Aug 2010, 13:36
Code: invoke GetSystemMetrics,SM_CXSCREEN invoke wsprintf,lpOut,'%d',SM_CXSCREEN invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,'Software\azz',\ NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE or KEY_READ,NULL,phkResult,NULL invoke RegSetValueEx,phkResult,'\lpValueName',NULL,'REG_SZ',lpOut,100 invoke RegCloseKey,phkResult exit: invoke ExitProcess,0 section '.data' data readable writable phkResult dw ? lpOut rb 1024 Please, i need keep SM_CXSCREEN in registry value. How to convert SM_CXSCREEN ? _________________ Windows 9, FL Studio 19 |
|||
![]() |
|
LocoDelAssembly 09 Aug 2010, 17:41
cinvoke wsprintf,lpOut,'%d',eax
|
|||
![]() |
|
Picnic 09 Aug 2010, 17:52
semiono wrote: typedef, big thanks! Picnic, big thanks! You're welcome, quite right i miss that ![]() |
|||
![]() |
|
semiono 10 Aug 2010, 14:51
Code: include '%fasm%\win32ax.inc' section '.code' executable start: invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,'Software\$$debug',\ NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE+KEY_READ,NULL,phkResult,NULL invoke RegSetValueEx,HKEY_LOCAL_MACHINE,NULL,NULL,NULL,addr lpData,cbData invoke RegCloseKey,phkResult exit: invoke ExitProcess,NULL section '.data' readable writable lpData db 'ntdll.dll',0 cbData dw 1024 phkResult dd ? .end start Anybody, why RegSetValueEx not work? ![]() |
|||
![]() |
|
bitshifter 10 Aug 2010, 17:39
At first glance i see this fix..
Code: cbData dd 9 ... invoke RegSetValueEx,HKEY_LOCAL_MACHINE,NULL,NULL,REG_SZ ,lpData,[cbData] addr is only required when data is relative to local stack frame. Since its global memory there is need for it. Also cbData should be passed by value (not pointer) Also you should specify a "type" field value. There may be more problems but i have no time to try... |
|||
![]() |
|
semiono 11 Aug 2010, 14:04
Full work example!
![]() Code: include '%fasm%\win32ax.inc' section '.code' executable start: invoke RegOpenKeyEx,HKEY_CURRENT_USER,\ 'Software\Microsoft\Windows\CurrentVersion\Applets\Regedit',\ NULL,KEY_WRITE,phkResult invoke RegSetValueEx,[phkResult],'LastKey',NULL,REG_SZ,\ 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run',76 invoke RegCloseKey,[phkResult] @@: invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,\ 'Software\Microsoft\Windows\CurrentVersion\Run',\ NULL,KEY_WRITE,phkResult invoke RegSetValueEx,[phkResult],'Explorer.exe',NULL,REG_SZ,\ '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}',41 invoke RegCloseKey,[phkResult] exit: invoke WinExec,"regedit.exe",SW_SHOWNORMAL invoke ExitProcess,NULL section '.data' readable writable phkResult dd ? .end start section '.rsrc' resource readable directory RT_ICON,icons,RT_GROUP_ICON,group_icons,RT_VERSION,versions resource icons,\ 1,LANG_NEUTRAL,icon_data1,\ 2,LANG_NEUTRAL,icon_data2,\ 3,LANG_NEUTRAL,icon_data3,\ 4,LANG_NEUTRAL,icon_data4 resource group_icons,17,LANG_NEUTRAL,main_icon resource versions,1,LANG_NEUTRAL,version icon main_icon,\ icon_data1,'%fasm%\exec1.ico',\ icon_data2,'%fasm%\exec2.ico',\ icon_data3,'%fasm%\exec3.ico',\ icon_data4,'%fasm%\exec4.ico' versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\ 'FileDescription','RegSetValueEx.exe',\ 'LegalCopyright','2001-2005 GmbH',\ 'FileVersion','1.0.0.0',\ 'ProductVersion','1.0.0.0',\ 'OriginalFilename','RegSetValueEx.exe',\ 'Company','Semiono' |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.