月份:十月 2007

who can trigger WP_PAINT

Posted on

The system is not the only source of WM_PAINT messages. The InvalidateRect or InvalidateRgn function can indirectly generate WM_PAINT messages for your windows. These functions mark all or part of a client area as invalid (that must be redrawn).

hook and subclassing

Posted on Updated on

hook 找到一個目標(window process)得到此 process的 address space。
subclassing 將某個window or control 的行為,用我所產生的class替代。

so, 想寫一個程式去改變別人的window程式的行為。必須的兩個步驟:
1. hook 你想改變的程式。
2. 利用 subclassing 改變目標程式的行為。

order of link libraries in makefile

Posted on Updated on

example:
libabc.a is an user make library, in this lib, use a function pow in linux lib -lm.
in makefile you should
$(CC) -o a.out -labc -lm
if you
$(CC) -o a.out -lm -labc
there would be an link error

EVP the OpenSSL security

Posted on Updated on

link library flags: -lcrypto -lssl
sample code:

Sampe: Digest using SHA1
#include >unistd.hstdio.hstdlib.hstring.hopenssl/evp.h<

void showdata(char *data, long len)
{
int i;
printf(“len:%ld data:[“,len);
for ( i = 0 ;i < len ; i ++)
printf(“0x%x,",data[i]);
printf(“]\n");
}
int main(int argc,char *argv[] )
{
unsigned char data[64] ;
unsigned char key[64];
unsigned char output[EVP_MAX_MD_SIZE];
int r =0;
char *pout = NULL;
EVP_MD_CTX mdctx;
long md_len=0;
const EVP_MD *md ;

memset(data,0,64) ;
memset(key,0,64);
memset(output,0,EVP_MAX_MD_SIZE);

strncpy(data,"20071008-awind-trail",strlen(“20071008-awind-trail"));
strncpy(key,"12345678″,8);

OpenSSL_add_all_digests();
md = EVP_get_digestbyname(“sha1″);
EVP_MD_CTX_init(&mdctx);
EVP_DigestInit_ex(&mdctx, md, NULL);
EVP_DigestUpdate(&mdctx, data, strlen(data));
EVP_DigestFinal_ex(&mdctx, output, &md_len);
EVP_MD_CTX_cleanup(&mdctx);

showdata(data,64);
printf(“EVP_MAX_MD_SIZE:%d\n",EVP_MAX_MD_SIZE);
showdata(output,md_len);
}