Skip to content

Commit 896a839

Browse files
committed
Merge branch 'fix/bool-struct-marshaling'
Fix interop struct bool fields marshaled as 4-byte Win32 BOOL instead of native 1-byte C++ bool, which shifted every field after a bool (e.g. BNBoolWithConfidence confidence, BNDataVariable typeConfidence). 44 fields across 28 structs get [MarshalAs(UnmanagedType.I1)]. Verified by reflection layout check + full e2e.
2 parents 43480a9 + 2a230b5 commit 896a839

28 files changed

Lines changed: 44 additions & 44 deletions

Struct/BNAnalysisParameters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public unsafe struct BNAnalysisParameters
3636
/// <summary>
3737
/// bool suppressNewAutoFunctionAnalysis
3838
/// </summary>
39-
internal bool suppressNewAutoFunctionAnalysis;
39+
[MarshalAs(UnmanagedType.I1)] internal bool suppressNewAutoFunctionAnalysis;
4040

4141
/// <summary>
4242
/// BNAnalysisMode mode
@@ -46,7 +46,7 @@ public unsafe struct BNAnalysisParameters
4646
/// <summary>
4747
/// bool alwaysAnalyzeIndirectBranches
4848
/// </summary>
49-
internal bool alwaysAnalyzeIndirectBranches;
49+
[MarshalAs(UnmanagedType.I1)] internal bool alwaysAnalyzeIndirectBranches;
5050

5151
/// <summary>
5252
/// uint64_t advancedAnalysisCacheSize

Struct/BNBasicBlockAnalysisContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ internal unsafe struct BNBasicBlockAnalysisContext
2121
/// <summary>
2222
/// bool guidedAnalysisMode
2323
/// </summary>
24-
public bool guidedAnalysisMode;
24+
[MarshalAs(UnmanagedType.I1)] public bool guidedAnalysisMode;
2525

2626
/// <summary>
2727
/// bool triggerGuidedOnInvalidInstruction
2828
/// </summary>
29-
public bool triggerGuidedOnInvalidInstruction;
29+
[MarshalAs(UnmanagedType.I1)] public bool triggerGuidedOnInvalidInstruction;
3030

3131
/// <summary>
3232
/// bool translateTailCalls
3333
/// </summary>
34-
public bool translateTailCalls;
34+
[MarshalAs(UnmanagedType.I1)] public bool translateTailCalls;
3535

3636
/// <summary>
3737
/// bool disallowBranchToString
3838
/// </summary>
39-
public bool disallowBranchToString;
39+
[MarshalAs(UnmanagedType.I1)] public bool disallowBranchToString;
4040

4141
/// <summary>
4242
/// uint64_t maxFunctionSize
@@ -66,7 +66,7 @@ internal unsafe struct BNBasicBlockAnalysisContext
6666
/// <summary>
6767
/// bool maxSizeReached
6868
/// </summary>
69-
public bool maxSizeReached;
69+
[MarshalAs(UnmanagedType.I1)] public bool maxSizeReached;
7070

7171
/// <summary>
7272
/// uint64_t contextualFunctionReturnCount

Struct/BNBasicBlockEdge.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ internal unsafe struct BNBasicBlockEdge
2222
/// <summary>
2323
/// bool backEdge
2424
/// </summary>
25-
internal bool backEdge;
25+
[MarshalAs(UnmanagedType.I1)] internal bool backEdge;
2626

2727
/// <summary>
2828
/// bool fallThrough
2929
/// </summary>
30-
internal bool fallThrough;
30+
[MarshalAs(UnmanagedType.I1)] internal bool fallThrough;
3131
}
3232

3333

Struct/BNBoolWithConfidence.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal unsafe struct BNBoolWithConfidence
1111
/// <summary>
1212
/// bool value
1313
/// </summary>
14-
public bool value;
14+
[MarshalAs(UnmanagedType.I1)] public bool value;
1515

1616
/// <summary>
1717
/// uint8_t confidence

Struct/BNCallLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal unsafe struct BNCallLayout
2121
/// <summary>
2222
/// bool returnValueValid
2323
/// </summary>
24-
internal bool returnValueValid;
24+
[MarshalAs(UnmanagedType.I1)] internal bool returnValueValid;
2525

2626
/// <summary>
2727
/// BNValueLocation returnValue

Struct/BNConstantReference.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ internal unsafe struct BNConstantReference
2121
/// <summary>
2222
/// bool pointer
2323
/// </summary>
24-
public bool pointer;
24+
[MarshalAs(UnmanagedType.I1)] public bool pointer;
2525

2626
/// <summary>
2727
/// bool intermediate
2828
/// </summary>
29-
public bool intermediate;
29+
[MarshalAs(UnmanagedType.I1)] public bool intermediate;
3030
}
3131

3232
public sealed class ConstantReference

Struct/BNDataVariable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public unsafe struct BNDataVariable
2121
/// <summary>
2222
/// bool autoDiscovered
2323
/// </summary>
24-
internal bool autoDiscovered;
24+
[MarshalAs(UnmanagedType.I1)] internal bool autoDiscovered;
2525

2626
/// <summary>
2727
/// uint8_t typeConfidence

Struct/BNDataVariableAndName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public unsafe struct BNDataVariableAndName
2626
/// <summary>
2727
/// bool autoDiscovered
2828
/// </summary>
29-
internal bool autoDiscovered;
29+
[MarshalAs(UnmanagedType.I1)] internal bool autoDiscovered;
3030

3131
/// <summary>
3232
/// uint8_t typeConfidence

Struct/BNDataVariableAndNameAndDebugParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal unsafe struct BNDataVariableAndNameAndDebugParser
3131
/// <summary>
3232
/// bool autoDiscovered
3333
/// </summary>
34-
public bool autoDiscovered;
34+
[MarshalAs(UnmanagedType.I1)] public bool autoDiscovered;
3535

3636
/// <summary>
3737
/// uint8_t typeConfidence

Struct/BNDisassemblyTextLineTypeInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public unsafe struct BNDisassemblyTextLineTypeInfo
1111
/// <summary>
1212
/// bool hasTypeInfo
1313
/// </summary>
14-
internal bool hasTypeInfo;
14+
[MarshalAs(UnmanagedType.I1)] internal bool hasTypeInfo;
1515

1616
/// <summary>
1717
/// BNType* parentType

0 commit comments

Comments
 (0)