/*
 * Try to print the callstack.
 * That is very sensitive to the operating system, hardware, compiler and runtime!
 * The code is not meant for production environment, it's using functions not whitelisted for usage in a signal handler function.
 */
static void print_stacktrace(FILE* f, bool demangling, int maxdepth)
{
#if defined(USE_UNIX_BACKTRACE_SUPPORT)
// 32 vs. 64bit
#define ADDRESSDISPLAYLENGTH ((sizeof(long)==8)?12:8)
    void *array[32]= {0}; // the less resources the better...
    const int depth = backtrace(array, (int)GetArrayLength(array));
    const int offset=3; // the first two entries are simply within our own exception handling code, third is within libc
    if (maxdepth<0)
        maxdepth=depth+offset;
    else
        maxdepth+=offset;
    char **symbolstrings = backtrace_symbols(array, depth);
    if (symbolstrings) {
        fputs("Callstack:\n", f);
        for (int i = offset; i < maxdepth; ++i) {
            const char * const symbol = symbolstrings[i];
            char * realname = nullptr;
            const char * const firstBracketName = strchr(symbol, '(');
            const char * const firstBracketAddress = strchr(symbol, '[');
            const char * const secondBracketAddress = strchr(firstBracketAddress, ']');
            const char * const beginAddress = firstBracketAddress+3;
            const int addressLen = int(secondBracketAddress-beginAddress);
            const int padLen = int(ADDRESSDISPLAYLENGTH-addressLen);
            if (demangling && firstBracketName) {
                const char * const plus = strchr(firstBracketName, '+');
                if (plus && (plus>(firstBracketName+1))) {
                    char input_buffer[512]= {0};
                    strncpy(input_buffer, firstBracketName+1, plus-firstBracketName-1);
                    char output_buffer[1024]= {0};
                    size_t length = GetArrayLength(output_buffer);
                    int status=0;
                    realname = abi::__cxa_demangle(input_buffer, output_buffer, &length, &status); // non-NULL on success
                }
            }
            const int ordinal=i-offset;
            fprintf(f, "#%-2d 0x",
                    ordinal);
            if (padLen>0)
                fprintf(f, "%0*d",
                        padLen, 0);
            if (realname) {
                fprintf(f, "%.*s in %s\n",
                        (int)(secondBracketAddress-firstBracketAddress-3), firstBracketAddress+3,
                        realname);
            } else {
                fprintf(f, "%.*s in %.*s\n",
                        (int)(secondBracketAddress-firstBracketAddress-3), firstBracketAddress+3,
                        (int)(firstBracketAddress-symbol), symbol);
            }
        }
        free(symbolstrings);
    } else {
        fputs("Callstack could not be obtained\n", f);
    }
#undef ADDRESSDISPLAYLENGTH
#endif
}
// 生成签名密钥对
void CClassCommon::InitArgsSKFGenSM2KeyPair(VARIANT aArrayArgIN)
{
	int inBuffSize  = 0;

	GetArrayLength(aArrayArgIN.pdispVal,&inBuffSize);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_STRING(file_log_name, "START");

	::FILE_LOG_NUMBER(file_log_name, inBuffSize);

	if (1 != inBuffSize)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,0, m_szPIN, &m_iPINLen);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_STRING(file_log_name, "END");

	ulResult = 0;
}
void CClassCommon::InitArgsSignedCert(VARIANT aArrayArgIN)
{
	int inBuffSize  = 0;

	unsigned char data_value_cert_b64[BUFFER_LEN_1K * 4]; 
	unsigned long data_len_cert_b64;

	GetArrayLength(aArrayArgIN.pdispVal,&inBuffSize);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_NUMBER(file_log_name, inBuffSize);

	if (3 != inBuffSize)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,0, (char *)data_value_cert_b64,(int *) (&data_len_cert_b64));

	m_iCertLen = modp_b64_decode((char *)m_szCert, (char *)data_value_cert_b64,data_len_cert_b64);

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,1, m_szPIN, &m_iPINLen);

	GetArrayNumberOfIndex(aArrayArgIN.pdispVal,2,&ulContype);

	ulResult = 0;
}
/*
 * Simple mapping
 */
