示例#1
0
int wmain(int argc, wchar_t* argv[])
{
	if (argc < 2)
	{
		wprintf(L"Regemu Patcher\n\n");
		wprintf(L"Usage: REGEMU32 file [option]\n\n");
		wprintf(L"  -p,  --patch             Replaces ADVAPI32 with REGEMU32 in FILE.\n");
		wprintf(L"  -u,  --unpatch           Replaces REGEMU32 with ADVAPI32 in FILE.\n");
		wprintf(L"\nDefault auto mode, unpatch is run if patch is unsuccessful.\n");

		return ERROR_SUCCESS;
	}

	std::wstring filename = parse_command_line(argc, argv);
	if (filename.empty()) return ERROR_SUCCESS;

	if (filename[0] == L'"') filename = filename.substr(1, filename.find_last_of(L'"') - 1);
	wprintf(L"%s (%d): ", filename.c_str(), setting_mode);

	std::fstream file(filename, std::ios::in | std::ios::out | std::ios::binary | std::ios::ate);
	
	if(file.is_open())
	{
		size_t size = static_cast<size_t>(file.tellg());
		char *buffer = new char[size];

		file.seekg(0, std::ios::beg);
		file.read(buffer, size);

		switch (setting_mode)
		{
		case MODE_AUTO: if (!patch(file, buffer, size)) unpatch(file, buffer, size); break;
		case MODE_PATCH: patch(file, buffer, size);  break;
		case MODE_UNPATCH: unpatch(file, buffer, size);  break;
		}

		wprintf(L"\n");

		//for each(int func in functionlist)
		//{
		//	wchar_t buff[64]; 
		//	CheapWide(Advapi_Function[func], buff, 64);
		//	message.append(buff).append(Advapi_Support[func] ? L"\t[o]" : L"\t[x]").append(L"\n");
		//}

		delete[] buffer;
		file.close();
	}
	else
	{
		wprintf(L"Could not open file.\n");
	}
	
	return EXIT_SUCCESS;
}
示例#2
0
void cleanup_module() {
	//Make sure this function can safely be called multiple times.
	//The API can be called to deactivate the module.

	//restore the system call table, in reverse order
	//unpatch(SYS_close);
	//unpatch(SYS_open);
	//unpatch(SYS_clone);
	//unpatch(SYS_fork);
	unpatch(SYS_mkdir);
	//unpatch(SYS_read);
	unpatch(SYS_getdents);
	memcpy(sys_call_table, backup_sys_call_table, sizeof(backup_sys_call_table));
	if (hiddenDirectories) {
		vector_free(hiddenDirectories);
		hiddenDirectories = 0;
	}
	printk(KERN_INFO "Module unloaded\n");
}
示例#3
0
文件: UGen.cpp 项目: EQ4/minim-cpp
void UGen::unpatch( AudioOutput & output )
{
	unpatch( output.mSummer );
}
示例#4
0
文件: ADSR.cpp 项目: doorxp/minim-cpp
//-----------------------------
void Minim::ADSR::uGenerate( float* channels, int numChannels )
{
    if ( !isTurnedOn )
    {
        for( int i = 0; i < numChannels; ++i )
        {
            channels[i] = beforeAmplitude*audio.getLastValues()[i];
        }
    }
    else if ( timeFromOff > releaseTime )
    {
        for ( int i = 0; i < numChannels; ++i )
        {
            channels[i] = afterAmplitude*audio.getLastValues()[i];
        }
        
        if ( bUnpatchAfterRelease )
        {
            if ( outputToUnpatch )
            {
                unpatch( *outputToUnpatch );
                outputToUnpatch = NULL;
            }
            if ( ugenOutputToUnpatch )
            {
                unpatch( *ugenOutputToUnpatch );
                ugenOutputToUnpatch = NULL;
            }
            
            bUnpatchAfterRelease = false;
        }
    }
    else
    {
        if ( isTurnedOn && !isTurnedOff )
        {
            // ATTACK
            if (timeFromOn <= attackTime)
            {
                // use time remaining until maxAmplitude to change amplitude
                float timeRemain = (attackTime - timeFromOn);
                amplitude += (maxAmplitude - amplitude)*timeStepSize/timeRemain;				
            }
            // DECAY
            else if ((timeFromOn > attackTime) && (timeFromOn <= (attackTime+decayTime)))
            {
                // use time remaining until sustain to change to sustain level
                float timeRemain = (attackTime + decayTime - timeFromOn);
                amplitude += (sustainLevel*maxAmplitude - amplitude)*timeStepSize/timeRemain;			
            }
            // SUSTAIN
            else if (timeFromOn > (attackTime+decayTime))
            {
                // hold the sustain level
                amplitude = sustainLevel*maxAmplitude;
            }
            timeFromOn += timeStepSize;
        }
        // RELEASE
        else //isTurnedOn and isTurnedOFF and timeFromOff < releaseTime
        {
            // use remaining time to get to afterAmplitude
            float timeRemain = (releaseTime - timeFromOff);
            amplitude += (afterAmplitude - amplitude)*timeStepSize/timeRemain;
            timeFromOff += timeStepSize;
        }
        // finally multiply the input audio to generate the output
        for(int i = 0; i < numChannels; i++)
        {
            channels[i] = amplitude*audio.getLastValues()[i];
        }	        
    }
}