
    6LjK                       d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZmZ ddlmZ  ee      j#                         j$                  d   Zed	z  Zed
z  Zedz  ZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d#d$dZ#d%dZ$d&dZ%d'dZ&d'dZ'd(d)dZ(	 	 	 d*	 	 	 	 	 	 	 	 	 	 	 	 	 d+dZ)d,dZ*d-d Z+d.d!Z,e-d"k(  r e. e,             y)/a  Classify the parent context of the grounded HUD top-menu sequence.

The top menu object sequence at 0x004ddc6c draws/attaches the #6/#3/#4 HUD
menu regions.  Earlier scans proved the payload, but not the normal-field
ESC/X opener that schedules it.  This review keeps those two facts separate:

* 0x004ddc6c is the grounded top-menu construction sequence.
* Its only direct pointer reference is the operand of a VM call command inside
  0x0047e6a0, whose own parent context is not referenced as a normal field
  input/open-menu root.
    )annotationsN)Path)Any)offset_to_varead_sectionsva_to_offset)decode_stream   zHwanse2.exeoutwebilM iG iG i|G iG iG i$G i,J iM iXM iM ihM c                    | dS d| d| dS )N-0x0x )valuewidths     3tools/build_hud_menu_top_sequence_context_review.pyhxr   ,   s#    -3;r%%z):%;;    c                V    t        j                  | dd      S t        |       d      S )N T)quote)htmlescapestr)r   s    r   hr   0   s%    ;;U]r$GGE
$GGr   c                ^    t        ||      }|t        dt        |       d      | |||z    S )NzVA z is outside raw sections)r   
ValueErrorr   )exesectionsvasizeoffsets        r   read_atr&   4   s=    (B'F~3r"vh&>?@@vv}%%r   c                    t        j                  d|      }g }| j                  |      }|dk7  r:t        ||      }||j	                  |       | j                  ||dz         }|dk7  r:|S )N<Ir
   )structpackfindr   append)r!   r"   r   needlerefsposr#   s          r   all_refsr1   ;   sl    [[u%FD
((6
C
)(C(>KKOhhvsQw'	 )
 Kr   c                T   t        j                  d|      }g }|D ]  }|j                  d      dk7  rt        |d         }|t        |d         z   }| j	                  |||      }|dk7  sPt        ||      }	|	|j                  |	       | j	                  ||dz   |      }|dk7  r; |S )Nr(   namez.textrawraw_sizer)   r
   )r*   r+   getintr,   r   r-   )
r!   r"   r   r.   r/   sectionstartendr0   r#   s
             r   	text_refsr;   G   s    [[u%FD 
1;;v')GEN#c'*-..hhvuc*Rih,B~B((637C0C	 Ri
1 Kr   c                j   t        | |||d      }|t        |      |j                  dd      |j                  dg       D cg c]e  }|j                  d      |j                  d      |j                  d      |j                  d	      |j                  d
      |j                  d      dg c}dS c c}w )Ni`  )max_commands	max_bytesdecodedCommandCountr   commandsvaHex	opcodeHex
opcodeNamelengthsummaryrawHex)rA   rB   rC   rD   rE   rF   )startVa
startVaHexr?   r@   )r	   r   r6   )r!   r"   start_var=   decodedcommands         r   command_digestrL   X   s    C8,Z_`Gl&{{+@!D #;;z26

  !W-$[[5%kk,7!++h/";;y1!++h/

	 

s   A*B0
c                   t        ||      }|g S | ||z   ||z   |z    }g }|j                  d      D ]  }	|	s|r |S t        |	      dk(  rt        j                  d|	      d   dkD  r6t        d |	D              r |S 	 |	j                  d      }
d|
vrd	|
vr|
j                         s |S |j                  |
       t        |      |k\  s |S  |S # t        $ r Y  |S w xY w)
