sprintf an LPCWSTR variable
Posted
by Julio
on Stack Overflow
See other posts from Stack Overflow
or by Julio
Published on 2010-06-14T14:02:49Z
Indexed on
2010/06/14
18:32 UTC
Read the original article
Hit count: 525
Hello everyone. I'm trying to debug print an LPCWSTR string, but I get a problem during the sprintf push in the buffer, because it retrieve only the first character from the string. Here is the code:
HANDLE WINAPI hookedCreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { char buffer[1024]; sprintf_s(buffer, 1024, "CreateFileW: %s", lpFileName); OutputDebugString(buffer); return trueCreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, dwCreationDisposition, hTemplateFile); }
For example I get "CreateFileW: C" or "CreateFileW: \". How do I properly push it in the buffer?
Thank you.
© Stack Overflow or respective owner