已知C++代码
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include <stdio.h>
#include <WTypes.h>
//定义CTXStringW为BSTR
typedef BSTR CTXStringW;
CTXStringW AllocTXString(const wchar_t* lpSrc)
{
if (lpSrc == NULL) return NULL;
BYTE* bBuffer = new BYTE[16 + (wcslen(lpSrc) + 1) * 2];
if (bBuffer == NULL) return NULL;
DWORD dwZero = 0;
DWORD dwCount = 3;
DWORD dwLenth = wcslen(lpSrc) + 1;
memmove(bBuffer + 0 * 4, &dwZero, 4);
memmove(bBuffer + 1 * 4, &dwCount, 4);
memmove(bBuffer + 2 * 4, &dwLenth, 4);
memmove(bBuffer + 3 * 4, &dwLenth, 4);
wcscpy((wchar_t*)(bBuffer + 4 * 4), lpSrc);
return CTXStringW(bBuffer + 16);
}
VOID GETQQ()
{
do {
HMODULE hKernelUtil = GetModuleHandle(L"KernelUtil.dll");
if (hKernelUtil == NULL)
{
OutputDebugStringA("Get KernelUtil Module failed \n");
break;
}
PVOID PtrGetSelfUin = GetProcAddress(hKernelUtil, "?GetSelfUin@Contact@Util@@YAKXZ");
if (PtrGetSelfUin == NULL)
{
OutputDebugStringA("Get GetSelfUin Function failed \n");
break;
}
DWORD uin = ((int(*)(int))PtrGetSelfUin)(1);
if (uin == NULL)
{
OutputDebugStringA("Invoke GetSelfUin Function failed \n");
break;
}
// Print QQ number
char szUin[MAX_PATH] = { 0 };
sprintf(szUin, "%d", uin);
} while (0);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
GETQQ();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
能不能拿Java代码实现获取当前登录的QQ号功能呢?
相似问题