A
A
armadillo-cld2020-09-10 20:20:54
assembler
armadillo-cld, 2020-09-10 20:20:54

Can't get a character from a string on FASM?

Windows, FASM x86, exe
There is a PROCESSENTRY32 structure, I fill it through Process32First\Process32Next, and I need to get the first element from szExeFile.
I try like this, but it says "Operand size not specified":

mov eax, 0
cinvoke printf, pe32.szExeFile[eax]

What to do? How to be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
armadillo-cld, 2020-09-10
@armadillo-cld

Apparently, I need to learn more about assembler functions, because I am limited to only lea, mov, jmp, jnz, je, jz, etc. I didn’t know
about it, so I couldn’t complete this task.rep movsbcld

cld
                        mov ecx,processname_len-1
                        lea esi,[processname+1]
                        lea edi,[processname]
                        mov byte al,[edi]
                        rep movsb
                        mov byte [edi],al

This piece of code shifts the string to the left by one character, moving the first character of the string to the last character. In order not to shift the null-terminator terminating the string, we add a minus one when defining strlen. And in ECX we put another one less, since one character will be processed separately through the AL register. We load the address of the beginning of the string into the receiver, and the address of the second character (stroka + 1) into the source. Before starting copying the byte chain, we store the first character in AL. After copying, we extract it at the address contained in the EDI - this will already be the address of the last character of the string

F
freeExec, 2020-09-10
@freeExec

And so?

mov eax, 0
lea eax, pe32.szExeFile[eax]
cinvoke printf, eax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question