1

I'm trying to run gflags x64 on my Release x64 binary built by Visual Studio 2013 to detect access violations.

I downloaded Windows Debugging Tools from Microsoft website.
I added C:\Program Files (x86)\Windows Kits\10\Debuggers\x64 to my PATH environment variable, gflags and windbg are found in Windows prompt.

Edit: Added already tried commands

I tried to flag with following commands:
gflags /p /enable D:\MyBinary.exe /full /protect
gflags /p /enable D:\MyBinary.exe
gflags /p /enable MyBinary.exe /full /protect
gflags /p /enable -i MyBinary.exe /full /protect
gflags /p /enable /i MyBinary.exe /full /protect
gflags -p -enable -i MyBinary.exe -full -protect

then I want to check if binary is properly flagged with
gflags /p

MyBinary.exe is not listed, gflags /p displays nothing.

I retried by disabling UAC to see if it's different, no better result.
I also tried to flag another binary (notepad++.exe), still no flagging.

What's wrong with my commands ?

Richard Dally
  • 1,432
  • 2
  • 21
  • 38
  • Try without the path `gflags /p /enable MyBinary.exe /full /protect` also shouldn't you be using `-i` to specify the imageFileName? `gflags /p /enable -i MyBinary.exe /full /protect`? – EdChum Nov 24 '15 at 10:27
  • Just tried `gflags /p /enable MyBinary.exe /full /protect` and `gflags /p /enable -i MyBinary.exe /full /protect`, still no result in `gflags /p` – Richard Dally Nov 24 '15 at 10:31
  • you may have better joy using the gui version of gflags by double-clicking this in the debuggers folder and then toggling the flags and entering the app name on the Image File tab – EdChum Nov 24 '15 at 10:35
  • I also tried with `/i` instead of `-i`, `gflags /p /enable /i MyBinary.exe /full /protect`, still does not work. – Richard Dally Nov 24 '15 at 10:41
  • @EdChum, actually I really need to execute gflags in command line, it's part of daily tests in Jenkins. – Richard Dally Nov 24 '15 at 10:43
  • I don't have the windows 10 version installed but the 8.1 SDK version shows that the flags are passed using `-` rather than `/` can you try substituting `/` for `-` and see if it works – EdChum Nov 24 '15 at 10:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/96016/discussion-between-leflou-and-edchum). – Richard Dally Nov 24 '15 at 10:46

1 Answers1

1

In an Administrator prompt, this command is working:
D:\>gflags /p /enable MyBinary.exe /full /protect path: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options mybinary.exe: page heap enabled

Richard Dally
  • 1,432
  • 2
  • 21
  • 38