static const char *signal_name(int signo)
{
    for (size_t s=0; s<GetArrayLength(listofsignals); ++s) {
        if (listofsignals[s].signalnumber==signo)
            return listofsignals[s].signalname;
    }
    return "";
}
void CClassCommon::InitArgsSM2Keys(VARIANT aArrayArgIN)
{
	int inBuffSize  = 0;

	unsigned char data_value_key_b64[BUFFER_LEN_1K * 4]; 
	unsigned long data_len_key_b64 = BUFFER_LEN_1K * 4;

	unsigned char data_value_key[BUFFER_LEN_1K * 4]; 
	unsigned long data_len_key = BUFFER_LEN_1K * 4;

	GetArrayLength(aArrayArgIN.pdispVal,&inBuffSize);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_STRING(file_log_name, "START");

	::FILE_LOG_NUMBER(file_log_name, inBuffSize);

	if (3 != inBuffSize)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,0, (char *)data_value_key_b64,(int *) (&data_len_key_b64));

	data_len_key = modp_b64_decode((char *)data_value_key, (char *)data_value_key_b64,data_len_key);

	::FILE_LOG_STRING(file_log_name, "data_len_key");

	::FILE_LOG_NUMBER(file_log_name, data_len_key);

	::FILE_LOG_HEX(file_log_name, data_value_key,data_len_key);

	if (sizeof(OPST_PCI_ECCrefPublicKey) + sizeof(OPST_PCI_ECCrefPrivateKey) != data_len_key)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	::FILE_LOG_STRING(file_log_name, "SM2KEYS");
	::FILE_LOG_HEX(file_log_name,data_value_key, data_len_key);

	memcpy(&m_stPublicKey,data_value_key,sizeof(OPST_PCI_ECCrefPublicKey));
	memcpy(&m_stPrivateKey,data_value_key + sizeof(OPST_PCI_ECCrefPublicKey), sizeof(OPST_PCI_ECCrefPrivateKey));

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,1, m_szPIN, &m_iPINLen);

	GetArrayNumberOfIndex(aArrayArgIN.pdispVal,2,&ulContype);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_STRING(file_log_name, "END");

	ulResult = 0;
}
Exemple #6
0
static void sDumpObject(header_t* h) {
    if (0 <= h->e.classId && h->e.classId < cpNumberOfAllClassInstanceInfo) {
        if (isObjectArray(h->e.classId)) {
            jobjectArray oa = (jobjectArray) getObjectFromHeader(h);
            size_t length = GetArrayLength((jarray) oa);
            size_t i;
            for (i = 0; i < length; i++) {
                jobject obj = GetObjectArrayElement(NULL, oa, i);
                header_t* oh = getHeader(obj);
                consout("    [%d] %p\n", i, oh);
            }
        }
    }
    // else: Class Id out of range; can't dump
}
static void callJNIReturnString(const char* str, char* result)
{
	auto env = gApp->activity->env;
	auto vm = gApp->activity->vm;
	auto obj = gApp->activity->clazz;

	vm->AttachCurrentThread( &env, NULL );
	auto clazz = env->GetObjectClass(obj);
	jmethodID methodID = env->GetMethodID(clazz, str, "()[B");

	auto array = (jbyteArray)env->CallObjectMethod(obj, methodID);
	auto ptr   = env->GetByteArrayElements(array, 0);
	int len   = env->GetArrayLength(array);

	memcpy(result, ptr, len);
	result[len] = '\0';

	env->ReleaseByteArrayElements(array, ptr, JNI_ABORT);

	vm->DetachCurrentThread();
}
// 初始化交换数字信封
void CClassCommon::InitArgsSKFImportSM2KeyPair(VARIANT aArrayArgIN)
{
	int inBuffSize  = 0;

	unsigned char szEnvelopedKeyBlobB64[BUFFER_LEN_1K * 4]; 
	unsigned long ulEnvelopedKeyBlobB64Len = BUFFER_LEN_1K * 4;
	unsigned long ulEnvelopedKeyBlobLen = BUFFER_LEN_1K * 4;

	GetArrayLength(aArrayArgIN.pdispVal,&inBuffSize);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);

	::FILE_LOG_STRING(file_log_name, "START");

	::FILE_LOG_NUMBER(file_log_name, inBuffSize);

	if (2 != inBuffSize)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,0, m_szPIN, &m_iPINLen);
	GetArrayStrOfIndex(aArrayArgIN.pdispVal,1, (char *)szEnvelopedKeyBlobB64,(int *)(&ulEnvelopedKeyBlobB64Len));

	ulEnvelopedKeyBlobLen = modp_b64_decode((char *)&m_stEnvelopedKeyBlobEX, (const char *)szEnvelopedKeyBlobB64,ulEnvelopedKeyBlobB64Len);

	::FILE_LOG_STRING(file_log_name, "m_stEnvelopedKeyBlobEX");

	::FILE_LOG_HEX(file_log_name, (const unsigned char *)&m_stEnvelopedKeyBlobEX,sizeof(OPST_SKF_ENVELOPEDKEYBLOB));

	if (sizeof(OPST_SKF_ENVELOPEDKEYBLOB) != ulEnvelopedKeyBlobLen)
	{
		::FILE_LOG_STRING(file_log_name, "sizeof(OPST_SKF_ENVELOPEDKEYBLOB) != ulEnvelopedKeyBlobLen");
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	ulResult = 0;
}
/**
 * Signal/SEH handling
 * Has to be clean for using with SEH on windows, i.e. no construction of C++ object instances is allowed!
 * TODO Check for multi-threading issues!
 *
 */