N       r(   r   i  @ c              3  4   K   | ]  }|d k  xs |dkD    yw)    ~   Nr   ).0bytes     r   	<genexpr>z c_string_list.<locals>.<genexpr>   s      <dtd{)dTk)<s   ascii._)
r   splitlenr*   unpackanydecodeUnicodeDecodeErrorisalnumr-   )r!   r"   r#   r$   limitskipr%   r4   namestokentexts              r   c_string_listre   l   s    (B'F~	
ftmVd]T1
2CE7#  L u:?v}}T59!<zI<e<< L	<<(D d?s$t||~ L 	Tu:L%$ L " 	 L	s   >C	CCc                 z
   t         j                         } t        |       }t        | |t              }t        | |t
              }t        | |t              }t        | |t              }t        | |t              }t        | |t              }t        | |t              }t        | |t              }	t        | |t              }
t        | |t        d      }t        | |t         d      }t#        j$                  d|d      d   }|d d dk(  xr |t        k(  xr t&        |v }|t&        gk(  }d}i dt)        t              d	t+        |      d
|D cg c]  }t)        |       c}dt+        t-        | |t                    dt)        t
              dt+        |      d|D cg c]  }t)        |       c}dt)        t              dt+        |      d|D cg c]  }t)        |       c}dt)        t              dt+        |      d|D cg c]  }t)        |       c}dt)        t              dt+        |      d|D cg c]  }t)        |       c}dt)        t               t)        |      ||t+        |      t+        |      t+        |	      t+        |
      t)        t              |h dj/                  t1        |            rdnd|dd}ddd |t3        | |t        d!"      t3        | |t        d"      t3        | |t        d"      t3        | |t
        d#"      t3        | |t        d!"      d$d%t)        t              |D cg c]  }t)        |       c}d&d'd(t)        t              |D cg c]  }t)        |       c}d)d'd*t)        t              |D cg c]  }t)        |       c}d+d'd,t)        t
              |D cg c]  }t)        |       c}d-d'd.t)        t              |D cg c]  }t)        |       c}d/d'd0t)        t              t        | |t              D cg c]  }t)        |       c}d1j5                  |d d2       d'd3t)        t              |D cg c]  }t)        |       c}d4d'd5t)        t              |D cg c]  }t)        |       c}d4d'd6t)        t              |	D cg c]  }t)        |       c}d4d'd7t)        t              |
D cg c]  }t)        |       c}d8d'g
g d9g d:d;S c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w c c}w )<NrO   )ra      r(   r   s      FtopMenuObjectSequenceVaHextopMenuSequenceAllRefCounttopMenuSequenceAllRefsHextopMenuSequenceTextRefCounttopMenuWrapperVaHextopMenuWrapperDirectRefCounttopMenuWrapperDirectRefsHextopMenuPreWrapperGateVaHex#topMenuPreWrapperGateDirectRefCount"topMenuPreWrapperGateDirectRefsHextopMenuRejectLoopVaHextopMenuRejectLoopDirectRefCounttopMenuRejectLoopDirectRefsHextopMenuParentContextVaHextopMenuParentDirectRefCounttopMenuParentDirectRefsHexwrapperCallCommandVaHex>   aaa.cns	title.cnscompile.cnslogo_00.cnszintro/title-resource-contextzunclassified-parent-contexta  0x004ddc6c top-menu sequence is grounded as the #6/#3/#4 menu construction stream, but its only direct reference is the inline operand of the 0x04 call command at 0x0047e6ac. The immediate pre-wrapper gate at 0x0047e688 is now decoded as two 0x6e active group-key branches and one 0xe6 active-descriptor-count branch, all targeting the stop/jump loop at 0x0047e67c when the gate fails. The nearby parent resource list contains intro/title assets such as compile.cns, aaa.cns, logo_00.cns, title.cns, and btl_k*.  The wrapper 0x0047e6a0 and parent context 0x0047e624 have no direct pointer refs, so this pass does not prove the normal-field ESC/X opener.)wrapperCallOperandVaHexwrapperCallsTopMenuSequence"topSequenceRefIsWrapperOperandOnly statusRegion6ChildScriptRefCount$rightPanelRegion3ChildScriptRefCount$rightPanelRegion4ChildScriptRefCountrightPanelPageScriptRefCountintroTitleResourceListVaHexintroTitleResourceListPreviewparentContextClassificationnormalFieldEscOpenerProvendecisionz+hwanse-hud-menu-top-sequence-context-reviewz3tools/build_hud_menu_top_sequence_context_review.pyz*top-menu-sequence-grounded-opener-unproven   )r=      )parentContextpreWrapperGate
rejectLoopwrappertopMenuSequenceztop menu object sequencez.grounded sequence; only ref is wrapper operand)labelrA   refsHexclassificationzpre-wrapper gatezQactive group-key / active-descriptor-count gate; target refs point to reject loopzpre-wrapper reject loopz2stop-tick then jump back toward selected-root callztop menu wrapperz&unreferenced wrapper; not opener proofztop menu parent contextzKunreferenced parent context; adjacent resource list is intro/title-orientedzintro/title resource list, 
   zregion #6 child scriptzreferenced by top-menu sequencezregion #3 child scriptzregion #4 child scriptzshifted/right-panel page scriptz6secondary page/menu payload context; not normal opener)z;No direct pointer refs to the wrapper stream at 0x0047e6a0.zBNo direct pointer refs to the parent context stream at 0x0047e624.zjThe sole 0x004ddc6c ref is 0x0047e6b0, an operand address inside the 0x04 command beginning at 0x0047e6ac.zThe repeated 7c e6 47 00 bytes before the wrapper are not opcode 0x7c commands; they are little-endian target pointers to 0x0047e67c.zfThe adjacent resource list at 0x004a2cb0 is intro/title-oriented, not a normal-field HUD menu context.zThis review does not find an input-edge, field-mode, or descriptor-add producer that schedules the wrapper from normal field state.)zFind the upstream selector/descriptor producer that schedules 0x0047e6a0 or its parent context without relying on direct pointer refs.zePrioritize field mode/state transitions after ESC/X edge handling, not menu-internal cursor handlers.zSDo not promote 0x004ddc6c itself as the opener; it is the menu construction callee.)kindsourcestatusrE   contextsreferenceSurfacesnegativeEvidencenextFrontier)EXE
