LOFTER for ipad —— 让兴趣,更有趣

点击下载 关闭

LOFTER-网易轻博

16进制

217浏览    5参与
栖叶

【PC】16进制编辑器(做个备份)

  • 010editor7.0.2  链接: https://pan.baidu.com/s/1nuKmIO5 密码: 3yie (汉化文件改名替换原版(已破解)来自52破解)注册码分析http://www.52pojie.cn/thread-578380-1-1.html

  • Winhex18.2绿色版   链接: https://pan.baidu.com/s/1jIofclK 密码: 2rnb  (by Menglv大神 -不是最新版但基本够用)


  • 010editor7.0.2  链接: https://pan.baidu.com/s/1nuKmIO5 密码: 3yie (汉化文件改名替换原版(已破解)来自52破解)注册码分析http://www.52pojie.cn/thread-578380-1-1.html

  • Winhex18.2绿色版   链接: https://pan.baidu.com/s/1jIofclK 密码: 2rnb  (by Menglv大神 -不是最新版但基本够用)



栖叶

16进制编辑器Hexeditor3.1.27汉化

新版暂时没空搞  先上个旧版的。

链接: https://pan.baidu.com/s/1nvz3y7B 密码: 2m5w

新版暂时没空搞  先上个旧版的。

链接: https://pan.baidu.com/s/1nvz3y7B 密码: 2m5w

The Nine

delphi编写的载封包

在Windows XP,D7编译测试通过

HOOK.DLL源码

library HOOK;

