Matt Elson
Matt Elson

Reputation: 4355

How to use an argument for aS command in WinDBG

When I used the following way, win32.hlp can be correctly opened.

0:000> aS api .shell -x winhlp32.exe -k createfile win32.hlp
0:000> w

However, When I want to use an argument $arg1, as follows,

0:000> aS api .shell -x winhlp32.exe -k ${$arg1} win32.hlp
0:000> w createfile

An error message is displayed:

"Cannot find the win32.hlp createfile file. Do you want to try to find this file yourself?"

Any ideas?

[UPDATE]

snoone's way can work well most time, but sometimes the following dialog will be displayed.

Obviously, the file name "win32.hlp" is mistakenly regarded as a part of search word. What am I doing wrong?

enter image description here

Upvotes: 1

Views: 786

Answers (2)

snoone
snoone

Reputation: 5489

Jason is right, you can't pass arguments like this. In order to implement this, you'll need to do it indirectly through a script file.

For example, create a file e:\hlplaunch.wbs and put the following line in it:

.shell -x winhlp32.exe -k ${$arg1} win32.hlp

Then create your alias to launch the script instead of creating the shell directly:

aS ${/v:api} "$$>a<e:\\hlplaunch.wbs"

You can then launch the help viewer using your same command you were using:

api createfile

Upvotes: 1

jcopenha
jcopenha

Reputation: 3975

I don't think this is possible. This looks like confusion between an alias and a script.

Using an Alias in the Debugger Command Window

After you define an alias, you can use it in any command entry. The alias name is automatically replaced with the alias equivalent. Therefore, you can use the alias as an expression or as a macro.

So, aliases are simple text replacement they don't get arguments passed to them like a script file does.

The closest I came to getting your alias to work is

0:000> aS api .shell -x notepad.exe -k 
0:000> api c:\temp\j.txt

This launched notepad.exe opening c:\temp\j.txt.

Upvotes: 1

Related Questions