get rid of some warnings

This commit is contained in:
Akash Mozumdar 2018-09-22 15:45:54 -04:00
parent 22c4f10c82
commit 310d12ea14
10 changed files with 15 additions and 55 deletions

View File

@ -7,20 +7,12 @@ project(NextHooker)
add_compile_options(
/std:c++17
#/Zc:auto # config.pri
/wd4819 # config.pri
/MP
/GS-
)
add_definitions(
/D_SECURE_SCL=0 # config.pri
/D_SCL_SECURE_NO_WARNINGS # config.pri
/D_CRT_SECURE_NO_WARNINGS # config.pri
/DUNICODE # config.pri
/D_UNICODE
/D_CRT_NON_CONFORMING_SWPRINTFS # common.pri
/DITH_HAS_CRT
)
include_directories(include)

View File

@ -29,7 +29,7 @@ std::map<int, QString> LoadExtensions()
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo)
{
wchar_t* sentenceBuffer = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t));
wcscpy(sentenceBuffer, sentence.c_str());
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
InfoForExtension* miscInfoLinkedList = new InfoForExtension;
InfoForExtension* miscInfoTraverser = miscInfoLinkedList;
for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->nextProperty = new InfoForExtension{ i.first.c_str(), i.second, nullptr };

View File

@ -4,7 +4,7 @@
bool RemoveRepeatedChars(std::wstring& sentence)
{
unsigned int repeatNumber = 0;
int repeatNumber = 0;
wchar_t prevChar = sentence[0];
for (auto i : sentence)
if (i == prevChar) repeatNumber++;
@ -25,7 +25,7 @@ bool RemoveRepeatedChars(std::wstring& sentence)
bool RemoveCyclicRepeats(std::wstring& sentence)
{
unsigned int junkLength = 0;
int junkLength = 0;
wchar_t junk[2000] = {};
while (wcsstr(sentence.c_str() + junkLength, junk))
{
@ -41,9 +41,9 @@ bool RemoveCyclicRepeats(std::wstring& sentence)
return false;
}
bool RemoveRepeatedSentences(std::wstring& sentence, int handle)
bool RemoveRepeatedSentences(std::wstring& sentence, int64_t handle)
{
static std::set<std::pair<int, std::wstring>> seenSentences;
static std::set<std::pair<int64_t, std::wstring>> seenSentences;
static std::mutex m;
std::lock_guard<std::mutex> l(m);
if (seenSentences.count({ handle, sentence }) != 0) throw std::exception();

View File

@ -41,7 +41,7 @@ static bool operator==(const ThreadParam& one, const ThreadParam& two) { return
struct InsertHookCmd // From host
{
InsertHookCmd(HookParam hp, std::string name = "") : hp(hp) { strncpy(this->name, name.c_str(), 500); };
InsertHookCmd(HookParam hp, std::string name = "") : hp(hp) { strcpy_s<MESSAGE_SIZE>(this->name, name.c_str()); };
int command = HOST_COMMAND_NEW_HOOK;
HookParam hp;
char name[MESSAGE_SIZE] = {};
@ -56,7 +56,7 @@ struct RemoveHookCmd // From host
struct ConsoleOutputNotif // From hook
{
ConsoleOutputNotif(std::string message = "") { strncpy(this->message, message.c_str(), 500); };
ConsoleOutputNotif(std::string message = "") { strcpy_s<MESSAGE_SIZE>(this->message, message.c_str()); };
int command = HOST_NOTIFICATION_TEXT;
char message[MESSAGE_SIZE] = {};
};

View File

@ -28,21 +28,12 @@ add_library(vnrhook SHARED ${vnrhook_src})
enable_language(ASM_MASM)
set_source_files_properties(
${PROJECT_SOURCE_DIR}/winseh/safeseh.asm
PROPERTIES
# CMAKE_ASM_MASM_FLAGS /safeseh # CMake bug 14711: http://www.cmake.org/Bug/view.php?id=14711
COMPILE_FLAGS /safeseh
)
set_target_properties(vnrhook PROPERTIES
LINK_FLAGS "/SUBSYSTEM:WINDOWS /MANIFEST:NO"
)
target_compile_options(vnrhook PRIVATE
/EHa
$<$<CONFIG:Release>:>
$<$<CONFIG:Debug>:>
/wd4819
)
set(vnrhook_libs
@ -54,7 +45,7 @@ target_link_libraries(vnrhook ${vnrhook_libs})
target_compile_definitions(vnrhook
PRIVATE
ITH_HAS_CRT
ITH_HAS_SEH
_CRT_NON_CONFORMING_SWPRINTFS
_SCL_SECURE_NO_WARNINGS # config.pri
_CRT_SECURE_NO_WARNINGS
)

View File

@ -13,7 +13,6 @@
#include "main.h"
#include "engine/mono/funcinfo.h"
#include "engine/ppsspp/funcinfo.h"
#include "except.h"
#include "ithsys/ithsys.h"
#include "memdbg/memsearch.h"
#include "disasm/disasm.h"

View File

@ -13,7 +13,6 @@
#include "util/growl.h"
#include "util/util.h"
#include "main.h"
#include "except.h"
#include "ithsys/ithsys.h"
//#define ConsoleOutput(...) (void)0 // jichi 8/18/2013: I don't need ConsoleOutput

View File

@ -12,7 +12,6 @@
#include "hijack/texthook.h"
#include "MinHook.h"
#include "engine/match.h"
#include "except.h"
#include "main.h"
#include "pipe.h"
#include "const.h"

View File

@ -12,4 +12,9 @@ void NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
void RemoveHook(uint64_t addr);
void SwitchTrigger(DWORD on);
#define ITH_RAISE (*(int*)0 = 0) // raise C000005, for debugging only
#define ITH_TRY __try
#define ITH_EXCEPT __except(EXCEPTION_EXECUTE_HANDLER)
#define ITH_WITH_SEH(...) ITH_TRY { __VA_ARGS__; } ITH_EXCEPT {}
// EOF

View File

@ -1,25 +0,0 @@
#pragma once
// except.h
// 9/17/2013 jichi
#define ITH_RAISE (*(int*)0 = 0) // raise C000005, for debugging only
#ifdef ITH_HAS_SEH
# define ITH_TRY __try
# define ITH_EXCEPT __except(EXCEPTION_EXECUTE_HANDLER)
# define ITH_WITH_SEH(...) \
ITH_TRY { __VA_ARGS__; } ITH_EXCEPT {}
#else // for old msvcrt.dll on Windows XP that does not have exception handler
// Currently, only with_seh is implemented. Try and catch are not.
# define ITH_TRY if (true)
# define ITH_EXCEPT else
# include "winseh/winseh.h"
# define ITH_WITH_SEH(...) seh_with(__VA_ARGS__)
#endif // ITH_HAS_SEH
// EOF