I'm using IDA Pro with the Hexrays decompiler.

There is a function like this:

Function 1

That function assigns the result of sub_100033AE to dword_10005368. So to know what the DWORD is, I checked what does that sub_100033AE do, but surprise...

Function 2

Its assembly is:

enter image description here

What I am wondering is: how is it just returning a call to new()? What is its purpose? What does it return?


Maybe the decompiler failed to recognize a register argument to new(). new(n) usually takes a nr of bytes, and allocates memory.

sub_100033ae just forwards the call to new.

  • So it's basically something like malloc?
    – rev
    Jul 20 '14 at 13:00
  • 6
    @AcidShout It's basically the C++ version of malloc in that it gives you a pointer to at least x bytes of consecutive memory. There are some differences though, operator new can throw exceptions and cause new handlers to be called. There could also be a difference between what sort of meta data is stored about the allocated memory between malloc and new. They're different functions so it's best to treat them as such. After allocation you usually have object construction into the allocated memory. Jul 20 '14 at 15:14
  • @PeterAndersson thanks, really good explanation. This can be considered solved!
    – rev
    Jul 20 '14 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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