Giter Site home page Giter Site logo

libpe's Introduction

LibPE

Module Version Hex Docs Total Download License Last Updated

Library and mix tasks to read and update Windows PE file resources. Based on https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

Only tested/needed with .exe files so far.

Example Usage

To check an existing PE file (.exe)

  mix pe.checksum <filename.exe>

To update the checksum:

  mix pe.update <filename.exe>

To list all resources in a file:

  mix pe.dump <filename.exe>

To set an icon resource (and update the checksum):

  mix pe.update --set-icon <icon.png> <filename.exe>

Installation

To add LibPE to your build steps and make the tasks availabe add libpe to your list of dependencies in mix.exs:

def deps do
  [
    {:libpe, "~> 1.0.0", only: :dev, runtime: false}
  ]
end

libpe's People

Contributors

dominicletz avatar moogle19 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

moogle19

libpe's Issues

Cannot set icon

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.