-
-
[求助]移位算法实现请教
-
发表于: 2018-1-2 13:38 2729
-
#include<stdio.h>
#include<Windows.h>
void log_hex_2_hexstring(const char *title, unsigned char *buf, size_t len){
size_t i;
printf("%s\n", title);
for (i = 0; i < len; i++)
printf("%c%c", "0123456789ABCDEF"[buf[i] / 16],
"0123456789ABCDEF"[buf[i] % 16]);
printf("\n");
}
unsigned char mac[8] ={ 0xd4, 0xbe, 0xd9, 0x79, 0x52, 0xeb };
unsigned char out[8] ={};
//#define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff))
//#define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
//#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
//#define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
#define QWORD_HI(x) ((UINT32)((UINT64)(x) >> 32))
#define QWORD_LO(x) ((UINT32)((UINT64)(x)& 0xFFFFFF))
#define DWORD_HI(x) ((unsigned short)((unsigned long)(x) >> 16)) //0x12345678 DWORD_HI 0x1234
#define DWORD_LO(x) ((unsigned short)((unsigned long)(x)& 0xFFFF)) //0x12345678 DWORD_OL 0x5678
#define WORD_HI (x) ((byte)((unsigned short)(x) >> 8)) //0x12345678 WORD_HI 0x56
#define WORD_LO (x) ((byte)((unsigned short)(x)& 0xFF)) //0x12345678 WORD_LO 0x78
#define BYTE_HI (x) ((byte)((byte)(x) >> 4)) //0x12345678 BYTE_HI 0x7
#define BYTE_LO (x) ((byte)((byte)(x)& 0xF)) //0x12345678 BYTE_LO 0x8
#define A(x) ((byte)((byte)(x) >> 4))
#define B(x) ((byte)((byte)(x) << 4))
//#define C(x) ((byte)((byte)(x)& 0xF))
int main(){
char temp = 0;
//_asm {
// pushad
// pushfd
// xor eax,eax
// mov al,0x0d
// SHL al, 4//交换位
// popfd
// popad
//}
for (size_t i = 0; i < 12; i++)
{
temp = mac[i]; //0xd4, 0xbe, 0xd9, 0x79, 0x52, 0xeb, 0x00, 0x00 原始
out[i] = A(temp); //0d //0xe0, 0x52, 0x79, 0x19, 0xfb, 0x52, 0x03, 0x00 输出 //WORD_LO (x) ((byte)((unsigned short)(x)& 0xF))
temp = out[i];
out[i] = B(temp);//d0
//怎么接着填充低位?
//上面是out[0]
//out[1]=04-->40-->填充out[0]低位d 0的0位40并且取消0 = d4
//sleep 到 0x79 的时候 out[0] 和out[5]均变化: 0xe0 0x52 0x19 0xfb 0x52 0x03 这里看不懂
//0xd4, 0xbe, 0xd9, 0x79, 0x52, 0xeb, 0x00, 0x00 原始
//0d
//d0
//0d0
//0d04
//0d40
//00d40b
//00d4d0
//00d40d
//000d4d00e
//000d4d0e0
//0000d4d0e0d
//.........0x79 0xd4改变 0x52, 0xeb, 0x00, 0x00也变
//0xe0, 0x52, 0x79, 0x19, 0xfb, 0x52, 0x03, 0x00 正确输出
}
log_hex_2_hexstring("kk", out, sizeof out);
system("pause");
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
- [求助]求职 34551
- [讨论]请教下win10 20分钟左右自动嗝屁ept 5138
- [讨论]win10教育版禁止加载驱动程序 5672
- [求助]寻实现算法 4895
- [求助]移位算法实现请教 2730
看原图
赞赏
雪币:
留言: