檢測dll是32/64位?(直接讀dll文件包含的某幾個字節進行判斷)
阿新 • • 發佈:2018-04-07
tle toc 進行 too mach comm include hello urn
檢查dll是32位還是64位?
[cpp] view plain copy
- #include "stdafx.h"
- #include <Windows.h>
- int _tmain(int argc, _TCHAR* argv[])
- {
- BYTE buf[4];
- FILE *fp = fopen("D:\\plugin_d.dll", "rb");
- fseek(fp, 0x40-4, 0);
- fread(buf, sizeof(char), 4, fp);
- int a = int(buf[0]);
- int b = int(buf[1])*256;
- int c = int(buf[2])*256*256;
- int d = int(buf[3])*256*256*256;
- int sum = a+b+c+d;
- fseek(fp, sum+4, 0);
- BYTE bufMachine[2];
- fread(bufMachine, sizeof(char), 2, fp);
- int machine = (int)bufMachine[0] + (int)(bufMachine[1])*256;
- if(machine == 0x14C)//332
- {
- printf("32 bit\r\n");
- }
- else if(machine == 0x8664)//34404
- {
- printf("64 bit\r\n");
- }
- else
- {
- printf("Unknow bit\r\n");
- }
- //system("pause");
- getchar();
- return 0;
- }
https://blog.csdn.net/hellokandy/article/details/73863510
檢測dll是32/64位?(直接讀dll文件包含的某幾個字節進行判斷)