Skip to content

Commit

Permalink
Built WlanHelper.exe in Unicode instead of Multi-Byte. This will fix …
Browse files Browse the repository at this point in the history
…the wrong display of non-English characters.
  • Loading branch information
hsluoyz committed Nov 8, 2016
1 parent dbdcb7d commit 5951895
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
40 changes: 15 additions & 25 deletions packetWin7/WlanHelper/WlanHelper/Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../../../Common/WpcapNames.h"
// "\\Device\\NPF_{%s}" or "\\Device\\NPCAP_{%s}"
#define NPF_DRIVER_FORMAT_STR _T("\\Device\\") _T(NPF_DRIVER_NAME) _T("_WIFI_{%s}")
#define NPF_DRIVER_FORMAT_STR "\\Device\\" NPF_DRIVER_NAME "_WIFI_{%s}"

vector<tstring> g_strAdapterNames;
vector<tstring> g_strAdapterGUIDs;
Expand Down Expand Up @@ -224,7 +224,7 @@ tstring NdisStatus2Message(DWORD dwStatus)
}
else
{
return "";
return _T("");
}
}

Expand Down Expand Up @@ -286,37 +286,27 @@ BOOL wstring2string(const std::wstring &wstr, std::string &str)
return TRUE;
}

wstring any2wstring_a(string &str)
wstring tstring2wstring(tstring &str)
{
#ifdef UNICODE
return str;
#else
wstring wstr;
string2wstring(str, wstr);
return wstr;
#endif
}

wstring any2wstring_w(wstring &wstr)
{
return wstr;
}

string any2string_a(string &str)
{
return str;
}

string any2string_w(wstring &wstr)
string tstring2string(tstring &str)
{
string str;
wstring2string(wstr, str);
return str;
}

#ifdef UNICODE
#define any2wstring any2wstring_w
#define any2string any2string_w
string astr;
wstring2string(str, astr);
return astr;
#else
#define any2wstring any2wstring_a
#define any2string any2string_a
return str;
#endif
}

tstring itos(int i)
{
Expand Down Expand Up @@ -506,7 +496,7 @@ BOOL makeOIDRequest(tstring strAdapterGUID, ULONG iOid, BOOL bSet, PVOID pData,
}

char strAdapterName[256];
sprintf_s(strAdapterName, 256, NPF_DRIVER_FORMAT_STR, any2string(strAdapterGUID).c_str());
sprintf_s(strAdapterName, 256, NPF_DRIVER_FORMAT_STR, tstring2string(strAdapterGUID).c_str());

LPADAPTER pAdapter = My_PacketOpenAdapter(strAdapterName);
if (pAdapter == NULL)
Expand Down Expand Up @@ -542,7 +532,7 @@ BOOL makeOIDRequest(tstring strAdapterGUID, ULONG iOid, BOOL bSet, PVOID pData,
DWORD dwErrorCode = GetLastError() & ~(1 << 29);

LPTSTR strErrorText;
HMODULE hModule = LoadLibrary("NTDLL.DLL");
HMODULE hModule = LoadLibrary(_T("NTDLL.DLL"));
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE,
hModule, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&strErrorText, 0, NULL);
if (strErrorText != NULL && strErrorText[_tcslen(strErrorText) - 2] == _T('\r') && strErrorText[_tcslen(strErrorText) - 1] == _T('\n'))
Expand Down
8 changes: 4 additions & 4 deletions packetWin7/WlanHelper/WlanHelper/WlanHelper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define /*
!define /**/ WINPCAP_BUILD 921
#define /*
!define /**/ WINPCAP_VER_STRING "0.10 r16"
!define /**/ WINPCAP_VER_STRING "0.10 r17"

#define WINPCAP_PACKET9x_STRING_VERSION WINPCAP_VER_STRING
#define WINPCAP_WPCAP_STRING_VERSION WINPCAP_VER_STRING
Expand Down

0 comments on commit 5951895

Please sign in to comment.