TEA Source Code

Here is source code for the Tiny Encryption Algorithm in a variety of forms:ANSI Cvoid encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k){ register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9, a=k[0],b=k[1],c=k[2],d=k[3],n=32; ...
基础知识 | 2010-07-23 00:20 | 阅读 1620 次 | 评论 3 条

vc下调试activex控件

vc下调试activex控件 在vc下调试activex控件.出现了First-chance exception in xxx.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.异常. 实际上在vc下一般利用TSTCON32.EXE调试控件.目前我的程序底层封装成dll.留接口给ocx调用.这里在你按F5调式ocx的时候,一般会选择调试方式.选择TSTCON32.EXE去调试控件. 出现问题最终解决了,是我没有把动态库和ocx放在同一个目录下.导致ocx不...
技术 | 2010-07-19 00:18 | 阅读 8123 次 | 评论 1 条

windowsx.h 和windows.h的区别

WINDOWSX.H 头文件为W32SDK的程序员提供方便(工具?)很多初中级程序员用C/C++编写Windwos API的程序时,经常面对面条式的switch...case语句块当你在Window过程(回调函数、下称过程)中加入大量诸如 WM_COMMAND or WM_CHAR的消息捕获时。真是一场噩梦。关于上千行代码的Window过程的问题,随着 C/C++ 7.0 编译器和Windows SDK for Windows 3.1发行时带的一个头文件而被解决。这个头文件 是<windowsx.h> 以及所包含的大量的有用的宏。
经验 | 2010-07-17 00:33 | 阅读 1693 次 | 评论 0 条

puts 与 write 的关系

#include <stdio.h>#include <io.h>int main( int ac, char **av ){ char str[] = "hello world.\n"; //write( (int)stdout, str, strlen(str)); write( 1, str, strlen(str)); return 0;}puts(buffer)与write( 1, buffer, strlen(buffer)) 具有等效的功能。
技术 | 2010-07-16 23:53 | 阅读 1569 次 | 评论 0 条

Linux下线程的挂起和恢复

Linux下线程的挂起和恢复 POSIX的Linux操作系统没有提供线程挂起和恢复的例程,在网上找了找,看到一个老外写的程序,感觉想法不错,放在这里大家分享一下。理 论上应该可以实现,不过我没有试,给大家提供一个参考。 (在读取缓存里的数据时,当缓存中没有数据最好把 线程挂起)void CPrcThread <Worker>::suspend() { ifdef WIN32 //do windows specific things here... #endif #ifdef __linux__ p...
技术 | 2010-07-10 00:04 | 阅读 1728 次 | 评论 0 条

makefile 编译多文件程序实例

原始版本:CC=gccsources=log.c u_socket.c u_task.cobjects=log.o u_socket.o u_task.o include_dirs= CFLAGS=$(include_dirs) -O0 -DU_OS=OS_LINUXall: $(objects) u_tasklog.o: log.c $(CC) -c $(CFLAGS) $< -o $@ u_socket.o: u_socket.c $(CC) -c $(CFLAGS) $< -o $@ u_task.o: u_task.c $(CC) -c ...
经验 | 2010-07-09 23:37 | 阅读 1955 次 | 评论 1 条

对Windows和Linux的Socket进一步封装

呵呵,昨天对Windows下的Socket API进行了简单的封装,今天趁热打铁把Linux下的Socket也一起封装了到了一个类中,相比昨天的那个类,只是做了少些修改,增加了一些宏,废话 不多说了,看下面代码,(顺便带上一个简单的聊天代码Linux和Windows对聊的)。如果用C++的异常对出错进行处理就更好了,呵呵,有时间在添 加上^_^////////////////////////////////////////////////////////////////////////////////////////////////////////////////////...
技术 | 2010-07-04 03:15 | 阅读 3106 次 | 评论 0 条

Thread ID 和 Thread Handle 的区别

在Windows程序设计中,句柄是无法精确定义的术语。随便找一个高手,让他 给你讲讲句柄是什么,恐怕他都很难给你一个具体的定义来。 在Windows程序设计中,句柄无所不在,窗口有窗口的句柄HWND,线程和进程也有句柄HANDLE,甚至有人把套接字也称为句柄(我就是这样的)。 句柄在英文中是handle,作为动词讲是处理的意思。简而言之,句柄是处理对象的一个接口,对于程序中所涉及的对象,你可以通过句柄去操作他。你不应该 试图去回答句柄是什么,而应该从务虚的角度去理解他,知道他干什么即可。 有人说,因为handle的定义是void *,因此他是一个指针。有些熟悉内...
基础知识 | 2010-07-03 16:10 | 阅读 7908 次 | 评论 2 条

把 n 用m 进制显示

#include <stdio.h>// #include <WATLIB.H> 测试表明lib库不通用//#include <vcLIB.H>typedef char BOOL ;typedef unsigned char UCHAR8 ;#define NUM 10void PN(int n,int m) /* 把 n 用m 进制显示 */{ char temp[10]={0}; int i=0; do { temp[i] = n%m; i++; n /= m; }while(n>0); for(i -...
编码 | 2010-07-03 00:15 | 阅读 1349 次 | 评论 1 条

VC 下的汇编实例

汇编一void func() { goto C_Dest; /* 合法 */ //goto c_dest; /* 错误 */ goto A_Dest; /* 合法 */ goto a_dest; /* 合法 */ __asm { JMP C_Dest ; 合法 ;JMP c_dest ; MSDN上说合法,但是我在VS.NET中编译,认为这样不合法 JMP A_Dest ; 合法 JMP a_dest ; 合法 ...
汇编 | 2010-07-02 23:04 | 阅读 1878 次 | 评论 1 条

字符字串替换

#include <stdio.h>//#include <string.h>#include <string>char* source = "sdabcs";int main(){ std::string cc; char dec[100]={0}; int i ; char *pstr = source,*pstr1=source; printf("%s\n",source); for (i=0;i<(strlen(source)-2);i++) { printf("%d,%s\n",strncmp( pstr,"abc",3)...
编码 | 2010-07-02 20:14 | 阅读 1511 次 | 评论 0 条

C ++ 中类赋初值的方法

#include "dd.h"#include <iostream.h>class A {private: const int x; enum { num =10}; static int y,z; int arr[num];public: A (int val = 0):x(val) { for (int i=0;i<x;i++) { arr[i] = i; } cout<<"static value1 A::y = "<<y<<endl; y = 0...
基础知识 | 2010-07-02 20:11 | 阅读 1540 次 | 评论 5 条

template 模板使用

#include <string>template <typename T>inline T const&amp; max(T a,T b){ return a<b?b:a;}int main(){ std::string s; const char *a1="apple",*a2="peach"; const char aa1[]="apple",aa2[]="peacha"; ::max(a1,a2); ::max(aa1,aa2); ::max("apple","peach"); ::max("apple","peacha"); ...
技术 | 2010-07-02 19:56 | 阅读 1963 次 | 评论 0 条

BSD Sockets 对比 Winsock

BSD Sockets Compatibility by Warren Young So you say you’re a long-time Unix hacker who’s new to Windows programming? And you’ve heard of this great API called Winsock that’s compatibile with your beloved BSD sockets, but try as you might, you just can’t find the readv() call? Well bunk...
技术 | 2010-07-02 19:34 | 阅读 1958 次 | 评论 1 条

测试文件读取模式(用于程序优化)

/**************************************************\* Functions developed by zhong yunde. ** filename : test_readfile.cpp ** creat time : 2008/05/08 ** 功能:测试文件读取模式(用于程序优化) *\************************************************...
技术 | 2010-07-02 01:07 | 阅读 1667 次 | 评论 0 条

线程也能阻塞 accept

UINT ThreadProc(LPVOID pPara) { Info *fo; fo = (Info*)pPara; int nSize = sizeof(fo-> server); SOCKET s = accept(fo-> s, (sockaddr*) &amp;fo-> server,&amp;nSize); char buffer[100]; ZeroMemory(buffer,100); recv(s, buffer,100,0); AfxMessageBox(buffer); retur...
基础知识 | 2010-07-01 09:48 | 阅读 1531 次 | 评论 1 条

实现了一个文件树遍历小程序

// 其实算是抄书上的,ft// printdir.c#include <unistd.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <dirent.h>void printdir(char *dir, int depth);int main(int argc, char *argv[]){ if (argc!=2) { printf("usage: printdir [path]"); retur...
技术 | 2010-06-28 06:05 | 阅读 1773 次 | 评论 0 条

编程之修改文件修改时间的程序

 一次偶然挂马。用了好多IIS挂马,ISAPI,文件重定向挂马方法,不久后被管理员KILL。无奈只能用原始方法,因此,修改文件修改时间是必要的,管理员也因此用这个查。虽然海洋ASP木马上有这个功能,但经过测试,有的时候不行(原因不明,估计是权限问题),所以自己尝试写了这么个软件,代码如下: #include "stdafx.h" #include "windows.h" #include "iostream.h" #include "stdlib.h" int main(int argc, char* argv[]) { if (argc =...
技术 | 2010-06-28 06:01 | 阅读 1499 次 | 评论 0 条

pc-lint 安装排错

PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software 1985-2007 error 314: (Error -- Previously used .lnt file: lnt\env-vc6.lnt)意味着lnt\env-vc6.lnt文件的检测顺序出错 ,看到vc的customize对pclint参数配置-u std.lnt lnt\env-vc6.lnt "$(FilePath)$(FileExt)",然而std.lnt文件中又定义lnt\lib-mfc.lntlnt\lib-w32.lntlnt\co-m...
技术 | 2010-06-27 11:51 | 阅读 4223 次 | 评论 0 条

ASCII 码 对照表

# Updated versions of this file may be found in:# <ftp://ftp.unicode.org/Public/MAPPINGS/>## Any comments or problems, contact http://www.unicode.org/reporting.html#0x00 0x0000 # NULL # <NUL> ISO6460x01 0x0001 # START OF HEADING # <SOH> ISO6460x02 0x0002 # START OF TEXT # <STX> ISO64...
基础知识 | 2010-06-26 00:01 | 阅读 2461 次 | 评论 0 条
浏览1942855次