zydiskell 0.1.0.1 → 0.1.1.0
raw patch · 7 files changed
+39/−26 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Zydis.Constants: type ZydisCpuFlagMaxValue = 21
+ Zydis.Constants: type ZydisCpuFlagMaxValue = 20
- Zydis.Operand: OperandImmediate :: !Word8 -> !Word8 -> {-# UNPACK #-} !Word64 -> OperandImmediate
+ Zydis.Operand: OperandImmediate :: {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word64 -> OperandImmediate
- Zydis.Operand: OperandMemoryDisplacement :: !Word8 -> {-# UNPACK #-} !Int64 -> OperandMemoryDisplacement
+ Zydis.Operand: OperandMemoryDisplacement :: {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Int64 -> OperandMemoryDisplacement
- Zydis.Operand: [operandImmediateIsRelative] :: OperandImmediate -> !Word8
+ Zydis.Operand: [operandImmediateIsRelative] :: OperandImmediate -> {-# UNPACK #-} !Word8
- Zydis.Operand: [operandImmediateIsSigned] :: OperandImmediate -> !Word8
+ Zydis.Operand: [operandImmediateIsSigned] :: OperandImmediate -> {-# UNPACK #-} !Word8
- Zydis.Operand: [operandMemoryDisplacementHasDisplacement] :: OperandMemoryDisplacement -> !Word8
+ Zydis.Operand: [operandMemoryDisplacementHasDisplacement] :: OperandMemoryDisplacement -> {-# UNPACK #-} !Word8
Files
- README.md +19/−12
- external/zydis/dependencies/zycore/include/Zycore/Defines.h +1/−1
- external/zydis/dependencies/zycore/include/Zycore/Types.h +2/−2
- src/Zydis/Constants.hs +1/−1
- src/Zydis/Operand.hs +3/−3
- test/Main.hs +12/−6
- zydiskell.cabal +1/−1
README.md view
@@ -14,19 +14,20 @@ We currently expose three functions: ```haskell+import Data.ByteString (ByteString) import qualified Zydis as Z -Z.initialize :: MachineMode -> AddressWidth -> IO (Either ZyanStatus Decoder)+Z.initialize :: Z.MachineMode -> Z.AddressWidth -> IO (Either Z.ZyanStatus Z.Decoder) Z.decodeBuffer- :: Decoder+ :: Z.Decoder -> ByteString- -> Offset- -> Length- -> IO (Either ZyanStatus DecodedInstruction)+ -> Z.Offset+ -> Z.Length+ -> IO (Either Z.ZyanStatus Z.DecodedInstruction) Z.decodeFullBuffer- :: Decoder -> ByteString -> IO (Either ZyanStatus (Vector DecodedInstruction))+ :: Z.Decoder -> ByteString -> IO (Either Z.ZyanStatus (Vector Z.DecodedInstruction)) ``` ## Example@@ -35,7 +36,7 @@ module Main where -import Data.Bitraversable+import Data.Vector import Data.Bifoldable import qualified Zydis as Z @@ -45,27 +46,33 @@ test :: IO () test = bitraverse_ initFailure decode =<< initZydis where+ zyanError :: Show a => String -> a -> IO () zyanError s = putStrLn . ((s <> ". ZyanStatus: ") <>) . show - initFailure = zyanError "Failed to initialize decoder"+ initFailure :: Z.ZyanStatus -> IO ()+ initFailure = zyanError "Failed to initialize decoder" - initZydis = Z.initialize Z.MachineModeLong64 Z.AddressWidth64+ initZydis :: IO (Either Z.ZyanStatus Z.Decoder)+ initZydis = Z.initialize Z.MachineModeLong64 Z.AddressWidth64 {- mov rax, 0xCAFEBABECAFEBABE push rax ret -}- buffer = "\x48\xB8\xBE\xBA\xFE\xCA\xBE\xBA\xFE\xCA\x50\xC3"+ buffer = "\x48\xB8\xBE\xBA\xFE\xCA\xBE\xBA\xFE\xCA\x50\xC3" + decodingFailure :: Z.ZyanStatus -> IO () decodingFailure = zyanError "Failed to decode buffer" {- Given the decoded buffer, should output: [MnemonicMov,MnemonicPush,MnemonicRet] -}- printMnemonics = print . fmap Z.decodedInstructionMnemonic+ printMnemonics :: Vector Z.DecodedInstruction -> IO ()+ printMnemonics = print . fmap Z.decodedInstructionMnemonic + decode :: Z.Decoder -> IO () decode decoder =- bitraverse decodingFailure printMnemonics+ bitraverse_ decodingFailure printMnemonics =<< Z.decodeFullBuffer decoder buffer ```
external/zydis/dependencies/zycore/include/Zycore/Defines.h view
@@ -202,7 +202,7 @@ * Marks the current code path as unreachable. */ #if defined(ZYAN_RELEASE)-# if defined(ZYAN_CLANG) // GCC eagerly evals && RHS, we have to use nested ifs.+# if defined(ZYAN_CLANG) /* GCC eagerly evals && RHS, we have to use nested ifs. */ # if __has_builtin(__builtin_unreachable) # define ZYAN_UNREACHABLE __builtin_unreachable() # else
external/zydis/dependencies/zycore/include/Zycore/Types.h view
@@ -39,8 +39,8 @@ /* ============================================================================================== */ #if defined(ZYAN_NO_LIBC) || \- (defined(ZYAN_MSVC) && defined(ZYAN_KERNEL)) // The WDK LibC lacks stdint.h.- // No LibC mode, use compiler built-in types / macros.+ (defined(ZYAN_MSVC) && defined(ZYAN_KERNEL)) /* The WDK LibC lacks stdint.h. */+ /* No LibC mode, use compiler built-in types / macros. */ # if defined(ZYAN_MSVC) || defined(ZYAN_ICC) typedef unsigned __int8 ZyanU8; typedef unsigned __int16 ZyanU16;
src/Zydis/Constants.hs view
@@ -27,7 +27,7 @@ ) where -type ZydisCpuFlagMaxValue = 21+type ZydisCpuFlagMaxValue = 20 type ZydisMaxInstructionLength = 15 type ZydisMaxOperandCount = 10 type ZydisRawImmediateCount = 2
src/Zydis/Operand.hs view
@@ -43,8 +43,8 @@ data OperandImmediate = OperandImmediate- { operandImmediateIsSigned :: !Word8- , operandImmediateIsRelative :: !Word8+ { operandImmediateIsSigned :: {-# UNPACK #-}!Word8+ , operandImmediateIsRelative :: {-# UNPACK #-}!Word8 , operandImmediateValue :: {-# UNPACK #-}!Word64 } deriving stock (Show, Eq)@@ -85,7 +85,7 @@ data OperandMemoryDisplacement = OperandMemoryDisplacement- { operandMemoryDisplacementHasDisplacement :: !Word8+ { operandMemoryDisplacementHasDisplacement :: {-# UNPACK #-}!Word8 , operandMemoryDisplacementValue :: {-# UNPACK #-}!Int64 } deriving stock (Show, Eq)
test/Main.hs view
@@ -21,8 +21,8 @@ module Main where +import Data.Vector import Data.Bifoldable-import Data.Bitraversable import qualified Zydis as Z main :: IO ()@@ -31,26 +31,32 @@ test :: IO () test = bitraverse_ initFailure decode =<< initZydis where+ zyanError :: Show a => String -> a -> IO () zyanError s = putStrLn . ((s <> ". ZyanStatus: ") <>) . show - initFailure = zyanError "Failed to initialize decoder"+ initFailure :: Z.ZyanStatus -> IO ()+ initFailure = zyanError "Failed to initialize decoder" - initZydis = Z.initialize Z.MachineModeLong64 Z.AddressWidth64+ initZydis :: IO (Either Z.ZyanStatus Z.Decoder)+ initZydis = Z.initialize Z.MachineModeLong64 Z.AddressWidth64 {- mov rax, 0xCAFEBABECAFEBABE push rax ret -}- buffer = "\x48\xB8\xBE\xBA\xFE\xCA\xBE\xBA\xFE\xCA\x50\xC3"+ buffer = "\x48\xB8\xBE\xBA\xFE\xCA\xBE\xBA\xFE\xCA\x50\xC3" + decodingFailure :: Z.ZyanStatus -> IO () decodingFailure = zyanError "Failed to decode buffer" {- Given the decoded buffer, should output: [MnemonicMov,MnemonicPush,MnemonicRet] -}- printMnemonics = print . fmap Z.decodedInstructionMnemonic+ printMnemonics :: Vector Z.DecodedInstruction -> IO ()+ printMnemonics = print . fmap Z.decodedInstructionMnemonic + decode :: Z.Decoder -> IO () decode decoder =- bitraverse decodingFailure printMnemonics+ bitraverse_ decodingFailure printMnemonics =<< Z.decodeFullBuffer decoder buffer
zydiskell.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: zydiskell-version: 0.1.0.1+version: 0.1.1.0 synopsis: Haskell language binding for the Zydis library, a x86/x86-64 disassembler. description: Please see the README on GitHub at <https://github.com/nerded1337/zydiskell#readme> category: System, Parsing, Disassembler