flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution
Perhaps you can define a buffer that stores incoming keystrokes and when Enter is pressed you search your command table for a matching string.
|
|||
![]() |
|
CampTheBoss
do you mean like using an if statement? (.if BYTE[buffer]=variableofkeyword)
I also don't know how to set a buffer up for the msvcrt function: _fgetchar, so I might need help with that. (i am new to win64/32 assembly, I came off DOS as an expert) |
|||
![]() |
|
CampTheBoss
do you mean like using an if statement? (.if BYTE[buffer]=variableofkeyword)
I also don't know how to set a buffer up for the msvcrt function: _fgetchar, so I might need help with that. (i am new to win64/32 assembly, I came off DOS as an expert) |
|||
![]() |
|
revolution
I mean to keep loading key presses one-by-one into a multi-byte buffer until either Enter is detected or the buffer overflows. Then in a different part of the code, after Enter has been detected, compare the contents of the buffer to a list of valid commands and act accordingly.
|
|||
![]() |
|
catafest
I saw you put your username , I think you need to get the default user under your OS. also you can change and update your code with some specials commands like: ls , grep or awk or maybe make some default shells to your applications , like : python 2.7, 3.0 , gimp ...
This can be great. |
|||
![]() |
|
CampTheBoss
I am adding some stuff to it using ShellExecute, so it can load web pages etc.
The only thing i want to change is the WinExec permissions file. i want to make it a configuration file (in assembly format) and the program reads it without another compile |
|||
![]() |
|
CampTheBoss
I tried making a buffer:
Code: buff db 0,0,0,0 helpstr db 'help' looper: invoke getchar jmp makeabuff makeabuff: cmp al, 0ah je cmpstrings mov BYTE[buff],al jmp looper cmpstrings: cmp BYTE[buff], BYTE[helpstr] je good jne exit but it never compiles. why? |
|||
![]() |
|
revolution
Your buffer is four bytes in size so your maximum command length is 4 characters.
But you need to add each keypress to the next position in the buffer. Currently you keep overwriting the first position with each incoming keypress. Also, perhaps you can review the docs for the cmps instruction (and the prefix repz) to do comparisons with memory to memory directly. You'll need the RSI, RDI and RCX registers to be properly set for that to work. |
|||
![]() |
|
typedef
Why not just make the shell load 'cmdlets' from a folder instead of hard coding your commands?
This will give you lots of advantages because your shell will not need to load a network library when all you want to do is find a local file. Load your cmdlets when your shell loads and also have a command to reload the cmdlets on demand. Add integrity checks as well. |
|||
![]() |
|
CampTheBoss
Do you mean like loads of includes?
And at execution time, it calls them? |
|||
![]() |
|
CampTheBoss
How do i do it? I don't know how to load cmdlets at execution time.
|
|||
![]() |
|
typedef
No. I mean like, take a look at CMD.EXE. It calls other console EXEs but also has few built in commands.
Now imagine if all those other system console EXEs were packaged into CMD.EXE. ![]() |
|||
![]() |
|
CampTheBoss
typedef wrote: No. I mean like, take a look at CMD.EXE. It calls other console EXEs but also has few built in commands. Do you mean I should use ShellExecute to load other files? |
|||
![]() |
|
typedef
I'd recommend CreateProcess so you can redirect their IO handles to the console's STDIN/OUT and wait for the processes to get their exit code and other info.
However you load them, you just gotta make sure they receive and return data to and from the console. After all, they will be console apps. |
|||
![]() |
|
CampTheBoss
so, I should make macros and implement them into the program to test if they direct to an executable in a working directory?
|
|||
![]() |
|
typedef
No. My point is to avoid hard coding.
Here, I just whipped up an example for you. I'd advise you to focus more on the methodology and not so much on the code. List of internal commands (hard coded): clear, time, help, exit List of external commands (EXEs in cmdlets folder): input, delete, whoami You can type all those in the shell and it will try to resolve them. You'll get the idea.
|
|||||||||||
![]() |
|
typedef
Update
Function is_cmdlet can be optimized to this: Code: proc is_cmdlet ; if parameters, get the name part only and check if an EXE by that name exists in the 'cmdlets' folder call has_Params cmp eax, TRUE jne .no_params push szCmdletName jmp .findCmdlet .no_params: push szInput .findCmdlet: push szCmdletPathFmt push szCmdletPath call [wsprintfA] add esp, 4 * 3 ; check if cmdlet by this name exists call cmdlet_Exists .finish: ret endp |
|||
![]() |
|
CampTheBoss
Hey, I am kind of stuck because I usually like to do all of my work in high-level code, so could I use the code you have used and optimise it?
|
|||
![]() |
|
typedef
CampTheBoss wrote: Hey, I am kind of stuck because I usually like to do all of my work in high-level code, so could I use the code you have used and optimise it? Sure go ahead. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.