home *** CD-ROM | disk | FTP | other *** search
- /*
- DBSTR -- Dump memory as bytes for a given BSTR
- DBSTR (<variable> | <address> | <range>)
- >dbstr var /* Dumps the BSTR pointed to by var */
- >dbstr 0x82034 /* Dumps the BSTR at location 0x002080d0 */
- Note that a BSTR is an address shifted right 2 pointing to a buffer
- with a preceeding length byte.
- */
- address 'COMMAND'
- 'version >nil: exec.library 36 '
- lrc = rc
-
- if (rc = 0) then
- check = addlib('rexxsupport.library',0,-30,0)
-
- address
-
- parse arg expr
- if (expr = '?') then
- do
- do i = 2 to 7
- 'd "' strip(sourceline(i),'T', "0a"x) '"'
- end
- exit(0)
- end
- options failat 3
- options results
- 'd ' expr '"%d"'
- stat = rc
- val = strip(result,'T',"0a"x)
- options
- if (stat ~= 0) then
- do
- 'd "Error: can''t find' expr '"'
- exit(0)
- end
- val = strip(val)
- say val
- bptr = d2c(c2d(d2c(val))*4,4)
- bstr = import(offset(bptr,1),c2d(import(bptr,1)))
- do forever
- y = verify(bstr, '"'||'0a0d00'x,'m')
- if y = 0 then leave
- c = substr(bstr,y,1)
- if c = '"' then
- bstr = left(bstr,y-1)||'\'||'05'x||substr(bstr,y+1)
- else
- bstr = left(bstr,y-1)||'\\'||translate(c,'nr0','0a0d00'x)||substr(bstr,y+1)
- end
- bstr = translate(bstr, '"', '05'x)
- 'd "0x'||c2x(bptr)||': \"'||bstr||'\""'
- exit(0)
-