From: John Bond on
My driver is currently using WPP tracing to assist my development and
debugging. I need to see details that occur early, and decided to attempt
using the Global Logger Session. After reading several related pages, I
added the #define WPP_GLOBALLOGGER to my trace.h file after the #define
WPP_CONTROL_GUIDS macro definition.

I now get the following compile error in only the .cpp file that has the
WPP_INIT_TRACING macro call (SwrxDriver.cpp in the DriverEntry function):

....SwrxDriver.tmh(2048) : error C2664: 'RtlStringFromGUID' : cannot convert
parameter 1 from 'LPCGUID' to 'const GUID &'

When I commend out the #define WPP_GLOBALLOGGER macro, the driver compiles
without comment.

Any suggestions? John Bond
From: Doron Holan [MSFT] on
try wrapping the #include of the tmh file in an extern "C" { } block

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


"John Bond" <johnbond(a)newsgroup.nospam> wrote in message
news:BE215B0A-B743-4D34-83A1-1305FDF9D45D(a)microsoft.com...
> My driver is currently using WPP tracing to assist my development and
> debugging. I need to see details that occur early, and decided to attempt
> using the Global Logger Session. After reading several related pages, I
> added the #define WPP_GLOBALLOGGER to my trace.h file after the #define
> WPP_CONTROL_GUIDS macro definition.
>
> I now get the following compile error in only the .cpp file that has the
> WPP_INIT_TRACING macro call (SwrxDriver.cpp in the DriverEntry function):
>
> ...SwrxDriver.tmh(2048) : error C2664: 'RtlStringFromGUID' : cannot
> convert
> parameter 1 from 'LPCGUID' to 'const GUID &'
>
> When I commend out the #define WPP_GLOBALLOGGER macro, the driver compiles
> without comment.
>
> Any suggestions? John Bond

From: John Bond on
Thx Doron, but I still get the same compile error:

----------------------------------------------------code
snippet-----------------------------
//SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
driver model

//Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
reserved.
// Started with shell of MT2HAdriver which used pcidrv and plx9x5x example
code from the WDF samples
// Updated 18 September 2009 with code to create single fixed-name IOCTL
target for the driver.

//include the precompiled header file
#include "precomp.h"
#define WPP_GLOBALLOGGER

//*.tmh - trace message headers generated by the WPP preprocessor must
preceed WPP macro calls
// which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
precomp.h
// This is required to support TraceEvents(level, flags, msg, ...) trace
statements.
// The name "TraceEvents" is defined in the sources file under the RUN_WPP
build directive
extern "C" {
#include "SwrxDriver.tmh"
}
------------------------------------------------end code
snippet-----------------------------

-----------------------SwrxDriver.tmh generated header
snippet-------------------------
#ifdef WPP_GLOBALLOGGER
#define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
#define WPP_TEXTGUID_LEN 38
#define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH

WPPINIT_EXPORT
void WppInitGlobalLogger(
__in LPCGUID ControlGuid,
__out PTRACEHANDLE LoggerHandle,
__out PULONG Flags,
__out PUCHAR Level
)
{
WCHAR GRegValueName[GREGVALUENAMELENGTH];
RTL_QUERY_REGISTRY_TABLE Parms[3];
ULONG CurrentFlags = 0;
ULONG CurrentLevel = 0;
ULONG Start = 0;
NTSTATUS Status;
ULONG Zero = 0;
UNICODE_STRING GuidString;


PAGED_CODE();

WppDebug(0,("WPP checking Global Logger\n"));


//
// Fill in the query table to find out if the Global Logger is Started
//
// Trace Flags
Parms[0].QueryRoutine = NULL;
Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[0].Name = L"Start";
Parms[0].EntryContext = &Start;
Parms[0].DefaultType = REG_DWORD;
Parms[0].DefaultData = &Zero;
Parms[0].DefaultLength = sizeof(ULONG);
// Termination
Parms[1].QueryRoutine = NULL;
Parms[1].Flags = 0;
//
// Perform the query
//

Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
RTL_REGISTRY_OPTIONAL,
DEFAULT_GLOBAL_LOGGER_KEY,
Parms,
NULL,
NULL);
if (!NT_SUCCESS(Status) || Start == 0 ) {
return;
}

