From aa8fcf34e5016cd51f79c1c1435af789a117e2c2 Mon Sep 17 00:00:00 2001 From: Admin <2762713521@qq.com> Date: Thu, 20 Jun 2024 15:27:15 +0800 Subject: [PATCH] bind sdk fix decode bit start index --- gengo/bind/sdkMerge/bug/bug.hpp | 122 ++++++++++++++--------------- gengo/bind/sdkMerge/bug/tmp/bug.go | 2 - gengo/clang/layout_parse.go | 11 +-- gengo/gengo/generate.go | 2 +- 4 files changed, 66 insertions(+), 71 deletions(-) diff --git a/gengo/bind/sdkMerge/bug/bug.hpp b/gengo/bind/sdkMerge/bug/bug.hpp index daf8cbd96..aa9798640 100644 --- a/gengo/bind/sdkMerge/bug/bug.hpp +++ b/gengo/bind/sdkMerge/bug/bug.hpp @@ -57,64 +57,64 @@ typedef unsigned __int64 UINT64, *PUINT64; - typedef struct xed_immdis_s { - unsigned int currently_used_space :4; // current number of assigned bytes - unsigned int max_allocated_space :4; // max allocation, 4 or 8 - int present : 1; - int immediate_is_unsigned : 1; - } xed_immdis_t; - -typedef union -{ - struct VMX_SEGMENT_ACCESS_RIGHTS_TYPE - { - /** - * [Bits 3:0] Segment type. - */ - UINT32 Type : 4; - - /** - * [Bit 4] S - Descriptor type (0 = system; 1 = code or data). - */ - UINT32 DescriptorType : 1; - - /** - * [Bits 6:5] DPL - Descriptor privilege level. - */ - UINT32 DescriptorPrivilegeLevel : 2; - - /** - * [Bit 7] P - Segment present. - */ - UINT32 Present : 1; - - UINT32 Reserved1 : 4; - - /** - * [Bit 12] AVL - Available for use by system software. - */ - UINT32 AvailableBit : 1; - - /** - * [Bit 13] Reserved (except for CS). L - 64-bit mode active (for CS only). - */ - UINT32 LongMode : 1; - - /** - * [Bit 14] D/B - Default operation size (0 = 16-bit segment; 1 = 32-bit segment). - */ - UINT32 DefaultBig : 1; - - /** - * [Bit 15] G - Granularity. - */ - UINT32 Granularity : 1; - /** - * [Bit 16] Segment unusable (0 = usable; 1 = unusable). - */ - UINT32 Unusable : 1; - UINT32 Reserved2 : 15; - }; - - UINT32 AsUInt; -} VMX_SEGMENT_ACCESS_RIGHTS_TYPE; +// typedef struct xed_immdis_s { +// unsigned int currently_used_space :4; // current number of assigned bytes +// unsigned int max_allocated_space :4; // max allocation, 4 or 8 +// int present : 1; +// int immediate_is_unsigned : 1; +// } xed_immdis_t; + +//typedef union +//{ +// struct VMX_SEGMENT_ACCESS_RIGHTS_TYPE +// { +// /** +// * [Bits 3:0] Segment type. +// */ +// UINT32 Type : 4; +// +// /** +// * [Bit 4] S - Descriptor type (0 = system; 1 = code or data). +// */ +// UINT32 DescriptorType : 1; +// +// /** +// * [Bits 6:5] DPL - Descriptor privilege level. +// */ +// UINT32 DescriptorPrivilegeLevel : 2; +// +// /** +// * [Bit 7] P - Segment present. +// */ +// UINT32 Present : 1; +// +// UINT32 Reserved1 : 4; +// +// /** +// * [Bit 12] AVL - Available for use by system software. +// */ +// UINT32 AvailableBit : 1; +// +// /** +// * [Bit 13] Reserved (except for CS). L - 64-bit mode active (for CS only). +// */ +// UINT32 LongMode : 1; +// +// /** +// * [Bit 14] D/B - Default operation size (0 = 16-bit segment; 1 = 32-bit segment). +// */ +// UINT32 DefaultBig : 1; +// +// /** +// * [Bit 15] G - Granularity. +// */ +// UINT32 Granularity : 1; +// /** +// * [Bit 16] Segment unusable (0 = usable; 1 = unusable). +// */ +// UINT32 Unusable : 1; +// UINT32 Reserved2 : 15; +// }; +// +// UINT32 AsUInt; +//} VMX_SEGMENT_ACCESS_RIGHTS_TYPE; diff --git a/gengo/bind/sdkMerge/bug/tmp/bug.go b/gengo/bind/sdkMerge/bug/tmp/bug.go index 79ceb1125..4f5a131d9 100644 --- a/gengo/bind/sdkMerge/bug/tmp/bug.go +++ b/gengo/bind/sdkMerge/bug/tmp/bug.go @@ -55,8 +55,6 @@ type Uint64 = uint64 type Puint64 = *uint64 type Cr3Type = any type Pcr3Type = unsafe.Pointer -type XedImmdisT = any -type VmxSegmentAccessRightsType = any // Gengo init function. func init() {} diff --git a/gengo/clang/layout_parse.go b/gengo/clang/layout_parse.go index 99f63c6a4..000df0436 100644 --- a/gengo/clang/layout_parse.go +++ b/gengo/clang/layout_parse.go @@ -66,12 +66,9 @@ func (r *RecordLayout) UnmarshalString(data string) error { // mylog.Check(errors.New("improperly terminated layout")) switch { - case strings.Contains(data, "unnamed at"): - //return nil - //mylog.Warning("skip unmarshal RecordLayout", data) case strings.Contains(data, "__NSConstantString_tag"): - mylog.Warning("skip unmarshal RecordLayout", data) - return nil + //mylog.Warning("skip unmarshal RecordLayout", data) + //return nil } first := true @@ -117,7 +114,7 @@ func (r *RecordLayout) UnmarshalString(data string) error { typen := after //save strut type todo test if strings.HasPrefix(typen, "struct ") { - typen = "struct " + //typen = "struct " } if lastSpace := strings.LastIndex(after, " "); lastSpace != -1 { // If the last space is followed by a closing parenthesis, then it is part of the type. @@ -131,7 +128,7 @@ func (r *RecordLayout) UnmarshalString(data string) error { } if name == "" { - continue + //continue } // Create node diff --git a/gengo/gengo/generate.go b/gengo/gengo/generate.go index fdb0a56b7..1bde07239 100644 --- a/gengo/gengo/generate.go +++ b/gengo/gengo/generate.go @@ -642,7 +642,7 @@ func (mod Module) EmitFrom(ast clang.Node, layouts *clang.LayoutMap) { mylog.Todo("TypedefDecl cpp model not working") // Define typedefs. clang.Visit(ast, func(td *clang.TypedefDecl) bool { - mylog.Warning("TypedefDecl "+td.Name, td.Type.QualType) + mylog.Warning(td.Name, td.Type.QualType) if td.Name == "CR3_TYPE" { println() }