Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Parse C Source..." changes enum 'members' into their actual values if they're previously defined. #6418

Open
Wall-AF opened this issue Apr 13, 2024 · 0 comments
Assignees
Labels
Feature: C-Parser Status: Triage Information is being gathered

Comments

@Wall-AF
Copy link

Wall-AF commented Apr 13, 2024

Describe the bug
Given a C source file like:

// 2 #define statements from winnt.h
#define STATUS_WAIT_0                    ((DWORD   )0x00000000L)    
#define STATUS_ABANDONED_WAIT_0          ((DWORD   )0x00000080L)    

typedef enum enumDWORD_EXCEPTION_CODES_STATUS {
    STATUS_WAIT_0=0,
    STATUS_ABANDONED_WAIT_0=128,
    STATUS_USER_APC=192,
    STATUS_TIMEOUT=258,
    STATUS_PENDING=259,
    .
    .
    .
    STATUS_SXS_INVALID_DEACTIVATION=3222601744
} enumDWORD_EXCEPTION_CODES_STATUS;

parsing this causes an error. When examining the XXX_CParser.out file, the member names have been substituted for their values, so that the enum becomes:

typedef enum enumDWORD_EXCEPTION_CODES_STATUS {
    ((DWORD   )0x00000000L)=0,
    ((DWORD   )0x00000080L)=128,
    STATUS_USER_APC=192,
    STATUS_TIMEOUT=258,
    STATUS_PENDING=259,
    .
    .
    .
    STATUS_SXS_INVALID_DEACTIVATION=3222601744
} enumDWORD_EXCEPTION_CODES_STATUS;

To Reproduce
Steps to reproduce the behavior:

  1. Create a header file from the above example
  2. Choose "Parse C Source..." from a CodeBrowser's "File" menu
  3. Setup Parse Configuration and Parse the file
  4. See error

Expected behavior
enum 'members' should not be substituted as they are effectively l-values.

Screenshots
N/A

Attachments
N/A

Environment (please complete the following information):

  • OS: Windows 11
  • Java Version: 17.0.3.1
  • Ghidra Version: 11.1-DEV
  • Ghidra Origin: locally

Additional context
N/A

@Wall-AF Wall-AF changed the title "Parse C Source..." changes enum 'named values' into their actual values if they're previously defined. "Parse C Source..." changes enum 'members' into their actual values if they're previously defined. Apr 13, 2024
@ryanmkurtz ryanmkurtz added Feature: C-Parser Status: Triage Information is being gathered labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: C-Parser Status: Triage Information is being gathered
Projects
None yet
Development

No branches or pull requests

3 participants