Skip to content

Commit

Permalink
Support setting demo/.AVI file names via Drag and Drop; some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rygorous committed Oct 26, 2010
1 parent adca1df commit ef6cb5a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
65 changes: 49 additions & 16 deletions kkapture/kkapture.cpp
Expand Up @@ -32,7 +32,7 @@
#pragma comment(lib,"vfw32.lib")
#pragma comment(lib,"msacm32.lib")

#define COUNTOF(x) (sizeof(x)*sizeof*(x))
#define COUNTOF(x) (sizeof(x)/sizeof(*x))

static const TCHAR RegistryKeyName[] = _T("Software\\Farbrausch\\kkapture");
static const int MAX_ARGS = _MAX_PATH*2;
Expand Down Expand Up @@ -215,6 +215,50 @@ static bool ParsePositiveRational(const TCHAR *buffer,int &num,int &denom)
return false;
}

static void SetDefaultAVIName(HWND hWndDlg)
{
// set demo .avi file name if not yet set
TCHAR drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT],path[_MAX_PATH];
int nChars = GetDlgItemText(hWndDlg,IDC_TARGET,fname,_MAX_FNAME);
if(!nChars)
{
GetDlgItemText(hWndDlg,IDC_DEMO,path,COUNTOF(path));
_tsplitpath(path,drive,dir,fname,ext);
_tmakepath(path,drive,dir,fname,_T(".avi"));
SetDlgItemText(hWndDlg,IDC_TARGET,path);
}
}

static LRESULT CALLBACK EditBoxSubProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
TCHAR buffer[_MAX_PATH];
WNDPROC chain = (WNDPROC) GetWindowLongPtr(hWnd,GWLP_USERDATA);
HDROP drop;

switch (msg)
{
case WM_DROPFILES:
drop = (HDROP) wParam;
if(DragQueryFile(drop,0,buffer,COUNTOF(buffer)))
{
SetWindowTextA(hWnd,buffer);
if(GetWindowLongPtr(hWnd,GWLP_ID) == IDC_DEMO)
SetDefaultAVIName(GetParent(hWnd));
}
DragFinish(drop);
return 0;
}

return CallWindowProc(chain,hWnd,msg,wParam,lParam);
}

static void EditBoxEnableDragDrop(HWND hWnd)
{
LONG_PTR oldproc = SetWindowLongPtr(hWnd,GWLP_WNDPROC,(LONG_PTR) EditBoxSubProc);
SetWindowLongPtr(hWnd,GWLP_USERDATA,oldproc);
DragAcceptFiles(hWnd,TRUE);
}

