I'm analysing some malware executable with ImmDBG and IDA Pro.

The executable calls the kernel32.VirtualAlloc() at runtime with an argument lpAddress=NULL what means that an operating system decides itself where the memory has to be allocated. The VirtualAlloc() returns an address 0x003F0000. After that the executable writes some function to this memory, which is quite big, and I would like to analyse this function in IDA Pro.

The problem is, that my executable is loaded to the 0x004010000 in IDA Pro and I don't know how could I extend the memory of the executable in IDA Pro in order to create this function manually(with help of PatchBytes).

Also maybe it's possible somehow to build a function from a sequence of opcodes in IDA Pro?

Thank you in advance!

  • 1
    Did you try running it using the IDA debugger? It allows you to take snapshots of the memory and keep them inside the IDB.
    – tmr232
    Commented Jul 19, 2015 at 11:00

2 Answers 2


The most reliable solution I've found is to add a new section to the PE file and force the process to write the unpacked code into that new section in memory.

I wrote up a blog post a few years ago with a full walk-through of this approach: http://blog.crowdstrike.com/unpacking-dynamically-allocated-code/



I solved this issue by creating a new section in IDA Pro (File -> Segments -> Create segment). After that I dumped new section in OllyDBG (binary copy) and transferred it to the new created section in IDA Pro (with a Python script). After that I could analyse the code and write comments in IDA to make better analysis and documentation.

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.