read_bytesr   r1   TOP_MENU_OBJECT_SEQUENCE_VATOP_MENU_WRAPPER_VATOP_MENU_PRE_WRAPPER_GATE_VATOP_MENU_REJECT_LOOP_VATOP_MENU_PARENT_CONTEXT_VASTATUS_REGION6_CHILD_SCRIPT_VA#RIGHT_PANEL_REGION3_CHILD_SCRIPT_VA#RIGHT_PANEL_REGION4_CHILD_SCRIPT_VA"RIGHT_PANEL_REGION4_PAGE_SCRIPT_VAre   INTRO_TITLE_RESOURCE_LIST_VAr&    TOP_MENU_WRAPPER_CALL_COMMAND_VAr*   unpack_from TOP_MENU_WRAPPER_CALL_OPERAND_VAr   rZ   r;   issubsetsetrL   join)r!   r"   top_refswrapper_refspre_wrapper_refsreject_loop_refsparent_refsregion6_refsregion3_refsregion4_refs	page_refsintro_title_resource_nameswrapper_call_rawwrapper_call_operandwrapper_calls_top_menutop_ref_is_operandnormal_field_esc_opener_provenrefrE   s                      r   build_reportr      s~   
..
CS!HX'BCHC+>?LX/KLX/FG3*DEKC+IJLC+NOLC+NOLh(JKI!.sH>Zab!csH.NPQR!--d4DaHK! 33 	9 $??	9,8  "&F%GG%*"+$b)D&E+$c(m+ 	$%B#bg%B+ 	&s9S(D_+`'a	+
 	r"56+ 	'L(9+ 	&<'HC3'H+ 	%b)E&F+ 	.s3C/D+ 	-BR.S3r#w.S+ 	!"%<"=+ 	*3/?+@+ 	)>N*Os2c7*O+ 	$R(B%C+ 	&s;'7+  	%+&F3r#w&F!+" 	"2&F#G#+$ $&&:#;'=.@,/,=03L0A03L0A(+I')*F'G)C FNNsSmOno +.&DIE+G\ >G>+C;Udfg,S(<Xghi(h8O^_`%c85HWYZ-c8=Xgij
 478/78BsG8"R	 ,89/?@BsG@"u	 334/?@BsG@"V	 ,/0/;<BsG<"J	 367/:;BsG;"o	 589/7XGc/deBsGe"&)),Fs,K"L	 2:;/;<BsG<"C	 2?@/;<BsG<"C	 2?@/;<BsG<"C	 ;>?/89BsG9"Z	o=
