Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25815 Location: The netherlands
|
Posted: Tue Oct 23, 2018 7:24 am Post subject: |
|
|
Try:
| Code: |
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(PREFEREDALIGNMENT,4)
TypeName:
db '3 Byte Big Endian',0
PREFEREDALIGNMENT:
db 1
ByteSize:
dd 3
//The convert routine should hold a routine that converts the data to an integer (in eax)
//function declared as: stdcall int ConvertRoutine(unsigned char *input);
//Note: Keep in mind that this routine can be called by multiple threads at the same time.
ConvertRoutine:
//jmp dllname.functionname
[64-bit]
//or manual:
//parameters: (64-bit)
//rcx=address of input
xor eax,eax
//aa bb cc -> 0xaabbcc
//0 1 2
//(0xaabb << 8)->0xaabb00
mov ah,[rcx+0]
mov al,[rcx+1]
shl eax,8
mov al,[rcx+2]
ret
[/64-bit]
[32-bit]
//jmp dllname.functionname
//or manual:
//parameters: (32-bit)
push ebp
mov ebp,esp
//[ebp+8]=input
//example:
push ecx
mov ecx,[ebp+8] //place the address that contains the bytes into eax
xor eax,eax
mov ah,[ecx+0]
mov al,[ecx+1]
shl eax,8
mov al,[ecx+2]
pop ecx
pop ebp
ret 4
[/32-bit]
//The convert back routine should hold a routine that converts the given integer back to a row of bytes (e.g when the user wats to write a new value)
//function declared as: stdcall void ConvertBackRoutine(int i, unsigned char *output);
ConvertBackRoutine:
//jmp dllname.functionname
//or manual:
[64-bit]
//parameters: (64-bit)
//ecx=input
//rdx=address of output
//example:
//0xaabbcc-> aa bb cc
// chcl
mov [rdx+2],cl
mov [rdx+1],ch
shr ecx,8
mov [rdx+0],ch
ret
[/64-bit]
[32-bit]
//parameters: (32-bit)
push ebp
mov ebp,esp
//[ebp+8]=input
//[ebp+c]=address of output
//example:
push eax
push ebx
mov eax,[ebp+8] //load the value into eax
mov ebx,[ebp+c] //load the address into ebx
//convert the value to big endian
mov [ebx+2],al
mov [ebx+1],ah
shr eax,8
mov [ebx],ah
pop ebx
pop eax
pop ebp
ret 8
[/32-bit]
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|