@@ -200,7 +200,8 @@ LRESULT CProcessInlineHookTable::OnRBtnDown(UINT uMsg, WPARAM wParam, LPARAM lPa
200200 bool show = Tablefunction (m_hWnd, uMsg, wParam, lParam);
201201 if (show) {
202202 int selected = m_Table.data .selected ;
203- ATLASSERT (selected >= 0 );
203+ if (selected == -1 )
204+ return 0 ;
204205 auto & info = m_Table.data .info [selected];
205206 if (!info.CanRestore )
206207 EnableMenuItem (hSubMenu, ID_INLINEHOOK_RESTORE, MF_DISABLED);
@@ -778,6 +779,7 @@ void CProcessInlineHookTable::Refresh() {
778779 auto m = GetModuleByAddress (address);
779780 bool isX64Module = true ;
780781 bool isCheckCode = true ;
782+ isCheckCode = false ;
781783 void * local_image_base = nullptr ;
782784 if (m != nullptr ) {
783785 moduleSize = m->ModuleSize ;
@@ -786,38 +788,38 @@ void CProcessInlineHookTable::Refresh() {
786788 PEParser parser (path.c_str ());
787789 isX64Module = parser.IsPe64 ();
788790
789- uint32_t image_size = parser.GetImageSize ();
790- local_image_base = ::VirtualAlloc (nullptr , image_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
791- if (!local_image_base)
792- isCheckCode = false ;
793-
794- if (local_image_base) {
795- BYTE* data = (BYTE*)parser.GetBaseAddress ();
796- LARGE_INTEGER fileSize = parser.GetFileSize ();
797-
798- uint64_t real_image_base = (uint64_t )m->ImageBase ;
799-
800- // Copy image headers
801- memcpy (local_image_base, data, parser.GetHeadersSize ());
802-
803- // Copy image sections
804-
805- for (auto i = 0 ; i < parser.GetSectionCount (); ++i) {
806- auto section = parser.GetSectionHeader (i);
807- if ((section[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) > 0 )
808- continue ;
809- auto local_section = reinterpret_cast <void *>(reinterpret_cast <uint64_t >(local_image_base)
810- + section[i].VirtualAddress );
811- if (section[i].PointerToRawData + section[i].SizeOfRawData > fileSize.QuadPart ) {
812- continue ;
813- }
814- memcpy (local_section, reinterpret_cast <void *>(reinterpret_cast <uint64_t >(data)
815- + section[i].PointerToRawData ), section[i].SizeOfRawData );
816- }
817-
818- std::vector<RelocInfo> relocs = parser.GetRelocs (local_image_base);
819- PEParser::RelocateImageByDelta (relocs, real_image_base - parser.GetImageBase ());
820- }
791+ // uint32_t image_size = parser.GetImageSize();
792+ // local_image_base = ::VirtualAlloc(nullptr, image_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
793+ // if (!local_image_base)
794+ // isCheckCode = false;
795+
796+ // if (local_image_base) {
797+ // BYTE* data = (BYTE*)parser.GetBaseAddress();
798+ // LARGE_INTEGER fileSize = parser.GetFileSize();
799+
800+ // uint64_t real_image_base = (uint64_t)m->ImageBase;
801+
802+ // // Copy image headers
803+ // memcpy(local_image_base, data, parser.GetHeadersSize());
804+
805+ // // Copy image sections
806+
807+ // for (auto i = 0; i < parser.GetSectionCount(); ++i) {
808+ // auto section = parser.GetSectionHeader(i);
809+ // if ((section[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) > 0)
810+ // continue;
811+ // auto local_section = reinterpret_cast<void*>(reinterpret_cast<uint64_t>(local_image_base)
812+ // + section[i].VirtualAddress);
813+ // if (section[i].PointerToRawData + section[i].SizeOfRawData > fileSize.QuadPart) {
814+ // continue;
815+ // }
816+ // memcpy(local_section, reinterpret_cast<void*>(reinterpret_cast<uint64_t>(data)
817+ // + section[i].PointerToRawData), section[i].SizeOfRawData);
818+ // }
819+
820+ // std::vector<RelocInfo> relocs = parser.GetRelocs(local_image_base);
821+ // PEParser::RelocateImageByDelta(relocs, real_image_base - parser.GetImageBase());
822+ // }
821823 }
822824 else {
823825 moduleBase = 0 ;
@@ -1114,7 +1116,8 @@ void CProcessInlineHookTable::CheckX64HookType4(cs_insn* insn, size_t j, size_t
11141116
11151117LRESULT CProcessInlineHookTable::OnHookCopy (WORD /* wNotifyCode*/ , WORD /* wID*/ , HWND /* hWndCtl*/ , BOOL& /* bHandled*/ ) {
11161118 int selected = m_Table.data .selected ;
1117- ATLASSERT (selected >= 0 );
1119+ if (selected == -1 )
1120+ return 0 ;
11181121 auto & info = m_Table.data .info [selected];
11191122
11201123 std::wstring text = GetSingleHookInfo (info);
@@ -1213,7 +1216,8 @@ bool CProcessInlineHookTable::CheckCode(ULONG_PTR addr, SIZE_T size, ULONG_PTR i
12131216
12141217LRESULT CProcessInlineHookTable::OnRestore (WORD, WORD, HWND, BOOL&) {
12151218 int selected = m_Table.data .selected ;
1216- ATLASSERT (selected >= 0 );
1219+ if (selected == -1 )
1220+ return 0 ;
12171221 auto & info = m_Table.data .info [selected];
12181222
12191223 SIZE_T bytes = 0 ;
0 commit comments