RE: Kernel32.dll Beep Function 04-26-2013, 03:36 AM
#6
I imrpoved the byte code a bit by splitting the register into a 16 bit portion to hold the smaller integer value. This trims off the 0x0's effectively, which is a good thing, and because the params given will probably never be up to the size of a 32 bit (4 byte) integer value, there's no need for it. I thought of storing the full value in a register, and then pushing the high and low off on the stack separately before, which should work. Unless I go with higher values. 8 bits is really small though... So unless I'm dealing with really small values, it would be stupid to do that.
I could have probably even utilized some bitshifting tricks to get rid of some 0x0's... This is good enough though, a value such as 0x3E8 is a bit too big for an 8 bit storage space however, so 16 bits was the next step up.
Anyways here's what I came up with:
Which would be:
And all works fine, no 0x0's. The above byte code is with one added byte for the return, in addition to the instructions from the above C++ code. I'm getting tired of having to find the address of the function each time though, although it makes things a bit simpler once you have the address... I would like to create a more "universal" revision.
I could have probably even utilized some bitshifting tricks to get rid of some 0x0's... This is good enough though, a value such as 0x3E8 is a bit too big for an 8 bit storage space however, so 16 bits was the next step up.
Anyways here's what I came up with:
Code:
__asm
{
mov ecx, dword ptr 0x755631AF
xor eax, eax
mov ax, 0x320
push eax
mov ax, 0x450
push eax
call ecx
}Which would be:
Code:
0xB9 0xAF 0x31 0x56 0x75 0x33 0xC0 0x66 0xB8 0x20 0x03 0x50 0x66 0xB8 0x50 0x04 0x50 0xFF 0xD1 0xC3​And all works fine, no 0x0's. The above byte code is with one added byte for the return, in addition to the instructions from the above C++ code. I'm getting tired of having to find the address of the function each time though, although it makes things a bit simpler once you have the address... I would like to create a more "universal" revision.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)