|
-
May 26th, 2011, 10:10 PM
#5
Re: helo on converting some c++ codes into assembly
thanks 
im using Masm 6.14 .
------------
i generated an assembly source code out of my c++ project using visual studio
but i have couple of problems with compiling the asm source code.
the first one is there is a listing.inc file missing ! i dont know where to get it or how to make one !
visual studio made the source code and i have no idea where that came from!
the second problem is that i dont know what those wierd looking symbols mean! i would appreciate anyone helping me on figuring these weird symbols 
and finally this is the C++ code and its asm counter part :
C++:
Code:
#include <windows.h>
void SetKey( BOOL bState,int keyID )
{
BYTE keyState[256];
GetKeyboardState((LPBYTE)&keyState);
if( (bState && !(keyState[keyID] & 1)) || (!bState && (keyState[keyID] & 1)) )
{
keybd_event( keyID,0x45,KEYEVENTF_EXTENDEDKEY | 0,0 );
// Simulate a key release
keybd_event( keyID,0x45,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
}
}
int main()
{
while (true)
{
SetKey(TRUE,20);//capsluck
SetKey(TRUE,144);//numluck
SetKey(TRUE,145);//scrolluck
for(int i = 0; i < 99999999;i++);
SetKey(FALSE,20);//capsluck
SetKey(FALSE,144);//numluck
SetKey(FALSE,145);//scrolluck
for(int i = 0; i < 99999999;i++);
}
return 0;
}
and the generated asm source code :
Code:
; Listing generated by Microsoft (R) Optimizing Compiler Version 15.00.21022.08
TITLE d:\Documents and Settings\Master\Desktop\eli asm\cpp\CAPS\CAPS\main.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES
PUBLIC __$ArrayPad$
PUBLIC ?SetKey@@YAXHH@Z ; SetKey
EXTRN __imp__keybd_event@16:PROC
EXTRN __imp__GetKeyboardState@4:PROC
EXTRN ___security_cookie:DWORD
EXTRN @__security_check_cookie@4:PROC
EXTRN @_RTC_CheckStackVars@8:PROC
EXTRN __RTC_CheckEsp:PROC
EXTRN __RTC_Shutdown:PROC
EXTRN __RTC_InitBase:PROC
; COMDAT rtc$TMZ
; File d:\documents and settings\master\desktop\eli asm\cpp\caps\caps\main.cpp
rtc$TMZ SEGMENT
__RTC_Shutdown.rtc$TMZ DD FLAT:__RTC_Shutdown
rtc$TMZ ENDS
; COMDAT rtc$IMZ
rtc$IMZ SEGMENT
__RTC_InitBase.rtc$IMZ DD FLAT:__RTC_InitBase
; Function compile flags: /Odtp /RTCsu /ZI
rtc$IMZ ENDS
; COMDAT ?SetKey@@YAXHH@Z
_TEXT SEGMENT
_keyState$ = -264 ; size = 256
__$ArrayPad$ = -4 ; size = 4
_bState$ = 8 ; size = 4
_keyID$ = 12 ; size = 4
?SetKey@@YAXHH@Z PROC ; SetKey, COMDAT
push ebp
mov ebp, esp
sub esp, 460 ; 000001ccH
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-460]
mov ecx, 115 ; 00000073H
mov eax, -858993460 ; ccccccccH
rep stosd
mov eax, DWORD PTR ___security_cookie
xor eax, ebp
mov DWORD PTR __$ArrayPad$[ebp], eax
mov esi, esp
lea eax, DWORD PTR _keyState$[ebp]
push eax
call DWORD PTR __imp__GetKeyboardState@4
cmp esi, esp
call __RTC_CheckEsp
cmp DWORD PTR _bState$[ebp], 0
je SHORT $LN1@SetKey
mov eax, DWORD PTR _keyID$[ebp]
movzx ecx, BYTE PTR _keyState$[ebp+eax]
and ecx, 1
je SHORT $LN2@SetKey
$LN1@SetKey:
cmp DWORD PTR _bState$[ebp], 0
jne SHORT $LN4@SetKey
mov eax, DWORD PTR _keyID$[ebp]
movzx ecx, BYTE PTR _keyState$[ebp+eax]
and ecx, 1
je SHORT $LN4@SetKey
$LN2@SetKey:
mov esi, esp
push 0
push 1
push 69 ; 00000045H
movzx eax, BYTE PTR _keyID$[ebp]
push eax
call DWORD PTR __imp__keybd_event@16
cmp esi, esp
call __RTC_CheckEsp
mov esi, esp
push 0
push 3
push 69 ; 00000045H
movzx eax, BYTE PTR _keyID$[ebp]
push eax
call DWORD PTR __imp__keybd_event@16
cmp esi, esp
call __RTC_CheckEsp
$LN4@SetKey:
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN8@SetKey
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
pop ebx
mov ecx, DWORD PTR __$ArrayPad$[ebp]
xor ecx, ebp
call @__security_check_cookie@4
add esp, 460 ; 000001ccH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 3
$LN8@SetKey:
DD 1
DD $LN7@SetKey
$LN7@SetKey:
DD -264 ; fffffef8H
DD 256 ; 00000100H
DD $LN6@SetKey
$LN6@SetKey:
DB 107 ; 0000006bH
DB 101 ; 00000065H
DB 121 ; 00000079H
DB 83 ; 00000053H
DB 116 ; 00000074H
DB 97 ; 00000061H
DB 116 ; 00000074H
DB 101 ; 00000065H
DB 0
?SetKey@@YAXHH@Z ENDP ; SetKey
_TEXT ENDS
PUBLIC _main
_TEXT SEGMENT
_i$62694 = -20 ; size = 4
_i$62690 = -8 ; size = 4
_main PROC ; COMDAT
push ebp
mov ebp, esp
sub esp, 216 ; 000000d8H
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-216]
mov ecx, 54 ; 00000036H
mov eax, -858993460 ; ccccccccH
rep stosd
$LN8@main:
mov eax, 1
test eax, eax
je $LN7@main
push 20 ; 00000014H
push 1
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
push 144 ; 00000090H
push 1
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
push 145 ; 00000091H
push 1
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
mov DWORD PTR _i$62690[ebp], 0
jmp SHORT $LN6@main
$LN5@main:
mov eax, DWORD PTR _i$62690[ebp]
add eax, 1
mov DWORD PTR _i$62690[ebp], eax
$LN6@main:
cmp DWORD PTR _i$62690[ebp], 99999999 ; 05f5e0ffH
jge SHORT $LN4@main
jmp SHORT $LN5@main
$LN4@main:
push 20 ; 00000014H
push 0
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
push 144 ; 00000090H
push 0
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
push 145 ; 00000091H
push 0
call ?SetKey@@YAXHH@Z ; SetKey
add esp, 8
mov DWORD PTR _i$62694[ebp], 0
jmp SHORT $LN3@main
$LN2@main:
mov eax, DWORD PTR _i$62694[ebp]
add eax, 1
mov DWORD PTR _i$62694[ebp], eax
$LN3@main:
cmp DWORD PTR _i$62694[ebp], 99999999 ; 05f5e0ffH
jge SHORT $LN1@main
jmp SHORT $LN2@main
$LN1@main:
jmp $LN8@main
$LN7@main:
xor eax, eax
pop edi
pop esi
pop ebx
add esp, 216 ; 000000d8H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
_main ENDP
_TEXT ENDS
END
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|