Access violation in EngMultiByteToWideChar().

Hi,
I am getting access violation() in EngMultiByteToWideChar() when I am
calling ChangeDisplaySettings() for my mirror driver but is not happening
with UltraVNC mirror driver. I have checked all parameters are same and
correct.

[

Access violation - code c0000005 (!!! second chance !!!)
*** ERROR: Symbol file could not be found. Defaulted to export symbols for
win32k.sys -
win32k!EngMultiByteToWideChar+0x2f5:
91f25d79 397e14 cmp dword ptr [esi+14h],edi

]

I tried to google issues related to EngMultiByteToWideChar() but did not
find any thing relevant. My doubt is what could be probable reasons of
failing EngMultiByteToWideChar() call.

Any suggestion or pointer will be highly appreciable.

/sarbojit

My application first checks wether driver is installed or not if it is
installed then it is calling ChangeDisplaySettingsEx() with my mirror driver
to attach the driver and here is issue [access violation error in
EngMultiByteToWideChar()] comes but it is working absolutely fine for mv2
mirror driver(UltraVNC mirror driver).

I am clueless here so please help me.

/sarbojit

On Tue, Dec 14, 2010 at 12:22 PM, Sarbojit Sarkar wrote:

> Hi,
> I am getting access violation() in EngMultiByteToWideChar() when I am
> calling ChangeDisplaySettings() for my mirror driver but is not happening
> with UltraVNC mirror driver. I have checked all parameters are same and
> correct.
>
> [
> …
> Access violation - code c0000005 (!!! second chance !!!)
> *** ERROR: Symbol file could not be found. Defaulted to export symbols for
> win32k.sys -
> win32k!EngMultiByteToWideChar+0x2f5:
> 91f25d79 397e14 cmp dword ptr [esi+14h],edi
> …
> ]
>
> I tried to google issues related to EngMultiByteToWideChar() but did not
> find any thing relevant. My doubt is what could be probable reasons of
> failing EngMultiByteToWideChar() call.
>
> Any suggestion or pointer will be highly appreciable.
>
> /sarbojit
>

Try with the following function for driver Side:-
RtlUnicodeToUTF8N()
The RtlUnicodeToUTF8N routine converts a Unicode string to a UTF-8 string.

RtlUTF8ToUnicodeN()
The RtlUTF8ToUnicodeN routine converts a UTF-8 string to a Unicode string.

RtlxUnicodeStringToAnsiSize
The RtlxUnicodeStringToAnsiSize routine returns the number of bytes required for a NULL-terminated ANSI string that is equivalent to a specified Unicode string.

RtlxAnsiStringToUnicodeSize
The RtlxAnsiStringToUnicodeSize routine returns the number of bytes that are required for a NULL-terminated Unicode string that is equivalent to a specified ANSI string.

Try with the following function forApplication Side:-

wmemset(HubPhyPath,0,MAX_PHY_PATH_LEN);
wcscat(HubPhyPath,PHY_DRIVE_PREFIX);
wcscat(HubPhyPath,pConnectionName->NodeName);

CString sHubPath(stArrayOfDevice[giDriveNumber].strHubName);
MultiByteToWideChar( CP_ACP, 0, DevPath, -1, gDevicePhysicalPath, iCnt);
wmemcpy(strHubName, stArrayOfDevice[DeviceNum].strHubName, wcslen(stArrayOfDevice[DeviceNum].strHubName));
/* Copy the physical path of device to global structure */
wmemset(gDevicePhysicalPath, 0x00, UFD_STRING_PATH_LENGTH);
wmemset(stArrayOfDevice[gdwDriveIndex].gAryDevicePhysicalPath, 0x00, UFD_STRING_PATH_LENGTH);
CString stTmp(pDeviceDetailData->DevicePath);
MultiByteToWideChar( CP_ACP, 0, stTmp, -1, gDevicePhysicalPath, stTmp.GetLength());
MultiByteToWideChar( CP_ACP, 0, stTmp, -1, stArrayOfDevice[gdwDriveIndex].gAryDevicePhysicalPath, stTmp.GetLength());
wmemcpy(stArrayOfDevice[.gdwDriveIndex].strHubName, HubPhyPath, wcslen(HubPhyPath));
//wmemcpy(stArrayOfDevice[gdwDriveIndex].strHubName, strHubName, strHubName.GetLength());
wmemset(strHubName, 0x00, DEVICE_STRING_INFO_LENGTH);
MultiByteToWideChar( CP_ACP, 0, strHubName, -1, .strHubName, strHubName.GetLength());