|

eW WU &C (I /T +P 'GZ 9 A A = < f = = = :sZ   S2S7
S< T6T6T T
T4TTT$T)=T. 'T3"T8$c                p   | d   }d| d   fd|d   fd|d   fd|d   fd	|d
   fd|d   fd|d   fd|d   fg}dj                  d |D              }d,d}d}dD ](  \  }}| d   |   }|dt        |       d ||       dz  }* dj                  d | d   D              }	dj                  d | d   D              }
dj                  d | d   D              }t        j                  | d       }d!t        |d"          d#| d$|	 d%| d&|
 d'| d(| d)}d*j                  d+ |j	                         D              d*z   S )-NrE   r   ztop seqrh   ztop refsri   zpre-gate refsrp   zwrapper refsrm   zparent refsrv   zparent classr   openerr   r   c              3  X   K   | ]"  \  }}d t        |       dt        |       d $ yw)z<div class='card'><b>z
</b><span>z</span></div>Nr   )rS   kvs      r   rU   zrender_html.<locals>.<genexpr>;  s/     gTXTUWX+AaD6AaD6Ogs   (*c                R    dj                  d | j                  dg       D              S )Nr   c              3  0  K   | ]  }d t        |j                  d             dt        |j                  d             dt        |j                  d             dt        |j                  d             dt        |j                  d	             d
  yw)z<tr><td><code>rA   z</code></td><td><code>rB   z</code><br>rC   z	</td><td>rE   </td><td><code>rF   </code></td></tr>N)r   r6   )rS   rK   s     r   rU   z7render_html.<locals>.render_commands.<locals>.<genexpr>>  s      
 7;;w/01 27;;{345[7;;|C\A]@^ _W[[+,- .7;;x012 3	
s   BBr@   )r   r6   )contexts    r   render_commandsz$render_html.<locals>.render_commands=  s-    ww 
 #;;z26
 
 	
r   ))r   zParent Context 0x0047e624)r   zReject Loop 0x0047e67c)r   zPre-wrapper Gate 0x0047e688)r   zWrapper 0x0047e6a0)r   zTop Menu Sequence 0x004ddc6cr   z!
        <section>
          <h2>z</h2>
          <table>
            <thead><tr><th>VA</th><th>opcode</th><th>summary</th><th>raw</th></tr></thead>
            <tbody>z7</tbody>
          </table>
        </section>
        c              3     K   | ]V  }d t        |d          dt        |d          dt        |d          dt        dj                  |d         xs d	       d
	 X yw)z<tr><td>r   z
