{"id":17398475,"url":"https://github.com/vweevers/pe-signature","last_synced_at":"2025-06-12T10:05:17.843Z","repository":{"id":55828233,"uuid":"76778754","full_name":"vweevers/pe-signature","owner":"vweevers","description":"Test if buffer is a PE signature","archived":false,"fork":false,"pushed_at":"2020-12-11T17:49:50.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T21:39:07.267Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-18T11:25:00.000Z","updated_at":"2020-11-24T18:31:13.000Z","dependencies_parsed_at":"2022-08-15T07:31:18.476Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/pe-signature","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpe-signature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpe-signature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpe-signature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpe-signature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/pe-signature/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237436,"owners_count":20745348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T14:57:08.299Z","updated_at":"2025-03-29T20:15:34.883Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pe-signature\n\n**Test if buffer is a [PE](https://en.wikipedia.org/wiki/Portable_Executable) signature. As specified by [Microsoft PE and COFF Specification 9.3](https://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/pecoff_v83.docx) \u003csup\u003e[doc]\u003c/sup\u003e, section 3.2:**\n\n\u003e After the MS-DOS stub, at the file offset specified at offset `0x3c`, is a 4-byte signature that identifies the file as a PE format image file. This signature is `PE\\0\\0` (the letters \"P\" and \"E\" followed by two null bytes).\n\n[![npm status](http://img.shields.io/npm/v/pe-signature.svg?style=flat-square)](https://www.npmjs.org/package/pe-signature) [![node](https://img.shields.io/node/v/pe-signature.svg?style=flat-square)](https://www.npmjs.org/package/pe-signature) [![Travis build status](https://img.shields.io/travis/vweevers/pe-signature.svg?style=flat-square\u0026label=travis)](http://travis-ci.org/vweevers/pe-signature) [![AppVeyor build status](https://img.shields.io/appveyor/ci/vweevers/pe-signature.svg?style=flat-square\u0026label=appveyor)](https://ci.appveyor.com/project/vweevers/pe-signature) [![Dependency status](https://img.shields.io/david/vweevers/pe-signature.svg?style=flat-square)](https://david-dm.org/vweevers/pe-signature)\n\n## usage\n\n```js\nconst psig = require('pe-signature')\n\nconst a = Buffer('PE\\0\\0')\nconst b = Buffer('PE\\0\\0xxx')\nconst c = Buffer('xxxPE\\0\\0')\n\nconsole.log(psig.is(a))    // true\nconsole.log(psig.is(b))    // false\nconsole.log(psig.has(b))   // true\nconsole.log(psig.is(c, 3)) // true\n```\n\n## related\n\nUse [pe-signature-offset](https://github.com/vweevers/pe-signature-offset) to get the position of the signature in a PE file:\n\n```js\nconst open = require('fs-maybe-open')\n    , getOffset = require('pe-signature-offset')\n    , fs = require('fs')\n    , len = psig.length\n\nfunction isPEFile (fdOrFile, done) {\n  open(fdOrFile, 'r', function (err, fd, close) {\n    if (err) return done(err)\n\n    getOffset(fd, function (err, offset) {\n      if (err) return close(done, err)\n\n      fs.read(fd, Buffer(len), 0, len, offset, function (err, bytesRead, buf) {\n        if (err) return close(done, err)\n\n        close(done, null, psig.is(buf))\n      })\n    })\n  })\n}\n\nisPEFile('chrome.exe', function (err, is) {\n  if (err) throw err\n  console.log(is) // true\n})\n```\n\n## install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install pe-signature\n```\n\n## license\n\n[MIT](http://opensource.org/licenses/MIT) © Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fpe-signature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fpe-signature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fpe-signature/lists"}