Commit 7884a569 authored by Grant Kim's avatar Grant Kim

[ModOrganizer-Ui][libhook]Cleanup compiler warnings

parent 84fc2658
......@@ -14,12 +14,13 @@
# error Please check compiler target!
#endif // _NOT_ WIN32
#define WINVER 0x0502
#define WINVER 0x0600
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif // define WIN32_LEAN_AND_MEAN
#undef NOMINMAX
#define NOMINMAX // std::min and std::max
#include <windows.h>
......
......@@ -39,6 +39,8 @@ ADD_LIBRARY(hookdll MODULE ${hookdll_HDRS} ${hookdll_SRCS})
target_link_libraries( hookdll PRIVATE shared )
# Win32
target_link_libraries( hookdll PUBLIC psapi version shlwapi bsatk z Boost::thread )
target_include_directories(hookdll PUBLIC
${CMAKE_SOURCE_DIR}/src/common/platforms/msw)
# include_directories()
......
......@@ -21,11 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef APIHOOK_H
#define APIHOOK_H
#define WIN32_LEAN_AND_MEAN
#include "disasm.h"
#include <windows.h>
class ApiHook
{
......
......@@ -21,8 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef DISASM_H
#define DISASM_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <WindowsCore.h>
class Disasm
{
......@@ -52,8 +51,8 @@ public:
/// \param target the target address to copy to
/// \param pos1 beginning of the whole copy operation (including previous
/// and future CopyTos)
/// This (and the next parameter) is important to decide whether
///a relative jump has to be adjusted
/// This (and the next parameter) is important to decide
/// whether a relative jump has to be adjusted
/// \param size number of bytes that are being copied
/// \return the first byte after the copied instruction
PBYTE CopyTo( PBYTE target, PBYTE pos1, size_t size );
......
......@@ -204,7 +204,7 @@ BOOL CreateDirectoryRecursive(
wcsncpy( buffer, lpPathName, currentLen );
if ( CreateDirectoryW_reroute( buffer, lpSecurityAttributes ) )
{
if ( ::GetLastError() != ERROR_ALREADY_EXISTS )
if (::GetLastError() != ERROR_ALREADY_EXISTS )
{
Logger::Instance().error(
"failed to create intermediate directory %ls: %lu",
......@@ -239,8 +239,8 @@ BOOL WINAPI CreateProcessA_rep(
{
char buffer[MAX_PATH];
LPSTR filePart = nullptr;
if ( ( ::GetFullPathNameA(
lpApplicationName, MAX_PATH, buffer, &filePart ) != 0 ) &&
if ( (::GetFullPathNameA(
lpApplicationName, MAX_PATH, buffer, &filePart ) != 0 ) &&
( filePart != nullptr ) )
{
for ( char *pos = filePart; *pos != '\0'; ++pos )
......@@ -304,7 +304,7 @@ BOOL WINAPI CreateProcessA_rep(
}
if ( !susp &&
( ::ResumeThread( lpProcessInformation->hThread ) == (DWORD)-1 ) )
(::ResumeThread( lpProcessInformation->hThread ) == (DWORD)-1 ) )
{
Logger::Instance().error( "failed to inject into spawned process" );
return FALSE;
......@@ -334,8 +334,8 @@ BOOL WINAPI CreateProcessW_rep(
{
wchar_t buffer[MAX_PATH];
LPWSTR filePart = nullptr;
if ( ( ::GetFullPathNameW(
lpApplicationName, MAX_PATH, buffer, &filePart ) != 0 ) &&
if ( (::GetFullPathNameW(
lpApplicationName, MAX_PATH, buffer, &filePart ) != 0 ) &&
( filePart != nullptr ) )
{
for ( wchar_t *pos = filePart; *pos != L'\0'; ++pos )
......@@ -408,7 +408,7 @@ BOOL WINAPI CreateProcessW_rep(
}
if ( !susp &&
( ::ResumeThread( lpProcessInformation->hThread ) == (DWORD)-1 ) )
(::ResumeThread( lpProcessInformation->hThread ) == (DWORD)-1 ) )
{
Logger::Instance().error( "failed to inject into spawned process" );
return FALSE;
......@@ -417,7 +417,7 @@ BOOL WINAPI CreateProcessW_rep(
}
HMODULE WINAPI
LoadLibraryExW_rep( LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags )
LoadLibraryExW_rep( LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags )
{
PROFILE();
std::wstring rerouteFilename = modInfo->getRerouteOpenExisting( lpFileName );
......@@ -432,7 +432,7 @@ HMODULE WINAPI LoadLibraryW_rep( LPCWSTR lpFileName )
}
HMODULE WINAPI
LoadLibraryExA_rep( LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags )
LoadLibraryExA_rep( LPCSTR lpFileName, HANDLE hFile, DWORD dwFlags )
{
PROFILE();
return LoadLibraryExW_rep(
......@@ -810,7 +810,7 @@ BOOL GetNext( HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData )
}
BOOL WINAPI
FindNextFileW_rep( HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData )
FindNextFileW_rep( HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData )
{
PROFILE();
......@@ -1085,7 +1085,7 @@ static std::wstring GetSectionName( PVOID address )
HANDLE process = ::GetCurrentProcess();
HMODULE modules[1024];
DWORD required;
if ( ::EnumProcessModules( process, modules, sizeof( modules ), &required ) )
if (::EnumProcessModules( process, modules, sizeof( modules ), &required ) )
{
for ( DWORD i = 0;
i < ( std::min<DWORD>( 1024UL, required ) / sizeof( HMODULE ) );
......@@ -1097,8 +1097,8 @@ static std::wstring GetSectionName( PVOID address )
{
wchar_t modName[MAX_PATH];
if ( ::GetModuleFileNameExW(
GetCurrentProcess(), modules[i], modName, MAX_PATH ) )
if (::GetModuleFileNameExW(
GetCurrentProcess(), modules[i], modName, MAX_PATH ) )
{
return std::wstring( modName );
}
......@@ -1504,7 +1504,7 @@ DWORD WINAPI GetPrivateProfileStringA_rep(
int res = (std::min<int>)( nSize - 1, defLength );
if ( res > 0 )
{
strncpy( lpReturnedString, lpDefault, res );
memcpy( lpReturnedString, lpDefault, res );
lpReturnedString[res] = '\0';
return res;
}
......@@ -1555,7 +1555,7 @@ DWORD WINAPI GetPrivateProfileStringA_rep(
rerouteFilename.c_str() );
// lpFileName can't be nullptr here because there is a test earlier in the
// function
if ( ( ::GetLastError() == ERROR_FILE_NOT_FOUND ) &&
if ( (::GetLastError() == ERROR_FILE_NOT_FOUND ) &&
( lpFileName != nullptr ) &&
!( existingIniA.find( lpFileName ) != existingIniA.end() ) &&
!FileExists( lpFileName ) )
......@@ -2108,7 +2108,7 @@ BOOL WINAPI WritePrivateProfileStructW_rep(
}
HFILE WINAPI
OpenFile_rep( LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle )
OpenFile_rep( LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle )
{
PROFILE();
......@@ -2371,7 +2371,7 @@ DWORD WINAPI GetFullPathNameW_rep(
return length + 1;
}
}
else if ( ::PathIsRelativeW( searchPath ) )
else if (::PathIsRelativeW( searchPath ) )
{
WCHAR temp[MAX_PATH];
......@@ -2380,7 +2380,7 @@ DWORD WINAPI GetFullPathNameW_rep(
WCHAR temp2[MAX_PATH];
size_t count = 0UL;
if ( ::PathCanonicalizeW( temp2, temp ) )
if (::PathCanonicalizeW( temp2, temp ) )
{
size_t length = wcslen( temp2 );
if ( ( lpBuffer != nullptr ) && ( nBufferLength > 0 ) )
......@@ -2674,7 +2674,7 @@ BOOL WINAPI GetFileVersionInfoExW_rep(
}
DWORD WINAPI
GetFileVersionInfoSizeW_rep( LPCWSTR lptstrFilename, LPDWORD lpdwHandle )
GetFileVersionInfoSizeW_rep( LPCWSTR lptstrFilename, LPDWORD lpdwHandle )
{
PROFILE();
......@@ -2702,7 +2702,7 @@ GetFileVersionInfoSizeW_rep( LPCWSTR lptstrFilename, LPDWORD lpdwHandle )
}
DWORD WINAPI
GetModuleFileNameW_rep( HMODULE hModule, LPWSTR lpFilename, DWORD nSize )
GetModuleFileNameW_rep( HMODULE hModule, LPWSTR lpFilename, DWORD nSize )
{
PROFILE();
......@@ -2749,7 +2749,7 @@ GetModuleFileNameW_rep( HMODULE hModule, LPWSTR lpFilename, DWORD nSize )
}
DWORD WINAPI
GetModuleFileNameA_rep( HMODULE hModule, LPSTR lpFilename, DWORD nSize )
GetModuleFileNameA_rep( HMODULE hModule, LPSTR lpFilename, DWORD nSize )
{
PROFILE();
......@@ -2975,57 +2975,66 @@ void GetInfoData(
{
switch ( infoClass )
{
case FileBothDirectoryInformation: {
case FileBothDirectoryInformation:
{
FILE_BOTH_DIR_INFORMATION *info =
reinterpret_cast<FILE_BOTH_DIR_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileDirectoryInformation: {
case FileDirectoryInformation:
{
FILE_DIRECTORY_INFORMATION *info =
reinterpret_cast<FILE_DIRECTORY_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileNamesInformation: {
case FileNamesInformation:
{
FILE_NAMES_INFORMATION *info =
reinterpret_cast<FILE_NAMES_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileIdFullDirectoryInformation: {
case FileIdFullDirectoryInformation:
{
FILE_ID_FULL_DIR_INFORMATION *info =
reinterpret_cast<FILE_ID_FULL_DIR_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileFullDirectoryInformation: {
case FileFullDirectoryInformation:
{
FILE_FULL_DIR_INFORMATION *info =
reinterpret_cast<FILE_FULL_DIR_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileIdBothDirectoryInformation: {
case FileIdBothDirectoryInformation:
{
FILE_ID_BOTH_DIR_INFORMATION *info =
reinterpret_cast<FILE_ID_BOTH_DIR_INFORMATION *>( address );
offset = info->NextEntryOffset;
fileName.assign( info->FileName, info->FileNameLength / sizeof( WCHAR ) );
}
break;
case FileObjectIdInformation: {
case FileObjectIdInformation:
{
offset = sizeof( FILE_OBJECTID_INFORMATION );
}
break;
case FileReparsePointInformation: {
case FileReparsePointInformation:
{
offset = sizeof( FILE_REPARSE_POINT_INFORMATION );
}
break;
default: {
default:
{
offset = ULONG_MAX;
}
break;
......@@ -3381,7 +3390,7 @@ BOOL InitHooks()
ULONGLONG mask =
::VerSetConditionMask( 0, VER_MAJORVERSION, VER_GREATER_EQUAL );
if ( ::VerifyVersionInfo( &versionInfo, VER_MAJORVERSION, mask ) )
if (::VerifyVersionInfo( &versionInfo, VER_MAJORVERSION, mask ) )
{
// if (versionInfo.dwMajorVersion >= 6) { // vista and up
INITHOOK( TEXT( "version.dll" ), GetFileVersionInfoExW );
......@@ -3648,7 +3657,7 @@ void writeMiniDump( PEXCEPTION_POINTERS exceptionPtrs )
if ( funcDump )
{
wchar_t dmpPath[MAX_PATH_UNICODE];
if ( ::GetModuleFileNameW( dllModule, dmpPath, MAX_PATH_UNICODE ) == 0 )
if (::GetModuleFileNameW( dllModule, dmpPath, MAX_PATH_UNICODE ) == 0 )
{
Logger::Instance().error(
"No crash dump created, failed to determine destination directory. "
......@@ -3819,14 +3828,14 @@ BOOL Init( int logLevel, const wchar_t *profileName )
mutexName[100] = '\0';
instanceMutex = ::CreateMutexW( nullptr, FALSE, mutexName );
if ( ( instanceMutex == nullptr ) ||
( ::GetLastError() == ERROR_ALREADY_EXISTS ) )
(::GetLastError() == ERROR_ALREADY_EXISTS ) )
{
return TRUE;
}
wchar_t pathBuffer[MAX_PATH_UNICODE];
{
if ( ::GetModuleFileNameW( dllModule, pathBuffer, MAX_PATH_UNICODE ) == 0 )
if (::GetModuleFileNameW( dllModule, pathBuffer, MAX_PATH_UNICODE ) == 0 )
{
MessageBox(
nullptr,
......@@ -3976,11 +3985,13 @@ BOOL APIENTRY DllMain( HMODULE module, DWORD reasonForCall, LPVOID )
LPVOID tlsData;
switch ( reasonForCall )
{
case DLL_PROCESS_ATTACH: {
case DLL_PROCESS_ATTACH:
{
dllModule = module;
}
break;
case DLL_PROCESS_DETACH: {
case DLL_PROCESS_DETACH:
{
RemoveHooks();
// TProfile::displayProfile();
......@@ -3988,11 +3999,13 @@ BOOL APIENTRY DllMain( HMODULE module, DWORD reasonForCall, LPVOID )
modInfo = nullptr;
}
break;
case DLL_THREAD_ATTACH: {
case DLL_THREAD_ATTACH:
{
tlsData = ::InitTLS();
}
break;
case DLL_THREAD_DETACH: {
case DLL_THREAD_DETACH:
{
tlsData = ::TlsGetValue( tlsIndex );
if ( tlsData != nullptr )
{
......
......@@ -23,13 +23,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "stdafx.h"
// Consider to clean up these macros. Unless we are going to use a pure
// C compilers
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C
#endif // __cplusplus
#ifdef _WINDLL
# define DLLEXPORT __declspec( dllexport )
# ifdef __cplusplus
# define LIBHOOKAPI EXTERN_C
# else
# define LIBHOOKAPI __declspec( dllexport )
# endif // __cplusplus
#else
# define DLLEXPORT __declspec( dllimport )
# define LIBHOOKAPI __declspec( dllimport )
#endif
extern "C" DLLEXPORT
BOOL __cdecl Init( int logLevel, const wchar_t *profileName );
BOOL __cdecl Init( int logLevel, const wchar_t *profileName );
#endif // DLLMAIN_H
#ifndef PROFILE_H
#define PROFILE_H
#include "stdafx.h"
#include <cfloat>
#include <ctime>
#include <map>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class TProfile
{
......
......@@ -4,10 +4,8 @@
//
#ifndef HOOKDLL_STDAFX_H
#define HOOKDLL_STDAFX_H
#define STRICT
#define WINVER 0x600
#define _WIN32_WINNT WINVER
// Windows Header Files:
#include <windows.h>
#include <WindowsCore.h>
#include <shellapi.h>
#endif // HOOKDLL_STDAFX_H
\ No newline at end of file
......@@ -20,9 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef HOOKDLL_UTILITY_H
#define HOOKDLL_UTILITY_H
#define WIN32_LEAN_AND_MEAN
#define STRICT
#include <Windows.h>
#include <WindowsCore.h>
#include <shellapi.h>
#include <string>
bool StartsWith( LPCSTR string, LPCSTR subString );
......@@ -48,7 +47,4 @@ void Canonicalize(
const wchar_t *wcsrpbrk( const wchar_t *string, const wchar_t *control );
#define MO_Deprecated __declspec( deprecated )
#define MO_Deprecated( x ) __declspec( deprecated ) x
#endif // HOOKDLL_UTILITY_H
\ No newline at end of file
......@@ -200,7 +200,7 @@ set(organizer_UIS
set(organizer_QRCS resources.qrc stylesheet_resource.qrc)
set(organizer_RCS app_icon.rc version.rc)
set(organizer_RCS version.rc)
source_group(Source FILES ${organizer_SRCS})
source_group(Headers FILES ${organizer_HDRS})
......
#include "Winver.h"
// 1 24 "ModOrganizer.manifests.xml"
1 24 "ModOrganizer.manifests.xml"
IDI_ICON1 ICON DISCARDABLE "mo_icon.ico"
#define VER_FILEVERSION 1,5,0,0
#define VER_FILEVERSION_STR "1,5,0,0\0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment