簡體   English   中英

python構造結構無效的DWORDLONG值

[英]python construct struct invalid DWORDLONG vallues

我正在嘗試使用構造庫在 python 中解析 ac 結構這是我的結構:

typedef struct _MACHINEID {
    UINT32        ui32Hash;
    DWORD        dwLength;
    DWORD        dwMemoryLoad;
    DWORDLONG    ullTotalPhys;
    DWORDLONG    ullAvailPhys;
    DWORDLONG    ullTotalPageFile;
    DWORDLONG    ullAvailPageFile;
    DWORDLONG    ullTotalVirtual;
    DWORDLONG    ullAvailVirtual;
    DWORDLONG    ullAvailExtendedVirtual;
} MACHINEID, * PMACHINEID;
from construct import Int32un, Int8sn, Int16un, Int64un, Int
from construct import Array, Struct
MACHINE_ID = Struct(
    'ui32Hash' / Int32un,
    'dwLength' / Int32un,
    'dwMemoryLoad' / Int32un,
    'ullTotalPhys' / Int64un,
    'ullAvailPhys' / Int64un,
    'ullTotalPageFile' / Int64un,
    'ullAvailPageFile' / Int64un,
    'ullTotalVirtual' / Int64un,
    'ullAvailVirtual' / Int64un,
    'ullAvailExtendedVirtual' / Int64un
)

但是當我在 python 中接收結構作為字節對象時,所有DWORDLONG成員的值都不正確。 有誰知道這是什么原因造成的?

正如“一些程序員老兄”所暗示的那樣,它與填充有關。 __pragma(pack(push, 1))__pragma(pack(pop))我的結構周圍以禁用填充解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM