C++ Get File Details From File?

Hello To All!
I made an anti-cheat dll i wanna add some functions for protection , i will enum all off modules of my process then i will get the path of modules so i can get the file description of modules when i get it i will look for known cheaters name and tadaaa error message will appear :D
But i can't get the file description so can someone help me ?

Here is my enum modules function :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "stdafx.h"
#include <windows.h>
// For CreateToolhelp32Snapshot()
#include <tlhelp32.h>
#include <stdio.h>
#include <iostream>
using namespace std;
// Function prototypes...
BOOL ListProcessModules(DWORD dwPID);
void printError(TCHAR* msg);
 
int main(int argc, char argv[])
{
	int xy;
	DWORD my;
	my = GetCurrentProcessId();
// 0 means current process, that is this program...
ListProcessModules(my);

cin >> xy;
return 0;
}
 
BOOL ListProcessModules(DWORD dwPID)
{
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
 
// Take a snapshot of all modules in the specified process.
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
 
if(hModuleSnap == INVALID_HANDLE_VALUE)
{
printError(L"CreateToolhelp32Snapshot()");
return (FALSE);
}
// Set the size of the structure before using it.
me32.dwSize = sizeof(MODULEENTRY32);
 
// Retrieve information about the first module, and exit if unsuccessful
if(!Module32First(hModuleSnap, &me32))
{
printError(L"Module32First()"); // Show cause of failure
CloseHandle(hModuleSnap); // Must clean up the snapshot object
return (FALSE);
}
 
// Now walk the module list of the process, and display information about each module
do
{
printf("\n\n MODULE NAME = %S", me32.szModule);
printf("\n executable = %S", me32.szExePath);
} while (Module32Next(hModuleSnap, &me32));
 
// Do not forget to clean up the snapshot object.
CloseHandle(hModuleSnap);
return (TRUE);
}
 
// Printing the error if any
void printError(TCHAR* msg)
{
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
eNum = GetLastError();
 
// FormatMessageW - unicode, FormatMessageA - ANSI
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, eNum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
sysMsg, 256, NULL);
// Trim the end of the line and terminate it with a null
p = sysMsg;
while ((*p > 31) || (*p == 9))
++p;
do { *p-- = 0; }
while ((p >= sysMsg) && ((*p == '.') || (*p < 33)));
// Display the message...
printf("\n WARNING: %S failed with error %d (%s)\n", msg, eNum, sysMsg);
}


So i can get the path of my modules.
I want to get this dll's file details then i can find this dll has been written by "someone" :))
http://i.hizliresim.com/ZNnmZ0.png

HOW CAN I GET THE FILE DESCRIPTION FROM A FILE?
I'm not sure if I understand your question right, but I think you want to get the full path to a particular DLL.

That can be done by "opening" the DLL with LoadLibrary() and passing the returned handle to the function GetModuleFileName().

Maybe it's sufficient to pass 'hModuleSnap' to GetModuleFileName(). You should try that first.

Otherwise maybe the function GetFullPathName() might help. (probably not)

MSDN links for the mentioned functions:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963%28v=vs.85%29.aspx

Last edited on
Topic archived. No new replies allowed.