<br><code>rA   z</code></td><td>r   r   r   r   r   r   N)r   r   )rS   rows     r   rU   zrender_html.<locals>.<genexpr>[  sy       	Wz!CL/): ;%&'( )tyyY07C89 :	s   AAr   c              3  :   K   | ]  }d t        |       d  ywz<li>z</li>Nr   rS   items     r   rU   zrender_html.<locals>.<genexpr>c  s     U$$qwiu-U   r   c              3  :   K   | ]  }d t        |       d  ywr   r   r   s     r   rU   zrender_html.<locals>.<genexpr>d  s     Udd1T7)51Ur   r   F)ensure_asciia  <!doctype html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>HUD Menu Top Sequence Context Review</title>
  <style>
    body { margin:0; background:#101318; color:#edf1f7; font-family:system-ui,sans-serif; }
    main { max-width:1280px; margin:0 auto; padding:24px; }
    a { color:#8ecbff; }
    .nav { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
    .chip { border:1px solid #334155; border-radius:999px; padding:6px 10px; text-decoration:none; background:#161b22; }
    .summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin:16px 0; }
    .card { border:1px solid #2b3544; border-radius:8px; padding:12px; background:#161b22; }
    .card b { display:block; color:#9fb1c9; font-size:12px; text-transform:uppercase; }
    .card span { display:block; margin-top:8px; font-size:18px; overflow-wrap:anywhere; }
    section { border:1px solid #273244; border-radius:10px; padding:16px; margin:16px 0; background:#141922; overflow:auto; }
    table { border-collapse:collapse; width:100%; min-width:1040px; font-size:13px; }
    th,td { border-bottom:1px solid #283342; padding:8px; text-align:left; vertical-align:top; }
    th { color:#b9c7dc; background:#111722; }
    code { color:#dbeafe; overflow-wrap:anywhere; }
    pre { white-space:pre-wrap; background:#0b0f14; border:1px solid #253044; border-radius:8px; padding:12px; max-height:420px; overflow:auto; }
  </style>
</head>
<body>
<main>
  <div class="nav">
    <a class="chip" href="index.html">index</a>
    <a class="chip" href="hud_menu_opener_frontier_review.html">opener frontier</a>
    <a class="chip" href="hud_menu_selected_root_frontier_review.html">selected-root frontier</a>
    <a class="chip" href="hud_menu_preview.html">HUD menu preview</a>
    <a class="chip" href="../out/hud_menu_top_sequence_context_review.json">JSON</a>
  </div>
  <h1>HUD Menu Top Sequence Context Review</h1>
  <p>r   z</p>
  <div class="summary">z</div>
  <section>
    <h2>Reference Surfaces</h2>
    <table><thead><tr><th>surface</th><th>classification</th><th>refs</th></tr></thead><tbody>z </tbody></table>
  </section>
  z4
  <section>
    <h2>Negative Evidence</h2>
    <ul>zB</ul>
  </section>
  <section>
    <h2>Next Frontier</h2>
    <ul>z</ul>
  </section>
  <section>
    <h2>Raw JSON</h2>
    <pre id="json"></pre>
  </section>
</main>
<script>
window.HWANSE_HUD_MENU_TOP_SEQUENCE_CONTEXT_REVIEW = z;
document.getElementById('json').textContent = JSON.stringify(window.HWANSE_HUD_MENU_TOP_SEQUENCE_CONTEXT_REVIEW, null, 2);
</script>
</body>
</html>

c              3  <   K   | ]  }|j                           y w)N)rstrip)rS   lines     r   rU   zrender_html.<locals>.<genexpr>  s     EtT[[]Es   )r   dict[str, Any]returnr   )r   r   jsondumps
splitlines)reportrE   
card_itemscardsr   context_tableskeytitler   ref_rows	negativesnext_frontierpayloadhtml_docs                 r   render_htmlr   /  s   YG	6(#$	G89:	W9:;	'"GHI	!?@A	 =>?	!>?@	7789	J GGg\fggE	
 N 
U $S) xj  $G,- .	 	$ ww  -. H U&AS:TUUIGGUf^>TUUMjje4G"D 
 w _ `h^h i 	 
 	 
 6 7>Y ?o<Hz 99Ex/B/B/DEELLr   c                 2   t               } t        j                  d       t        j                  d       t        dz  j	                  t        j                  | dd      dz   d	       t        d
z  j	                  t        |       d	       t        d       y)NT)exist_okz)hud_menu_top_sequence_context_review.jsonF   )r   indentr   zutf-8)encodingz)hud_menu_top_sequence_context_review.htmlz'hud_menu_top_sequence_context_review okr   )	r   OUTmkdirWEB
write_textr   r   r   print)r   s    r   mainr     s    ^FIItIIItI66BB

6a84? C  	66BB;vCVahBi	
34r   __main__)rg   )r   z
int | Noner   r7   r   r   )r   r   r   r   )
r!   bytesr"   list[dict[str, Any]]r#   r7   r$   r7   r   r   )r!   r   r"   r   r   r7   r   z	list[int])   )
r!   r   r"   r   rI   r7   r=   r7   r   r   )   r   r   )r!   r   r"   r   r#   r7   r$   r7   r`   r7   ra   r7   r   z	list[str])r   r   )r   r   r   r   )r   r7   )/__doc__
__future__r   r   r   r*   pathlibr   typingr   probe_exe_scene_tablesr   r   r   'summarize_object_payload_442c75_callersr	   __file__resolveparentsROOTr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r&   r1   r;   rL   re   r   r   r   __name__
SystemExitr   r   r   <module>r     sL  
 #      L L A H~''*
]
Ul
Ul(   ) $ #-  #-  ' ) !+ &0 #&0 #%/ "<H&	"0 	" 	 	
   D^BtMn
 z
TV
 r   