diff --git a/.gitignore b/.gitignore index a8ac2d0..84adb6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.dll *.exe *.cfg + +Trash/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b1b319a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Includes/PB-Win32-GetConsoleProcessList"] + path = Includes/PB-Win32-GetConsoleProcessList + url = https://github.com/aziascreations/PB-Win32-GetConsoleProcessList diff --git a/Includes/ImageNtHeaderHelper.pbi b/Includes/ImageNtHeaderHelper.pbi index d4745fd..5a4de35 100644 --- a/Includes/ImageNtHeaderHelper.pbi +++ b/Includes/ImageNtHeaderHelper.pbi @@ -1,17 +1,18 @@ ;{- Code Header ; ==- Basic Info -================================ ; Name: ImageNtHeaderHelper.pbi -; Version: 0.0.1 +; Version: 0.0.2 ; Author: Herwin Bozet (NibblePoker) ; ; ==- Compatibility -============================= ; Compiler version: -; * PureBasic 6.0 LTS -; * PureBasic 6.0 LTS - C Backend +; * PureBasic 5.73 LTS (x86/x64) +; * PureBasic 6.0 LTS (x64) +; * PureBasic 6.0 LTS - C Backend (x64) ; ; ==- Links & License -=========================== -; License: Unlicense -; GitHub: ??? +; License: CC0 1.0 Universal (Public Domain) +; GitHub: https://github.com/aziascreations/PB-PEArch ;} @@ -26,6 +27,7 @@ DeclareModule ImageNtHeaderHelper #INHH_ERROR_CannotCreateFileMapping #INHH_ERROR_CannotMapViewOfFile #INHH_ERROR_CannotRetrieveHeaders + #INHH_ERROR_InvalidId EndEnumeration ; Loads the given file into memory, maps a view of it into memory and attempts to retrieve the IMAGE_NT_HEADERS32 structure. @@ -64,10 +66,9 @@ Module ImageNtHeaderHelper Define ImageNtHeaderId$ If ImageNtHeaderId = #PB_Any - Repeat - RandomData(@ImageNtHeaderId, SizeOf(ImageNtHeaderId)) - ImageNtHeaderId$ = Str(ImageNtHeaderId) - Until FindMapElement(OpenImageNtHeaders(), ImageNtHeaderId$) = #Null + DebuggerError("Unable to us #PB_Any as 'ImageNtHeaderId' !") + LastErrorCode = #INHH_ERROR_InvalidId + Goto INHH_GetImageNtHeader32_BadEnding Else ImageNtHeaderId$ = Str(ImageNtHeaderId) If FindMapElement(OpenImageNtHeaders(), ImageNtHeaderId$) <> #Null @@ -157,18 +158,3 @@ Module ImageNtHeaderHelper LastErrorCode = 0 EndProcedure EndModule - - -;- Tests -CompilerIf #PB_Compiler_IsMainFile - - - -CompilerEndIf - -; IDE Options = PureBasic 6.21 (Windows - x64) -; CursorPosition = 120 -; FirstLine = 102 -; Folding = -- -; EnableXP -; DPIAware \ No newline at end of file diff --git a/Includes/PB-Win32-GetConsoleProcessList b/Includes/PB-Win32-GetConsoleProcessList new file mode 160000 index 0000000..a920e85 --- /dev/null +++ b/Includes/PB-Win32-GetConsoleProcessList @@ -0,0 +1 @@ +Subproject commit a920e851d57d2e8ee1e386206cb51dc00f3df2b6 diff --git a/Includes/WinApi_GetConsoleProcessList.pbi b/Includes/WinApi_GetConsoleProcessList.pbi deleted file mode 100644 index 6692d3b..0000000 --- a/Includes/WinApi_GetConsoleProcessList.pbi +++ /dev/null @@ -1,35 +0,0 @@ -;{- Code Header -; ==- Basic Info -================================ -; Name: WinApi_GetConsoleProcessList.pbi -; Version: 0.0.1 -; Author: Herwin Bozet (NibblePoker) -; -; ==- Compatibility -============================= -; Compiler version: -; * PureBasic 6.0 LTS -; * PureBasic 6.0 LTS - C Backend -; -; ==- Links & License -=========================== -; License: Unlicense -; GitHub: ??? -;} - -EnableExplicit - -CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 - #WinApi_GetConsoleProcessList_LibPath$ = "../Libs/X86/kernel32.lib" -CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 - #WinApi_GetConsoleProcessList_LibPath$ = "../Libs/X64/kernel32.lib" -CompilerElse - CompilerError "Please use x64 or x86 compilers for this include !" -CompilerEndIf - -Import #WinApi_GetConsoleProcessList_LibPath$ - GetConsoleProcessList_.l(*lpdwProcessList, dwProcessCount.l) As "GetConsoleProcessList" -EndImport - -; IDE Options = PureBasic 6.21 (Windows - x64) -; CursorPosition = 27 -; Folding = - -; EnableXP -; DPIAware \ No newline at end of file diff --git a/LICENSE b/LICENSE index 68a49da..0e259d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,24 +1,121 @@ -This is free and unencumbered software released into the public domain. +Creative Commons Legal Code -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. +CC0 1.0 Universal -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +Statement of Purpose -For more information, please refer to +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/Libs/0_config.cmd b/Libs/0_config.cmd deleted file mode 100644 index 1d3e7da..0000000 --- a/Libs/0_config.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -:: These variables should point to '.exe' files. -set MSVC_DUMPBIN="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\Hostx64\x64\dumpbin.exe" -set MSVC_LIB="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\Hostx64\x64\lib.exe" - -exit /b diff --git a/Libs/3_make_lib.cmd b/Libs/3_make_lib.cmd deleted file mode 100644 index ee8f91a..0000000 --- a/Libs/3_make_lib.cmd +++ /dev/null @@ -1,43 +0,0 @@ -@echo off -setlocal - -pushd %CD% -cd /D "%~dp0" - -call "%~dp0\0_config.cmd" - -echo Checking the PATH -IF NOT EXIST %MSVC_LIB% ( - echo ^> Unable to find 'lib.exe' as indicated in '%%MSVC_DUMPBIN%%' ! - echo ^> Please check the '0_config.cmd' script ! - goto end -) -echo ^> Found 'lib.exe' at the given location ! - -echo Removing old '.lib' files -del /S /Q .\*.lib 2> nul - -echo Iterating over all '.def' files in 'libs/' for 'x64', 'x86' and 'arm64'... -for /R ".\" %%i in (*.def) do call :sub-make-lib X64 %%i -for /R ".\" %%i in (*.def) do call :sub-make-lib X86 %%i -for /R ".\" %%i in (*.def) do call :sub-make-lib ARM64 %%i -echo Done ! - -:end -popd -endlocal -pause -exit /b - - -:sub-make-lib -echo ^> %2 -pushd %~dp2 -::set _RAW_DEF_NAME=%~nx2 -::set _RAW_DEF_NAME=%_RAW_DEF_NAME:.raw.def=% -::echo lib.exe /nologo /def:%_RAW_DEF_NAME%.raw.def /out:%_RAW_DEF_NAME%.lib /machine:%1 -::%MSVC_LIB% /nologo /def:%_RAW_DEF_NAME%.raw.def /out:%_RAW_DEF_NAME%.lib /machine:%1 -mkdir .\%1 -%MSVC_LIB% /nologo /def:%~nx2 /out:.\%1\%~n2.lib /machine:%1 -popd -exit /b diff --git a/Libs/ARM64/kernel32.exp b/Libs/ARM64/kernel32.exp deleted file mode 100644 index bffe59a..0000000 Binary files a/Libs/ARM64/kernel32.exp and /dev/null differ diff --git a/Libs/ARM64/kernel32.lib b/Libs/ARM64/kernel32.lib deleted file mode 100644 index c4ed5e4..0000000 Binary files a/Libs/ARM64/kernel32.lib and /dev/null differ diff --git a/Libs/X64/kernel32.exp b/Libs/X64/kernel32.exp deleted file mode 100644 index 9c6c583..0000000 Binary files a/Libs/X64/kernel32.exp and /dev/null differ diff --git a/Libs/X64/kernel32.lib b/Libs/X64/kernel32.lib deleted file mode 100644 index fbb90b1..0000000 Binary files a/Libs/X64/kernel32.lib and /dev/null differ diff --git a/Libs/X86/kernel32.exp b/Libs/X86/kernel32.exp deleted file mode 100644 index 764dc2b..0000000 Binary files a/Libs/X86/kernel32.exp and /dev/null differ diff --git a/Libs/X86/kernel32.lib b/Libs/X86/kernel32.lib deleted file mode 100644 index a96403a..0000000 Binary files a/Libs/X86/kernel32.lib and /dev/null differ diff --git a/Libs/kernel32.def b/Libs/kernel32.def deleted file mode 100644 index 20b472e..0000000 --- a/Libs/kernel32.def +++ /dev/null @@ -1,4 +0,0 @@ -LIBRARY msvcrt.dll - -EXPORTS -GetConsoleProcessList diff --git a/Main_PEArch.pb b/Main_PEArch.pb index 3720a2d..8fe0e71 100644 --- a/Main_PEArch.pb +++ b/Main_PEArch.pb @@ -1,24 +1,26 @@ ;{- Code Header ; ==- Basic Info -================================ ; Name: Main_PEArch.pb -; Version: 0.0.1 +; Version: 1.1.x ; Author: Herwin Bozet (NibblePoker) ; ; ==- Compatibility -============================= ; Compiler version: -; * PureBasic 6.0 LTS -; * PureBasic 6.0 LTS - C Backend +; * PureBasic 5.73 LTS (x86/x64) +; * PureBasic 6.0 LTS (x64) +; * PureBasic 6.0 LTS - C Backend (x64) ; ; ==- Links & License -=========================== -; License: Unlicense -; GitHub: ??? +; License: CC0 1.0 Universal (Public Domain) +; GitHub: https://github.com/aziascreations/PB-PEArch ;} + ;- Compiler directive EnableExplicit XIncludeFile "./Includes/ImageNtHeaderHelper.pbi" -XIncludeFile "./Includes/WinApi_GetConsoleProcessList.pbi" +XIncludeFile "./Includes/PB-Win32-GetConsoleProcessList/Includes/Win32_GetConsoleProcessList.pbi" ;- Constants @@ -322,7 +324,7 @@ DataSection Data.s "PEArch.exe [/?] [/E|/AsError] [/H|/AsHex] [/F|/FullText] " + #CRLF$ + "" + #CRLF$ + "Options:" + #CRLF$ + - " /? Prints this help text." + #CRLF$ + + " /? Prints this help text, and some additional details." + #CRLF$ + " /E, /AsError Gives out the result as an error code." + #CRLF$ + " /H, /AsHex Prints the architecture as a hex number." + #CRLF$ + " /F, /FullText Prints a longer description of the architecture." + #CRLF$ diff --git a/Project_PEarch.pbp b/Project_PEarch.pbp index 8e5b36d..0f710e4 100644 --- a/Project_PEarch.pbp +++ b/Project_PEarch.pbp @@ -7,20 +7,20 @@
- +
- + - + - - - + + +
@@ -33,17 +33,18 @@ - - + + - - + + - - + + + @@ -55,17 +56,18 @@ - - + + - - + + - - + + +
diff --git a/readme.md b/readme.md index 4679d36..226780e 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,18 @@ A small tool that tells you which [CPU architecture](https://learn.microsoft.com a given [Windows PE](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format) is made for. ## Usage -TODO +``` +PEArch.exe [/?] [/E|/AsError] [/H|/AsHex] [/F|/FullText] + +Options: + /? Prints this help text, and some additional details. + /E, /AsError Gives out the result as an error code. + /H, /AsHex Prints the architecture as a hex number. + /F, /FullText Prints a longer description of the architecture. +``` + +## Cloning +**TODO: Add instructions related to the submodule** ## License All the code in this repo is released in the [Public Domain](LICENSE).