Check the Arquitecture of Files and DLLs

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
307
Reaction score
77
First Language
English
Primarily Uses
RMXP
Check the Arquitecture of Files and DLLs with a Ruby script!

I'm posting this scriptlet here because it's not RGSS based but a common Ruby script so it might work on any version of RGSS in theory. You can also run it as a typical Ruby script on your PC in case you have already installed the Ruby interpreter there. Place the script in the same directory as the executable or DLL's and run it! Or paste it in the script editor as you'd do with any RGSS script, save your project and run it! :o

Usually the results would be either 32 bit (i386) or 64 bit (x64). I doubt any of you is currently running any Itanium based PC. :D

Code:
#!/usr/bin/env ruby
# Find out if your executables and libraries are compiled for a 32 or 64 bit architecture!
def arch_of(fn)
  f = File.open(fn,"rb")
  dos = f.read(64)
  magic, padding, offset = dos.unpack("a2a58l")
  if magic != "MZ"
    puts "This is neither an executable nor a library!"
    return
  end
  f.pos = offset
  hdr = f.read(6)
  sig, padding, machine = hdr.unpack("a2a2v")
  f.close
  if sig != "PE"
    return puts "File #{fn} has an unknown architecture..."
  end
  if machine == 0x014c
    puts fn + " architecture detected: i386"
  elsif machine == 0x0200
    puts fn + " architecture detected: IA64"
  elsif machine == 0x8664
    puts fn + " architecture detected: x64"
  else
    puts "File #{fn} has an unknown architecture..."
  end
end

filenames = Dir['*.exe'].sort + Dir['*.dll'].sort
filenames.each {|fn| arch_of(fn) }

NOTE: #!/usr/bin/env ruby line included in the script above means it can be run on Linux as well, just in case you ever wanted to know that...

Terms

You're free to use, it's free as in speech and as in beer!
I would appreciate if you include me in your credits.
 

Latest Threads

Latest Posts

Latest Profile Posts

My first game is gonna be a really ambitious one. But it's costing me a lot of money to make lol. it'll be worth it though
Ugh...Guests always put the Ketchup in the fridge....bloody savages the lot of them! :)
daysbetweendatescalculator.jpg
It may be useful for some weird purposes in the game and outside the game.:kaojoy:
I'm taking a break from Game Work to actually play a game (NEO: The World Ends With You) and I'm terrified that I'm gonna lose the drive for my project, since prior to picking up NEO, I'd been doing at least a little bit of work on the project each day ahhh. My brain is very much an "all or nothing" kind of brain, sigh.
bandicam 2021-08-05 15-10-37-143.png
Configuration menu and icons test

Forum statistics

Threads
113,951
Messages
1,078,623
Members
148,056
Latest member
srabon
Top