News:

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

GetCL bug

Started by brethren, March 01, 2011, 05:53:05 PM

Previous topic - Next topic

brethren

from the masm32 docs
QuoteThe buffer for the returned argument should be set at 128 bytes in length which is the maximum allowable.

if a commandline arg is larger than 128 bytes then the assigned buffer overflows. try overflowing it in olly and you'll see. for example if you were to pass a commandline arg of say 200 's' character, olly will give the error "dont know how to continue because memory at address 73737373 is not readable. Try to change EIP or pass exception to program".
test program

INCLUDE \masm32\include\masm32rt.inc

.data?
buf BYTE 128 DUP(?)

.code
start:

INVOKE GetCL, 1, ADDR buf
print ustr$(eax), 13, 10                   ;return value for GetCL
print ustr$(len(ADDR buf)), 13, 10         ;length of string returned from GetCL
print ADDR buf, 13, 10                     ;display the string

exit
END start

jj2007

Conventional wisdom was that commandlines would not exceed 128 chars. But I tested it with a batch file and a 1024+ arg, and it works fine. MasmBasic could handle 640kB, but it seems 32767 bytes is Windows' limit - The Old New Thing: What is the command line length limit?