/** * 파일을 열거나 생성 */ FILE* fopen( const char* pcFileName, const char* pcMode ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pcFileName; PARAM( 1 ) = ( QWORD ) pcMode; // 시스템 콜 호출 return ( FILE* ) ExecuteSystemCall( SYSCALL_FOPEN, &stParameter ); }
/** * 시리얼 포트로 데이터를 송신 */ void SendSerialData( BYTE* pbBuffer, int iSize ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pbBuffer; PARAM( 1 ) = ( QWORD ) iSize; // 시스템 콜 호출 ExecuteSystemCall( SYSCALL_SENDSERIALDATA, &stParameter ); }
/** * 커서의 위치를 설정 * 문자를 출력할 위치도 같이 설정 */ BOOL SetCursor( int iX, int iY ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) iX; PARAM( 1 ) = ( QWORD ) iY; // 시스템 콜 호출 return ExecuteSystemCall( SYSCALL_SETCURSOR, &stParameter ); }
uint Advapi32_RegOpenKeyExW(Processor *cpu) { RET_VALUE = (u32) RegOpenKeyExW( (HKEY) PARAM(0), (LPCWSTR) PARAM_PTR(1), (DWORD) PARAM(2), (REGSAM) PARAM(3), (PHKEY) PARAM_PTR(4) ); RET_PARAMS(5); }
/** * 시리얼 포트에서 데이터를 읽음 */ int ReceiveSerialData( BYTE* pbBuffer, int iSize ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pbBuffer; PARAM( 1 ) = ( QWORD ) iSize; // 시스템 콜 호출 return ( int ) ExecuteSystemCall( SYSCALL_RECEIVESERIALDATA, &stParameter ); }
/** * 윈도우를 해당 위치로 이동 */ BOOL MoveWindow( QWORD qwWindowID, int iX, int iY ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) iX; PARAM( 2 ) = ( QWORD ) iY; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_MOVEWINDOW, &stParameter ); }
/** * X, Y좌표가 윈도우의 닫기 버튼 위치에 있는지를 반환 */ BOOL IsInCloseButton( QWORD qwWindowID, int iX, int iY ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) iX; PARAM( 2 ) = ( QWORD ) iY; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_ISINCLOSEBUTTON, &stParameter ); }
void sceIoGetstat() { const char *filename = Memory::GetCharPointer(PARAM(0)); u32 addr = PARAM(1); SceIoStat *stat = (SceIoStat*)Memory::GetPointer(addr); PSPFileInfo info = pspFileSystem.GetFileInfo(filename); __IoGetStat(stat, info); DEBUG_LOG(HLE,"sceIoGetstat(%s, %08x) : sector = %08x",filename,addr,info.startSector); RETURN(0); }
t_clist *init_param(void) { t_clist *param; t_float *content; param = (t_clist *)malloc(sizeof(t_clist) * NB_PARAM + 10); content = (t_float *)malloc(sizeof(t_float) * NB_INT + 10100); param->bit = content; free(PARAM(2)); PARAM(2) = NULL; return (param); }
u32 sceKernelLoadModule(const char *name, u32 flags) { if(!name) return 0; PSPFileInfo info = pspFileSystem.GetFileInfo(name); std::string error_string; s64 size = (s64)info.size; if (!info.exists) { ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): File does not exist", name, flags); return SCE_KERNEL_ERROR_NOFILE; } if (!size) { ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): Module file is size 0", name, flags); return SCE_KERNEL_ERROR_ILLEGAL_OBJECT; } DEBUG_LOG(LOADER, "sceKernelLoadModule(%s, %08x)", name, flags); SceKernelLMOption *lmoption = 0; int position = 0; // TODO: Use position to decide whether to load high or low if (PARAM(2)) { lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2)); } Module *module = 0; u8 *temp = new u8[(int)size]; u32 handle = pspFileSystem.OpenFile(name, FILEACCESS_READ); pspFileSystem.ReadFile(handle, temp, (size_t)size); module = __KernelLoadELFFromPtr(temp, 0, &error_string); delete [] temp; pspFileSystem.CloseFile(handle); if (!module) { // Module was blacklisted or couldn't be decrypted, which means it's a kernel module we don't want to run. // Let's just act as if it worked. NOTICE_LOG(LOADER, "Module %s is blacklisted or undecryptable - we lie about success", name); return 1; } if (lmoption) { INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,%08x,%08x,%08x,position = %08x)", module->GetUID(),name,flags, lmoption->size,lmoption->mpidtext,lmoption->mpiddata,lmoption->position); } else { INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,(...))", module->GetUID(), name, flags); } return module->GetUID(); }
/** * 윈도우 화면 버퍼에 윈도우 제목 표시줄 그리기 */ BOOL DrawWindowTitle( QWORD qwWindowID, const char* pcTitle, BOOL bSelectedTitle ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) pcTitle; PARAM( 2 ) = ( QWORD ) bSelectedTitle; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_DRAWWINDOWTITLE, &stParameter ); }
/** * JPEG 이미지 파일의 전체가 담긴 파일 버퍼와 크기를 이용해서 JPEG 자료구조를 초기화 * 파일 버퍼의 내용을 분석하여 이미지 전체의 크기와 기타 정보를 JPEG 자료구조에 삽입 */ BOOL JPEGInit(JPEG *jpeg, BYTE* pbFileBuffer, DWORD dwFileSize) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) jpeg; PARAM( 1 ) = ( QWORD ) pbFileBuffer; PARAM( 2 ) = ( QWORD ) dwFileSize; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_JPEGINIT, &stParameter ); }
/** * CMOS 메모리에서 RTC 컨트롤러가 저장한 현재 시간을 읽음 */ BOOL ReadRTCTime( BYTE* pbHour, BYTE* pbMinute, BYTE* pbSecond ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pbHour; PARAM( 1 ) = ( QWORD ) pbMinute; PARAM( 2 ) = ( QWORD ) pbSecond; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_READRTCTIME, &stParameter ); }
/** * X, Y좌표가 윈도우의 제목 표시줄 위치에 있는지를 반환 */ BOOL IsInTitleBar( QWORD qwWindowID, int iX, int iY ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) iX; PARAM( 2 ) = ( QWORD ) iY; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_ISINTITLEBAR, &stParameter ); }
void sceAtracGetStreamDataInfo() { u32 atracID = PARAM(0); u32 writePointerAddr = PARAM(1); u32 availableBytesAddr = PARAM(2); u32 readOffsetAddr = PARAM(3); ERROR_LOG(HLE, "FAKE sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writePointerAddr, availableBytesAddr, readOffsetAddr); Memory::Write_U32(0, readOffsetAddr); Memory::Write_U32(0, availableBytesAddr); Memory::Write_U32(0, writePointerAddr); RETURN(0); }
/** * 태스크의 우선 순위를 변경 */ BOOL ChangePriority( QWORD qwID, BYTE bPriority, BOOL bExecutedInInterrupt ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwID; PARAM( 1 ) = ( QWORD ) bPriority; PARAM( 2 ) = ( QWORD ) bExecutedInInterrupt; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_CHANGEPRIORITY, &stParameter ); }
/** * 파일 포인터의 위치를 이동 */ int fseek( FILE* pstFile, int iOffset, int iOrigin ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pstFile; PARAM( 1 ) = ( QWORD ) iOffset; PARAM( 2 ) = ( QWORD ) iOrigin; // 시스템 콜 호출 return ( int ) ExecuteSystemCall( SYSCALL_FSEEK, &stParameter ); }
uint Advapi32_CryptAcquireContextW(Processor *cpu) { RET_VALUE = (u32) CryptAcquireContextW( (HCRYPTPROV *) PARAM_PTR(0), (LPCWSTR) PARAM_PTR(1), (LPCWSTR) PARAM_PTR(2), (DWORD) PARAM(3), (DWORD) PARAM(4) ); RET_PARAMS(5); }
void sceAudioOutput2OutputBlocking() { int vol = PARAM(0); u32 dataPtr = PARAM(1); WARN_LOG(HLE,"FAKE sceAudioOutput2OutputBlocking(%i, %08x)", vol, dataPtr); chans[0].running = true; chans[0].leftVolume = vol; chans[0].rightVolume = vol; chans[0].sampleAddress = dataPtr; RETURN(chans[0].sampleCount); __AudioEnqueue(chans[0], 0, true); }
//extern Thread *currentThread; void sceKernelCreateCallback() { u32 entrypoint = PARAM(1); u32 callbackArg = PARAM(2); const char *name = Memory::GetCharPointer(PARAM(0)); u32 id = __KernelCreateCallback(name, entrypoint, callbackArg); DEBUG_LOG(HLE,"%i=sceKernelCreateCallback(name=%s,entry= %08x, callbackArg = %08x)", id, name, entrypoint, callbackArg); RETURN(id); }
/** * 버퍼의 데이터를 파일에 씀 */ DWORD fwrite( const void* pvBuffer, DWORD dwSize, DWORD dwCount, FILE* pstFile ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pvBuffer; PARAM( 1 ) = ( QWORD ) dwSize; PARAM( 2 ) = ( QWORD ) dwCount; PARAM( 3 ) = ( QWORD ) pstFile; // 시스템 콜 호출 return ExecuteSystemCall( SYSCALL_FWRITE, &stParameter ); }
/** * 윈도우 내부에 점 그리기 */ BOOL DrawPixel( QWORD qwWindowID, int iX, int iY, COLOR stColor ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) iX; PARAM( 2 ) = ( QWORD ) iY; PARAM( 3 ) = ( QWORD ) stColor; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_DRAWPIXEL, &stParameter ); }
static uintptr_t CPROC ProcessConfig( uintptr_t psv, arg_list args ) { PARAM( args, size_t, length ); PARAM( args, CPOINTER, data ); uint8_t* realdata; size_t reallength; PCONFIG_HANDLER pch = CreateConfigurationHandler(); AddRules( pch ); SRG_DecryptRawData( (uint8_t*)data, length, &realdata, &reallength ); ProcessConfigurationInput( pch, (CTEXTSTR)realdata, reallength, 0 ); DestroyConfigurationEvaluator( pch ); return psv; }
uint Advapi32_RegEnumKeyExA(Processor *cpu) { RET_VALUE = (u32) RegEnumKeyExA( (HKEY) PARAM(0), (DWORD) PARAM(1), (LPSTR) PARAM_PTR(2), (LPDWORD) PARAM_PTR(3), (LPDWORD) PARAM_PTR(4), (LPSTR) PARAM_PTR(5), (LPDWORD) PARAM_PTR(6), (PFILETIME) PARAM_PTR(7) ); RET_PARAMS(8); }
static void mdlOutputs(SimStruct *S,int_T tid) { InputRealPtrsType uPtrs0 = ssGetInputPortRealSignalPtrs(S,0); InputRealPtrsType uPtrs1 = ssGetInputPortRealSignalPtrs(S,1); real_T prev = ssGetRWorkValue(S,0); bool dataPort = PARAM(2)[0]; int_T i; #ifndef MATLAB_MEX_FILE rosShmData_t *shm = (rosShmData_t *)ssGetPWorkValue(S,0); SEM *sem = (SEM *)ssGetPWorkValue(S,1); #endif char_T *msg; unsigned int strlen = sizeof(char_T)*(PARAM_SIZE(1)+1); UNUSED_ARG(tid); /* not used in single tasking mode */ if (U0(0) > 0.5 && U0(0) > prev) { msg = (char_T *)malloc(strlen); mxGetString(ssGetSFcnParam(S,1), msg, strlen); #ifndef MATLAB_MEX_FILE if (dataPort) { for (i = 0; i < ssGetInputPortWidth(S,1); ++i) { asprintf(&msg, "%s %f", msg, U1(i)); } } if (rt_sem_wait_if(sem) != 0) { memcpy(shm->msg.text, msg, MAX_LOG_MSG_SIZE); shm->msg.state = NEW_VALUE; rt_sem_signal(sem); } #else switch ((int)PARAM(0)[0]) { case 1: printf("DEBUG"); break; case 2: printf("INFO"); break; case 3: printf("WARN"); break; case 4: printf("ERROR"); break; case 5: printf("FATAL"); break; default: printf("NONE"); break; } printf(": %s", msg); if (dataPort) { for (i = 0; i < ssGetInputPortWidth(S,1); ++i) { printf(" %f", U1(i)); } } printf("\n"); #endif free(msg); } ssSetRWorkValue(S,0,U0(0)); }
int get_param(int param_nb, t_vm *data, t_proc *process) { int param_value; if (PARAM_TYPE(param_nb) == REG_CODE && is_reg(process, param_nb)) param_value = REG(param_nb); else if (PARAM_TYPE(param_nb) == DIR_CODE) param_value = PARAM(param_nb); else if (PARAM_TYPE(param_nb) == IND_CODE) param_value = ft_ramcpy(data, 4, PC + PARAM(param_nb)); else return (ERR_CODE_PARAM); return (param_value); }
/** * 윈도우의 크기를 변경 */ BOOL ResizeWindow( QWORD qwWindowID, int iX, int iY, int iWidth, int iHeight ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = qwWindowID; PARAM( 1 ) = ( QWORD ) iX; PARAM( 2 ) = ( QWORD ) iY; PARAM( 3 ) = ( QWORD ) iWidth; PARAM( 4 ) = ( QWORD ) iHeight; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_RESIZEWINDOW, &stParameter ); }
/** * CMOS 메모리에서 RTC 컨트롤러가 저장한 현재 일자를 읽음 */ BOOL ReadRTCDate( WORD* pwYear, BYTE* pbMonth, BYTE* pbDayOfMonth, BYTE* pbDayOfWeek ) { PARAMETERTABLE stParameter; // 파라미터 삽입 PARAM( 0 ) = ( QWORD ) pwYear; PARAM( 1 ) = ( QWORD ) pbMonth; PARAM( 2 ) = ( QWORD ) pbDayOfMonth; PARAM( 3 ) = ( QWORD ) pbDayOfWeek; // 시스템 콜 호출 return ( BOOL ) ExecuteSystemCall( SYSCALL_READRTCDATE, &stParameter ); }
//int sceKernelSignalSema(SceUID semaid, int signal); void sceKernelSignalSema() { //TODO: check that this thing really works :) SceUID id = PARAM(0); u32 signal = PARAM(1); u32 error; Semaphore *s = kernelObjects.Get<Semaphore>(id, error); if (s) { int oldval = s->ns.currentCount; s->ns.currentCount += signal; DEBUG_LOG(HLE,"sceKernelSignalSema(%i, %i) (old: %i, new: %i)", id, signal, oldval, s->ns.currentCount); bool wokeThreads = false; retry: //TODO: check for threads to wake up - wake them std::vector<SceUID>::iterator iter; for (iter = s->waitingThreads.begin(); iter!=s->waitingThreads.end(); s++) { SceUID id = *iter; int wVal = (int)__KernelGetWaitValue(id, error); if (wVal <= s->ns.currentCount) { __KernelResumeThread(id); s->ns.currentCount -= wVal; wokeThreads = true; s->waitingThreads.erase(iter); goto retry; } else { break; } } //pop the thread that were released from waiting // I don't think we should reschedule here //if (wokeThreads) // __KernelReSchedule("semaphore signalled"); RETURN(0); } else { ERROR_LOG(HLE, "sceKernelSignalSema : Trying to signal invalid semaphore %i", id); RETURN(error); } }
void sceCtrlReadBufferPositive() { u32 ctrlDataPtr = PARAM(0); // u32 nBufs = PARAM(1); DEBUG_LOG(HLE,"sceCtrlReadBufferPositive(%08x)", PARAM(0)); std::lock_guard<std::recursive_mutex> guard(ctrlMutex); // Let's just ignore if ctrl is inited or not; some games don't init it (Super Fruit Fall) //if (ctrlInited) //{ SampleControls(); memcpy(Memory::GetPointer(ctrlDataPtr), &ctrl, sizeof(_ctrl_data)); //} RETURN(1); }