主题:高手看看有什么问题 急死了
编译没有问题 就是调用函数的时候
老是说这 没有发现函数
应该是函数调用失败了
文件一
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
HMODULE dll_handle;
HWND win_handle;
char win_name[64] = {0};
char dll_name[] = "d_99.dll";
char fil_name[] = "address.txt";
char fon_name[] = "sethook";
FILE *file_p;
int idHook = WH_GETMESSAGE;
unsigned long ThreadId;
HHOOK hook;
int n = 0;
file_p = fopen(fil_name,"rb");
if(!file_p){MessageBox (NULL,TEXT ("没有发现地址文件"),TEXT ("警告"),0);return(0);}
for(;;)
{ if(!fread(win_name,1,1,file_p)){break;}
if(win_name[0] == 47 || win_name[0] == 13){break;}
n++;
}
if(n >= 63){MessageBox (NULL,TEXT ("标题太长"),TEXT ("警告"),0);return(0);}
if(n == 0){MessageBox (NULL,TEXT ("文件错误"),TEXT ("警告"),0);return(0);}
fseek(file_p,0,0);
fread (win_name,n,1,file_p);
MessageBox (NULL,win_name,TEXT ("警告"),0);
fclose (file_p);
dll_handle = LoadLibrary (dll_name);
if(!dll_handle){MessageBox (NULL,TEXT ("没有发现DLL"),TEXT ("警告"),0);return(0);}
win_handle = FindWindow (NULL,win_name);
if(!win_handle){MessageBox (NULL,TEXT ("没有发现窗口"),TEXT ("警告"),0);return(0);}
ThreadId = GetWindowThreadProcessId(win_handle,NULL);
typedef long (__stdcall *LPFNREGISTER)(int nCode, WPARAM wParam, LPARAM lParam);
LPFNREGISTER lpfnRegister;
lpfnRegister = (LPFNREGISTER)GetProcAddress(dll_handle,fon_name);
if(!lpfnRegister){MessageBox (NULL,TEXT ("没有发现函数"),TEXT ("警告"),0);return(0);}
/*
hook = SetWindowsHookEx(idHook, // 钩子类型
lpfnRegister, // 钩子函数
dll_handle, // DLL句柄
ThreadId); // 线程ID
UnhookWindowsHookEx(hook);
*/
FreeLibrary(dll_handle);
return(0);
}
文件2
#include "d_resource.h"
int WINAPI DllMain (HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
return TRUE ;
}
EXPORT long __stdcall sethook(int nCode, WPARAM wParam, LPARAM lParam)
{
MessageBox (NULL,TEXT ("函数检测"),TEXT ("警告"),0);
return(0);
}
文件3《d_resource.h》
#include <windows.h>
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
EXPORT long __stdcall sethook(int nCode, WPARAM wParam, LPARAM lParam);
老是说这 没有发现函数
应该是函数调用失败了
文件一
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
HMODULE dll_handle;
HWND win_handle;
char win_name[64] = {0};
char dll_name[] = "d_99.dll";
char fil_name[] = "address.txt";
char fon_name[] = "sethook";
FILE *file_p;
int idHook = WH_GETMESSAGE;
unsigned long ThreadId;
HHOOK hook;
int n = 0;
file_p = fopen(fil_name,"rb");
if(!file_p){MessageBox (NULL,TEXT ("没有发现地址文件"),TEXT ("警告"),0);return(0);}
for(;;)
{ if(!fread(win_name,1,1,file_p)){break;}
if(win_name[0] == 47 || win_name[0] == 13){break;}
n++;
}
if(n >= 63){MessageBox (NULL,TEXT ("标题太长"),TEXT ("警告"),0);return(0);}
if(n == 0){MessageBox (NULL,TEXT ("文件错误"),TEXT ("警告"),0);return(0);}
fseek(file_p,0,0);
fread (win_name,n,1,file_p);
MessageBox (NULL,win_name,TEXT ("警告"),0);
fclose (file_p);
dll_handle = LoadLibrary (dll_name);
if(!dll_handle){MessageBox (NULL,TEXT ("没有发现DLL"),TEXT ("警告"),0);return(0);}
win_handle = FindWindow (NULL,win_name);
if(!win_handle){MessageBox (NULL,TEXT ("没有发现窗口"),TEXT ("警告"),0);return(0);}
ThreadId = GetWindowThreadProcessId(win_handle,NULL);
typedef long (__stdcall *LPFNREGISTER)(int nCode, WPARAM wParam, LPARAM lParam);
LPFNREGISTER lpfnRegister;
lpfnRegister = (LPFNREGISTER)GetProcAddress(dll_handle,fon_name);
if(!lpfnRegister){MessageBox (NULL,TEXT ("没有发现函数"),TEXT ("警告"),0);return(0);}
/*
hook = SetWindowsHookEx(idHook, // 钩子类型
lpfnRegister, // 钩子函数
dll_handle, // DLL句柄
ThreadId); // 线程ID
UnhookWindowsHookEx(hook);
*/
FreeLibrary(dll_handle);
return(0);
}
文件2
#include "d_resource.h"
int WINAPI DllMain (HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
return TRUE ;
}
EXPORT long __stdcall sethook(int nCode, WPARAM wParam, LPARAM lParam)
{
MessageBox (NULL,TEXT ("函数检测"),TEXT ("警告"),0);
return(0);
}
文件3《d_resource.h》
#include <windows.h>
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
EXPORT long __stdcall sethook(int nCode, WPARAM wParam, LPARAM lParam);