REDIVIVUS

Proposals / #997

LINKEDLIST_InsertAfter returns its object pointer (pList), like a constructor

applied · by Niehztog · submitted 2026-11-02, applied 2026-11-02

Ghidra v1846 · 4ca0e98

The function opens with 0041d923 MOV EAX,ECX and does all its stores through EAX: [EAX+0x8] and [EAX] = pNode, [EAX+0x4] = pNewNode, [EAX+0xc] and [EAX+0x10] = 0 (0041d928..0041d938), then RET 0x8. With a void return VC8 stores through ECX and needs no copy; keeping the object in EAX to the end is how it returns this. Its only caller hands it a stack object (0041f994 LEA ECX,[EBP-0x14]; 0041f997 CALL), the shape of a constructor on a local. Typed D2BitStreamWriterStrc * returning pList, the function recompiles byte-identical with VC8 SP1 (oracle, tree 3dba660: OUR-1, similarity 0.320 -> MATCH); no function lost. Return type only; storage and names unchanged.

Changes 1, applied together

  1. Set prototype win 0x0041d920

    signaturevoid LINKEDLIST_InsertAfter(D2BitStreamWriterStrc * pList, uint8_t * pNode, int32_t pNewNode)→D2BitStreamWriterStrc * LINKEDLIST_InsertAfter(D2BitStreamWriterStrc * pList, uint8_t * pNode, int32_t pNewNode)
    convention__fastcall