You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NtExecutableResource.d.ts 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import type NtExecutable from './NtExecutable.js';
  2. import type { ImageSectionHeader } from './format/ImageSectionHeaderArray.js';
  3. import type ResourceEntry from './type/ResourceEntry.js';
  4. /** Manages resource data for NtExecutable */
  5. export default class NtExecutableResource {
  6. /** The timestamp for resource */
  7. dateTime: number;
  8. /** The major version data for resource */
  9. majorVersion: number;
  10. /** The minor version data for resource */
  11. minorVersion: number;
  12. /** Resource entries */
  13. entries: ResourceEntry[];
  14. /**
  15. * The section data header of resource data (used by outputResource method).
  16. * This instance will be null if the base executable does not contain resource data.
  17. * You can override this field before calling outputResource method.
  18. * (Note that the addresses and sizes are ignored for output)
  19. */
  20. sectionDataHeader: ImageSectionHeader | null;
  21. private originalSize;
  22. private constructor();
  23. private parse;
  24. /**
  25. * Parses resource data for `NtExecutable`.
  26. * This function returns valid instance even if
  27. * the executable does not have resource data.
  28. * @param exe `NtExecutable` instance
  29. * @param ignoreUnparsableData (default: false) specify true if skipping 'unparsable' (e.g. unusual format) data.
  30. * When true, the resource data may break on write operation.
  31. */
  32. static from(exe: NtExecutable, ignoreUnparsableData?: boolean): NtExecutableResource;
  33. /**
  34. * Add or replace the resource entry.
  35. * This method replaces the entry only if there is an entry with `type`, `id` and `lang` equal.
  36. */
  37. replaceResourceEntry(entry: ResourceEntry): void;
  38. /**
  39. * Returns all resource entries, which has specified type and id, as UTF-8 string data.
  40. * @param type Resource type
  41. * @param id Resource id
  42. * @returns an array of lang and value pair (tuple)
  43. */
  44. getResourceEntriesAsString(type: string | number, id: string | number): Array<[lang: string | number, value: string]>;
  45. /**
  46. * Add or replace the resource entry with UTF-8 string data.
  47. * This method is a wrapper of {@link NtExecutableResource.replaceResourceEntry}.
  48. */
  49. replaceResourceEntryFromString(type: string | number, id: string | number, lang: string | number, value: string): void;
  50. /**
  51. * Removes resource entries which has specified type and id.
  52. */
  53. removeResourceEntry(type: string | number, id: string | number, lang?: string | number): void;
  54. /**
  55. * Generates resource data binary for NtExecutable (not for .res file)
  56. * @param virtualAddress The virtual address for the section
  57. * @param alignment File alignment value of executable
  58. * @param noGrow Set true to disallow growing resource section (throw errors if data exceeds)
  59. * @param allowShrink Set true to allow shrinking resource section (if the data size is less than original)
  60. */
  61. generateResourceData(virtualAddress: number, alignment: number, noGrow?: boolean, allowShrink?: boolean): {
  62. bin: ArrayBuffer;
  63. rawSize: number;
  64. dataOffset: number;
  65. descEntryOffset: number;
  66. descEntryCount: number;
  67. };
  68. /**
  69. * Writes holding resource data to specified NtExecutable instance.
  70. * @param exeDest An NtExecutable instance to write resource section to
  71. * @param noGrow Set true to disallow growing resource section (throw errors if data exceeds)
  72. * @param allowShrink Set true to allow shrinking resource section (if the data size is less than original)
  73. */
  74. outputResource(exeDest: NtExecutable, noGrow?: boolean, allowShrink?: boolean): void;
  75. }