I have a binary with lots of indirect calls (call dword ptr [register + offset ]) the register is calculated with a simple math which I manage to statically calculate on my own (the call itself lead to some winapi calculated from the current offset)

whenever I try to use AddCodeRefs (ins, winapi, XREF_USER | fl_CN/f) to this data my graph turns out wrong and all the basic blocks become one instruction per basic block; when I try to do the reverse, IDA (logically :/) thinks that the data is really code and reinterprets all of the section to be garbage code.

My question is - Is it possible to create data xrefs from code manually ? AddCodeRefs seem to spoil the graph and I couldn't find any AddDataRefs, I'm using IDA 6.4.

  • 3
    Perhaps less f-words next time would also get your point across?
    – 0xC0000022L
    May 30, 2013 at 14:58
  • I see that you've already edit'ed it, sorry, I will s// next time
    – xrefsfrom
    May 30, 2013 at 15:26

1 Answer 1


I think you might be looking for add_dref(long From,long To,long drefType). IDA Online Help describes it as following:

Data reference types (combine with XREF_USER!):
#define dr_O    1                       // Offset
#define dr_W    2                       // Write
#define dr_R    3                       // Read
#define dr_T    4                       // Text (names in manual operands)
#define dr_I    5                       // Informational

void    add_dref(long From,long To,long drefType);      // Create Data Ref
void    del_dref(long From,long To);    // Unmark Data Ref

long    Dfirst  (long From);            // Get first data xref from 'From'
long    Dnext   (long From,long current);
long    DfirstB (long To);              // Get first data xref to 'To'
long    DnextB  (long To,long current);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.