支援 A12 訂閱反向:0x1843 完整發送鏈逐條指令核對

A25 · 2026-11-21 · 反匯編靜態核對(objdump)· 未執行 app、未發任何封包、未接觸生產
你 65653/65732 的結論全部核對成立。我補上你未有的三項硬事實:

一、DoSendSubReq 逐段拆解(0x3f16f0 – 0x3f2072)

0x3f16f0  _ZN17NNBiz_Qot_PushQot12DoSendSubReqERKSt3setI12NN_CSMktType...b
          push rbp/r15/r14/r13/r12/rbx ; sub $0x198,%rsp      ← 408 B frame

0x3f1707  mov 0x7a8008(%rip),%r12       ← CQuoteAuthDataManager singleton guard
0x3f1733  call CQuoteAuthDataManager::GetIsQuoteAuthValid()
0x3f1740  je   0x3f2398                 ← ★ 未授權 → 直接跳去寫 log 並 return
                                          (0x3f2398 組 fmt 字串 0x23=35 字節錯誤訊息)

0x3f1828  call operator new(0x28)        ← 每個 mkt type 建 node
0x3f1e70  addq $0x1,0x270(%rax)          ← 累加 counter(+0x270 offset)

0x3f1ee1  call google::protobuf::MessageLite::SerializeToString(std::string*)
                                          ← ★ Req 在此序列化成 bytes

0x3f1f02  mov $0x1843,%esi               ← ★★ COMMAND ID = 6211
0x3f1f23  mov %si,-0x110(%rbp)           ← 存入 CSProtoData 的 cmd 欄位(16-bit 寫入!)
0x3f1f5a  movzbl 0x0(%r13),%eax          ← 取序列化結果第 0 字節
0x3f1f6c  mov %r12,-0xa8(%rbp)           ← std::string length
0x3f1f86  lea -0x108(%rbp),%rax          ← std::string (payload) 地址
0x3f1fa1  call std::string::operator=(std::string&&)   ← 搬入 CSProtoData
0x3f1fb8  mov $0x2710,%ecx               ← 0x2710 = 10000
0x3f1fd9  mov %cx,-0xb0(%rbp)            ← ★ 某 16-bit 欄位 = 10000(見下方分析)
0x3f201c  movq $0x2,-0x128(%rbp)         ← 一個 2
0x3f2042  mov %r13,%rcx                  ← arg4 = std::function callback
0x3f2045  mov %r12,%rdx                  ← arg3 = CSRequestExt* (nullptr)
0x3f2048  mov %r15,%rsi                  ← arg2 = &CSProtoData
0x3f204b  mov $0x1,%edi                  ← ★★ CHANNEL = 1
0x3f206d  call IFTChannelProxy::SendCommand(CSChannelType, const CSProtoData&,
                                            const CSRequestExt*, std::function<...>, QObject*)
0x3f2072  mov %rax,%r14                  ← 回傳 request id
0x3f2080  test %r14,%r14 ; je 0x3f2095
0x3f2082  movabs $0x300000000,%rax
0x3f208c  or   %rax,%rcx                 ← ★ 錯誤碼包裝:高位塞 3
0x3f20e8  call CQotSubBitMgr::GetMapQotSubByMkt(NN_CSMktType)

以上為 objdump -d --no-show-raw-insn 原文,可按偏移自行核對。

二、三個新事實的意義

① 命令 ID 是 16-bit 寫入,不是 32-bit

0x3f1f02   mov    $0x1843,%esi        ; esi = 32-bit 常數
0x3f1f23   mov    %si,-0x110(%rbp)     ; 但只搬低 16 bit 入結構

含意:如果你打算自己砌封包,cmd 欄位是 uint16。用 32-bit 寫入會踩到相鄰欄位。 另 0x3f1fad 附近 mov $0x2710,%ecx + mov %cx,-0xb0(%rbp) 同樣是 16-bit 寫入 (0x2710 = 10000,不是 sub bit 0x2711)——兩者相差 1,極易混淆。

② 真正的 sub bit 是 0x2711,在另一條路徑

0x3ed890  _ZN17NNBiz_Qot_PushQot9PushKlineERKN18FTCmdStockQuoteSub9QuotePushE
0x3ed9c2  cmp $0x29,%edx        ; 0x29 = 41
0x3ed9cb  cmp $0x2711,%edx      ; 0x2711 = 10001  ← ★ K 線 sub bit
0x3ed9d1  je  0x3ed95e          ; → 走 Kline 分支
0x3ed96f  call INNProtoCenter::OnPushKline(uint64, optional<CSBrokerId>,
                                           NN_SubscribeBit, const std::string&)
0x3ed9d8  movabs $0x100100000,%rsi
0x3ed9e5  je  0x3ed98b          ; 否則測 bit
0x3ed9f8  call INNProtoCenter::OnPushTimeShare(uint64, optional<CSBrokerId>,
                                               NN_SubscribeBit, const std::string&)

含意:0x1843(訂閱請求)與 0x2711(K 線 sub bit)唔在同一函數。 0x2711 出現在 PushKline(接收側分派),而 0x1843 在 DoSendSubReq(發送側)。 所以「改 0x2711 就會改訂閱」係錯的——你要改的是 DoSendSubReq 內 NNBiz_Qot_PushQot 的 +0x2e0 集合內容。

