Bonjour,

J'essais de cr�er un dll consistant � interdire l'ex�cution de certains programme lorsque que mon programme main.exe est entrain d'�tre ex�cut�.

Cependant cela ne fonctionne uniquement si mon main.exe ne s'ex�cute pas : je lance un programme que j'ai banni dans mon DLL, puis le je lance mon main.exe et la mon erreur arrive disant que mon main ne peut se lancer tant que le programme banni est lanc�.

Mais si je lance le main et apr�s un programme banni, rien ne ce passe OR j'aimerais que mon main affiche un message et se ferme.

Bien �videmment, le dll est merge/hook au .exe

Voici le code :
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#define _CRT_SECURE_NO_DEPRECATE
 
#include "Stdafx.h"
#include <Iostream>
#include <Fstream>
#include <String>
#include <Sstream>
#include <Locale>
#include <Vector>
#include <Array>
#include <Ctime>
#include <Csignal>
#include <Sys/types.h>
#include <Sys/stat.h>
#include <Windows.h>
#include <Aclapi.h>
#include <Direct.h>
#include <WinSock2.h>
#include <MMSystem.h>
#include <ShellAPI.h>
#include <Windows.h>
#include <TlHelp32.h>
#include <cstdlib>
#include <iostream>
#include <TlHelp32.h>
#include <tchar.h>
#include <strsafe.h>
#include <sddl.h>
#include <cstdio>
#include <stdio.h>
 
#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "winmm.lib")
 
using namespace std;
 
#define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (addValue) )
#define MYDLL extern "C" __declspec(dllexport)
 
void msg_box(){
    MessageBoxA(NULL,"An illegal choice has been detected!", "Sh", MB_SERVICE_NOTIFICATION | MB_ICONWARNING);
    ExitProcess(0);
}
 
void ClasseWindow(LPCSTR WindowClass) {
    HWND WindClass = FindWindowExA(NULL, NULL, WindowClass, NULL);
    if (WindClass > 0) {
        {
            using namespace std;
 
            time_t timer = time(0);
            char chartime[26];
            struct tm* tm_info = localtime(&timer);
 
            strftime(chartime, 26, "%Y-%m-%d %H:%M:%S", tm_info);
 
            fstream textfile;
            textfile.open("log.log", ios::out | ios::app);
            textfile << "[" << chartime << "] Sh : Program Detected" << endl;
 
            msg_box();
 
            ShellExecuteA(NULL, "open", "log.log", NULL, NULL, SW_SHOWNORMAL);
            exit(0);
        }
    }
}
 
bool TitleWindow(LPCSTR WindowTitle) {
    HWND WindTitle = FindWindowA(NULL, WindowTitle);
    if (WindTitle > 0) {
        {
            using namespace std;
 
            time_t timer = time(0);
            char chartime[26];
            struct tm* tm_info = localtime(&timer);
 
            strftime(chartime, 26, "%Y-%m-%d %H:%M:%S", tm_info);
 
            fstream textfile;
            textfile.open("log.log", ios::out | ios::app);
            textfile << "[" << chartime << "] Sh : Error 300" << endl;
            textfile << "[" << chartime << "] Sh : Game Closed..." << endl;
 
            msg_box();
 
            ShellExecuteA(NULL, "open", "log.log", NULL, NULL, SW_SHOWNORMAL);
            exit(0);
        }
    }
    return 1;
}
 
void ClasseCheckWindow() {
    ClasseWindow("WindowsForms10.Window.8.app.0.141b42a_r11_ad1"); //delite class
}
 
void TitleCheckWindow() {
    TitleWindow("Cheat Engine 6.8.1"); //title window to block
}
 
MYDLL void Main(){
    __asm{
        push ss
            pop ss
            mov eax, 9
            xor edx, edx
    }
    CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(ClasseCheckWindow), NULL, 0, 0);
    CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(TitleCheckWindow), NULL, 0, 0);
 
}
 
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul, LPVOID lpReserved) {
    if (ul == DLL_PROCESS_ATTACH) {
        Main();
    }
    return TRUE;
}
De plus sur mon pc cela marche mais chez quelqu'un d'autre (en lui donnant le main.exe et le dll)..

Bonne soir�e,