int CppCheckExecutor::check_wrapper(CppCheck& cppcheck, int argc, const char* const argv[])
{
#ifdef USE_WINDOWS_SEH
    FILE *f = stdout;
    __try {
        return check_internal(cppcheck, argc, argv);
    } __except (filterException(GetExceptionCode(), GetExceptionInformation())) {
        // reporting to stdout may not be helpful within a GUI application..
        fputs("Please report this to the cppcheck developers!\n", f);
        return -1;
    }
#elif defined(USE_UNIX_SIGNAL_HANDLING)
    // determine stack vs. heap
    char stackVariable;
    char *heapVariable=(char*)malloc(1);
    bStackBelowHeap = &stackVariable < heapVariable;
    free(heapVariable);

    // set up alternative stack for signal handler
    stack_t segv_stack;
    segv_stack.ss_sp = mytstack;
    segv_stack.ss_flags = 0;
    segv_stack.ss_size = MYSTACKSIZE;
    sigaltstack(&segv_stack, NULL);

    // install signal handler
    struct sigaction act;
    memset(&act, 0, sizeof(act));
    act.sa_flags=SA_SIGINFO|SA_ONSTACK;
    act.sa_sigaction=CppcheckSignalHandler;
    for (std::size_t s=0; s<GetArrayLength(listofsignals); ++s) {
        sigaction(listofsignals[s].signalnumber, &act, NULL);
    }
    return check_internal(cppcheck, argc, argv);
#else
    return check_internal(cppcheck, argc, argv);
#endif
}
STDMETHODIMP CClassCommon::FILE_LOG_BYTEARRAY(BSTR fileName, VARIANT vArray)
{
	// TODO: 在此添加实现代码
	int len = 0;

	HRESULT hr = GetArrayLength(vArray.pdispVal, &len);

	if (FAILED(hr))
	{
		return hr;
	}


	int filename_data_len = 1024 * 1024;
	char * filename_data_value = new char[filename_data_len];

	WideCharToMultiByte( CP_ACP, 0, fileName,wcslen(fileName),  
        filename_data_value, filename_data_len, NULL, NULL);


	int write_data_len = len * 4;
	unsigned char * write_data_value = new unsigned char[write_data_len];


	for(int i = 0; i < len; i++)
	{
		GetArrayNumberOfIndex(vArray.pdispVal, i, (int *)write_data_value + i);
	}

	::FILE_LOG_BYTE(filename_data_value, write_data_value, write_data_len);

	delete filename_data_value;
	delete write_data_value;

	return S_OK;
}
/**
 * Signal/SEH handling
 * Has to be clean for using with SEH on windows, i.e. no construction of C++ object instances is allowed!
 * TODO Check for multi-threading issues!
 *
 */
