• Welcome to Valhalla Legends Archive.
 

lstrcmp [masm32]

Started by Metis, April 07, 2005, 02:55 AM

Previous topic - Next topic

Metis

I am trying to get the following program to work, I need this option for a program I am writing, but it only works when I use the following line to read into the buffer:


invoke StdIn,addr buffer,4


as soon as I change the '4' into a longer value it won't work anymore...

is there a workaround for this?

Program code:

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib

.data

string1 db "Enter: ",0
string2 db 13,10,"equal",0
string3 db 13,10,"not equal",0
teststring db "exit",0
test2 db "exit",0
buffer db 50 dup (?)
vier db "4",0
.code

start:

invoke StdOut,addr string1
invoke StdIn,addr buffer,6
invoke lstrcmpA,addr test2,addr buffer
.if eax==0
invoke StdOut,addr string2
invoke ExitProcess,0
.endif
invoke StdOut,addr string3
invoke ExitProcess,0

end start



I've tried adding the ending [color=blue 13 and 10 (CR and LF)[/color] to the buffer and then it works. But this will not work for my program since I need to compare the userinput with the strings generated by the Process32Next API...

Piece of my real program code:
Code:

invoke Process32Next,[Snap],offset proc32

;if we have finished the last process listing
;------------------------------------------------------
.if eax!=TRUE
jmp again
.endif
;------------------------------------------------------

invoke lstrcmpA, addr ProcToKill,addr proc32.szExeFile
.if eax == 0
jmp contin
.endif


Joe[x86]

QuoteI've tried adding the ending [color=blue 13 and 10 (CR and LF)[/color] to the buffer and then it works. But this will not work for my program since I need to compare the userinput with the strings generated by the Process32Next API...

Can't you do something like this, except not in Java?..
if(userinput + "\n\r" == process32nextret)
{
  //stuff
}
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

MyndFyre

Quote from: Joex86] link=topic=11209.msg111190#msg111190 date=1115328175]
QuoteI've tried adding the ending [color=blue 13 and 10 (CR and LF)[/color] to the buffer and then it works. But this will not work for my program since I need to compare the userinput with the strings generated by the Process32Next API...

Can't you do something like this, except not in Java?..
if(userinput + "\n\r" == process32nextret)
{
  //stuff
}

Joe, he wasn't talking about appending a newline to a string.  The strings returned from Process32Next are going to be inside of a structure and null-terminated.  And the lovely string concatenation you use in Java is much more memory-intensive that it seems because you have to generally have to reallocate the string somewhere else in memory.

I'm not familiar with StdIn.  Could you maybe use something like getchar()?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Metis

It has been about a month since I posted my problem and since then I've fixed the error, thank you anyway.