News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Instring Masm?

Started by AgentSmithers, June 20, 2009, 12:39:37 AM

Previous topic - Next topic

AgentSmithers

mov eax, 1
@InStr(eax, ADDR Buf, ADDR RecvBuff)


it keeps saying it needs a const expression, Anyone have an alternative that will work for me

I do have defined
.const
Buf  db "Works"


But still no luck =(

dedndave

@InStr(ADDR Buf, ADDR RecvBuff)

AgentSmithers

Error A2026: constant expected
@InStr<1>: Macro Called From 2015
error A2008: syntax error: integer

dedndave

that's supposed to be optional
but......

@InStr(1, ADDR Buf, ADDR RecvBuff)

try that

AgentSmithers

That Cleared one Error
Syntax Error : Integer

ecube

try a variable, or a register other than eax, since instring returns in eax as do most functions.

local var:DWORD
mov var,1
@InStr(var, ADDR Buf, ADDR RecvBuff)

or simple invoke InString,var,ADDR Buf, ADDR RecvBuff

AgentSmithers

Now the Error returns...

Error A2026: constant expected
@InStr<1>: Macro Called From 2015
error A2008: syntax error: integer

can this be effecting the macro?
                  ;include \masm32\include\masm32rt.inc

                  include \masm32\include\windows.inc

                  include \masm32\include\user32.inc
                  include \masm32\include\kernel32.inc
                  include \masm32\include\masm32.inc
                  include \masm32\include\wsock32.inc
                  ;include \masm32\include\ws2_32.inc

                  includelib \masm32\lib\user32.lib
                  includelib \masm32\lib\kernel32.lib
                  includelib \masm32\lib\masm32.lib
                  includelib \masm32\lib\wsock32.lib
                  ;includelib \masm32\lib\ws2_32.lib


                    WIN32_LEAN_AND_MEAN equ 1

dedndave

it must not like the string pointers
it wants to see strings, i guess

i have never used it
if i wanted to do that, i'd use repnz scas - lol

ecube

yeah it maybe the macro, i'm not a macro guy, try just the invoke InString,var,ADDR Buf, ADDR RecvBuff

AgentSmithers

Pefect, What DLL and header does Instring reside in? I was looking for it and could not locate it. (Core.dll / kernel32.dll)

P.S. is their a hotkey to Automaticly save Build and run a EXE from the IDE?

How do I use Macros such as Hex$ and Str$ it appears my IDE at build time does not reconize the commands, what needs to be imported. I belive when I import masm32rt all my invokes become invalid.

sinsi

@InStr is a predefined macro inside MASM that uses literal strings, it isn't a proc to call and doesn't create any code.
I think you might be looking for this from the masm32 lib
InString proc startpos:DWORD,lpSource:DWORD,lpPattern:DWORD
Light travels faster than sound, that's why some people seem bright until you hear them.

AgentSmithers

How do I pass a literal Strings?
I got it, The issue was no null terminator on the string that was being searched for, The function looks for a Zero '0'

hutch--

AgentSmithers,

Something to get the swing of with macros, it is normally called a "preprocessor" for a very obvious reason, they modify the source code BEFORE it is assembled so it can only manipulate "known" data that is in the .DATA section, not dynamic data at runtime. The "InString" in the masm32 library is a procedure that is available at runtime. literally while the code is running.

Essentially a macro is a way of expanding and performing text substitution on code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi AgentSmithers,

Here is where you can find information about Masm's macro system :

Chapter Nine: Using Macros