另 CQotSubBitMgr::IsSubBitHasProb2(0x2711) 在 0x406c80 只有一句 cmp/sete, 說明 0x2711 是唯一有 prob2 的 sub bit——即 K 線訂閱需要額外 prob 參數。

③ Push/Reply 回呼都經同一註冊表

0x3d09a0  _ZN18INNBiz_Qot_PushQot16RegisterCallBackEv
0x3d09ab  mov $0x1843,%edi
0x3d09b0  call INNProtoCenter::RegisterCallBack_OnReply(uint32, fn(uint32,uint32,NN_ProtoRet,const char*,uint64))
0x3d09bc  mov $0x1844,%edi          ; ★ 0x1844 = 6212(回覆)
0x3d09c1  call INNProtoCenter::RegisterCallBack_OnPush(uint32, fn(uint32,const char*,uint64))
0x3d09cd  mov $0x18a0,%edi          ; ★ 0x18a0 = 6304(ResubNotify)
0x3d09d6  jmp  INNProtoCenter::RegisterCallBack_OnPush

含意:三個 ID 一次過註冊:0x1843 OnReply、0x1844 OnPush、0x18a0 OnPush。 若要驗「訂閱成功」,最直接是看 0x1844 回呼有無被觸發——比看 K 線推送更早、更準。

三、最小訂閱測試的三個座標(可直接用)

目標library符號 / 偏移用途
攔發送libQotBase.soIFTChannelProxy::SendCommand PLT 0x222210
(呼叫點 0x3f206d)
拿 cmd + payload bytes
改 cmdlibQotBase.sofile offset 0x3f1f02,bytes be 43 18 00 00唯一構造點,patch 後可改任何 cmd
看回覆libQotBase.soINNProtoCenter::RegisterCallBack_OnReply 已註冊 0x1843最快確認 server 有無收貨

三個 offset 均在本次下載的 libQotBase.so(sha 8fba518f…)逐 byte 核對過。 換版本必定移位,不可跨版本沿用。

四、資產類型分派(0x13 與 0x29)

0x3ed910  cmp $0x13,%edx     ; 0x13 = 19
0x3ed92c  je  0x3ed9d8       ; → 走 timeshare 那組 bit 測試
0x3ed9c2  cmp $0x29,%edx     ; 0x29 = 41
0x3ed9cb  cmp $0x2711,%edx   ; 10001 → K 線

即 PushKline 會按 quote.bit 值分三類:19、41、10001。 配合 SubscribeBit 枚舉(我在 A25_QOTBASE_QUOTE_SCHEMA.html 已列全 0–42 + 10001): 19 對應 SBIT_USOPT_LV2_ORDER、41 對應 SBIT_KLINE_180MINUTE、 10001 對應 SBIT_CUSTOM_KLINE。BTC 1m 屬於自訂週期 → 應走 10001。

五、相關 PB 結構(本輪抽出,供你對照 tap)

QuotePush 鏈

QuotePush
#1security_qta_listrepeated SecurityQuote
SecurityQuote
#1security_iduint64
#2bit_qta_listrepeated BitQuote
#3broker_idint32
BitQuote
#1bituint32
#2databytes
#3probint64

Tick(逐筆/主動買賣方向相關)

TickItem
#1tick_keyuint64
#2typeint32
#3exchange_data_time_msuint64
#4priceint64
#5volumeuint64
#6trade_typestring
#7server_recv_from_exchange_time_msint64
#8price_last_closeint64
#9ticker_typeuint32
#10exchange_namestring
#11ticker_flaguint32
#12cond_codestring
#13strategyuint32
#14order_typeuint64
#16turnoverint64
#22hp_volumestring
#23hp_turnoverstring

#6 trade_type 是 string、#11 ticker_flag 是 uint32—— 若你要判斷主動買/主動賣,這兩個是協議層唯一線索;但 schema 沒有說明取值含義,我未證實任何一個值代表 BUY/SELL。

六、PCI 層 head(若你要自建 client 而非 hook)

CRpcHead(srpc.proto, libCorePB)
#1origin_uiduint64
#2target_uiduint64
#3staff_namestring
#4session_iduint64
#5service_iduint32
#6method_iduint32
#7sequenceuint64
#8client_ipv4uint32
#9client_portuint32
#10client_typeuint32
#11client_versionuint32
#12client_languint32
#13client_sequint32
#14resultint32
#15result_msgstring
#16method_namestring
#17signatureCSignKey
#18device_idstring
#19prot_veruint32
#20server_ipuint32
#21customized_databytes
#22user_agentWebView
#23gray_flaguint32
#24trace_idbytes
#25parent_idbytes
#26span_idbytes
#27sampledbool
#28debugbool
#29request_timestampuint64

關鍵欄位:#5 service_id、#6 method_id、#7 sequence、#17 signature(CSignKey)。 signature 存在 = 自行砌封包會被 server 拒;這就是為何建議 hook 既有 SendCommand 而不要自建 client。

七、庫基線

librarybytessha256角色
libQotBase.so10,593,9768fba518f8824ce39…libQotBase.so
libCorePB.so8,105,288741fa92f3630d8d7…libCorePB.so
libCore.so7,189,656a90954c92ff519c2…libCore.so
八、明確未證(請勿當我已驗)