BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10

If I submit command "help help" from command line, there show matching results in help documentation:

1.jpg

Fine, that is what I am expect. But it hits no results if I type "dm 'help help';" and submit it from program editor:

2.jpg

What is the reason of this? Are they really differs on "help" window?

 

By the way, I am run SAS 9.4M5 on Win10 machine.

1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

Display Manager is a thick client with a lot of legacy things going on.  I think the differences you found between submitting DM 'HELP HELP' and issuing HELP HELP in the COMMAND Bar (or COMMAND Line) is not something of significant matter.

 

The Help window raised is owned by the SAS DM session process, so there is likely some behind the scenes windows messaging going on to execute some routine in MVADocWin.dll (found in folder "C:\Program Files\SASHome\SASHelpViewerforWindows\<version>, which also contains standalone program "SASDocViewer.exe", which no doubt uses the same dll)

 

You would need a powerful tool to examine the differences in the messages to understand why the DM "HELP HELP" does not properly pass the keyword to the doc system.  One possibility is that (internally) the DM command statement that the job supervisor hands off to the help statement executor uses a buffer that does not contain a zero-termination byte the dll routine expects, which could cause a keyword search term that has no match.

 

Indeed, the supposition is proven by submitting the command as a hexadecimal string literal containing the necessary zero-byte termination. (thanks Best String to Hex Converter Online to Convert Text to Hex. (codebeautify.org)

 

dm '68656c702068656c7000'x;

 

Unfortunately, the Help window will not be raised on top of all other windows, but it will be there

 

Note: Improperly formed commands submitted as hex string literals can crash your SAS Display Manager session.   This is a security issue for SAS because additional exploitation of DM statement by a blackhat coder could cause unintended code execution or data leakage.

 

Regards,

Richard DeVenezia

 

 

View solution in original post

6 REPLIES 6
ballardw
Super User

There are some limitation as to window focus when a DM statement is issued. You really want to make sure to include the window name because not all commands are valid in every window.

To be reasonably sure of sending the command to proper window the window name should be the first parameter in a DM statement.

RichardDeVen
Barite | Level 11

Display Manager is a thick client with a lot of legacy things going on.  I think the differences you found between submitting DM 'HELP HELP' and issuing HELP HELP in the COMMAND Bar (or COMMAND Line) is not something of significant matter.

 

The Help window raised is owned by the SAS DM session process, so there is likely some behind the scenes windows messaging going on to execute some routine in MVADocWin.dll (found in folder "C:\Program Files\SASHome\SASHelpViewerforWindows\<version>, which also contains standalone program "SASDocViewer.exe", which no doubt uses the same dll)

 

You would need a powerful tool to examine the differences in the messages to understand why the DM "HELP HELP" does not properly pass the keyword to the doc system.  One possibility is that (internally) the DM command statement that the job supervisor hands off to the help statement executor uses a buffer that does not contain a zero-termination byte the dll routine expects, which could cause a keyword search term that has no match.

 

Indeed, the supposition is proven by submitting the command as a hexadecimal string literal containing the necessary zero-byte termination. (thanks Best String to Hex Converter Online to Convert Text to Hex. (codebeautify.org)

 

dm '68656c702068656c7000'x;

 

Unfortunately, the Help window will not be raised on top of all other windows, but it will be there

 

Note: Improperly formed commands submitted as hex string literals can crash your SAS Display Manager session.   This is a security issue for SAS because additional exploitation of DM statement by a blackhat coder could cause unintended code execution or data leakage.

 

Regards,

Richard DeVenezia

 

 

whymath
Lapis Lazuli | Level 10

Impressive and very professional.

whymath
Lapis Lazuli | Level 10

@RichardDeVen Richard, I tried you hex way, just fall into another trap:

%macro help(key);
%local _helpinhex_;
%let _help_=help &key.;

%do i=1 %to %length(&_help_.);
  %let _helpinhex_=&_helpinhex_.%qsysfunc(putc(%qsubstr(&_help_.,&i.,1),$hex2.));
%end;
%let _helpinhex00_=&_helpinhex_.00;
%put &_helpinhex00_.;
%put dm "&_helpinhex00_."x;
dm "&_helpinhex00_."x;
%mend;

%help(help);

I get the following messages in log:

68656C702068656C7000
dm "68656C702068656C7000"x
ERROR: Invalid hexadecimal constant string "68656C702068656C7000"x.

The "" on my SAS log window just show like " =". How do you think of that?

RichardDeVen
Barite | Level 11

%qsysfunc is just introducing more noise to whatever you are attempting.  The macro quoting causes hidden demarcators to be in the _helpindex_ symbol value.  There are many excellent papers about macro quoting and the hidden secrets therein.

 

Instead, use the $HEX<len>. format to obtain the hex literal representation of a string.

%macro help(term);
  %local length helphex;

  %let length = %eval (10 + 2 * %length(&term));
  %let helphex = %sysfunc(putc(help &term, $hex&length..));

  dm "&helphex.00"x;  
%mend;

options mprint; %help (help)

Happy coding whymath.

whymath
Lapis Lazuli | Level 10
Awesome and thanks again, Richard, I'll learn about %qsysfunc more further.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 471 views
  • 2 likes
  • 3 in conversation