|
[讨论]来个简单题目,看哪位兄弟写的最好!
VC6,位数不限(不过当然要求输入和输出值都小于2的32次方),从最高位开始转换 #pragma optimize("",off) unsigned int reva(unsigned int a) { unsigned int f2=1000000000; unsigned int f1=1; return (((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10))&&((!(a/f2))&&(f2/=10)&&(f1*=10)))*0+((f1=f2)*0+(f2=1)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1+(f1/=10)*0+(f2*=10)*0+((a/f2)%10)*f1); } int main(int argc, char* argv[]) { printf("%u %u %u\r\n",reva(1234567893),reva(12345),reva(0)); return 0; } 输出: 3987654321 54321 0 Press any key to continue |
|
[求助]各位大虾,推荐一个写驱动集成开发环境
[QUOTE=qdk;296003]以前下载了个DDK,装上以后都不知道从那里下手,编辑器都找不到因此作罢了QUOTE] 当初我学驱动时也是遇到这种尴尬 我觉得学习的话还是DDK+VC好一些,就象WIN32编程虽然可以MFC,但还是要从SDK学起 新版的DDK里没有编辑器,一般是用VC写CPP文件,然后在那个目录里建个Sources,把开始菜单里Build Environment的相应控制台图标拖进去,然后把Makefile文件也复制进去,在控制台里把目录cd到当前文件夹然后打build就可以编译了。也还算方便,关键你要写个Sources文件,然后Build Environment那个快捷方式目标后面加个“&& cd 当前目录”这样点开来打个build就可以了 我驱动时写的一个小程序,照kmdkit那教程写的,DDK编译时要把Win XP Checked Build Environment.lnk里目录改成你的目录 |
|
各位大虾,编写驱动的问题
楼上说的对,你关驱动时没有停止服务(ControlService,SERVICE_CONTROL_STOP),所以这个服务还存在,下在再CreateService时就ERROR_SERVICE_EXISTS错误了 我写的一段动态加载sys的代码,你可以看看 int loadsys(char*p) { char syspath[MAX_PATH]; char srvname[MAX_PATH]; p=getword(p,syspath); p=getword(p,srvname); if(!*syspath)return 0; if(!*srvname)return 0; char path[MAX_PATH]; GetCurrentDirectory(MAX_PATH,path); strcat(path,syspath); msgoutf("try load %s...\r\n",path); SC_HANDLE hSCManager; SC_HANDLE hService; hSCManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); if(!hSCManager)return msgoutf("can't OpenSCManager[err=%d]\r\n",GetLastError()); hService=CreateService( hSCManager, srvname, "helper sys load by injector", SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, path, NULL,NULL,NULL,NULL,NULL); if(!hService)return msgoutf("can't CreateService[err=%d]\r\n",GetLastError()); ret=StartService(hService,0,NULL); if(!ret)msgoutf("can't StartService[err=%d]\r\n",GetLastError()); CloseServiceHandle(hSCManager); CloseServiceHandle(hService); return 1; } int unloadsys(char*p) { char srvname[MAX_PATH]; p=getword(p,srvname); if(!*srvname)return 0; msgoutf("try stop service %s...\r\n",srvname); SC_HANDLE hSCManager; SC_HANDLE hService; hSCManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); if(!hSCManager)return msgoutf("can't OpenSCManager[err=%d]\r\n",GetLastError()); hService=OpenService(hSCManager,srvname,SERVICE_ALL_ACCESS); if(!hService)return msgoutf("can't OpenService[err=%d]\r\n",GetLastError()); SERVICE_STATUS ss; ret=ControlService(hService,SERVICE_CONTROL_STOP,&ss); if(!ret)msgoutf("can't stop service, !ControlService[err=%d]\r\n",GetLastError()); ret=DeleteService(hService); if(!ret)msgoutf(msg,"can't DeleteService[err=%d]\r\n",GetLastError()); CloseServiceHandle(hService); CloseServiceHandle(hSCManager); return 1; } |
|
[求助]!!!高分求助 VC++ 中怎样从同一工程的另一个文件中获取静态全局变量或静态函数,实现对其访问
呃。。莫非你只能写一个CPP,其他的都不能碰? 如果只是针对某个特定情况的话,可以搜索进程空间,结合某些内存特征分析出来 |
|
[求助]!!!高分求助 VC++ 中怎样从同一工程的另一个文件中获取静态全局变量或静态函数,实现对其访问
我的意思就是 你非要在其他CPP里访问static变量,从语法角度看当然是不行的 但是你可以改变VC对这些语法的解释 比如,逆向一下VC改变它的编译流程,呵呵,当然这是几乎不可能的 或者,写一个CL.exe替换VC的CL.exe,IDE编译C++时就会调用你写的CL.exe 这样你就有机会在编译之前对原代码进行处理,即可修改static的语义解释 当然这么做比较粗暴,VC已经提供了一个优美的方案,就是Custom Build,允许你自己控制编译过程 你可以打开Project Settings看,点一个CPP,在General里选上Always use custom build step 这样旁边就会Custom Build标签页,在里面你可以自己设定用哪个程序来编译这个CPP 所以,可以写一个程序,首先复制此CPP到临时目录,然后修改,然后调用CL.exe来编译它 如此以来你可以对语法重新解释,配合lex&yacc完全可以实现你自己喜欢的语法风格 举个例子,C语法不支持二进制数的代码表示,但是可以写个程序分析这个CPP,把0b11001010改成0xCA,然后调用CL.exe编译,用yacc的话这不是什么困难的事,这样就可以在VC的基础上扩展自己喜欢的语法 不过我不清楚你是在何种情况下需要访问另一CPP的static变量,不知道这种方式是否合适? 此外以上纯属猜想,我并未实验过 |
|
[求助]!!!高分求助 VC++ 中怎样从同一工程的另一个文件中获取静态全局变量或静态函数,实现对其访问
非要实现这样的功能也不是不可以,Custom Build,写一个程序去调用CL.exe,在编译前当然就可以做点想做的事,比如用lex&yacc写个脚本简单分析下语法,然后改改代码再编译,这样可以搞个自己喜欢的语法风格出来 |
|
能推荐几本关于缓冲区溢出方面的书么?
传说中的“溢经”――《网络渗透技术》 |
|
想问个学习问题
只要搞清楚CPU的大致结构(寄存器,内存,堆栈。。)并且找到一本适用的指令手册(推荐罗云彬hume翻译那本书后面那个以及intelmunual),并且知道如何使用这个手册,就可以学WIN32汇编了 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值