{ Important note about DLL memory management: ShareMem must be the

  first unit in your library's USES clause AND your project's (select

  Project-View Source) USES clause if your DLL exports any procedures or

  functions that pass...

在Windows XP,D7编译测试通过

HOOK.DLL源码

library HOOK;

{ Important note about DLL memory management: ShareMem must be the

  first unit in your library's USES clause AND your project's (select

  Project-View Source) USES clause if your DLL exports any procedures or

  functions that pass strings as parameters or function results. This

  applies to all strings passed to and from your DLL--even those that

  are nested in records and classes. ShareMem is the interface unit to

  the BORLNDMM.DLL shared memory manager, which must be deployed along

  with your DLL. To avoid using BORLNDMM.DLL, pass string information

  using PChar or ShortString parameters. }


uses

SysUtils,

windows,

Messages,

APIHook in 'APIHook.pas';

type

PData = ^TData;

TData = record

Hook: THandle;

Hooked: Boolean;

end;

var

DLLData: PData;

{------------------------------------}

{过程名:HookProc

{过程功能:HOOK过程

{过程参数:nCode, wParam, lParam消息的相

{ 关参数

{------------------------------------}

procedure HookProc(nCode, wParam, lParam: LongWORD);stdcall;

begin

if not DLLData^.Hooked then

begin

HookAPI;

DLLData^.Hooked := True;

end;

//调用下一个Hook

CallNextHookEx(DLLData^.Hook, nCode, wParam, lParam);

end;

{------------------------------------}

{函数名:InstallHook

{函数功能:在指定窗口上安装HOOK

{函数参数:sWindow:要安装HOOK的窗口

{返回值:成功返回TRUE,失败返回FALSE

{------------------------------------}

function InstallHook(SWindow: LongWORD):Boolean;stdcall;

var

ThreadID: LongWORD;

begin

Result := False;

DLLData^.Hook := 0;

ThreadID := GetWindowThreadProcessId(sWindow, nil);

//给指定窗口挂上钩子

DLLData^.Hook := SetWindowsHookEx(WH_GETMESSAGE, @HookProc, Hinstance, ThreadID);

if DLLData^.Hook > 0 then

Result := True //是否成功HOOK

else

exIT;

end;

{------------------------------------}

{过程名:UnHook

{过程功能:卸载HOOK

{过程参数:无

{------------------------------------}

procedure UnHook;stdcall;

begin

UnHookAPI;

//卸载Hook

UnhookWindowsHookEx(DLLData^.Hook);

end;

{------------------------------------}

{过程名:DLL入口函数

{过程功能:进行DLL初始化,释放等

{过程参数:DLL状态

{------------------------------------}

procedure MyDLLHandler(Reason: Integer);

var

FHandle: LongWORD;

begin

case Reason of

DLL_PROCESS_ATTACH:

begin //建立文件映射,以实现DLL中的全局变量

FHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, $ffff, 'MYDLLDATA');

if FHandle = 0 then

if GetLastError = ERROR_ALREADY_EXISTS then

begin

FHandle := OpenFileMapping(FILE_MAP_ALL_ACCESS, False, 'MYDLLDATA');

if FHandle = 0 then Exit;

end else Exit;

DLLData := MapViewOfFile(FHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);

if DLLData = nil then

CloseHandle(FHandle);

end;

DLL_PROCESS_DETACH:

begin

if Assigned(DLLData) then

begin

UnmapViewOfFile(DLLData);

DLLData := nil;

end;

end;

end;

end;

{$R *.res}

exports

InstallHook, UnHook, HookProc;

begin

DLLProc := @MyDLLHandler;

MyDLLhandler(DLL_PROCESS_ATTACH);

DLLData^.Hooked := False;

end.

'APIHook.pas'源码

unit APIHook;

interface

uses

SysUtils,

Dialogs,

Windows, WinSock;

type

//要HOOK的API函数定义

TSockProc = function (s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;

PJmpCode = ^TJmpCode;

TJmpCode = packed record

JmpCode: BYTE;

Address: TSockProc;

MovEAX: Array [0..2] of BYTE;

end;

//--------------------函数声明---------------------------

procedure HookAPI;

procedure UnHookAPI;

procedure SaveInfo(var buf); stdcall;

function recvout(var Rbuf;RLen:Integer):Integer;

var

OldSend, OldRecv: TSockProc; //原来的API地址

JmpCode: TJmpCode;

OldProc: array [0..1] of TJmpCode;

AddSend, AddRecv: pointer; //API地址

TmpJmp: TJmpCode;

ProcessHandle: THandle;

implementation

procedure SaveInfo(var buf); stdcall;

var

  f: file;

  FileName:string;

begin

  {保存为文件信息}

  FileName:='c:\test.txt';

  assignfile(f, FileName);

  closefile(f);

end;

function recvout(var Rbuf;RLen:Integer):Integer;

Var

buf1:pchar;

i:integer;

ss:string;

Begin

buf1:=@Rbuf;

for i:=1 to Rlen do

    Begin

      ss:=ss+inttohex(byte(buf1^),2)+' ';

      buf1:=buf1+1;

    End;

ShowMessage('封包内容[16进制]:'+ss);

ShowMessage('发送封包长度:'+inttostr(Rlen));

End;

{---------------------------------------}

{函数功能:Send函数的HOOK

{函数参数:同Send

{函数返回值:integer

{---------------------------------------}

function MySend(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;

var

dwSize: cardinal;

begin

//这儿进行发送的数据处理

MessageBeep(1000); //简单的响一声

recvout(Buf,len);

//SaveInfo(Buf);

//调用直正的Send函数

WriteProcessMemory(ProcessHandle, AddSend, @OldProc[0], 8, dwSize);

Result := OldSend(S, Buf, len, flags);

JmpCode.Address := @MySend;

WriteProcessMemory(ProcessHandle, AddSend, @JmpCode, 8, dwSize);

end;

{---------------------------------------}

{函数功能:Recv函数的HOOK

{函数参数:同Recv

{函数返回值:integer

{---------------------------------------}

function MyRecv(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;

var

dwSize: cardinal;

begin

//这儿进行接收的数据处理

MessageBeep(1000); //简单的响一声

//调用直正的Recv函数

WriteProcessMemory(ProcessHandle, AddRecv, @OldProc[1], 8, dwSize);

Result := OldRecv(S, Buf, len, flags);

JmpCode.Address := @MyRecv;

WriteProcessMemory(ProcessHandle, AddRecv, @JmpCode, 8, dwSize);

end;

{------------------------------------}

{过程功能:HookAPI

{过程参数:无

{------------------------------------}

procedure HookAPI;

var

DLLModule: THandle;

dwSize: cardinal;

begin

ProcessHandle := GetCurrentProcess;

DLLModule := LoadLibrary('ws2_32.dll');

AddSend := GetProcAddress(DLLModule, 'send'); //取得API地址

AddRecv := GetProcAddress(DLLModule, 'recv');

JmpCode.JmpCode := $B8;

JmpCode.MovEAX[0] := $FF;

JmpCode.MovEAX[1] := $E0;

JmpCode.MovEAX[2] := 0;

ReadProcessMemory(ProcessHandle, AddSend, @OldProc[0], 8, dwSize);

JmpCode.Address := @MySend;

WriteProcessMemory(ProcessHandle, AddSend, @JmpCode, 8, dwSize); //修改Send入口

ReadProcessMemory(ProcessHandle, AddRecv, @OldProc[1], 8, dwSize);

JmpCode.Address := @MyRecv;

WriteProcessMemory(ProcessHandle, AddRecv, @JmpCode, 8, dwSize); //修改Recv入口

OldSend := AddSend;

OldRecv := AddRecv;

end;

{------------------------------------}

{过程功能:取消HOOKAPI

{过程参数:无

{------------------------------------}

procedure UnHookAPI;

var

dwSize: Cardinal;

begin

WriteProcessMemory(ProcessHandle, AddSend, @OldProc[0], 8, dwSize);

WriteProcessMemory(ProcessHandle, AddRecv, @OldProc[1], 8, dwSize);

end;

end.

测试代码

procedure TForm1.Button1Click(Sender: TObject);

var

  MOduleHandle:THandle;

  TmpWndHandle:THandle;

begin

  TmpWndHandle:=0;

  //TmpWndHandle:=FindWindow('IEFrame', nil);

  TmpWndHandle:=FindWindowA(nil,'《风云online》');

 

  if not IsWindow(TmpWndHandle) then

  begin

    MessageBox(Self.Handle,'没有找到窗口','!!',MB_OK);

    Exit;

  end;

  MOduleHandle:=LoadLibrary('HOOK.dll');

  @InstallHook:=GetProcAddress(MOduleHandle,'InstallHook');

  @UnHook:=GetProcAddress(MOduleHandle,'UnHook');

  if InstallHook(FindWindowA(nil,'《风云online》')) then

  ShowMessage('Hook OK');

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

UnHook;

end;

wuzhensong

C# 16进制与字符串、字节数组之间的转换

1.请问c#中如何将十进制数的字符串转化成十六进制数的字符串

//十进制转二进制
Console.WriteLine("十进制166的二进制表示: "+Convert.ToString(166, 2));
//十进制转八进制
Console.WriteLine("十进制166的八进制表示: "+Convert.ToString(166, 8));
//十进制转十六进制
Console.WriteLine("十进制166的十六进制表示: "+Convert.ToString(166, 16));
   
//二进制转十进...

1.请问c#中如何将十进制数的字符串转化成十六进制数的字符串

//十进制转二进制
Console.WriteLine("十进制166的二进制表示: "+Convert.ToString(166, 2));
//十进制转八进制
Console.WriteLine("十进制166的八进制表示: "+Convert.ToString(166, 8));
//十进制转十六进制
Console.WriteLine("十进制166的十六进制表示: "+Convert.ToString(166, 16));
   
//二进制转十进制
Console.WriteLine("二进制 111101 的十进制表示: "+Convert.ToInt32("111101", 2));
//八进制转十进制
Console.WriteLine("八进制 44 的十进制表示: "+Convert.ToInt32("44", 8));
//十六进制转十进制
Console.WriteLine("十六进制 CC的十进制表示: "+Convert.ToInt32("CC", 16));

2.在串口通讯过程中,经常要用到 16进制与字符串、字节数组之间的转换
private string StringToHexString(string s,Encoding encode)
        {
            byte[] b = encode.GetBytes(s);//按照指定编码将string编程字节数组
            string result = string.Empty;
            for (int i = 0; i < b.Length; i++)//逐字节变为16进制字符,以%隔开
            {
                result += "%"+Convert.ToString(b[i], 16);
            }
            return result;
        }
        private string HexStringToString(string hs, Encoding encode)
        {
            //以%分割字符串,并去掉空字符
            string[] chars = hs.Split(new char[]{'%'},StringSplitOptions.RemoveEmptyEntries);
            byte[] b = new byte[chars.Length];
            //逐个字符变为16进制字节数据
            for (int i = 0; i < chars.Length; i++)
            {
                b[i] = Convert.ToByte(chars[i], 16);
            }
            //按照指定编码将字节数组变为字符串
            return encode.GetString(b);
        } 


        /// <summary>
        /// 字符串转16进制字节数组
        /// </summary>
       /// <param name="hexString"></param>
        /// <returns></returns>
        private static byte[] strToToHexByte(string hexString)
        {
             hexString = hexString.Replace(" ", "");
           if ((hexString.Length % 2) != 0)
                 hexString += " ";
            byte[] returnBytes = new byte[hexString.Length / 2];
            for (int i = 0; i < returnBytes.Length; i++)
                returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
            return returnBytes;
         }


/// <summary>
        /// 字节数组转16进制字符串
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string byteToHexStr(byte[] bytes)
       {
            string returnStr = "";
            if (bytes != null)
            {
                for (int i = 0; i < bytes.Length; i++)
                {
                     returnStr += bytes[i].ToString("X2");
                 }
             }
            return returnStr;
         }

 


/// <summary>
        /// 从汉字转换到16进制
        /// </summary>
        /// <param name="s"></param>
        /// <param name="charset">编码,如"utf-8","gb2312"</param>
        /// <param name="fenge">是否每字符用逗号分隔</param>
       /// <returns></returns>
        public static string ToHex(string s, string charset, bool fenge)
        {
            if ((s.Length % 2) != 0)
            {
                 s += " ";//空格
                //throw new ArgumentException("s is not valid chinese string!");
             }
             System.Text.Encoding chs = System.Text.Encoding.GetEncoding(charset);
            byte[] bytes = chs.GetBytes(s);
            string str = "";
            for (int i = 0; i < bytes.Length; i++)
            {
                str += string.Format("{0:X}", bytes[i]);
                if (fenge && (i != bytes.Length - 1))
                {
                     str += string.Format("{0}", ",");
                 }
             }
            return str.ToLower();
         }


///<summary>
        /// 从16进制转换成汉字
        /// </summary>
        /// <param name="hex"></param>
        /// <param name="charset">编码,如"utf-8","gb2312"</param>
       /// <returns></returns>
        public static string UnHex(string hex, string charset)
        {
           if (hex == null)
                throw new ArgumentNullException("hex");
             hex = hex.Replace(",", "");
             hex = hex.Replace("\n", "");
             hex = hex.Replace("\\", "");
             hex = hex.Replace(" ", "");
            if (hex.Length % 2 != 0)
            {
                 hex += "20";//空格
             }
            // 需要将 hex 转换成 byte 数组。
            byte[] bytes = new byte[hex.Length / 2];

           for (int i = 0; i < bytes.Length; i++)
            {
                try
                {
                    // 每两个字符是一个 byte。
                     bytes[i] = byte.Parse(hex.Substring(i * 2, 2),
                     System.Globalization.NumberStyles.HexNumber);
                 }
                catch
                {
                    // Rethrow an exception with custom message.
                    throw new ArgumentException("hex is not a valid hex number!", "hex");
                 }
             }
             System.Text.Encoding chs = System.Text.Encoding.GetEncoding(charset);
            return chs.GetString(bytes);
         }
往事如烟

JS正则:16进制颜色值

/^#[0-9a-fA-F]{3,6}$/


同步自网易博客 (查看原文)

/^#[0-9a-fA-F]{3,6}$/


同步自网易博客 (查看原文)

LOFTER

让兴趣,更有趣

简单随性的记录
丰富多彩的内容
让生活更加充实

下载移动端
关注最新消息