Thanks for quick response…

But my doubt is crash in happening before DrvEnableDriver() call for my
driver. So why driver need any change?

I am very much interested to know what are probable reasons of failing
EngMultiByteToWideChar()
and when I am calling ChangeDisplaySettingsEx() which all functions will get
called?

/sarbojit

On Tue, Dec 14, 2010 at 7:09 PM, wrote:

> Try with the following function for driver Side:-
> RtlUnicodeToUTF8N()
> The RtlUnicodeToUTF8N routine converts a Unicode string to a UTF-8 string.
>
> RtlUTF8ToUnicodeN()
> The RtlUTF8ToUnicodeN routine converts a UTF-8 string to a Unicode string.
>
> RtlxUnicodeStringToAnsiSize
> The RtlxUnicodeStringToAnsiSize routine returns the number of bytes
> required for a NULL-terminated ANSI string that is equivalent to a specified
> Unicode string.
>
> RtlxAnsiStringToUnicodeSize
> The RtlxAnsiStringToUnicodeSize routine returns the number of bytes that
> are required for a NULL-terminated Unicode string that is equivalent to a
> specified ANSI string.
>
> Try with the following function forApplication Side:-
> ==========
> wmemset(HubPhyPath,0,MAX_PHY_PATH_LEN);
> wcscat(HubPhyPath,PHY_DRIVE_PREFIX);
> wcscat(HubPhyPath,pConnectionName->NodeName);
>
> CString sHubPath(stArrayOfDevice[giDriveNumber].strHubName);
> MultiByteToWideChar( CP_ACP, 0, DevPath, -1, gDevicePhysicalPath, iCnt);
> wmemcpy(strHubName, stArrayOfDevice[DeviceNum].strHubName,
> wcslen(stArrayOfDevice[DeviceNum].strHubName));
> /* Copy the physical path of device to global structure */
> wmemset(gDevicePhysicalPath, 0x00, UFD_STRING_PATH_LENGTH);
> wmemset(stArrayOfDevice[gdwDriveIndex].gAryDevicePhysicalPath, 0x00,
> UFD_STRING_PATH_LENGTH);
> CString stTmp(pDeviceDetailData->DevicePath);
> MultiByteToWideChar( CP_ACP, 0, stTmp, -1, gDevicePhysicalPath,
> stTmp.GetLength());
> MultiByteToWideChar( CP_ACP, 0, stTmp, -1,
> stArrayOfDevice[gdwDriveIndex].gAryDevicePhysicalPath, stTmp.GetLength());
> wmemcpy(stArrayOfDevice[.gdwDriveIndex].strHubName, HubPhyPath,
> wcslen(HubPhyPath));
> //wmemcpy(stArrayOfDevice[gdwDriveIndex].strHubName, strHubName,
> strHubName.GetLength());
> wmemset(strHubName, 0x00, DEVICE_STRING_INFO_LENGTH);
> MultiByteToWideChar( CP_ACP, 0, strHubName, -1, .strHubName,
> strHubName.GetLength());
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Sarbojit Sarkar wrote:

My application first checks wether driver is installed or not if it is
installed then it is calling ChangeDisplaySettingsEx() with my mirror
driver to attach the driver and here is issue [access violation error
in EngMultiByteToWideChar()] comes but it is working absolutely fine
for mv2 mirror driver(UltraVNC mirror driver).

I am clueless here so please help me.

I would hope that it was obvious that you haven’t given us nearly enough
information. You seem to be looking for bugs in EngMultiByteToWideChar,
when the problem is almost undoubtedly a bug in your mirror driver.
What does “!analyze -v” say? What does the call stack say? What were
the registers? How was your driver involved?

On Tue, Dec 14, 2010 at 12:22 PM, Sarbojit Sarkar
> wrote:
>
> Hi,
> I am getting access violation() in EngMultiByteToWideChar() when
> I am calling ChangeDisplaySettings() for my mirror driver but is
> not happening with UltraVNC mirror driver. I have checked all
> parameters are same and correct.
>

I’m dubious. How have you checked all the parameters?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Sarbojit Sarkar wrote:

But my doubt is crash in happening before DrvEnableDriver() call for
my driver.

How do you know that?

So why driver need any change?

I am very much interested to know what are probable reasons of
failing EngMultiByteToWideChar() and when I am calling
ChangeDisplaySettingsEx() which all functions will get called?

How are you calling ChangeDisplaySettingsEx? What was the value of
edi? Was it a null pointer, or a garbage pointer?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.