MS-PATCH § 2.2.2: realign code blocks

Ondra Hošek 0 Reputation points
2025-07-03T09:40:16.02+00:00

Greetings,

here is a request to slightly beautify the pseudocode in the MS-PATCH open specification section 2.2.2 (E8 Call Translation). It appears the alignment of the code blocks has gone a bit haywire.

I've performed the realignment myself. First block:

if (( chunk_offset < 0x40000000 ) && ( chunk_size > 10 ))
    for ( i = 0; i < (chunk_size – 10); i++ )
        if ( chunk_byte[ i ] == 0xE8 )
            long current_pointer = chunk_offset + i;
            long displacement =
                chunk_byte[ i+1 ]       |
                chunk_byte[ i+2 ] << 8  |
                chunk_byte[ i+3 ] << 16 |
                chunk_byte[ i+4 ] << 24;
            long target = current_pointer + displacement;
            if (( target >= 0 ) && ( target < E8_file_size+current_pointer))
                if ( target >= E8_file_size )
                    target = displacement – E8_file_size;
                endif
                chunk_byte[ i+1 ] = (byte)( target );
                chunk_byte[ i+2 ] = (byte)( target >> 8 );
                chunk_byte[ i+3 ] = (byte)( target >> 16 );
                chunk_byte[ i+4 ] = (byte)( target >> 24 );
            endif
            i += 4;
        endif
    endfor
endif

Second block:

long value =
    chunk_byte[ i+1 ]       |
    chunk_byte[ i+2 ] << 8  |
    chunk_byte[ i+3 ] << 16 |
    chunk_byte[ i+4 ] << 24;

if (( value >= -current_pointer ) && ( value < E8_file_size ))
    if ( value >= 0 )
        displacement = value – current_pointer;
    else
        displacement = value + E8_file_size;
    endif
    chunk_byte[ i+1 ] = (byte)( displacement );
    chunk_byte[ i+2 ] = (byte)( displacement >> 8 );
    chunk_byte[ i+3 ] = (byte)( displacement >> 16 );
    chunk_byte[ i+4 ] = (byte)( displacement >> 24 );
endif

I'd be grateful if this could be reflected in the next version of the document. Thank you in advance!

Kind regards, ~~ Ondra Hošek

Exchange | Exchange Server | Open Specifications
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Bowen 2,051 Reputation points Microsoft Employee Moderator
    2025-07-07T22:28:00.5566667+00:00

    Hi @Ondra Hošek ,

    Thanks for finding this and sending the corrected code snippets, we have verified the snippets and the update will be in a future release of MS-PATCH.

    Thanks for your help!

    Best regards, Michael Bowen Microsoft Open Specifications

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.