int CppCheckExecutor::check_wrapper(CppCheck& cppcheck, int argc, const char* const argv[])
{
#ifdef USE_WINDOWS_SEH
    FILE *f = stdout;
    __try {
        return check_internal(cppcheck, argc, argv);
    } __except (filterException(GetExceptionCode(), GetExceptionInformation())) {
        // reporting to stdout may not be helpful within a GUI application..
        fputs("Please report this to the cppcheck developers!\n", f);
        return -1;
    }
#elif defined(USE_UNIX_SIGNAL_HANDLING)
    struct sigaction act;
    memset(&act, 0, sizeof(act));
    act.sa_flags=SA_SIGINFO;
    act.sa_sigaction=CppcheckSignalHandler;
    for (std::size_t s=0; s<GetArrayLength(listofsignals); ++s) {
        sigaction(listofsignals[s].signalnumber, &act, NULL);
    }
    return check_internal(cppcheck, argc, argv);
#else
    return check_internal(cppcheck, argc, argv);
#endif
}
Exemple #12
0
JNIEXPORT jobjectArray JNICALL Java_org_tmu_core_Nauty_canonize
  (JNIEnv * env, jobject thisobj, jobjectArray arr, jint k){
    int subgraph_size=0;
	graph g[MAXN*MAXM];
	graph canong[MAXN*MAXM];
	int lab[MAXN],ptn[MAXN],orbits[MAXN];
	static DEFAULTOPTIONS_DIGRAPH(options);
	statsblk stats;

	subgraph_size=k;
		
	
	if (subgraph_size > MAXN)
        {
            printf("size of graph must be in the range 1..%d\n",MAXN);
            return NULL;
        }
	
	options.defaultptn = TRUE;
	options.getcanon = TRUE;
	
	
	char bin_adj[BUFSIZE];
	char zeroed_adj[BUFSIZE];
	char str[BUFSIZE];

	int n=subgraph_size;
	int m=SETWORDSNEEDED(n);
	nauty_check(WORDSIZE,m,n,NAUTYVERSIONID);
	
	int stringCount = GetArrayLength(env, arr);
	
	jobjectArray ret;
	ret= (jobjectArray)env->NewObjectArray(stringCount,  
         env->FindClass("java/lang/String"),  
         env->NewStringUTF(""));
		 

    
	for (int i=0; i<stringCount; i++) {
        jstring string = (jstring) GetObjectArrayElement(env, arr, i);
        const char *rawString = GetStringUTFChars(env, string, 0);
        strcpy(bin_adj,rawString);
		ReleaseStringUTFChars(rawString);
		int bin_len=strlen(bin_adj);
		if(bin_len<subgraph_size*subgraph_size){
			memset(zeroed_adj,'0',subgraph_size*subgraph_size-bin_len);
		}
		strcpy(zeroed_adj+subgraph_size*subgraph_size-bin_len,bin_adj);		
		EMPTYGRAPH(g,m,n);
		for (int i = 0; i < subgraph_size; i++)
            for (int j = 0; j < subgraph_size; j++)
                if (i!=j&&zeroed_adj[i * subgraph_size + j] == '1')
						ADDONEARC(g,i,j,m);
		
		densenauty(g,lab,ptn,orbits,&options,&stats,m,n,canong);
		
		memset(str,'0',subgraph_size*subgraph_size);
		for (int i = 0; i < subgraph_size; i++) {	
			for(int j = 0; j < subgraph_size; j++) {
				if(i!=j&&zeroed_adj[lab[i]*subgraph_size+lab[j]]=='1') 
					str[i*subgraph_size+j]='1';
			}
		}
		str[subgraph_size*subgraph_size]=0;
		
		env->SetObjectArrayElement(ret,i,env->NewStringUTF(str));
    }   
	
	return ret;  
}
static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
{
    if (!loadDbgHelp())
        return;
    const HANDLE hProcess   = GetCurrentProcess();
    const HANDLE hThread    = GetCurrentThread();
    BOOL result = pSymInitialize(
                      hProcess,
                      0,
                      TRUE
                  );
    CONTEXT             context = *(ex->ContextRecord);
    STACKFRAME64        stack= {0};
#ifdef _M_IX86
    stack.AddrPC.Offset    = context.Eip;
    stack.AddrPC.Mode      = AddrModeFlat;
    stack.AddrStack.Offset = context.Esp;
    stack.AddrStack.Mode   = AddrModeFlat;
    stack.AddrFrame.Offset = context.Ebp;
    stack.AddrFrame.Mode   = AddrModeFlat;
#else
    stack.AddrPC.Offset    = context.Rip;
    stack.AddrPC.Mode      = AddrModeFlat;
    stack.AddrStack.Offset = context.Rsp;
    stack.AddrStack.Mode   = AddrModeFlat;
    stack.AddrFrame.Offset = context.Rsp;
    stack.AddrFrame.Mode   = AddrModeFlat;
#endif
    IMAGEHLP_SYMBOL64_EXT symbol;
    symbol.SizeOfStruct  = sizeof(IMAGEHLP_SYMBOL64);
    symbol.MaxNameLength = maxnamelength;
    DWORD64 displacement   = 0;
    int beyond_main=-1; // emergency exit, see below
    for (ULONG frame = 0; ; frame++) {
        result = pStackWalk64
                 (
#ifdef _M_IX86
                     IMAGE_FILE_MACHINE_I386,
#else
                     IMAGE_FILE_MACHINE_AMD64,
#endif
                     hProcess,
                     hThread,
                     &stack,
                     &context,
                     NULL,
                     pSymFunctionTableAccess64,
                     pSymGetModuleBase64,
                     NULL
                 );
        if (!result)  // official end...
            break;
        pSymGetSymFromAddr64(hProcess, (ULONG64)stack.AddrPC.Offset, &displacement, &symbol);
        TCHAR undname[maxnamelength]= {0};
        pUnDecorateSymbolName((const TCHAR*)symbol.Name, (PTSTR)undname, (DWORD)GetArrayLength(undname), UNDNAME_COMPLETE);
        if (beyond_main>=0)
            ++beyond_main;
        if (_tcscmp(undname, _T("main"))==0)
            beyond_main=0;
        fprintf(f,
                "%lu. 0x%08LX in ",
                frame, (ULONG64)stack.AddrPC.Offset);
        fputs((const char *)undname, f);
        fputs("\n", f);
        if (0==stack.AddrReturn.Offset || beyond_main>2) // StackWalk64() sometimes doesn't reach any end...
            break;
    }

    FreeLibrary(hLibDbgHelp);
    hLibDbgHelp=0;
}
void Player::StepSkillWindow()
{
	//スキルウィンドウトグル
	if(CheckKeyDown(KEY_INPUT_LALT))SkillWindow.Visible = 1 - SkillWindow.Visible;

	//スキルウィンドウが有効であるかどうか確認
	if(!SkillWindow.Visible)return;

	for(int i=0;i<3;i++)
	{//装備中武器に合わせたスキルセットを取得
		EnableSkillList[i] = GetSkillList(GetEquipmentNameforEquipment(Equipments[i]));
	}

	//操作
	if(!SkillChangeFlag)
	{//カーソルが左にあり、変更操作をおこなっていない状態
		if(CheckKeyDown(KEY_INPUT_LEFT))SkillCursorPoint.x--;
		if(CheckKeyDown(KEY_INPUT_RIGHT))SkillCursorPoint.x++;
		if(CheckKeyDown(KEY_INPUT_UP))SkillCursorPoint.y--;
		if(CheckKeyDown(KEY_INPUT_DOWN))SkillCursorPoint.y++;
	
		if(SkillCursorPoint.x < 0)SkillCursorPoint.x = 2;
		else if(SkillCursorPoint.x > 2)SkillCursorPoint.x = 0;
		if(SkillCursorPoint.y < 0)SkillCursorPoint.y = 3;
		else if(SkillCursorPoint.y > 3)SkillCursorPoint.y = 0;
	}else
	{//スキル変更を行おうとしている状態
		if(CheckKeyDown(KEY_INPUT_LEFT))ChangeSkillPoint.x--;
		if(CheckKeyDown(KEY_INPUT_RIGHT))ChangeSkillPoint.x++;

		if(SkillCursorPoint.y != 0)
		{//スキル変更
			if(CheckKeyDown(KEY_INPUT_UP))
			{
				ChangeSkillPoint.x = 0;
				ChangeSkillPoint.y--;
			}
			if(CheckKeyDown(KEY_INPUT_DOWN))
			{
				ChangeSkillPoint.x = 0;
				ChangeSkillPoint.y++;
			}

			int Length = EnableSkillList[ChangeSkillPoint.y-1].size()-1;

			if(Length < ChangeSkillPoint.x)ChangeSkillPoint.x = 0;
			else if(0 > ChangeSkillPoint.x)ChangeSkillPoint.x = Length;

			if(ChangeSkillPoint.y < 1)ChangeSkillPoint.y = 3;
			else if(ChangeSkillPoint.y > 3)ChangeSkillPoint.y = 1;
		}else
		{//装備変更
			int Length = GetArrayLength(EquipmentNames)-1;
			if(ChangeSkillPoint.x < 0)ChangeSkillPoint.x = Length;
			else if(ChangeSkillPoint.x > Length)ChangeSkillPoint.x = 0;
		}
	}

	if(CheckKeyDown(KEY_INPUT_RETURN))
	{//変更決定
		if(!SkillChangeFlag)
		{
			ChangeSkillPoint.x = 0;
			ChangeSkillPoint.y = SkillCursorPoint.y;
		}else
		{
			if(SkillCursorPoint.y != 0)
			{
				SkillSet[SkillCursorPoint.x][SkillCursorPoint.y-1][0] = EnableSkillList[ChangeSkillPoint.y-1][ChangeSkillPoint.x];
				SkillSet[SkillCursorPoint.x][SkillCursorPoint.y-1][3] = 0;
			}else Equipments[SkillCursorPoint.x] = ChangeSkillPoint.x;

			for(int i=0;i<3;i++)
			{//装備中武器に合わせたスキルセットを取得
				EnableSkillList[i] = GetSkillList(GetEquipmentNameforEquipment(Equipments[i]));
			}

			#pragma region 使用できないスキルを検索し、無効にする
			vector<POINT> Points;

			int Skill[3][3];
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					Skill[i][j] = 0;
				}
			}
			
			for(int i=0;i<3;i++)
			{
				int Length = EnableSkillList[i].size();
				for(int j=0;j<Length;j++)
				{
					for(int x=0;x<3;x++)
					{
						for(int y=0;y<3;y++)
						{
							if(SkillSet[x][y][0] == EnableSkillList[i][j])
							{
								Skill[x][y] = 1;
							}
						}
					}
				}
			}

			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					if(!Skill[i][j])
					{
						SkillSet[i][j][0] = 0;
					}
				}
			}
			#pragma endregion
		}

		if(SkillChangeFlag)ChangeSkillPoint.x = ChangeSkillPoint.y = -1;
		SkillChangeFlag = 1 - SkillChangeFlag;
	}

	//描画
	SkillWindow.ReWindow();
	SkillWindow.SetDrawThisWindow();

	//DrawBox(15,10,110,35,Black,false);
	
	//パネルの制作
	int Length = AnimeGraphs.size();
	for(int i=0;i<Length;i++)
	{
		SkillPanels[i].ReWindow();
		SkillPanels[i].SetDrawThisWindow();

		SkillImages[i].x = SkillPanels[i].GetWidth()/2;
		SkillImages[i].y = SkillPanels[i].GetHeight()/2+24;
		SkillImages[i].Draw(true);
	}

	Length = EquipmentGraphs.size();
	for(int i=0;i<Length;i++)
	{
		EquipmentPanels[i].ReWindow();
		EquipmentPanels[i].SetDrawThisWindow();

		EquipmentImages[i].x = EquipmentPanels[i].GetWidth()/2;
		EquipmentImages[i].y = EquipmentPanels[i].GetHeight()/2+24;
		EquipmentImages[i].Draw(true);
	}

	SkillWindow.SetDrawThisWindow();

	for(int i=0;i<4;i++)
	{
		for(int j=0;j<3;j++)
		{
			int Select1 = 0,Select2 = 0;
			if(SkillCursorPoint.x == j && SkillCursorPoint.y == i)Select1 = 10;
			if(ChangeSkillPoint.x == j && ChangeSkillPoint.y == i && SkillChangeFlag)Select2 = 10;
			if(i>0)
			{//スキル窓の描画
				//DrawRotaGraph2(15+j*70+32,50+i*70+32,64,40,1,0,AnimeGraphs[SkillSet[j][i-1][0]][0],true);
				if(i < 4)
				{//使用中スキル
					SkillPanels[SkillSet[j][i-1][0]].x = 15+j*70;
					SkillPanels[SkillSet[j][i-1][0]].y = 50+i*70-Select1;
					SkillPanels[SkillSet[j][i-1][0]].Draw();
				}
				/*
				if(EnableSkillList[i-1].size() > j)
				{
					SkillPanels[EnableSkillList[i-1][j]].x = 15+j*70 + SkillWindow.GetWidth()/2;
					SkillPanels[EnableSkillList[i-1][j]].y = 50+i*70-Select2;
					SkillPanels[EnableSkillList[i-1][j]].Draw();
				}
				*/
			}else
			{//装備窓の描画
				//使用中装備
				EquipmentPanels[Equipments[j]].x = 15+j*70;
				EquipmentPanels[Equipments[j]].y = 50+i*70-Select1;
				EquipmentPanels[Equipments[j]].Draw();

			}
			//DrawBox(15+j*70,50+i*70,15+j*70+64,50+i*70+64,Black,false);
		}
	}

	for(int i=0;i<4;i++)
	{
		for(int j=0;j<5;j++)
		{
			int Select2 = 0;
			if(i>0)
			{//スキル窓の描画
				int ShowSkill = j + ChangeSkillPoint.x - 2;
				if(ChangeSkillPoint.x < 2)ShowSkill += 2 - ChangeSkillPoint.x;
				else if(ChangeSkillPoint.x >= EnableSkillList[i-1].size()-2)ShowSkill -= ChangeSkillPoint.x - (EnableSkillList[i-1].size()-3);
				if(ChangeSkillPoint.x == ShowSkill && ChangeSkillPoint.y == i && SkillChangeFlag)Select2 = 10;
				if(EnableSkillList[i-1].size() <= j)continue;
				SkillPanels[EnableSkillList[i-1][ShowSkill]].x = 15+j*70 + SkillWindow.GetWidth()/2;
				SkillPanels[EnableSkillList[i-1][ShowSkill]].y = 50+i*70-Select2;
				SkillPanels[EnableSkillList[i-1][ShowSkill]].Draw();
			}else
			{//装備窓の描画
				int ShowEquip = j;
				if(ChangeSkillPoint.x >= 5 && ChangeSkillPoint.y == i)ShowEquip += ChangeSkillPoint.x - 4;
				if(ChangeSkillPoint.x == ShowEquip && ChangeSkillPoint.y == i && SkillChangeFlag)Select2 = 10;
				if(GetArrayLength(EquipmentValueNames) > ShowEquip)
				{
					EquipmentPanels[ShowEquip].x = 15+j*70 + SkillWindow.GetWidth()/2;
					EquipmentPanels[ShowEquip].y = 50+i*70-Select2;
					EquipmentPanels[ShowEquip].Draw();
				}
			}
		}
	}

	InfoPanel.ReWindow();
	InfoPanel2.ReWindow();

	//装備、スキル説明の描画
	string StrInfo;
	if(SkillCursorPoint.y != 0)StrInfo = SkillInfo[SkillSet[SkillCursorPoint.x][SkillCursorPoint.y-1][0]];
	else StrInfo = EquipmentInfo[Equipments[SkillCursorPoint.x]];
	InfoPanel.DrawStringInWindow(5,5,DrawString_Left,StrInfo,FontSmall,White);
	SkillWindow.SetDrawThisWindow();
	InfoPanel.Draw();

	StrInfo = "";
	if(SkillChangeFlag)
	{
		if(SkillCursorPoint.y != 0)StrInfo = SkillInfo[EnableSkillList[ChangeSkillPoint.y-1][ChangeSkillPoint.x]];
		else StrInfo = EquipmentInfo[ChangeSkillPoint.x];
		InfoPanel2.DrawStringInWindow(5,5,DrawString_Left,StrInfo,FontSmall,White);
	}
	SkillWindow.SetDrawThisWindow();
	InfoPanel2.Draw();

	SetDrawScreen(DX_SCREEN_BACK);
	SkillWindow.Draw();
}
Exemple #15
0
USER_OBJECT_ 
RS_JAVA(MethodConverter)(jobject obj, jclass type, JNIEnv *env, RSFromJavaConverter *converter)
{
 int i = 0, k, n;
 int numSlots;
 USER_OBJECT_ ans, names;
 const char *tmp;

 jboolean isCopy;
 jstring jval;
 jclass klass;
 jobject jsig, jobj;
 ReflectanceMethodIDs *mids;
 boolean isMethod;
 jint modifier;

 if(ModifierStringID == NULL)
  initReflectanceMethods(env);

  /* Determine whether we have a constructor or method
     and set the method identifiers and number of slots
     appropriately.
   */
 isMethod = VMENV IsSameObject(env, type, VMENV FindClass(env, "java/lang/reflect/Method")) == JNI_TRUE;

 if(isMethod) {
   mids = &MethodIDs;
   numSlots = 6;
 } else {
   mids = &ConstructorIDs;
   numSlots = 5; /* Drop out the */
 }
 
 
 PROTECT(ans = NEW_LIST(numSlots));
 PROTECT(names = NEW_CHARACTER(numSlots));
 
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
 jval = VMENV CallObjectMethod(env, obj, mids->getName);
 tmp = VMENV GetStringUTFChars(env, jval, &isCopy);  
 SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
 if(isCopy)
   VMENV ReleaseStringUTFChars(env, jval, tmp);
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("name"));
 i++;

 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
 klass = VMENV CallObjectMethod(env, obj, mids->getClass);
 tmp = getClassName(env, klass, &isCopy);
 SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Declaring class")); 
 i++;


 jsig = VMENV CallObjectMethod(env, obj, mids->getParameters);
 n = VMENV GetArrayLength(env, jsig);
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n));
 for(k = 0; k < n ; k++) {
   jobj = VMENV GetObjectArrayElement(env, jsig, k);
   tmp = getClassName(env, jobj, &isCopy);
   SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp));
 }
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Parameters"));    
 i++;

 
 SET_VECTOR_ELT(ans, i, NEW_INTEGER(1));
 modifier = VMENV CallIntMethod(env, obj, mids->getModifiers);
 INTEGER_DATA(VECTOR_ELT(ans, i))[0] = modifier;
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Modifiers"));
 {
      /* Now get the string that represents the modifier value.
         Do this by calling the static method toString(int)
         in the java.lang.reflect.Modifier class.
         We assume we have initialized the ModifierStringID
         method id earlier when getting all the method ids
         for the reflectance classes.
       */
   USER_OBJECT_ tmpr;
   const char *modName;
   jstring jmodName;
    PROTECT(tmpr = NEW_CHARACTER(1));
    jmodName = VMENV CallStaticObjectMethod(env, (jclass)VMENV FindClass(env, "java/lang/reflect/Modifier"), ModifierStringID, modifier);

   if(jmodName != NULL_JAVA_OBJECT) {
      modName = VMENV GetStringUTFChars(env, jmodName, &isCopy);   
      SET_STRING_ELT(tmpr, 0, COPY_TO_USER_STRING(modName));
    }
    SET_NAMES(VECTOR_ELT(ans, i), tmpr);
    UNPROTECT(1);
 }
 i++;


 jsig = VMENV CallObjectMethod(env, obj, mids->getExceptions);
 n = VMENV GetArrayLength(env, jsig);
 SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n));
 for(k = 0; k < n ; k++) {
   jobj = VMENV GetObjectArrayElement(env, jsig, k);
   tmp = getClassName(env, jobj, &isCopy);
   SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp));
 }
 SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Exceptions"));    
 i++;

 

 if(isMethod) {
   SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1));
   klass = VMENV CallObjectMethod(env, obj, mids->getReturnType);
   tmp = getClassName(env, klass, &isCopy);
   SET_VECTOR_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp));
   SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Return type"));    
   i++;
 }
 
 SET_NAMES(ans, names); 
 
 /* Now set the class to be "JavaMethod" */

 UNPROTECT(2);

 return(ans);
}
/*
 * Java_java_io_PrintStream.c
 *
 *  Created on: Oct 28, 2011
 *      Author: hammer
 */

