Skip to content

Cannot set icon #1

Description

@wojtekmach

Here's a very simple program:

#include<stdio.h>

int main() {
  printf("Press enter to quit...\n");
  getc(stdin);
  return 0;
}

which I'm compiling with mingw:

$ x86_64-w64-mingw32-gcc -o hello.exe hello.c

Running a few libpe commands works well:

$ mix pe.dump hello.exe
Dumping file: hello.exe
=======================
NO RESOURCE TABLE

$ mix pe.checksum hello.exe
hello.exe            checksum:   317689, should:   317689 ==> CORRECT!

but not setting the icon. First, this is how I created the icon:

$ curl -LO https://elixir-lang.org/images/logo/logo.png
$ magick logo.png -background none -resize 128x128 -density 128x128 logo.ico

And now setting the icon:

$ mix pe.update --set-icon logo.ico hello.exe
Updating file hello.exe
** (FunctionClauseError) no function clause matching in LibPE.ResourceTable.set_resource/5

    The following arguments were given to LibPE.ResourceTable.set_resource/5:

        # 1
        nil

        # 2
        3

        # 3
        <<0, 0, 1, 0, 1, 0, 128, 53, 0, 0, 1, 0, 32, 0, 120, 109, 0, 0, 22, 0, 0, 0, 40, 0, 0, 0, 128, 0, 0, 0, 106, 0, 0, 0, 1, 0, 32, 0, 0, 0, 0, 0, 0, 106, 0, 0, 175, 19, 0, 0, ...>>

        # 4
        0

        # 5
        1033

    Attempted function clauses (showing 1 out of 1):

        def set_resource(table = %LibPE.ResourceTable{entries: entries}, resource_type, data, codepage, language) when is_binary(data)

    lib/libpe/resource_table.ex:114: LibPE.ResourceTable.set_resource/5
    (elixir 1.14.0-dev) lib/enum.ex:2458: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/mix/tasks/update.ex:58: Mix.Tasks.Pe.Update.update_resources/2
    lib/mix/tasks/update.ex:39: anonymous fn/2 in Mix.Tasks.Pe.Update.run/1
    (elixir 1.14.0-dev) lib/enum.ex:968: Enum."-each/2-lists^foreach/1-0-"/2
    (mix 1.14.0-dev) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (mix 1.14.0-dev) lib/mix/cli.ex:84: Mix.CLI.run_task/2

I'm using the latest libpe:

$ mix deps
* libpe 1.1.2 (Hex package) (mix)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions