flat assembler
Message board for the users of flat assembler.
Index
> Windows > Display the result of a registry addition Goto page Previous 1, 2 |
Author |
|
Furs 24 Jan 2018, 16:02
int instruction is for DOS or 32-bit Linux. It's a system call. You don't need a system call to print on Windows.
You can use WriteFile (Windows API, kernel32.dll) to write to the console directly, without printf. But it's more complicated. (you also have to obtain the stdout handle). That's the "lowest level" you can get, probably. Since Windows is based on user-mode APIs (libraries, DLLs) and all system calls are hidden (and they change amongst Windows versions! but APIs don't). printf probably ends up calling WriteFile anyway. BTW, "call" is also an instruction, just like "int". The difference is that the latter switches to kernel mode (and thus calls a system function). |
|||
24 Jan 2018, 16:02 |
|
Mino 24 Jan 2018, 16:21
OK thanks a lot
And when we use "int" then? |
|||
24 Jan 2018, 16:21 |
|
revolution 24 Jan 2018, 16:57
Mino wrote: OK thanks a lot |
|||
24 Jan 2018, 16:57 |
|
yeohhs 24 Jan 2018, 22:26
Mino wrote:
There is FASMLIB where many useful functions (including I/O) are implemented in asm. FASMLIB comes with source. You can download it from here. http://fasmlib.x86asm.net/ There is also BASELIB from fasmnewbie. https://sourceforge.net/projects/baselibs/files/ or https://plus.google.com/108856344528527240894 |
|||
24 Jan 2018, 22:26 |
|
Mino 25 Jan 2018, 17:25
Hello again!
I would like to know why, after compiling my file, it appears as such: The executable works, but it's a little annoying to have to be in Admin to run it. Do you have any idea ? PS: Thank you for the answer, I hadn't seen it |
|||
25 Jan 2018, 17:25 |
|
revolution 25 Jan 2018, 17:50
What code are you running? What OS are you using? Does your code try to write to any protected directories? Are you trying to access low level functions?
|
|||
25 Jan 2018, 17:50 |
|
Mino 26 Jan 2018, 07:22
Quote: What code are you running? I tried with the sent program, during the 1st post Quote: What OS are you using? Windows 10 Quote: Does your code try to write to any protected directories? Are you trying to access low level functions? It's possible, but frankly, I don't know. |
|||
26 Jan 2018, 07:22 |
|
revolution 26 Jan 2018, 07:31
The first post has this code:
Code: mov eax, 7 add eax, 3 ; Print what's in eax Normally programs won't need to be admin unless you are accessing protected resources. If you post the code you assembled we can probably help you. |
|||
26 Jan 2018, 07:31 |
|
Mino 26 Jan 2018, 11:36
The code is exactly the same as the file sent, but here it is anyway:
Code: ;---------------------------------------------------------- ; Program Name: integeradd ; Purpose : integer addition ; Date : August 2008 ; Author : Yeoh HS ; FASM : Built using Flat Assembler version 1.67.27 ; edited and compiled with FASM's IDE. ;---------------------------------------------------------- format PE CONSOLE 4.0 entry start include 'win32a.inc' section '.data' data readable writeable val1 dd 7 val2 dd 3 section '.code' code readable executable start: ;mov eax, [val1] mov eax, [val2] add [val1], eax stdcall show_me, dfmt,intval,[val1] stdcall waitforchar invoke ExitProcess,0 ;--------------------------------------------------------- ; Proc to show values of data variables. ;--------------------------------------------------------- proc show_me, fmt, prompt, val cinvoke printf, [fmt], [prompt], [val] cinvoke printf, strfmt, CRLF ret endp ;---------------------------------------------------------- ; Proc to prevent console window from closing immediately ;---------------------------------------------------------- proc waitforchar cinvoke printf, strfmt, CRLF cinvoke printf, strfmt, msg cinvoke getchar ret endp section '.data' data readable writeable CRLF db '',13,10,0 ; carriage return and linefeed dfmt db '%s = %d',0 intval db 'Integer value',0 strfmt db '%s',0 msg db 'Press the Enter key...',0 section '.idata' import data readable writeable library kernel32,'kernel32.dll',\ user32, 'user32.dll',\ msvcrt, 'msvcrt.dll' include 'api\kernel32.inc' include 'api\user32.inc' import msvcrt,\ printf, 'printf',\ getchar,'getchar' ; end of file ================================================================= |
|||
26 Jan 2018, 11:36 |
|
revolution 26 Jan 2018, 18:58
AFAICT there is nothing in that code that will need admin privilege.
Can you run the example "hello world!" code that comes with fasm? |
|||
26 Jan 2018, 18:58 |
|
Mino 26 Jan 2018, 20:51
An "Hello, world!" GUI program, from the FASM examples:
Code: include 'win32ax.inc' .code start: invoke MessageBox,HWND_DESKTOP,"Hello, world!",invoke GetCommandLine,MB_OK invoke ExitProcess,0 .end start What's strange is that if I change (drag and drop) the generated application, ADMIN mode is no longer required. |
|||
26 Jan 2018, 20:51 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.