void IH_cbDllEntryPoint() //DLL Entry callback { g_fdImageBase=GetDebuggedDLLBaseAddress(); g_PtrTargetData->ImageBase=g_fdImageBase; g_PtrTargetData->OEP=(unsigned int)(g_fdImageBase+g_fdEntryPoint); // Retrieve useful data from IAT IH_GetImportTableAddresses(); // Search free space IH_GetFreeSpaceAddr(); SetAPIBreakPoint((char*)"kernel32.dll", (char*)"VirtualProtect", UE_BREAKPOINT, UE_APISTART, (void*)IH_cbVirtualProtect); }
__declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchStart, DWORD SearchSize, void* SearchPattern, DWORD PatternSize, DWORD PatternDelta, ULONG_PTR BreakType, bool SingleBreak, DWORD Parameter1, DWORD Parameter2) { ULONG_PTR fPatternLocation; DWORD fBreakPointType = UE_BREAKPOINT; UnpackerInformation fUnpackerInformation = {}; if((int)SearchStart == UE_UNPACKER_CONDITION_SEARCH_FROM_EP) { if(EngineUnpackerFileStatus.FileIsDLL) { SearchStart = (void*)((ULONG_PTR)GetPE32DataW(szEngineUnpackerInputFile, NULL, UE_OEP) + (ULONG_PTR)GetDebuggedDLLBaseAddress()); } else { SearchStart = (void*)((ULONG_PTR)GetPE32DataW(szEngineUnpackerInputFile, NULL, UE_OEP) + (ULONG_PTR)GetDebuggedFileBaseAddress()); } } if(SearchSize == NULL) { SearchSize = 0x1000; } fPatternLocation = (ULONG_PTR)FindEx(pEngineUnpackerProcessHandle->hProcess, SearchStart, SearchSize, SearchPattern, PatternSize, NULL); if(fPatternLocation != NULL) { if(SingleBreak) { fBreakPointType = UE_SINGLESHOOT; } fPatternLocation = fPatternLocation + (int)PatternDelta; fUnpackerInformation.Parameter1 = Parameter1; fUnpackerInformation.Parameter2 = Parameter2; fUnpackerInformation.SingleBreak = SingleBreak; fUnpackerInformation.BreakPointAddress = fPatternLocation; if(BreakType == UE_UNPACKER_CONDITION_LOADLIBRARY) { if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyLoadLibraryCallBack)) { EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } else if(BreakType == UE_UNPACKER_CONDITION_GETPROCADDRESS) { if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyGetProcAddressCallBack)) { EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } else if(BreakType == UE_UNPACKER_CONDITION_ENTRYPOINTBREAK) { if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyGetProcAddressCallBack)) { EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } else if(BreakType == UE_UNPACKER_CONDITION_RELOCSNAPSHOT1) { if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyMakeSnapshotCallBack)) { fUnpackerInformation.SnapShotNumber = 1; EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } else if(BreakType == UE_UNPACKER_CONDITION_RELOCSNAPSHOT2) { if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyMakeSnapshotCallBack)) { fUnpackerInformation.SnapShotNumber = 2; EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } else { if(SetBPX(fPatternLocation, fBreakPointType, (void*)BreakType)) { EngineUnpackerBreakInfo.push_back(fUnpackerInformation); return true; } } } return false; }