packages feed

zydiskell 0.1.0.0 → 0.1.0.1

raw patch · 6 files changed

+16/−44 lines, 6 filesdep +fixed-vectorPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: fixed-vector

API changes (from Hackage documentation)

- Zydis.Util: StorableFixedArray :: Vector a -> StorableFixedArray a b
- Zydis.Util: [unStorableFixedArray] :: StorableFixedArray a b -> Vector a
- Zydis.Util: instance (Foreign.Storable.Storable a, GHC.TypeNats.KnownNat b) => Foreign.Storable.Storable (Zydis.Util.StorableFixedArray a b)
- Zydis.Util: instance forall a k (b :: k). GHC.Classes.Eq a => GHC.Classes.Eq (Zydis.Util.StorableFixedArray a b)
- Zydis.Util: instance forall a k (b :: k). GHC.Show.Show a => GHC.Show.Show (Zydis.Util.StorableFixedArray a b)
- Zydis.Util: newtype StorableFixedArray a b
+ Zydis.Operand: OperandImmediate :: !Word8 -> !Word8 -> {-# UNPACK #-} !Word64 -> OperandImmediate
+ Zydis.Operand: OperandMemory :: !OperandMemoryType -> !Register -> !Register -> !Register -> {-# UNPACK #-} !Word8 -> !OperandMemoryDisplacement -> OperandMemory
+ Zydis.Operand: OperandMemoryDisplacement :: !Word8 -> {-# UNPACK #-} !Int64 -> OperandMemoryDisplacement
+ Zydis.Operand: OperandPointer :: {-# UNPACK #-} !Word16 -> {-# UNPACK #-} !Word32 -> OperandPointer
+ Zydis.Operand: [operandImmediateIsRelative] :: OperandImmediate -> !Word8
+ Zydis.Operand: [operandImmediateIsSigned] :: OperandImmediate -> !Word8
+ Zydis.Operand: [operandImmediateValue] :: OperandImmediate -> {-# UNPACK #-} !Word64
+ Zydis.Operand: [operandMemoryBase] :: OperandMemory -> !Register
+ Zydis.Operand: [operandMemoryDisplacementHasDisplacement] :: OperandMemoryDisplacement -> !Word8
+ Zydis.Operand: [operandMemoryDisplacementValue] :: OperandMemoryDisplacement -> {-# UNPACK #-} !Int64
+ Zydis.Operand: [operandMemoryDisplacement] :: OperandMemory -> !OperandMemoryDisplacement
+ Zydis.Operand: [operandMemoryIndex] :: OperandMemory -> !Register
+ Zydis.Operand: [operandMemoryScale] :: OperandMemory -> {-# UNPACK #-} !Word8
+ Zydis.Operand: [operandMemorySegment] :: OperandMemory -> !Register
+ Zydis.Operand: [operandMemoryType] :: OperandMemory -> !OperandMemoryType
+ Zydis.Operand: [operandPointerOffset] :: OperandPointer -> {-# UNPACK #-} !Word32
+ Zydis.Operand: [operandPointerSegment] :: OperandPointer -> {-# UNPACK #-} !Word16
+ Zydis.Operand: data OperandImmediate
+ Zydis.Operand: data OperandMemory
+ Zydis.Operand: data OperandMemoryDisplacement
+ Zydis.Operand: data OperandPointer
- Zydis.Types: DecodedInstruction :: !MachineMode -> !Mnemonic -> {-# UNPACK #-} !Word8 -> !InstructionEncoding -> !OpcodeMap -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> !StorableFixedArray Operand ZydisMaxOperandCount -> {-# UNPACK #-} !Word64 -> !StorableFixedArray CPUFlagAction (ZydisCpuFlagMaxValue + 1) -> !DecodedInstructionAvx -> !DecodedInstructionMeta -> !DecodedInstructionRaw -> DecodedInstruction
+ Zydis.Types: DecodedInstruction :: !MachineMode -> !Mnemonic -> {-# UNPACK #-} !Word8 -> !InstructionEncoding -> !OpcodeMap -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> !Vec ZydisMaxOperandCount Operand -> {-# UNPACK #-} !Word64 -> !Vec (ZydisCpuFlagMaxValue + 1) CPUFlagAction -> !DecodedInstructionAvx -> !DecodedInstructionMeta -> !DecodedInstructionRaw -> DecodedInstruction
- Zydis.Types: DecodedInstructionRaw :: {-# UNPACK #-} !Word8 -> !StorableFixedArray DecodedInstructionRawPrefix ZydisMaxInstructionLength -> !DecodedInstructionRawRex -> !DecodedInstructionRawXop -> !DecodedInstructionRawVex -> !DecodedInstructionRawEvex -> !DecodedInstructionRawMvex -> !DecodedInstructionModRm -> !DecodedInstructionRawSib -> !DecodedInstructionRawDisp -> !StorableFixedArray DecodedInstructionRawImmediate ZydisRawImmediateCount -> DecodedInstructionRaw
+ Zydis.Types: DecodedInstructionRaw :: {-# UNPACK #-} !Word8 -> !Vec ZydisMaxInstructionLength DecodedInstructionRawPrefix -> !DecodedInstructionRawRex -> !DecodedInstructionRawXop -> !DecodedInstructionRawVex -> !DecodedInstructionRawEvex -> !DecodedInstructionRawMvex -> !DecodedInstructionModRm -> !DecodedInstructionRawSib -> !DecodedInstructionRawDisp -> !Vec ZydisRawImmediateCount DecodedInstructionRawImmediate -> DecodedInstructionRaw
- Zydis.Types: [decodedInstructionAccessedFlags] :: DecodedInstruction -> !StorableFixedArray CPUFlagAction (ZydisCpuFlagMaxValue + 1)
+ Zydis.Types: [decodedInstructionAccessedFlags] :: DecodedInstruction -> !Vec (ZydisCpuFlagMaxValue + 1) CPUFlagAction
- Zydis.Types: [decodedInstructionOperands] :: DecodedInstruction -> !StorableFixedArray Operand ZydisMaxOperandCount
+ Zydis.Types: [decodedInstructionOperands] :: DecodedInstruction -> !Vec ZydisMaxOperandCount Operand
- Zydis.Types: [decodedInstructionRawImmediates] :: DecodedInstructionRaw -> !StorableFixedArray DecodedInstructionRawImmediate ZydisRawImmediateCount
+ Zydis.Types: [decodedInstructionRawImmediates] :: DecodedInstructionRaw -> !Vec ZydisRawImmediateCount DecodedInstructionRawImmediate
- Zydis.Types: [decodedInstructionRawPrefixes] :: DecodedInstructionRaw -> !StorableFixedArray DecodedInstructionRawPrefix ZydisMaxInstructionLength
+ Zydis.Types: [decodedInstructionRawPrefixes] :: DecodedInstructionRaw -> !Vec ZydisMaxInstructionLength DecodedInstructionRawPrefix

Files

README.md view
@@ -25,7 +25,7 @@   -> Length   -> IO (Either ZyanStatus DecodedInstruction) -Z. decodeFullBuffer+Z.decodeFullBuffer   :: Decoder -> ByteString -> IO (Either ZyanStatus (Vector DecodedInstruction)) ``` 
src/Zydis/Operand.hs view
@@ -21,6 +21,10 @@  module Zydis.Operand   ( Operand(..)+  , OperandMemory(..)+  , OperandMemoryDisplacement(..)+  , OperandPointer(..)+  , OperandImmediate(..)   ) where 
src/Zydis/Types.hs view
@@ -48,10 +48,11 @@ where  import           Data.Int+import           Data.Vector.Fixed.Storable import           Data.Word import           Foreign.Storable import qualified Foreign.Storable.Record       as Store-import           GHC.TypeLits+import           GHC.TypeNats  import           Zydis.AddressWidth            as Z import           Zydis.BranchType              as Z@@ -73,7 +74,6 @@ import           Zydis.Register                as Z import           Zydis.RoundingMode            as Z import           Zydis.SwizzleMode             as Z-import           Zydis.Util  data DecodedInstructionRawImmediate =   DecodedInstructionRawImmediate@@ -380,7 +380,7 @@ data DecodedInstructionRaw =   DecodedInstructionRaw   { decodedInstructionRawPrefixCount :: {-# UNPACK #-}!Word8-  , decodedInstructionRawPrefixes    :: !(StorableFixedArray DecodedInstructionRawPrefix ZydisMaxInstructionLength)+  , decodedInstructionRawPrefixes    :: !(Vec ZydisMaxInstructionLength DecodedInstructionRawPrefix)   , decodedInstructionRawRex         :: !DecodedInstructionRawRex   , decodedInstructionRawXop         :: !DecodedInstructionRawXop   , decodedInstructionRawVex         :: !DecodedInstructionRawVex@@ -389,7 +389,7 @@   , decodedInstructionRawModRm       :: !DecodedInstructionModRm   , decodedInstructionRawSib         :: !DecodedInstructionRawSib   , decodedInstructionRawDisp        :: !DecodedInstructionRawDisp-  , decodedInstructionRawImmediates  :: !(StorableFixedArray DecodedInstructionRawImmediate ZydisRawImmediateCount)+  , decodedInstructionRawImmediates  :: !(Vec ZydisRawImmediateCount DecodedInstructionRawImmediate)   }   deriving stock (Show, Eq) @@ -526,9 +526,9 @@     , decodedInstructionOperandWidth  :: {-# UNPACK #-}!Word8     , decodedInstructionAddressWidth  :: {-# UNPACK #-}!Word8     , decodedInstructionOperandCount  :: {-# UNPACK #-}!Word8-    , decodedInstructionOperands      :: !(StorableFixedArray Operand ZydisMaxOperandCount)+    , decodedInstructionOperands      :: !(Vec ZydisMaxOperandCount Operand)     , decodedInstructionAttributes    :: {-# UNPACK #-}!Word64-    , decodedInstructionAccessedFlags :: !(StorableFixedArray CPUFlagAction (ZydisCpuFlagMaxValue + 1))+    , decodedInstructionAccessedFlags :: !(Vec (ZydisCpuFlagMaxValue + 1) CPUFlagAction)     , decodedInstructionAvx           :: !DecodedInstructionAvx     , decodedInstructionMeta          :: !DecodedInstructionMeta     , decodedInstructionRaw           :: !DecodedInstructionRaw
src/Zydis/Util.hs view
@@ -39,31 +39,17 @@ -- -- This type will be stored as a word32 (C enum FFI). ----- Using the 'StorableFixedArray', we are now able to encode fixed sizes in the type (in conjunction with storable-record "Foreign.Storable.FixedArray").------ @--- data X = X (StorableFixedArray Word32 10)--- @------ This type will be stored as 10 contiguous word32 (C fixed array).--- module Zydis.Util   ( StorableExt(..)-  , StorableFixedArray(..)   , Storable   ) where -import           Data.Foldable-import           Data.Proxy-import           Data.Vector+import           Data.Vector.Fixed.Storable import           Data.Word import           Foreign.Ptr import           Foreign.Storable-import qualified Foreign.Storable.FixedArray   as Fixed-import           GHC.TypeLits - -- | Wrapper to extend storable default instances. newtype StorableExt a =   StorableExt@@ -77,23 +63,3 @@   peek = fmap (StorableExt . toEnum . fromIntegral) . peek . castPtr @_ @Word32   poke ptr v =     poke (castPtr @_ @Word32 ptr) (fromIntegral $ fromEnum $ unStorableExt v)---- | Wrapper to extend storable default instances.-newtype StorableFixedArray a b =-  StorableFixedArray-    { unStorableFixedArray :: Vector a-    }-  deriving stock (Show, Eq)--instance forall a b. (Storable a, KnownNat b) => Storable (StorableFixedArray a b) where-  alignment = const $ alignment @a undefined-  sizeOf =-    const $ Fixed.sizeOfArray @a (fromIntegral $ natVal (Proxy @b)) undefined-  peek ptr = StorableFixedArray <$> Fixed.run ptr' loop-   where-    ptr' = castPtr ptr-    loop = replicateM (fromIntegral $ natVal (Proxy @b)) Fixed.peekNext-  poke ptr x = Fixed.run ptr' $ loop $ unStorableFixedArray x-   where-    ptr' = castPtr ptr-    loop = traverse_ Fixed.pokeNext
test/Main.hs view
@@ -21,8 +21,8 @@  module Main where -import           Data.Bitraversable import           Data.Bifoldable+import           Data.Bitraversable import qualified Zydis                         as Z  main :: IO ()
zydiskell.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           zydiskell-version:        0.1.0.0+version:        0.1.0.1 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@@ -140,6 +140,7 @@   build-depends:       base >=4.7 && <4.15     , bytestring >=0.10 && <0.11+    , fixed-vector >=1.2 && <1.3     , storable-record >=0.0.5 && <0.0.6     , vector >=0.12 && <0.13   default-language: Haskell2010@@ -155,6 +156,7 @@   build-depends:       base >=4.7 && <4.15     , bytestring >=0.10 && <0.11+    , fixed-vector >=1.2 && <1.3     , storable-record >=0.0.5 && <0.0.6     , vector >=0.12 && <0.13     , zydiskell