SourceCodeSky QQ客服 SourceCodeSky 400电话 客服电话 暂无

wfspyhook.cpp ( 文件浏览 )

  • keepall 发布于 2016-08-23 22:17
  • 浏览次数:560
  • 下载次数: 1
  • 下载需 10 积分
  • 侵权举报
// This is the main DLL file.

#include "stdafx.h"
#include "wfspyhook.h"

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace wfspy;
using namespace System::Reflection;

wchar_t __gc* GetAssemblyPath()
{
    return PtrToStringChars(Assembly::GetExecutingAssembly()->Location);
}

HMODULE GetThisModuleHandle()
{
    wchar_t __pin* wszModule = GetAssemblyPath();
    return GetModuleHandle(wszModule);
}

wchar_t __gc* GetFileMappingName(int processId = GetCurrentProcessId(), int threadId = GetCurrentThreadId())
{
    String* fileMappingName = String::Format(S"wfavhook_{0}_{1}_filemap", __box(processId), __box(threadId)); 
    return PtrToStringChars(fileMappingName);
}

wchar_t __gc* GetEventName(int processId = GetCurrentProcessId(), int threadId = GetCurrentThreadId())
{
    String* eventName = String::Format(S"wfavhook_{0}_{1}_event", __box(processId), __box(threadId)); 
    return PtrToStringChars(eventName);
}

template<class T>
void _Win32X(T t)
{
    if (t == NULL)
        Marshal::ThrowExceptionForHR(HRESULT_FROM_WIN32(GetLastError()));
}

struct WFAVCommunicationData
{
    BOOL m_bErrorFlag;
    HANDLE m_hFileMap; //Stored to help in cleanup
    HANDLE m_hEvent; //To be set when assembly is injected
    DWORD m_dwAssemblyPathSize;
    DWORD m_dwTypeNameSize;
    DWORD m_dwDataSize; //Length of additional data
    BYTE ab[1];
    
    //Assembly name starts at offset 0
    LPWSTR _GetAssemblyName()
    {
        return reinterpret_cast<LPWSTR>(&ab[0]);
    }
    
    //Immediately after the assembly name
    LPWSTR _GetTypeName()
    {
        return reinterpret_cast<LPWSTR>(&ab[m_dwAssemblyPathSize]);
    }
    
    //Immediately after the type name
    BYTE* _GetData()
    {
        return (&ab[m_dwAssemblyPathSize + m_dwTypeNameSize]);
    }
    
    //managed variants of the above methods
    String* GetAssemblyName()
    {
        return _GetAssemblyName();
    }
    
    String* GetTypeName()
    {
        return _GetTypeName();
    }
    
    Byte GetData() []
    {
        Byte data[] = new Byte[m_dwDataSize];
        Marshal::Copy(IntPtr(_GetData()), data, 0, m_dwDataSize);

        return data;
    }
    
    void Cleanup()
    {
        if (m_hEvent)
            CloseHandle(m_hEvent);

        if (m_hFileMap)
            CloseHandle(m_hFileMap);
    }
    
    static WFAVCommunicationData* Construct(int processID, int threadID, String* assemblyPath, String* typeName, Byte additionalData[])
    {
        DWORD dwAssemblyPathSize = (assemblyPath->Length + 1)*sizeof(WCHAR);
        DWORD dwTypeNameSize = (typeName->Length + 1)*sizeof(WCHAR);
        DWORD dwDataSize = additionalData->Length;
    
        DWORD cbTotalLen = 
                dwAssemblyPathSize + dwTypeNameSize + dwDataSize + //Length of data
                sizeof(DWORD)*3 + //Length of the data length holders
                sizeof(WFAVCommunicationData); //Size of structure itself
        
        WFAVCommunicationData* pwfcd = NULL;

        try
        {
            wchar_t __pin * wszFileMappingName = GetFileMappingName(processID, threadID);
            HANDLE hFileMapping = CreateFileMapping(NULL, NULL, PAGE_READWRITE, 0, cbTotalLen, wszFileMapping[!==More==!]			
...
展开> <收缩

下载源码到电脑,阅读使用更方便

1 积分

快速下载
还剩0行未阅读,继续阅读
免费下载源码
Sponsored links

源码文件列表

温馨提示: 点击源码文件名可预览文件内容哦 ^_^
...
名称 大小 修改日期
/wfspy.sln 1.75 KB 2003-08-16 22:55:14
/wfspy/App.ico 1.05 KB 2003-08-14 21:06:08
/wfspy/AssemblyInfo.cs 2.41 KB 2003-08-19 23:13:38
/wfspy/MainForm.cs 9.15 KB 2003-08-19 23:04:56
/wfspy/MainForm.resx 11.32 KB 2003-08-19 23:00:02
/wfspy/wfspy.csproj 5.27 KB 2003-08-17 22:54:46
/wfspy/wfspy.csproj.user 1.73 KB 2003-08-19 23:20:52
/wfspy/Window.ico 318 Bytes 2003-08-14 23:00:20
/wfspy/Window.Net.ico 318 Bytes 2003-08-14 23:03:38
/wfspy/WindowHidden.ico 318 Bytes 2003-08-14 22:55:08
/wfspy/WindowHidden.Net.ico 318 Bytes 2003-08-14 23:03:42
/wfspy/WindowPropertiesForm.cs 4.88 KB 2003-08-19 13:49:44
/wfspy/WindowPropertiesForm.resx 5.21 KB 2003-08-19 00:25:00
/wfspyhook/AssemblyInfo.cpp 2.28 KB 2003-08-16 22:47:54
/wfspyhook/ReadMe.txt 1.14 KB 2003-08-16 22:47:54
/wfspyhook/Stdafx.cpp 205 Bytes 2003-08-16 22:47:54
/wfspyhook/Stdafx.h 320 Bytes 2003-08-17 18:52:58
/wfspyhook/wfspyhook.cpp 6.88 KB 2003-08-19 00:07:40
/wfspyhook/wfspyhook.def 23 Bytes 2003-08-17 23:01:22
/wfspyhook/wfspyhook.h 431 Bytes 2003-08-17 18:54:20
/wfspyhook/wfspyhook.vcproj 3.27 KB 2003-08-17 23:01:22
/wfspylib/AssemblyInfo.cs 2.37 KB 2003-08-16 22:18:54
/wfspylib/FormSizeSaver.cs 1.50 KB 2003-08-19 22:31:22
/wfspylib/UnmanagedMethods.cs 2.47 KB 2003-08-19 22:37:50
/wfspylib/wfspylib.csproj 5.37 KB 2003-08-19 22:18:00
/wfspylib/wfspylib.csproj.user 1.73 KB 2003-08-19 23:20:52
/wfspylib/WindowProperties.cs 3.25 KB 2003-08-19 21:51:12
/wfspylib/WindowPropertiesView.cs 3.50 KB 2003-08-19 23:06:30
/wfspylib/WindowPropertiesView.resx 5.39 KB 2003-08-19 23:06:30
/wfspylib/WindowPropertiesView1.cs 2.11 KB 2003-08-18 12:56:16
/wfspylib/WindowPropertiesView1.resx 5.21 KB 2003-08-18 12:55:34
/wfspylib/WindowTreeBuilder.cs 2.55 KB 2003-08-19 22:58:22
/wfspylib/WindowTreeNode.cs 1.78 KB 2003-08-19 21:53:20
Sponsored links
正在加载中……

Switch to the English version?

Yes
SourceCodeSky 英文版
No
SourceCodeSky 中文版

完善个人资料,获价值¥30元积分奖励!