#include "jni.h"
#include "heap.h"
#include "console.h"
#include "constantpool.h"
#include "vmids.h"

void JNICALL Java_java_io_PrintStream_outString(JNIEnv *env, jobject this, jstring s) {
	u2 linkId = LINK_ID_java_lang_String_value__C;
	jcharArray charArray = (jcharArray) GetObjectField(s, linkId);

	size_t length = GetArrayLength(charArray);
	size_t i;
	for (i = 0; i < length; i++) {
		consout("%c", GetCharArrayElement(charArray, i));
	}
}

void JNICALL Java_java_io_PrintStream_outStringLf(JNIEnv *env, jobject this, jstring s) {
	Java_java_io_PrintStream_outString(env, this, s);
	consout("\n");
}

int VariantUtilities::ConvertVariantToJsonValue(const IECommandExecutor& executor,
                                                VARIANT variant_value,
                                                Json::Value* value) {
  int status_code = WD_SUCCESS;
  if (VariantIsString(variant_value)) { 
    std::string string_value = "";
    if (variant_value.bstrVal) {
      std::wstring bstr_value = variant_value.bstrVal;
      string_value = StringUtilities::ToString(bstr_value);
    }
    *value = string_value;
  } else if (VariantIsInteger(variant_value)) {
    *value = variant_value.lVal;
  } else if (VariantIsDouble(variant_value)) {
    *value = variant_value.dblVal;
  } else if (VariantIsBoolean(variant_value)) {
    *value = variant_value.boolVal == VARIANT_TRUE;
  } else if (VariantIsEmpty(variant_value)) {
    *value = Json::Value::null;
  } else if (variant_value.vt == VT_NULL) {
    *value = Json::Value::null;
  } else if (VariantIsIDispatch(variant_value)) {
    if (VariantIsArray(variant_value) ||
        VariantIsElementCollection(variant_value)) {
      Json::Value result_array(Json::arrayValue);

      long length = 0;
      status_code = GetArrayLength(variant_value.pdispVal, &length);

      for (long i = 0; i < length; ++i) {
        Json::Value array_item_result;
        int array_item_status = GetArrayItem(executor,
                                             variant_value.pdispVal,
                                             i,
                                             &array_item_result);
        result_array[i] = array_item_result;
      }
      *value = result_array;
    } else if (VariantIsObject(variant_value)) {
      Json::Value result_object;
      std::vector<std::wstring> property_names;
      status_code = GetPropertyNameList(variant_value.pdispVal,
                                        &property_names);

      for (size_t i = 0; i < property_names.size(); ++i) {
        CComVariant property_value_variant;
        GetVariantObjectPropertyValue(variant_value.pdispVal,
                                      property_names[i],
                                      &property_value_variant);

        Json::Value property_value;
        ConvertVariantToJsonValue(executor,
                                  property_value_variant,
                                  &property_value);

        std::string name = StringUtilities::ToString(property_names[i]);
        result_object[name] = property_value;
      }
      *value = result_object;
    } else {
      LOG(INFO) << "Unknown type of dispatch is found in result, assuming IHTMLElement";
      IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor);
      CComPtr<IHTMLElement> node;
      variant_value.pdispVal->QueryInterface<IHTMLElement>(&node);
      ElementHandle element_wrapper;
      mutable_executor.AddManagedElement(node, &element_wrapper);
      *value = element_wrapper->ConvertToJson();
    }
  } else {
    LOG(WARN) << "Unknown type of result is found";
    status_code = EUNKNOWNSCRIPTRESULT;
  }
  return status_code;
}
void CClassCommon::InitArgsUserInfo(VARIANT aArrayArgIN)
{
	int inBuffSize  = 0;

	wchar_t data_value[BUFFER_LEN_1K] = {0};
	int data_len = BUFFER_LEN_1K;

	memset(&userInfo,0,sizeof(OPST_USERINFO));

	GetArrayLength(aArrayArgIN.pdispVal,&inBuffSize);
	
	::FILE_LOG_STRING(file_log_name, __FUNCTION__);
	::FILE_LOG_STRING(file_log_name, "START");
	::FILE_LOG_NUMBER(file_log_name, inBuffSize);

	if (12 != inBuffSize)
	{
		ulResult = OPE_ERR_INVALID_PARAM;
		return;
	}

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,0, data_value, &data_len);
	UniToUTF8(data_value,userInfo.countryName);
	userInfo.ulLenC = strlen(userInfo.countryName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,1, data_value, &data_len);
	UniToUTF8(data_value,userInfo.stateOrProvinceName);
	userInfo.ulLenST = strlen(userInfo.stateOrProvinceName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,2, data_value, &data_len);
	UniToUTF8(data_value,userInfo.unstructuredName);
	userInfo.ulLenUN = strlen(userInfo.unstructuredName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,3, data_value, &data_len);
	UniToUTF8(data_value,userInfo.localityName);
	userInfo.ulLenL = strlen(userInfo.localityName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,4, data_value, &data_len);
	UniToUTF8(data_value,userInfo.organizationName);
	userInfo.ulLenO = strlen(userInfo.organizationName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,5, data_value, &data_len);
	UniToUTF8(data_value,userInfo.organizationalUnitName);
	userInfo.ulLenOU = strlen(userInfo.organizationalUnitName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,6, data_value, &data_len);
	UniToUTF8(data_value,userInfo.commonName);
	userInfo.ulLenCN = strlen(userInfo.commonName);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,7, data_value, &data_len);
	UniToUTF8(data_value,userInfo.emailAddress);
	userInfo.ulLenEA = strlen(userInfo.emailAddress);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,8, data_value, &data_len);
	UniToUTF8(data_value,userInfo.challengePassword);
	userInfo.ulLenCP = strlen(userInfo.challengePassword);

	data_len = BUFFER_LEN_1K;
	memset(data_value,0,BUFFER_LEN_1K*2);
	GetArrayWStrOfIndex(aArrayArgIN.pdispVal,9, data_value, &data_len);
	UniToUTF8(data_value,userInfo.idCardNumber);
	userInfo.ulLenID = strlen(userInfo.idCardNumber);

	GetArrayStrOfIndex(aArrayArgIN.pdispVal,10, m_szPIN, &m_iPINLen);
	GetArrayNumberOfIndex(aArrayArgIN.pdispVal,11,&ulContype);

	::FILE_LOG_STRING(file_log_name, __FUNCTION__);
	::FILE_LOG_STRING(file_log_name, "END");

	ulResult = 0;
}