- case M.lookup (fromIntegral signal_from) tmap of
- (Just (MI _)) -> return 0
- (Just (SFI _)) -> return 2
- (Just _) -> error "getTrapMap: doesn't happen"
- -- maybe we've a hit on the second `from' value
- Nothing -> case M.lookup (fromIntegral from2) tmap of
- (Just (VI True _)) -> return 1
- (Just (VI False _)) -> return 5
- (Just (II True _)) -> return 4
- (Just (II False _)) -> return 8
- (Just _) -> error "getTrapType: abort #1 :-("
- Nothing -> error $ "getTrapType: abort #2 :-(" ++ show signal_from ++ ", " ++ show from2 ++ ", " ++ show tmap
+ let reipw32 = fromIntegral reip
+ (deleteMe, ret_nreip) <- case M.lookup reipw32 tmap of
+ (Just (StaticMethod patcher)) ->
+ patchWithHarpy patcher reip >>= delFalse
+ (Just (StaticField _)) ->
+ staticFieldHandler reip >>= delTrue
+ (Just (ObjectField patcher)) ->
+ patchWithHarpy patcher reip >>= delTrue
+ (Just (InstanceOf patcher)) ->
+ patchWithHarpy (patcher reax) reip >>= delFalse
+ (Just (ThrowException patcher)) ->
+ patchWithHarpy (patcher reax resp) reip >>= delFalse
+ (Just (NewObject patcher)) ->
+ patchWithHarpy patcher reip >>= delTrue
+ (Just (VirtualCall False mi io_offset)) ->
+ patchWithHarpy (patchInvoke mi reax reax io_offset) reip
+ >>= delFalse
+ (Just (VirtualCall True mi io_offset)) ->
+ patchWithHarpy (patchInvoke mi rebx reax io_offset) reip
+ >>= delFalse
+ Nothing -> case resi of
+ 0x13371234 -> delFalse (-1)
+ _ -> error $ "getTrapType: abort :-( eip: "
+ ++ showHex reip ". " ++ concatMap (`showHex` ", ") (M.keys tmap)
+ when deleteMe $ setTrapMap $ M.delete reipw32 tmap
+ return ret_nreip
+ where
+ delTrue x = return (True,x)
+ delFalse x = return (False,x)