static INT_PTR CALLBACK MainDialogProc(HWND hWndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
Expand All @@ -234,7 +278,6 @@ static INT_PTR CALLBACK MainDialogProc(HWND hWndDlg,UINT uMsg,WPARAM wParam,LPAR
// set gui values
TCHAR buffer[32];
FormatRational(buffer,32,Params.FrameRateNum,Params.FrameRateDenom);
//_stprintf(buffer,"%d.%02d",Params.FrameRate/100,Params.FrameRate%100);
SetDlgItemText(hWndDlg,IDC_FRAMERATE,buffer);

_stprintf(buffer,"%d.%02d",Params.FirstFrameTimeout/1000,(Params.FirstFrameTimeout/10)%100);
Expand Down Expand Up @@ -266,6 +309,9 @@ static INT_PTR CALLBACK MainDialogProc(HWND hWndDlg,UINT uMsg,WPARAM wParam,LPAR
CheckDlgButton(hWndDlg,IDC_CAPTUREGDI,Params.EnableGDICapture ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWndDlg,IDC_VIRTFRAMEBUF,Params.VirtualFramebuffer ? BST_CHECKED : BST_UNCHECKED);

EditBoxEnableDragDrop(GetDlgItem(hWndDlg,IDC_DEMO));
EditBoxEnableDragDrop(GetDlgItem(hWndDlg,IDC_TARGET));

HIC codec = ICOpen(ICTYPE_VIDEO,Params.VideoCodec,ICMODE_QUERY);
SetVideoCodecInfo(hWndDlg,codec);
ICClose(codec);
Expand Down Expand Up @@ -374,16 +420,7 @@ static INT_PTR CALLBACK MainDialogProc(HWND hWndDlg,UINT uMsg,WPARAM wParam,LPAR
if(GetOpenFileName(&ofn))
{
SetDlgItemText(hWndDlg,IDC_DEMO,ofn.lpstrFile);

// also set demo .avi file name if not yet set
TCHAR drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT],path[_MAX_PATH];
int nChars = GetDlgItemText(hWndDlg,IDC_TARGET,fname,_MAX_FNAME);
if(!nChars)
{
_tsplitpath(ofn.lpstrFile,drive,dir,fname,ext);
_tmakepath(path,drive,dir,fname,_T(".avi"));
SetDlgItemText(hWndDlg,IDC_TARGET,path);
}
SetDefaultAVIName(hWndDlg);
}
}
return TRUE;
Expand Down Expand Up @@ -520,10 +557,6 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,i
ErrorMsg(_T("Startup instrumentation failed"));
break;

case ERR_COULDNT_FIND_ENTRY_POINT:
ErrorMsg(_T("Couldn't determine entry point!"));
break;

case ERR_COULDNT_EXECUTE:
ErrorMsg(_T("Couldn't execute target process"));
break;
Expand Down
1 change: 0 additions & 1 deletion kkapturedll/intercept.h
Expand Up @@ -33,7 +33,6 @@ enum ErrorCodes
{
ERR_OK = 0,
ERR_INSTRUMENTATION_FAILED,
ERR_COULDNT_FIND_ENTRY_POINT,
ERR_COULDNT_EXECUTE
};

Expand Down
6 changes: 0 additions & 6 deletions kkapturedll/sound.cpp
Expand Up @@ -1704,12 +1704,6 @@ static void initSoundsysFMODEx()
HookDLLFunction(&Real_System_playSound,fmodDll,"?playSound@System@FMOD@@QAG?AW4FMOD_RESULT@@W4FMOD_CHANNELINDEX@@PAVSound@2@_NPAPAVChannel@2@@Z",Mine_System_playSound);
GetDLLFunction(&Real_Channel_getFrequency,fmodDll,"?getFrequency@Channel@FMOD@@QAG?AW4FMOD_RESULT@@PAM@Z");
HookDLLFunction(&Real_Channel_getPosition,fmodDll,"?getPosition@Channel@FMOD@@QAG?AW4FMOD_RESULT@@PAII@Z",Mine_Channel_getPosition);

//Real_System_init = (PSYSTEM_INIT) DetourFunction((PBYTE) GetProcAddress(fmodDll,),(PBYTE) Mine_System_init);
//Real_System_setOutput = (PSYSTEM_SETOUTPUT) GetProcAddress(fmodDll,"?setOutput@System@FMOD@@QAG?AW4FMOD_RESULT@@W4FMOD_OUTPUTTYPE@@@Z");
//Real_System_playSound = (PSYSTEM_PLAYSOUND) DetourFunction((PBYTE) GetProcAddress(fmodDll,"?playSound@System@FMOD@@QAG?AW4FMOD_RESULT@@W4FMOD_CHANNELINDEX@@PAVSound@2@_NPAPAVChannel@2@@Z"),(PBYTE) Mine_System_playSound);
//Real_Channel_getFrequency = (PCHANNEL_GETFREQUENCY) GetProcAddress(fmodDll,"?getFrequency@Channel@FMOD@@QAG?AW4FMOD_RESULT@@PAM@Z");
//Real_Channel_getPosition = (PCHANNEL_GETPOSITION) DetourFunction((PBYTE) GetProcAddress(fmodDll,"?getPosition@Channel@FMOD@@QAG?AW4FMOD_RESULT@@PAII@Z"),(PBYTE) Mine_Channel_getPosition);
}
}
}
Expand Down

0 comments on commit ef6cb5a

Please sign in to comment.