- Detect platform toolset at compile time:
Go to "Properties" -> "C/C++" -> "Preprocessor" and add the following contents to "Preprocessor Definitions".
_MSC_PLATFORM_TOOLSET_$(PlatformToolset)
_MSC_PLATFORM_TOOLSET_VERSION=$(PlatformToolsetVersion)
Then you can use it in your code:
#ifndef _MSC_PLATFORM_TOOLSET_v141_xp
// ...
#endif
It seems that _USING_V110_SDK71_
inherited from defaults also works. :-D
- Open VS
- "Tools" -> "External Tools..." -> select "Visual Studio &Command Prompt"
- Change the value in "Initial directory" to
$(SolutionDir)
- Change the value in "Arguments" to
/K "vsdevcmd.bat -no_logo" & powershell
Similarily, you can open a command line prompt with all environment variables inherited from dev tools.
- Dev Command Prompt
Title | Command | Arguments | Initial directory |
---|---|---|---|
Dev Command | %systemroot%\system32\cmd.exe |
/K "vsdevcmd.bat -no_logo" |
$(ProjectDir) |
- Dev Powershell
Title | Command | Arguments | Initial directory |
---|---|---|---|
Dev Powershell | %systemroot%\system32\cmd.exe |
/K "vsdevcmd.bat -no_logo" & powershell |
$(ProjectDir) |
- Open Binary Directory
Title | Command | Arguments | Initial directory |
---|---|---|---|
Open Binary Directory | %systemroot%\system32\cmd.exe |
/C "start ." |
$(BinDir) |
See here for more options of cmd
.
- Output information of sections
dumpbin 0day-console-app.exe /headers
format-hex tmp.out
output:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 66 51 B4 01 fQ´.
/FA
: output assembly in text
Commands | Powershell | Batch |
---|---|---|
Print path |
echo $env:path |
echo %path% |
Print the working directory | echo $pwd |
echo %cd% |
Set an environment variable | $env:GEOS_DIR="$pwd\build" |
set GEOS_DIR=%cd%\build |
- Concantenate strings and ouput "Hello, world" using command substitution which is not supported in command prompt:
echo ", " > 1.in
echo "Hellow$(type 1.in)world!" > 2.in
type 2.in
However, neither type
nor gc
(Get-Content
) could outperform the unix-like cat
on manipulating binary file in a convenient way.
MinGW saves the day.:-p
Default settings for command prompt are stored under HKEY_CURRENT_USER\Console
and HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe
.
- Dump bytes to file using python
python -c "print('\x44'*(220-177))" > test.out
- Print file content:
type test.out
See here for tennical information.
Disable Windows error reporting:
Windows Error Reporting could be taking over the error handling on your computer. To fix this issue, use Registry Editor to add a DWORD Value of Disabled, with Value data of 1, to the following registry keys:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting
- (For 64-bit machines): HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows\Windows Error Reporting
Configuring Automatic Debugging:
A known Windows issue may be causing the Just-In-Time debugger to fail. The fix is to add a DWORD Value of Auto, with Value data of 1, to the following registry keys:
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
- (For 64-bit machines): HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug
Additionally, run windbg -I
to install windbg as the default debugger