KcProductionz 30 Posted July 20, 2008 Originally posted here Here is the source code to my command engine I developed for another project Im working on. Right now its patch's and everything are for starcraft but could be easily ported to wc, or any other game. Please give credit where credit is due. It's very easy to use, in your initialization code just put a invoke CommandEngine_NewCmd, addr CommandProc,CTEXT("moneyhax"),2 and whenever someone types and enters /moneyhax with two paremeters (or however many parameters you specify, but in this example I put it to two) it will call CommandEngine_NewCmd with those two arguments pushed onto the stack. Here is what the CommandProc proc would look like. CommandProc proc money:DWORD,gas:DWORD mov [YourMineralAddress],money mov [YourGasAddress],gas ret CommandProc endp And here is the actual source code to the commandengine. ;Uses functions from the masm32.asm file, htodw and atodw ;Functions: ; ; DWORD CommandEngine_NewCmd cbCallback:DWORD,lpCmdName:DWORD,iArgCount:DWORD ; the returned valued can be used with the CommandEngine_DeleteCmd to remove the ; command. ; ; DWORD CommandEngine_DeleteCmd cmdHandle:DWORD ; removes the cmdHandle command from the list Command_Struct struct next dd ? prev dd ? callback dd ? cmd db 16 dup (?) args dd ? Command_Struct ends .data CommandEngine_CmdFirst dd 0 CommandEngine_CmdLast dd 0 .data? CommandEngine_CmdCount dd ? CommandEngine_hHeap dd ? .code CommandEngine_NewCmd proc callback:DWORD,cmd:DWORD,args:DWORD LOCAL newObj:Dword pushad revoke newObj,HeapAlloc,CommandEngine_hHeap,HEAP_ZERO_MEMORY,sizeof Command_Struct .if newObj!=0 && cmd!=0 && callback assume edi:ptr Command_Struct inc CommandEngine_CmdCount .if CommandEngine_CmdFirst==0 mmv CommandEngine_CmdFirst,eax,newObj mmv CommandEngine_CmdLast,eax,newObj .else mov edi, CommandEngine_CmdLast mmv [edi].next,eax,newObj mov edi,newObj mmv [edi].prev,eax,CommandEngine_CmdLast mmv CommandEngine_CmdLast,eax,newObj .endif mov edi,newObj mmv [edi].callback,ebx,callback mmv [edi].args,ebx,args lea ebx,[edi].cmd invoke lstrcpyn,ebx,cmd,15 assume edi:Nothing .endif popad mov eax,newObj ret CommandEngine_NewCmd endp CommandEngine_DeleteCmd proc cmd:DWORD .if cmd!=0 pushad dec CommandEngine_CmdCount .if CommandEngine_CmdCount==0 mov CommandEngine_CmdFirst,0 mov CommandEngine_CmdLast,0 .else mov eax,CommandEngine_CmdFirst mov ebx,CommandEngine_CmdLast assume edi:ptr Command_Struct mov edi,cmd .if cmd==eax mov eax,[edi].next mov CommandEngine_CmdFirst,eax mov edi,eax mov [edi].prev,0 .elseif cmd==ebx mov eax,[edi].prev mov CommandEngine_CmdLast,eax mov edi,eax mov [edi].next,0 .else mov eax,[edi].prev mov ebx,[edi].next mov edi,eax mov [edi].next,ebx mov edi,ebx mov [edi].prev,eax .endif assume edi:Nothing .endif invoke HeapFree, CommandEngine_hHeap,0,cmd popad .endif ret CommandEngine_DeleteCmd endp CommandEngine_CommandSent proc string:DWORD LOCAL cmd[16]:BYTE LOCAL argbuff[33]:byte LOCAL args:DWORD LOCAL cbCalled:DWORD pushad mov args,0 mov cbCalled,0 mov esi,string .if byte ptr [esi]=="/" && byte ptr [esi+1]!=" " mov ebx,string inc ebx invoke GetWord,ebx,0," ",addr cmd,16;Get the Command .if eax!=-1 invoke GetWordCount,string mov ebx,eax dec ebx;Dont include the cmd itself in the argument count mov args,ebx .if eax!=-1 assume edi:ptr Command_Struct mov edi,CommandEngine_CmdFirst .while edi!=0 lea ebx,[edi].cmd push edi invoke lstrcmpi,ebx,addr cmd pop edi mov ebx,args .if eax==0 && ebx==[edi].args .if [edi].callback!=0 mov ebx,args .while ebx>0;Push the args onto the stack invoke GetWord,string,ebx," ",addr argbuff,32 lea ecx,argbuff xor eax,eax .if byte ptr [ecx]=="x";Is it a hex number? inc ecx invoke htodw,ecx .else;Its not a hex, so its a dec invoke atodw,ecx .endif push eax;Push the argument onto the stack dec ebx .endw call [edi].callback .endif mov cbCalled,1 .break .endif mov edi,[edi].next .endw assume edi:Nothing .endif .endif .endif popad mov eax,cbCalled ret CommandEngine_CommandSent endp CommandEngine_LANandOnlineandSinglePlayer proc invoke CommandEngine_CommandSent,edx .if eax==1 add esp,12 mov eax,004F2FFCh jmp eax .endif mov eax,0041008Eh call eax mov ecx,4F2FA2h jmp ecx CommandEngine_LANandOnlineandSinglePlayer endp CommandEngine_DoPatchs proc revoke CommandEngine_hHeap,HeapCreate,0,10000,0 .if CommandEngine_hHeap==0 invoke MessageBox,0,CTXT("Couldnt not create the heap!"),CTXT("Error!"),MB_ICONERROR .endif invoke ProcPatch,004F2F9Dh,addr CommandEngine_LANandOnlineandSinglePlayer,0e9h ret CommandEngine_DoPatchs endp Share this post Link to post