diff --git a/CMakeLists.txt b/CMakeLists.txt index d5ac899..fd0206f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 0e8b32f..99b69ae 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -29,7 +29,7 @@ std::map LoadExtensions() bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map 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 }; diff --git a/extensions/removerepeat.cpp b/extensions/removerepeat.cpp index 425db4d..a5c1b5c 100644 --- a/extensions/removerepeat.cpp +++ b/extensions/removerepeat.cpp @@ -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> seenSentences; + static std::set> seenSentences; static std::mutex m; std::lock_guard l(m); if (seenSentences.count({ handle, sentence }) != 0) throw std::exception(); diff --git a/include/types.h b/include/types.h index dee707c..8cbc503 100644 --- a/include/types.h +++ b/include/types.h @@ -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(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(this->message, message.c_str()); }; int command = HOST_NOTIFICATION_TEXT; char message[MESSAGE_SIZE] = {}; }; diff --git a/vnrhook/CMakeLists.txt b/vnrhook/CMakeLists.txt index abed544..85ede1c 100644 --- a/vnrhook/CMakeLists.txt +++ b/vnrhook/CMakeLists.txt @@ -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 - $<$:> - $<$:> + /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 ) \ No newline at end of file diff --git a/vnrhook/engine/engine.cc b/vnrhook/engine/engine.cc index 91d94f6..1cdb460 100644 --- a/vnrhook/engine/engine.cc +++ b/vnrhook/engine/engine.cc @@ -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" diff --git a/vnrhook/engine/match.cc b/vnrhook/engine/match.cc index 91fc4c7..7cbf14a 100644 --- a/vnrhook/engine/match.cc +++ b/vnrhook/engine/match.cc @@ -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 diff --git a/vnrhook/hijack/texthook.cc b/vnrhook/hijack/texthook.cc index 0dc481d..7e17842 100644 --- a/vnrhook/hijack/texthook.cc +++ b/vnrhook/hijack/texthook.cc @@ -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" diff --git a/vnrhook/main.h b/vnrhook/main.h index ea2063f..10e572d 100644 --- a/vnrhook/main.h +++ b/vnrhook/main.h @@ -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 diff --git a/vnrhook/util/except.h b/vnrhook/util/except.h deleted file mode 100644 index a8540bb..0000000 --- a/vnrhook/util/except.h +++ /dev/null @@ -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