Skip to content

Commit

Permalink
doc: add copy node executable guide on windows
Browse files Browse the repository at this point in the history
PR-URL: #47781
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Debadree Chatterjee <[email protected]>
  • Loading branch information
yjl9903 authored and debadree25 committed May 1, 2023
1 parent aa6600d commit d225d95
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions doc/api/single-executable-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,29 @@ tool, [postject][]:
```

4. Create a copy of the `node` executable and name it according to your needs:

* On systems other than Windows:

```console
$ cp $(command -v node) hello
```

* On Windows:

Using PowerShell:

```console
$ cp (Get-Command node).Source hello.exe
```

Using Command Prompt:

```console
$ for /F "tokens=*" %n IN ('where.exe node') DO @(copy "%n" hello.exe)
```

The `.exe` extension is necessary.

5. Remove the signature of the binary (macOS and Windows only):

* On macOS:
Expand All @@ -61,13 +80,14 @@ tool, [postject][]:
skipped, ignore any signature-related warning from postject.

```console
$ signtool remove /s hello
$ signtool remove /s hello.exe
```

6. Inject the blob into the copied binary by running `postject` with
the following options:

* `hello` - The name of the copy of the `node` executable created in step 2.
* `hello` / `hello.exe` - The name of the copy of the `node` executable
created in step 4.
* `NODE_SEA_BLOB` - The name of the resource / note / section in the binary
where the contents of the blob will be stored.
* `sea-prep.blob` - The name of the blob created in step 1.
Expand All @@ -79,12 +99,18 @@ tool, [postject][]:

To summarize, here is the required command for each platform:

* On systems other than macOS:
* On Linux:
```console
$ npx postject hello NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
```

* On Windows:
```console
$ npx postject hello.exe NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
```

* On macOS:
```console
$ npx postject hello NODE_SEA_BLOB sea-prep.blob \
Expand All @@ -106,15 +132,25 @@ tool, [postject][]:
binary would still be runnable.

```console
$ signtool sign /fd SHA256 hello
$ signtool sign /fd SHA256 hello.exe
```

8. Run the binary:

* On systems other than Windows

```console
$ ./hello world
Hello, world!
```

* On Windows

```console
$ .\hello.exe world
Hello, world!
```

## Generating single executable preparation blobs

Single executable preparation blobs that are injected into the application can
Expand Down

0 comments on commit d225d95

Please sign in to comment.