他人の空似自作物置場

DllPreloadingAttack.zip/PrintVersion_sono3/main.cpp


#include <cstdio>

#include <vector>

#include <Windows.h>

#pragma comment(lib, "OneCore.lib")

int main() {
   wchar_t path[MAX_PATH] = { 0 };
   ::GetModuleFileNameW(nullptr, path, _countof(path));
   std::vector<unsigned char> buf;
   buf.resize(::GetFileVersionInfoSizeW(path, 0));
   if (!::GetFileVersionInfoW(path, 0, buf.size(), &buf.front())) {
      return 1;
   }
   VS_FIXEDFILEINFO *info;
   unsigned int temp;
   if (!::VerQueryValueW(&buf.front(), L"\\", reinterpret_cast<void **>(&info), &temp)) {
      return 1;
   }
   ::printf("%d.%d.%d.%d", HIWORD(info->dwFileVersionMS), LOWORD(info->dwFileVersionMS), HIWORD(info->dwFileVersionLS), LOWORD(info->dwFileVersionLS));
   std::getchar();
   return 0;
}