1. 游戏中常用的词:
金币,钱:Cash、PremiumCurrency、Gold, money
无CD: Cooldown
2. Git pull 强制覆盖本地文件
git fetch --all
git reset --hard origin/master
git pull
3. dump: Il2cppReflection::dumpClassFromObj((Il2CppObject*)attribute);
4.在lua中..是字符串连接操作符
5.装包:arg1[2] =mono_string_new_wrapper(cmd.data);
6. Android根据图片文件名获取它的资源ID 的两种方式 :
方式1:
public int getResource(String imageName){
Context ctx=getBaseContext();
int resId = getResources().getIdentifier(imageName, "drawable" , ctx.getPackageName());
return resId;
}
方式2:
public int getResourceByReflect(String imageName){
Class drawable = R.drawable.class;
Field field = null;
int r_id ;
try {
field = drawable.getField(imageName);
r_id = field.getInt(field.getName());
} catch (Exception e) {
r_id=R.drawable.b_nothing;
Log.e("ERROR", "PICTURE NOT FOUND!");
}
return r_id;
}
checkbox事件:
viewHolder.cb.setOnClickListener(new CompoundButton.OnClickListener() {
@Override
public void onClick(View v) {
if (commodityInfo.isOwned()) {
boolean flag = commodityInfo.isOpen();
if (flag == true) {
viewHolder.cb.setChecked(true);
NativeUtils.nativeProcessCheat(commodityInfo.getNativeId(), 0, 1);
commodityInfo.setOpen(false);
}else{
viewHolder.cb.setChecked(false);
NativeUtils.nativeProcessCheat(commodityInfo.getNativeId(), 0, 0);
commodityInfo.setOpen(true);
}
} else {
viewHolder.cb.setChecked(false);
commodityInfo.setOpen(false);
GoodsManager.Buy(commodityInfo.getCommodityId());
}
}
});
6.U3D解密dll_dump
char * GetFilename(const char* fullpathname) { char* save_name, *pos; int name_len; name_len = strlen(fullpathname); pos = (char *) (fullpathname + name_len); while(*pos != '/' && pos != fullpathname) pos --; if(pos == fullpathname) { save_name = (char *) (fullpathname + 1); //LogD("<%s> filename=%s", __FUNCTION__, save_name); return save_name; } name_len = name_len-(pos-fullpathname); save_name = (char*) malloc(name_len+1); memcpy(save_name,pos+1,name_len); //LogD("<%s> filename=%s", __FUNCTION__, save_name); return save_name; } int dumpMonoImage(void * monoImage){ int img = (int) monoImage; if(!img){ return 1; } LogD("image=%x",img); char *data= (char *) *(int*)(img + 8); //LogD("<%s> data:%s", __FUNCTION__, data); int data_len=*(int *)(img+12); char *name =*(char **)(img+20); if(strstr(name, "Assembly-CSharp-firstpass.dll") || strstr(name,"Assembly-CSharp.dll")){ LogD("<%s> dump_dll_name:%s", __FUNCTION__, name); char *filename= GetFilename(name); FILE * stream; char *targetpath="/sdcard/DCIM/dlldump/"; int retlen=strlen(targetpath)+strlen(name)+1; char * result=(char *)malloc(retlen); strcpy(result,targetpath); strcat(result,filename); LogD("<%s> 开始写入解密文件=%s", __FUNCTION__, result); if((stream=fopen(result,"wb+"))==NULL){ LogD("<%s> null:%s", __FUNCTION__, "null"); } else{ fwrite(data,data_len,1,stream); fclose(stream); LogD("<%s> 解密文件写入完毕=%s", __FUNCTION__, result); } } return 1; } static unsigned long my_get_so_base(const char * name) { char path[1024], buf[1024], *start = NULL; unsigned long start_addr = -1; FILE *f = NULL; snprintf(path, sizeof(path), "/proc/self/maps"); if ((f = fopen(path, "r")) == NULL) { return 0; } for (;;) { if (!fgets(buf, sizeof(buf), f)) { break; } if (!strstr(buf, name)) { continue; } start = strtok(buf, "-"); sscanf(start, "%p", &start_addr); break; } fclose(f); return start_addr; } int CreatDir(char *pDir) { int i = 0; int iRet; int iLen; char* pszDir; if(NULL == pDir) { return 0; } pszDir = strdup(pDir); iLen = strlen(pszDir); // LogD("new --- <%s> %s", __FUNCTION__, pszDir); // 创建中间目录 for (i = 1; i < iLen; i++) { if (pszDir[i] == '\\' || pszDir[i] == '/') { pszDir[i] = '\0'; //如果不存在,创建 iRet = access(pszDir,0); if (iRet != 0) { MyLogD("666 --- <%s> %s ", __FUNCTION__, pszDir); iRet = mkdir(pszDir, 0); if (iRet != 0) { return -1; } } //支持linux,将所有\换成/ pszDir[i] = '/'; // LogD("new --- <%s> %s", __FUNCTION__, pszDir); } } // LogD("end 1111 --- <%s> %s", __FUNCTION__, pszDir); //iRet = mkdir(pszDir, 0); free(pszDir); return iRet; } int wirteLuaDataToFile(char * data, int sz, char *fileNamePath){ pthread_mutex_lock(&utils_lock); // char * fileName="/sdcard/DCIM/MyMainPlayer.lua"; //默认会写入到sandbox/0目录下面 MyLogD("<%s> filename=%s-- 1111 --- size:%d", __FUNCTION__, fileNamePath, sz); char *fileName=fileNamePath; FILE *fp; if ((fp = fopen(fileName, "w+")) == NULL){ MyLogD("<%s> filename=%s-- 创建文件失败", __FUNCTION__, fileName); exit(0); } fwrite(data, sizeof(char), sz, fp); fclose(fp); MyLogD("<%s> filename=%s-- 2222 --- size:%d", __FUNCTION__, fileName, sz); pthread_mutex_unlock(&utils_lock); return 0; } void test_dump(char *name, char *buff, int sz){ char *fileName=".lua"; char *dir="/sdcard/DCIM/luaDump_cgamex/"; if(strstr(name, fileName)){ char *newFilePath=(char*)malloc(100); memset(newFilePath,0,100); strcat(newFilePath, dir); strcat(newFilePath, name); MyLogD("new --- <%s> %s", __FUNCTION__, newFilePath); if(strstr(name,"/")){ CreatDir(newFilePath); } wirteLuaDataToFile((char *)buff, sz, newFilePath); free(newFilePath); } } void hexdump(void *data, unsigned int len) { // LogD("%s szTmp=%s",__FUNCTION__,"开始dump"); unsigned int i; unsigned int r, c; char szTmp[4096] = { 0x00 }; if (!data) return; if (len >= 4096) return; for (r = 0, i = 0; r < (len / 16 + (len % 16 != 0)); r++, i += 16) { // sprintf(szTmp, "%08x: ", (int)data+i); /* location of first byte in line */ // LogD("%s szTmp=%08x:",__FUNCTION__,(int)data+i); for (c = i; c < i + 16; c++) /* left half of hex dump */ if (c < len) sprintf(&szTmp[strlen(szTmp)], "%02X ", ((unsigned char *)data)[c]); else sprintf(&szTmp[strlen(szTmp)], " "); /* pad if short line */ for (c = i; c < i + 16; c++) /* ASCII dump */ if (c < len) if (((unsigned char *)data)[c] >= 32 && ((unsigned char *)data)[c] < 127) sprintf(&szTmp[strlen(szTmp)], "%c", ((char const *)data)[c]); else sprintf(&szTmp[strlen(szTmp)], "."); /* put this for non-printables */ // LogD("%s szTmp=%s",__FUNCTION__,szTmp); memset(szTmp, 0x00, 4096); } } char* Jstring2CStr(JNIEnv* env, jstring jstr) { char *rtn = NULL; jclass clsstring = env->FindClass("java/lang/String"); jstring strencode = env->NewStringUTF("utf-8"); jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode); jsize alen = env->GetArrayLength(barr); jbyte *ba = env->GetByteArrayElements(barr, JNI_FALSE); if (alen > 0) { rtn = (char *) malloc(alen + 1); //new char[alen+1]; memcpy(rtn, ba, alen); rtn[alen] = 0; } env->ReleaseByteArrayElements(barr, ba, 0); return rtn; }