flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vid 22 Nov 2007, 18:12
Code: call [GetStdHandle] |
|||
![]() |
|
LocoDelAssembly 22 Nov 2007, 18:18
STD_OUTPUT_HANDLE = -0x0B
As for the error box is because you forgot the brackets, GetStdHandle is a pointer to function, but you are calling the address where this pointer is stored so the processor executes the pointer rather than the actual GetStdHandle's code. Here is the proper way if you don't want to use invoke Code: push STD_OUTPUT_HANDLE call [GetStdHandle] Also: Code: stdcall [GetStdHandle], STD_OUTPUT_HANDLE |
|||
![]() |
|
AlexP 22 Nov 2007, 18:18
Oh.. Yeah, it's me Vid, kid you gave help to bout modulus thingies. Didn't know if were on.. Thanks!
|
|||
![]() |
|
AlexP 22 Nov 2007, 18:24
Yes, I didn't notice that little mistake ... I'm trying to get a console encrypted-password storing pgrm going, so I was using 0x0A for input buffer handle and 0x0B for output handle. Still working on some techinque I found for an almost-GetChar function. What am I doing wrong???
call AllocConsole push -0x0A call [GetStdHandle] mov [inhandle],eax push 0 push numread push 1 push inchar push [inhandle] call [ReadConsole] This is someone else's code, so bear with me while I debug it quick.. |
|||
![]() |
|
LocoDelAssembly 22 Nov 2007, 19:54
Quote:
Again? ![]() |
|||
![]() |
|
AlexP 22 Nov 2007, 20:01
Yeah.. sorry- just got that code and didn't look over it very well. It's goin good now, got handles workin for the buffers and I'm tryin to get the newilne workin.. Check this out:
message db 'Seperated Strings',0xD,'Newline!!',0 Not workin so far. probably another bug on my end.. |
|||
![]() |
|
AlexP 22 Nov 2007, 20:05
This is weird..
message1 db 'Praise the lord!!',0 ; just for testing.. message2 db 'Hello',0xA,'Newline ',0 ;Try newline I used two WriteConsole calls and it came up with this Praise the Lord!! lo Newline I don't know what is going on, the word Hello is cut off and I don't know why.. The ascii code 10 decimal, or 0xA, is making a newline but the previous word is cut off. Should I just use SetConsoleCursurPosition? but then, how do I define the structures to send to this API?? sorry for the newbieness, but I used to not need input or output in my prgs |
|||
![]() |
|
vid 22 Nov 2007, 20:13
Post entire source next time, and post code in [code] blocks.
Newline in windows should be 13, 10 (0xD, 0xA). |
|||
![]() |
|
AlexP 22 Nov 2007, 20:58
Here's what I've been having all the trouble with- Just trying to get the ReadConsole working on strings. It keeps overwriting and not working so well. Any suggestions?
Code: format PE console include 'C:\Documents and Settings\II K4RN4G3 II\Desktop\___\Fasm16723\INCLUDE\win32ax.inc' section '.data' data readable writeable ;WriteConsole message DB 'Enter a Number: ',0 TryThis DB 'Newline?',0 numwritten DB ? ;ReadConsole numread DD ? inchar DB ? ;GetStdHandle inhandle DD ? outhandle DD ? section '.code' code readable executable start: ;Get Input Buffer Handle push -10 call [GetStdHandle] mov [inhandle],eax ;Get Output Buffer Handle push -11 call [GetStdHandle] mov [outhandle],eax ;Write initial Message to console push 0 push numwritten push 16 push message push [outhandle] call [WriteConsole] ;Read in 2 bytes from the console push 0 push numread push 2 push inchar push [inhandle] call [ReadConsole] ;Display the bytes read from console push 0 push numwritten push numread ; Numread from previous call push inchar ;Using buffer from previous call push [outhandle] call [WriteConsole] ;Read in 2 bytes- This function doesn't even call properly push 0 push numread ;Overwrite other variable please? push 2 push inchar ;Buffer used before, should be overwritten here push [inhandle] call [ReadConsole] push 0 call [ExitProcess] .end start |
|||
![]() |
|
vid 22 Nov 2007, 21:09
inchar must be buffer big enough to hold entire string. Otherwise, data following it are rewritten by what you read. Your buffer has only single byte, but you are reading 2 characters. that means one byte of following "inhandle" will be overwritten.
use something like this: Code: inchar rb 100 ;100 byte buffer |
|||
![]() |
|
AlexP 22 Nov 2007, 23:47
Thanks again- I got all things set up and now I'm organizing the encrypted file structure. Just going to be a console app, not a command-line only thing. If I find a code section on this web site, I'll post the app there once I get it finished in a few days.
|
|||
![]() |
|
f0dder 23 Nov 2007, 03:17
Why do you insist on using magic numbers instead of symbolic constants? bad bad bad practice.
|
|||
![]() |
|
AlexP 23 Nov 2007, 19:39
Some one else's code, as I said before... Just tried to throw it together in a hurry, I have long since fixed those problems. The only thing now that is a mystery to me is how I can manually create a structure and pass it to SetConsoleCursorPosition. Using the fasm macros isn't working too well either. Here's the section of code that doesn't want to send the structure to API call.
Code: section '.data' data readable writeable struc pos x,y { .x dw x .y dw y } ;GetStdHandle hStdIn DD 1 hStdOut DD 1 ;PauseTemp PauseRead RB 2 PauseChar RB 100 ;ConsolePrint NumWritten RB 2 message DB 'Hello',0 section '.code' code readable executable SetConsoleCursorPos: ;Save eax, used for handle transfer push eax ;Get Input Buffer Handle push -0x0A call [GetStdHandle] mov [hStdIn],eax ;Get Output Buffer Handle push -0x0B call [GetStdHandle] mov [hStdOut],eax consolepos pos 4,5 ;SetCursorPos. to 4,5 push [consolepos] push [hStdOut] call [SetConsoleCursorPosition] ;Test Printout push 0 push NumWritten push 5 ; "Hello" push message push [hStdOut] call [WriteConsole] call PauseTemp ; Just a ReadConsole call push 0 call [ExitProcess] .end SetConsoleCursorPos |
|||
![]() |
|
bitRAKE 23 Nov 2007, 22:09
consolepos should be in the data section - not the middle of the code.
|
|||
![]() |
|
AlexP 23 Nov 2007, 22:18
I thought that I tried that already, but I'll check again.. I'm flying through the rest of the code but I keep getting stuck on any sort of output/input. I'm not used to having user-friendly programs . Thanks twice bitRAKE lol
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.