Skip to content

Commit

Permalink
Operate on a buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 15, 2023
1 parent facfd4e commit fcddbcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/bundle/otto/windows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {mkdir, open, writeFile} from 'node:fs/promises';
import {mkdir, open, readFile, writeFile} from 'node:fs/promises';
import {join as pathJoin, basename, dirname} from 'node:path';

import {trimExtension} from '../../util';
Expand Down Expand Up @@ -76,10 +76,12 @@ export class BundleOttoWindows extends BundleOtto {
}

const machine = v.getUint16(0, true);
// eslint-disable-next-line jsdoc/require-jsdoc
const res = async () => readFile(projector.path);
let launcher = null;
switch (machine) {
case 0x14c: {
launcher = await windowsLauncher('i686', projector.path);
launcher = await windowsLauncher('i686', await res());
break;
}
default: {
Expand Down
6 changes: 3 additions & 3 deletions src/util/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ export async function peResourceReplace(
* Get Windows launcher for the specified type.
*
* @param type Executable type.
* @param resources File to optionally copy resources from.
* @param resources Data to optionally copy resources from.
* @returns Launcher data.
*/
export async function windowsLauncher(
type: string,
resources: string | null = null
resources: Uint8Array | null = null
) {
let data;
switch (type) {
Expand All @@ -304,7 +304,7 @@ export async function windowsLauncher(

// Read resources from file.
const rsrc = NtExecutableResource.from(
NtExecutable.from(await readFile(resources), {
NtExecutable.from(resources, {
ignoreCert: true
})
);
Expand Down

0 comments on commit fcddbcb

Please sign in to comment.