This is all there is to it in a task form. The current list item is in the task list and contains the workflow listid and item id.
SPListItem currentListItem = SPContext.Current.ListItem;
if (currentListItem != null)
{
object wfListId = currentListItem["ows_WorkflowListId"];
object wfItemId = currentListItem["ows_WorkflowItemId"];
}