I'm looking for a way, to make programmatically change of data type. This is the same as you press 'C' or 'D'.

For example convert this:

.text:00401008 unk_401008      db  55h ; U             ; CODE XREF: start↑p
.text:00401009                 db  8Bh ; ‹
.text:0040100A                 db 0ECh ; ì
.text:0040100B                 db  83h ; ƒ
.text:0040100C                 db 0ECh ; ì

to this:

.text:00401008 loc_401008:                             ; CODE XREF: start↑p
.text:00401008                 push    ebp
.text:00401009                 mov     ebp, esp
.text:0040100B                 sub     esp, 0Ch

and vice versa.

These functions should be listed here https://www.hex-rays.com/products/ida/support/idapython_docs/ but I can't find it.

So far I found only this:

generate_disasm_line(here(), GENDSM_FORCE_CODE)

but it only prints data to output, and does not change the "IDA View" window content.



2 Answers 2


ah, to create code there is:


The last question, when I'm trying to create data from code I'm getting False:

Python>create_data(here(), FF_BYTE, 0x79, 0)

This is because I need previously del_items()

  • If you want to ask another question, ask new question. Don't "bundle" it together with an answer. It's confusing.
    – user202729
    Commented Aug 22, 2018 at 15:44
  • ok, next time I will, this is my first experience of using this platform, sorry
    – eXp
    Commented Aug 22, 2018 at 19:49

To create code, there is:


To create data:

ida_bytes.create_byte(here()) # create byte at the specified address
ida_bytes.create_data(here(), ida_bytes.dword_flag(), 4, ida_netnode.BADNODE) # create a dword variable at the specified address

ida_bytes.create_data documentation.

If you already have something defined there at that address, or something defined before it that spans through that address, for example, variable at address 0x100 that spans 8 bytes and you want to create a variable at address 0x104, use ida_bytes.del_items to undefine bytes first.

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.