// Fill in the query table to find out if we should use the Global logger
//
// Trace Flags
Parms[0].QueryRoutine = NULL;
Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[0].Name = L"Flags";
Parms[0].EntryContext = &CurrentFlags;
Parms[0].DefaultType = REG_DWORD;
Parms[0].DefaultData = &Zero;
Parms[0].DefaultLength = sizeof(ULONG);
// Trace level
Parms[1].QueryRoutine = NULL;
Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
Parms[1].Name = L"Level";
Parms[1].EntryContext = &CurrentLevel;
Parms[1].DefaultType = REG_DWORD;
Parms[1].DefaultData = &Zero;
Parms[1].DefaultLength = sizeof(UCHAR);
// Termination
Parms[2].QueryRoutine = NULL;
Parms[2].Flags = 0;


RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
(wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));

Status = RtlStringFromGUID(ControlGuid, &GuidString);
----------------------------------------end at line 2048 of
SwrxDriver.tmh----------------

The last line is the point of the compile error... hope this helps.

John Bond
From: Ivan Brugiolo [MSFT] on
I guess your driver is compiled with __cpluplus defined.
That would #define REFGUID differently.
It is not clear (unless you analyze the output of `cl.exe /showIncludes`)
who first defines _REFGUID_DEFINED and/or if your precompiled header
can be wrapped with #ifndef __cplusplus/extern "C" {/#endif.
Try to have the header that first defines REFGUID
to be trated as a C compilation unit.

Good Luck with header reshuffling.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"John Bond" <johnbond(a)newsgroup.nospam> wrote in message
news:55F6CB4D-9543-40CA-9EA5-568D6B05A3F6(a)microsoft.com...
> Thx Doron, but I still get the same compile error:
>
> ----------------------------------------------------code
> snippet-----------------------------
> //SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
> driver model
>
> //Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
> reserved.
> // Started with shell of MT2HAdriver which used pcidrv and plx9x5x
> example
> code from the WDF samples
> // Updated 18 September 2009 with code to create single fixed-name IOCTL
> target for the driver.
>
> //include the precompiled header file
> #include "precomp.h"
> #define WPP_GLOBALLOGGER
>
> //*.tmh - trace message headers generated by the WPP preprocessor must
> preceed WPP macro calls
> // which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
> precomp.h
> // This is required to support TraceEvents(level, flags, msg, ...) trace
> statements.
> // The name "TraceEvents" is defined in the sources file under the
> RUN_WPP
> build directive
> extern "C" {
> #include "SwrxDriver.tmh"
> }
> ------------------------------------------------end code
> snippet-----------------------------
>
> -----------------------SwrxDriver.tmh generated header
> snippet-------------------------
> #ifdef WPP_GLOBALLOGGER
> #define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
> #define WPP_TEXTGUID_LEN 38
> #define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
> wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH
>
> WPPINIT_EXPORT
> void WppInitGlobalLogger(
> __in LPCGUID ControlGuid,
> __out PTRACEHANDLE LoggerHandle,
> __out PULONG Flags,
> __out PUCHAR Level
> )
> {
> WCHAR GRegValueName[GREGVALUENAMELENGTH];
> RTL_QUERY_REGISTRY_TABLE Parms[3];
> ULONG CurrentFlags = 0;
> ULONG CurrentLevel = 0;
> ULONG Start = 0;
> NTSTATUS Status;
> ULONG Zero = 0;
> UNICODE_STRING GuidString;
>
>
> PAGED_CODE();
>
> WppDebug(0,("WPP checking Global Logger\n"));
>
>
> //
> // Fill in the query table to find out if the Global Logger is Started
> //
> // Trace Flags
> Parms[0].QueryRoutine = NULL;
> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[0].Name = L"Start";
> Parms[0].EntryContext = &Start;
> Parms[0].DefaultType = REG_DWORD;
> Parms[0].DefaultData = &Zero;
> Parms[0].DefaultLength = sizeof(ULONG);
> // Termination
> Parms[1].QueryRoutine = NULL;
> Parms[1].Flags = 0;
> //
> // Perform the query
> //
>
> Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
> RTL_REGISTRY_OPTIONAL,
> DEFAULT_GLOBAL_LOGGER_KEY,
> Parms,
> NULL,
> NULL);
> if (!NT_SUCCESS(Status) || Start == 0 ) {
> return;
> }
>
> // Fill in the query table to find out if we should use the Global
> logger
> //
> // Trace Flags
> Parms[0].QueryRoutine = NULL;
> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[0].Name = L"Flags";
> Parms[0].EntryContext = &CurrentFlags;
> Parms[0].DefaultType = REG_DWORD;
> Parms[0].DefaultData = &Zero;
> Parms[0].DefaultLength = sizeof(ULONG);
> // Trace level
> Parms[1].QueryRoutine = NULL;
> Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
> Parms[1].Name = L"Level";
> Parms[1].EntryContext = &CurrentLevel;
> Parms[1].DefaultType = REG_DWORD;
> Parms[1].DefaultData = &Zero;
> Parms[1].DefaultLength = sizeof(UCHAR);
> // Termination
> Parms[2].QueryRoutine = NULL;
> Parms[2].Flags = 0;
>
>
> RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
> (wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));
>
> Status = RtlStringFromGUID(ControlGuid, &GuidString);
> ----------------------------------------end at line 2048 of
> SwrxDriver.tmh----------------
>
> The last line is the point of the compile error... hope this helps.
>
> John Bond

