dll问题
#include <winsock2.h>
#include <stdio.h>
#pragma comment(linker,"section:Shared,rws")
#pragma data_seg("Shared")
char string[1024]="01";
HHOOK old=NULL;
HANDLE p=NULL;
bool y=false;
#pragma data_seg()
#pragma pack(push,1)
struct 
{
byte a;
int b;
}newdate,olddate;
#pragma pack(pop)
HANDLE Mutex;
int mysend(SOCKET s,const char FAR * buf,int len,int flags)
{   int x;
   WaitForSingleObject(Mutex, INFINITE);
   memcpy(string,(char *)buf,len);
   string[len]='\0';
 //  MessageBox(NULL,buf,"..",0);
   //MessageBox(NULL,string,"dll测试",0);
   ReleaseMutex(Mutex);
   WriteProcessMemory(p,send,&olddate,5,NULL);
   x=send(s,buf,len,flags);
   WriteProcessMemory(p,send,&newdate,5,NULL);  
 
   return x;}void HookSEND()
{
     p=OpenProcess(PROCESS_ALL_ACCESS,NULL,GetCurrentProcessId());
 newdate.a=0xE9;
     newdate.b=(int)mysend-(int)send-5;
     ReadProcessMemory(p,send,&olddate,5,NULL);
     WriteProcessMemory(p,send,&newdate,5,NULL);
 
}void UnHookSend()
{
      
  WriteProcessMemory(p,send,&olddate,5,NULL);
}LRESULT CALLBACK CallWndProc(    int nCode, // hook code
    WPARAM wParam, // current-process flag
    LPARAM lParam  // address of structure with message data
   )
{        if(y==false)
{
     HookSEND();
 y=true;
}
         
return CallNextHookEx(old,nCode,wParam,lParam);
}void SetHook()
{
Mutex=OpenMutex(MUTEX_ALL_ACCESS,NULL,"mutex");
if(Mutex==NULL)
Mutex=CreateMutex(NULL,false,"mutex");
    
// strcpy(string,"12345");
    memset(string,'0',1024);
    old=SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,GetModuleHandle("HookPack.dll"),0);
}
char *ReadDate ()
{
  return string;
    
}
exe部分
HANDLE Mutex;
BOOL CTestPackDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
Mutex=OpenMutex(MUTEX_ALL_ACCESS,NULL,"mutex");
if(Mutex==NULL)
Mutex=CreateMutex(NULL,false,"mutex");
    SetHook();
return TRUE;  // return TRUE  unless you set the focus to a control
}DWORD WINAPI ThreadFunc(LPVOID lpParameter)
{
    char *string=NULL;
char buf[1024];
CTestPackDlg *p=(CTestPackDlg*)lpParameter;
        string=ReadDate();
MessageBox(NULL,ReadDate(),"我是线程",0);
while(true)
{
           WaitForSingleObject(Mutex, INFINITE);  
string=ReadDate();
// MessageBox(NULL,ReadDate(),"....",0);
if(string!=NULL&&(*string)!='0')
{

 memcpy(buf,string,strlen(string));
 memset(string,'0',1024);
::SendMessage(p->m_hWnd,WM_SHOW,0,(LPARAM)buf);
}
  ReleaseMutex(Mutex);
  Sleep(10);
}
return 0;}
void CTestPackDlg::OnSHOW(WPARAM wParam,LPARAM lParam)
{
        CString str=(char *)lParam;
CString strtem;
GetDlgItemText(IDC_SEND,strtem);
str+="\r\n";
str+=strtem;
        SetDlgItemText(IDC_SEND,str);
 
}
void CTestPackDlg::OnHook() 
{
// TODO: Add your control notification handler code here
if(ishook==false)
{


        thread=CreateThread(NULL,0,ThreadFunc,(LPVOID)this,0,NULL);
ishook=true;
MessageBox(ReadDate());
}}void CTestPackDlg::OnUnHook() 
{
// TODO: Add your control notification handler code here
if(ishook==true)
{
ishook=false;
UnHookSend();
CloseHandle(thread);
}

}
通过exe把dll插进去然后挂钩游戏的send函数把封包读出来然后通过共享节传递数据,
但是我这个程序一运行就当掉后来我调试dll中发现string里面有内容但是读到exe线程中既然输出都是0!我不知道我那里错拉,希望大家给小弟指点迷津