Dbgprint output
1) Print the string directly.
Dbgprint ("Hello world!");
2) null-terminated string, you can use normal C syntax to represent string constants
Char variable_string[] = "Hello World";
Dbgprint ("%s", variable_string);
3) empty end of wide string (WCHAR type)
WCHAR string_w[] = L "Hello world!";
Dbgprint ("%ws", string_w);
Or
Dbgprint ("%s", string_w);
4) Unicode string, described by the unicode_string structure, contains 16-bit characters.
typedef struct _unicode_string{
USHORT Length;
USHORT MaximumLength;
Pwstr Buffer;
}unicode_string, *punicode_string;
unicode_string String_unicode = L "Hello world!";
Dbgprint ("%wz\n", &string_unicode);
5) ANSI string, described by the ansi_string structure, contains 8-bit characters.
typedef struct _string{
USHORT Length;
USHORT MaximumLength;
PCHAR Buffer;
}string, *pansi_string;
STRING Bar;
Or: Ansi_string bar;
Rtlinitansistring (&bar, "Hello world!");
Dbgprint ("%wz\n", &bar);
DebugPrint format specifier
Symbol format specifier type
%c,%LC ANSI character Char
%c,%WC wide character wchar_t
%d,%i decimal signed integer int
%d Decimal _int64 _int64
%l 16 binary Large_integer Large_integer
%s,%LS null-terminated ANSI string char*
%s,%WS null-terminated wide string wchar_t*
%Z ansi_string String
%wz unicode_string String
%u decimal of ULONG ulong
%x lowercase characters hexadecimal ulong ulong
%x uppercase character hexadecimal ulong ulong
%p pointer pointer 32/64-bit
According to DDK, the Unicode format (%c,%s,%LC,%ls,%WC,%ws, and%WZ) can only be used when IRQL = Passive_level.
The output information of the mode dbgprint in Vista cannot be output to WinDbg, because the new function DbgPrintEx is introduced under Vista (Dbgprint actually calls this function), This function controls the level of the output (which does not have to do it yourself). However, by default, the information output from Vista Dbgprint is not valid in WinDbg. You can make it work by following this method:
Open the registry to this path: hklm\system\ccs\control\session manager\debug Print Filter
Modify the default value to 0F and restart.
===========================================================
64 is an integral type of data type that has no deterministic specification in C + +. In today's mainstream compilers, support for the 64 integer is also standard and varies in form. In general, 64-bit integers are defined in long long and __int64 two (VC also supports _int64), while output to standard output is printf ("%lld", a), printf ("%i64d", a), and cout << A three different ways.
This article discusses the support for 64-bit integers in the five common C/s + + compilers, five of which are GCC (mingw32), g++ (MINGW32), GCC (Linux i386), g++ (Linux i386), Microsoft Visual C + + 6.0. Unfortunately, there is no combination of definitions and outputs that are compatible with these five compilers . To get a thorough understanding of the different compilers for 64-bit integers, I wrote the program to evaluate them, resulting in the following table.
variable definition |
Output Mode |
gcc (mingw32) |
g++ (MINGW32) |
gcc (Linux i386) |
g++ (Linux i386) |
microsoftvisual C + + 6.0 |
Long Long |
"%lld" |
Error |
Error |
That's right |
That's right |
Cannot compile |
Long Long |
"%i64d" |
That's right |
That's right |
Error |
Error |
Cannot compile |
__int64 |
"LLD" |
Error |
Error |
Cannot compile |
Cannot compile |
Error |
__int64 |
"%i64d" |
That's right |
That's right |
Cannot compile |
Cannot compile |
That's right |
Long Long |
cout |
Non-C + + |
That's right |
Non-C + + |
That's right |
Cannot compile |
__int64 |
cout |
Non-C + + |
That's right |
Non-C + + |
Cannot compile |
Cannot compile |
Long Long |
Printint64 () |
That's right |
That's right |
That's right |
That's right |
Cannot compile |
In the table above, correctly refers to the compilation pass, the operation is completely correct; the error means that the compilation passed, but the result is wrong; unable to compile means the compiler cannot compile at all. Observing the table above, we can find the following points:
- A long long definition can be used for gcc/g++, not platform-limited, but not for VC6.0.
- __int64 is the definition of the WIN32 platform compiler 64-bit long integer and cannot be used with Linux.
- "%lld" is used for the Linux i386 platform compiler, and "%i64d" is used for WIN32 platform compilers.
- Cout can only be used for C + + compilation, in VC6.0, the cout does not support 64-bit long integers.
The last line of output in the table is Printint64 () is a function I write myself, it can be seen that its compatibility is better than all other output methods, it is a code like this:
CPP void Printint64 (Long long a)
{
if (a<=100000000)
printf ("%d\n", a);
Else
{
printf ("%d", a/100000000);
printf ("d\n", a0000000);
}
}
The essence of this writing is to split the larger 64-bit integer into two 32-bit integers, then output sequentially, and the low part to be 0. What is the effect of a seemingly stupid writing? I compared it to the cout output mode, because it and cout are all cross-platform supported by C + +. First Printint64 () and cout(not emptying the buffer) run the same result without error. My experiment was to output 1 million random numbers using both, and the actual result was that Printint64 () ran out of the program in 1.5s, and cout needed 2s. cout a little bit slower, so when you're outputting a lot of data, try to avoid it.
//////////////////
d,lx,ld , Lu, these are all output 32-bit
hd,hx,hu, these are all output 16-bit data.
hhd,hhx,hhu, these are all 8-bit output.
LLD,LL,LLU,LLX, these are the output of 64-bit
%llu is a 64-bit unsigned
%LLX is the 64-bit 16 binary number
////////////////////////////////////////////////
Output formatted text format specifier according to the format specifier in the frm string is a subset of the standard format
%d--Output signed decimal integer
%o--Output unsigned octal integer
%x-Output unsigned hexadecimal integer
%x– In addition to capital letters using ' A '-' F ' with%x
%u-Output unsigned decimal integer
%s– output a null-terminated string with the C-Hollow character
%c– output only one character in ASCII character format
%f– output floating-point numbers in decimal form
%s– string constants for output in flash memory
If you specify a character between% and O or x, you will print 0 or at the beginning, respectively.
0x output Long Integer If there is an L (l) character specified between% and an integer format character
Instead of integers of integer type
The three versions that support printf depend on your needs and code size requirements The higher the code the larger
Primitives:%c,%d,%x,%u, and%s format specifiers are supported only without modifiers
Long shaping: Supports long shaping number modifier%ld,%lu,%LX, and width and precision modifiers
Floating point: Supports all formats including%f
%c ANSI character char
%d,%i decimal signed integer INT
%d Decimal __int64 __int64
%i IRP main function code and sub-function code PIRP
%l 16 binary __int64 __int64
%l Hex large_integer large_integer
%s null-terminated ANSI String char *
%s null-terminated wide string wchar_t *
%t unicode_string PUNICODE_ STRING
%u decimal ulong ulong
%x 16-based ULONG ULONG