From: Doron Holan [MSFT] on
what WDK are you using? I think we fixed this in the win7 wdk.

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


"Ivan Brugiolo [MSFT]" <ivanbrug(a)online.microsoft.com> wrote in message
news:OtUYm#hcKHA.744(a)TK2MSFTNGP05.phx.gbl...
> I guess your driver is compiled with __cpluplus defined.
> That would #define REFGUID differently.
> It is not clear (unless you analyze the output of `cl.exe /showIncludes`)
> who first defines _REFGUID_DEFINED and/or if your precompiled header
> can be wrapped with #ifndef __cplusplus/extern "C" {/#endif.
> Try to have the header that first defines REFGUID
> to be trated as a C compilation unit.
>
> Good Luck with header reshuffling.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "John Bond" <johnbond(a)newsgroup.nospam> wrote in message
> news:55F6CB4D-9543-40CA-9EA5-568D6B05A3F6(a)microsoft.com...
>> Thx Doron, but I still get the same compile error:
>>
>> ----------------------------------------------------code
>> snippet-----------------------------
>> //SwrxDriver.cpp -- driver entry points for SmartWORKS updated for KMDF
>> driver model
>>
>> //Created 21 August 2009, Copyright (c) 2009 AudioCodes, Inc. All rights
>> reserved.
>> // Started with shell of MT2HAdriver which used pcidrv and plx9x5x
>> example
>> code from the WDF samples
>> // Updated 18 September 2009 with code to create single fixed-name IOCTL
>> target for the driver.
>>
>> //include the precompiled header file
>> #include "precomp.h"
>> #define WPP_GLOBALLOGGER
>>
>> //*.tmh - trace message headers generated by the WPP preprocessor must
>> preceed WPP macro calls
>> // which requires that WPP_CONTROL_GUIDS macro be defined earlier, see
>> precomp.h
>> // This is required to support TraceEvents(level, flags, msg, ...) trace
>> statements.
>> // The name "TraceEvents" is defined in the sources file under the
>> RUN_WPP
>> build directive
>> extern "C" {
>> #include "SwrxDriver.tmh"
>> }
>> ------------------------------------------------end code
>> snippet-----------------------------
>>
>> -----------------------SwrxDriver.tmh generated header
>> snippet-------------------------
>> #ifdef WPP_GLOBALLOGGER
>> #define DEFAULT_GLOBAL_LOGGER_KEY L"WMI\\GlobalLogger\\"
>> #define WPP_TEXTGUID_LEN 38
>> #define GREGVALUENAMELENGTH (18 + WPP_TEXTGUID_LEN) //
>> wslen(L"WMI\\GlobalLogger\\") + GUIDLENGTH
>>
>> WPPINIT_EXPORT
>> void WppInitGlobalLogger(
>> __in LPCGUID ControlGuid,
>> __out PTRACEHANDLE LoggerHandle,
>> __out PULONG Flags,
>> __out PUCHAR Level
>> )
>> {
>> WCHAR GRegValueName[GREGVALUENAMELENGTH];
>> RTL_QUERY_REGISTRY_TABLE Parms[3];
>> ULONG CurrentFlags = 0;
>> ULONG CurrentLevel = 0;
>> ULONG Start = 0;
>> NTSTATUS Status;
>> ULONG Zero = 0;
>> UNICODE_STRING GuidString;
>>
>>
>> PAGED_CODE();
>>
>> WppDebug(0,("WPP checking Global Logger\n"));
>>
>>
>> //
>> // Fill in the query table to find out if the Global Logger is Started
>> //
>> // Trace Flags
>> Parms[0].QueryRoutine = NULL;
>> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[0].Name = L"Start";
>> Parms[0].EntryContext = &Start;
>> Parms[0].DefaultType = REG_DWORD;
>> Parms[0].DefaultData = &Zero;
>> Parms[0].DefaultLength = sizeof(ULONG);
>> // Termination
>> Parms[1].QueryRoutine = NULL;
>> Parms[1].Flags = 0;
>> //
>> // Perform the query
>> //
>>
>> Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL |
>> RTL_REGISTRY_OPTIONAL,
>> DEFAULT_GLOBAL_LOGGER_KEY,
>> Parms,
>> NULL,
>> NULL);
>> if (!NT_SUCCESS(Status) || Start == 0 ) {
>> return;
>> }
>>
>> // Fill in the query table to find out if we should use the Global
>> logger
>> //
>> // Trace Flags
>> Parms[0].QueryRoutine = NULL;
>> Parms[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[0].Name = L"Flags";
>> Parms[0].EntryContext = &CurrentFlags;
>> Parms[0].DefaultType = REG_DWORD;
>> Parms[0].DefaultData = &Zero;
>> Parms[0].DefaultLength = sizeof(ULONG);
>> // Trace level
>> Parms[1].QueryRoutine = NULL;
>> Parms[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
>> Parms[1].Name = L"Level";
>> Parms[1].EntryContext = &CurrentLevel;
>> Parms[1].DefaultType = REG_DWORD;
>> Parms[1].DefaultData = &Zero;
>> Parms[1].DefaultLength = sizeof(UCHAR);
>> // Termination
>> Parms[2].QueryRoutine = NULL;
>> Parms[2].Flags = 0;
>>
>>
>> RtlCopyMemory(GRegValueName, DEFAULT_GLOBAL_LOGGER_KEY,
>> (wcslen(DEFAULT_GLOBAL_LOGGER_KEY)+1) *sizeof(WCHAR));
>>
>> Status = RtlStringFromGUID(ControlGuid, &GuidString);
>> ----------------------------------------end at line 2048 of
>> SwrxDriver.tmh----------------
>>
>> The last line is the point of the compile error... hope this helps.
>>
>> John Bond
>