0

字符串表资源 ID 存储在哪里?我能够在表格中列出字符串,但似乎没有任何类型的标识符“原始资源”它只是一个(数组)USHORT(长度)后跟宽字符(字符串),有没有标识符。

PIMAGE_RESOURCE_DIR_STRING_U = ^TIMAGE_RESOURCE_DIR_STRING_U;
TIMAGE_RESOURCE_DIR_STRING_U = Record
  Count : USHORT;//Word;
  Name  : Array [0..0] of WideChar;
End;

PIMAGE_RESOURCE_DATA =^TIMAGE_RESOURCE_DATA;
TIMAGE_RESOURCE_DATA = Record
  rt_type :  DWORD; //RT_STRING
  lpName  :  ShortString; //tables name
  Address :  PDWORD; //address of the table
  dwSize  :  DWORD; //size of the data
end;

procedure GUIDataToString(IRD: TIMAGE_RESOURCE_DATA);
Type
  TStringArray = Array of String;


  Function SplitString(P: PByte; dwplen: Int32): TStringArray;
  //P is a Pointer to the string table, dwPLen is the size of the table
  Var
    Index : Int32;
    offset: Int32;
    dwLen : WORD;
    ST_ID : NativeUInt;
    rt_str: PIMAGE_RESOURCE_DIR_STRING_U;
  Begin
    Index := 0; //String Index
    offset:= 0;
    while (offset <= dwplen) do
    Begin
      SetLength(Result, Length(Result)+1);

      rt_str        := PIMAGE_RESOURCE_DIR_STRING_U(@P[offset]);
      Result[Index] := NameToStr(rt_str);
      //
      Inc(offset, (rt_str.Count * sizeof(WideChar) )+ sizeof(WORD));
      Inc(Index);
    End;
  End;

Var
  Table     : TStringArray;
  dwStrings : DWORD;
  I         : Int32;
  //d         :
begin
  Table   := SplitString(PByte(IRD.Address), IRD.dwSize);
  dwStrings := Length(Table);
  Memo1.Lines.Add('STRINGTABLE');
  Memo1.Lines.Add('{');

  for I := 0 to dwStrings-1 do
  Begin
    Memo1.Lines.Add(#9+Table[I]); //#9 is TAB
  End;
   Memo1.Lines.Add('}');
end;

我读过resourcestring(type) can be cast to a PResStringRecwhos .Identifierfield will give an identifier但是,我尝试使用我的“原始字符串”,它是一个随机的大数(比较的IDs resedit给出),关于如何找到ID的任何建议?

图片

4

2 回答 2

2

字符串表本身没有存储 ID。字符串资源以 16 个为一组进行组织。字符串 ID 实际上是一个 16 位整数,其中高 12 位标识表中捆绑包的索​​引,低 4 位标识捆绑包中字符串的索引。Raymond Chen 在他的 MSDN 博客上讨论了这一点:

字符串资源的格式

Win32 允许的最高数字资源 ID 是多少?

于 2015-12-30T01:38:30.900 回答
-2

求解,其中 dwGroups为组数, dwGroup为包含字符串的组索引, index为字符串(0..15)在组中的索引。

  Function MakeRtStringId(dwGroups, dwGroup, Index: DWORD): DWORD;
  Var
    dwIndex : DWORD;
  Begin
    dwIndex := 4096 - (dwGroups - dwGroup);
    Result  := (dwIndex shl 4) or Index;
  End;

如果您想出任何答案,请发布替代答案。

[编辑] 说真的,为什么投反对票?是因为我不解释吗?最多有 65535 个字符串,分成 16 个组,最多 4096 个组。字符串 ID 从 65535 开始并递减,因此如果您有 15 个字符串,则 ID 为 655 19、 655 20、 655 21、 [...]、65535。依此类推,因为最后一个 id 始终是 65535。最后一个数字是字符串,是它在组中的“索引”,因为单个十六进制数字是 0-F (0-15)。提示“16 人一组”。感谢 Remy Lebeau 提供的信息

于 2015-12-31T05:28:40.720 回答