Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions internal/winapi/cimfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ func CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSi
)(blockCimPath, isSealed, hashSize, signatureSize, fixedHeaderSize, hash, signature)
}

func CimGetVerificationInformation2(blockCimPath string, flags types.CimGetVerificationInfoFlags, isSealed *uint32, hashSize *uint64, signatureOffset *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte, signatureType *types.CimSignatureType, hashAlgorithm *types.CimHashAlgorithm) (hr error) {
return pickSupported(
cimwriter.CimGetVerificationInformation2,
cimfs.CimGetVerificationInformation2,
)(blockCimPath, flags, isSealed, hashSize, signatureOffset, signatureSize, fixedHeaderSize, hash, signature, signatureType, hashAlgorithm)
}

func CimQueryBlockInfo(blockCimPath string, cimInfoBufferSize uint32, cimInfoBuffer *types.CimFsCimInfo, requiredBufferSize *uint32, cimCount *uint32) (hr error) {
return pickSupported(
cimwriter.CimQueryBlockInfo,
cimfs.CimQueryBlockInfo,
)(blockCimPath, cimInfoBufferSize, cimInfoBuffer, requiredBufferSize, cimCount)
}

func CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *guid.GUID, hashSize uint16, hash *byte) error {
return cimfs.CimMountVerifiedImage(imagePath, fsName, flags, volumeID, hashSize, hash)
}
Expand Down
6 changes: 6 additions & 0 deletions internal/winapi/cimfs/cimfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type FsHandle = types.FsHandle
type StreamHandle = types.StreamHandle
type FileMetadata = types.CimFsFileMetadata
type ImagePath = types.CimFsImagePath
type CimInfo = types.CimFsCimInfo
type VerificationInfoFlags = types.CimGetVerificationInfoFlags
type SignatureType = types.CimSignatureType
type HashAlgorithm = types.CimHashAlgorithm

//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *GUID) (hr error) = cimfs.CimMountImage?
//sys CimDismountImage(volumeID *GUID) (hr error) = cimfs.CimDismountImage?
Expand All @@ -41,6 +45,8 @@ type ImagePath = types.CimFsImagePath
//sys CimCreateMergeLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateMergeLink?
//sys CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) = cimfs.CimSealImage?
//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimfs.CimGetVerificationInformation?
//sys CimGetVerificationInformation2(blockCimPath string, flags VerificationInfoFlags, isSealed *uint32, hashSize *uint64, signatureOffset *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte, signatureType *SignatureType, hashAlgorithm *HashAlgorithm) (hr error) = cimfs.CimGetVerificationInformation2?
//sys CimQueryBlockInfo(blockCimPath string, cimInfoBufferSize uint32, cimInfoBuffer *CimInfo, requiredBufferSize *uint32, cimCount *uint32) (hr error) = cimfs.CimQueryBlockInfo?
//sys CimMountVerifiedImage(imagePath string, fsName string, flags uint32, volumeID *GUID, hashSize uint16, hash *byte) (hr error) = cimfs.CimMountVerifiedImage?
//sys CimMergeMountVerifiedImage(numCimPaths uint32, backingImagePaths *ImagePath, flags uint32, volumeID *GUID, hashSize uint16, hash *byte) (hr error) = cimfs.CimMergeMountVerifiedImage?

Expand Down
92 changes: 71 additions & 21 deletions internal/winapi/cimfs/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/winapi/cimwriter/cimwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type FsHandle = types.FsHandle
type StreamHandle = types.StreamHandle
type FileMetadata = types.CimFsFileMetadata
type ImagePath = types.CimFsImagePath
type CimInfo = types.CimFsCimInfo
type VerificationInfoFlags = types.CimGetVerificationInfoFlags
type SignatureType = types.CimSignatureType
type HashAlgorithm = types.CimHashAlgorithm

//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimwriter.CimCreateImage?
//sys CimCreateImage2(imagePath string, flags uint32, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimwriter.CimCreateImage2?
Expand All @@ -37,6 +41,8 @@ type ImagePath = types.CimFsImagePath
//sys CimSealImage(blockCimPath string, hashSize *uint64, fixedHeaderSize *uint64, hash *byte) (hr error) = cimwriter.CimSealImage?

//sys CimGetVerificationInformation(blockCimPath string, isSealed *uint32, hashSize *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte) (hr error) = cimwriter.CimGetVerificationInformation?
//sys CimGetVerificationInformation2(blockCimPath string, flags VerificationInfoFlags, isSealed *uint32, hashSize *uint64, signatureOffset *uint64, signatureSize *uint64, fixedHeaderSize *uint64, hash *byte, signature *byte, signatureType *SignatureType, hashAlgorithm *HashAlgorithm) (hr error) = cimwriter.CimGetVerificationInformation2?
//sys CimQueryBlockInfo(blockCimPath string, cimInfoBufferSize uint32, cimInfoBuffer *CimInfo, requiredBufferSize *uint32, cimCount *uint32) (hr error) = cimwriter.CimQueryBlockInfo?

var load = sync.OnceValue(func() error {
// Pre-load the DLL with a restricted search path (System32 + application directory only)
Expand Down
82 changes: 66 additions & 16 deletions internal/winapi/cimwriter/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions internal/winapi/types/cimfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ import (
type FsHandle uintptr
type StreamHandle uintptr

type CimGetVerificationInfoFlags uint32

const (
CimGetVerificationInfoNone CimGetVerificationInfoFlags = 0
CimGetVerificationInfoFromSkeletonCim CimGetVerificationInfoFlags = 1
)

type CimSignatureType uint32

const (
CimSignatureNone CimSignatureType = 0
CimSignaturePKCS7 CimSignatureType = 1
)

type CimHashAlgorithm uint32

const (
CimHashAlgorithmSHA256 CimHashAlgorithm = 0
CimHashAlgorithmSHA512 CimHashAlgorithm = 1
)

type CimFsFileMetadata struct {
Attributes uint32
FileSize int64
Expand All @@ -34,3 +55,9 @@ type CimFsImagePath struct {
ImageDir *uint16
ImageName *uint16
}

type CimFsCimInfo struct {
NextEntryOffset uint32
CimNameLength uint16
CimName [1]uint16
}
Loading