Wednesday, September 7, 2016

How do you explain the basics of Git in simple words?

While working with code one often finds the strange words used by git version control system e.g. branch, tree, clone, commit etc. Most of the git tutorials and help available is difficult to understand and easily goes over head. This article will explain git in simple words and diagrams that I used myself to understand how git works.

Blob





You will not see the word blob much while working with Git but it is the most basic git data storage. Git stores just the contents of the files for each change which is called Blob in the git terminology.

Hash (e.g. 457AEF93)



The numbers you see are SHA1 hash of contents which identify every object in git, be it a commit, tree, or blob. It is 40 character but only first few characters (10 on Github) are enough to uniquely identify anything. On github you will see a hash with every commit.

Tree (OR Folder OR Directory)




Tree in Git terminology is like Folders or Directories. There is always a Tree on top of your git repository which knows what files (blobs) and folders (trees) it contains as seen in above diagram.
Each tree has a hash and contents info
More details Git Object: tree | GitGuys.com

Commit (OR Snapshot)

Following is an over-simplified diagram of what a commit represents.


A more detailed diagram of commit, tree and blob structure.

Commits can be thought of as snapshots: they know what the trees looked like at one point in time. Each commit has a hash, committer info, time and a comment. If you add edit a file and commit it again, git will save the updated file with all the changes as a new blob and this new commit will contain this whole new blob. Now your git repository have both versions of this file.
More Details Git Object: Git Commit - GitGuys

Check in = Doing a Commit

Check in is simply another name for doing a commit in the repository.

Commit History



If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. So the commits “flow” in one direction only. This flow of commits can be divide into multiple branches.
By default all commits go on master branch, but you can always create more branches. Commits are connect like a linked list where each new node points to previous node unlike simple link list. This gives us the power to create multiple nodes pointing to same previous commit. e.g. in above diagram 3rd and 4th commit both point to 2nd commit hence creating two branches.

Branch (OR Save as)



A branch is a series of commits that can be divided in further branches. Default branch name is master. A branch is actually only a move-able pointer. Initially you’re given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically pointing to the latest commit.
Like real branches, it can be divided into further branches. Pointer of every branch (the name of the branch) will keep moving to the latest commit you make on it. You can work on each branch independently e.g. to work on different versions independently e.g. for Windows XP and Windows 7. Imagine one base Linux with all different flavors as different branches.
You can visualize commits and branches using ‘git show-branch’ command similar to the picture below.


In this picture green, blue, yellow and purple lines are different branches visualized using a software.
More details Creating And Playing With Branches | Git Branch | GitGuys
Also see What a Branch Is for details.


The HEAD in Git is the pointer to the current branch reference, which is in turn a pointer to the last commit you made. It’s generally simplest to think of it as HEAD is the snapshot of your last commit.

Tag (OR Bookmark)



Branches can get complicated, tag is there to save you.** Tag is like a bookmark. **It is created to point to a specific commit anywhere on any branch. Unlike branch e.g. master, which moves forward to point to latest commit, a tag always point to the specified commit.
A tag represents a version of a particular branch at a moment in time.
For more details Git Object: Tag | Git Tag | GitGuys.com
[Source: Git objects: the tag]

Index or Staging Area



The Index is your proposed next commit. It’s basically a loading dock where you get to determine what changes get shipped away. Since the working directory and what gets saved by Git are essentially decoupled, this allows the developer to build up their commits however they want. Since there’s a layer between when Git actually saves the data, you gain a lot more flexibility and control.
More details What is the deal with the Git Index? What is the Git Index? - GitGuys

Checkout



Checking out a commit makes the entire working directory match that commit. This can be used to view an old state of your project without altering your current state in any way. Checking out a file lets you see an old version of that particular file, leaving the rest of your working directory untouched.
[image: http://www.ossxp.com/doc/gotgit-en/

Most of the images and text is taken from [git ready ” learn git one commit at a time] and [Pro Git - Pro Git Book] and blatantly edited and posted by me.
Other sources to learn git the easy way
Aha! Moments When Learning Git
Git documentation and Git tutorials on GitGuys | GitGuys.com

Tuesday, September 6, 2016

ID3D10Device VTable

Recently I got stuck trying to hook some DirectX 10 methods because I could not find index of OMGetRenderTargets. I found these VTables (ID3D10Device and ID3D11DeviceContext) somewhere on the web. Putting these here to save the trouble for someone else.

ID3D10Device VTable (d3d10_1core.dll ID3D10Device)

Index: 0 | QueryInterface
Index: 1 | AddRef
Index: 2 | Release
Index: 3 | VSSetConstantBuffers
Index: 4 | PSSetShaderResources
Index: 5 | PSSetShader
Index: 6 | PSSetSamplers
Index: 7 | VSSetShader
Index: 8 | DrawIndexed
Index: 9 | Draw
Index: 10 | PSSetConstantBuffers
Index: 11 | IASetInputLayout
Index: 12 | IASetVertexBuffers
Index: 13 | D0IASetIndexBuffer
Index: 14 | DrawIndexedInstanced
Index: 15 | DrawInstanced
Index: 16 | GSSetConstantBuffers
Index: 17 | GSSetShader
Index: 18 | IASetPrimitiveTopology
Index: 19 | VSSetShaderResources
Index: 20 | VSSetSamplers
Index: 21 | SetPredication
Index: 22 | GSSetShaderResources
Index: 23 | GSSetSamplers
Index: 24 | OMSetRenderTargets
Index: 25 | OMSetBlendState
Index: 26 | OMSetDepthStencilState
Index: 27 | SOSetTargets
Index: 28 | DrawAuto
Index: 29 | RSSetState
Index: 30 | RSSetViewports
Index: 31 | RSSetScissorRects
Index: 32 | CopySubresourceRegion
Index: 33 | CopyResource
Index: 34 | UpdateSubresource
Index: 35 | ClearRenderTargetView
Index: 36 | ClearDepthStencilView
Index: 37 | GenerateMips
Index: 38 | ResolveSubresource
Index: 39 | DVSGetConstantBuffers
Index: 40 | PSGetShaderResources
Index: 41 | PSGetShader
Index: 42 | PSGetSamplers
Index: 43 | VSGetShader
Index: 44 | PSGetConstantBuffers
Index: 45 | IAGetInputLayout
Index: 46 | IAGetVertexBuffers
Index: 47 | IAGetIndexBuffer
Index: 48 | GSGetConstantBuffers
Index: 49 | GSGetShader
Index: 50 | IAGetPrimitiveTopology
Index: 51 | VSGetShaderResources
Index: 52 | VSGetSamplers
Index: 53 | GetPredication
Index: 54 | GSGetShaderResources
Index: 55 | GSGetSamplers
Index: 56 | OMGetRenderTargets
Index: 57 | OMGetBlendState
Index: 58 | OMGetDepthStencilState
Index: 59 | SOGetTargets
Index: 60 | RSGetState
Index: 61 | RSGetViewports
Index: 62 | RSGetScissorRects
Index: 63 | GetDeviceRemovedReason
Index: 64 | SetExceptionMode
Index: 65 | GetExceptionMode
Index: 66 | GetPrivateData
Index: 67 | SetPrivateData
Index: 68 | SetPrivateDataInterface
Index: 69 | ClearState
Index: 70 | Flush
Index: 71 | CreateBuffer
Index: 72 | CreateTexture1D
Index: 73 | CreateTexture2D
Index: 74 | CreateTexture3D
Index: 75 | CreateShaderResourceView
Index: 76 | CreateRenderTargetView
Index: 77 | CreateDepthStencilView
Index: 78 | CreateInputLayout
Index: 79 | CreateVertexShader
Index: 80 | CreateGeometryShader
Index: 81 | CreateGeometryShaderWithStreamOutput
Index: 82 | CreatePixelShader
Index: 83 | CreateBlendState
Index: 84 | CreateDepthStencilState
Index: 85 | CreateRasterizerState
Index: 86 | CreateSamplerState
Index: 87 | CreateQuery
Index: 88 | CreatePredicate
Index: 89 | CreateCounter
Index: 90 | CheckFormatSupport
Index: 91 | CheckMultisampleQualityLevels
Index: 92 | CheckCounterInfo
Index: 93 | CheckCounter
Index: 94 | GetCreationFlags
Index: 95 | OpenSharedResource
Index: 96 | SetTextFilterSize
Index: 97 | GetTextFilterSize
Index: 98 | CreateShaderResourceView1
Index: 99 | CreateBlendState1
Index: 100 | GetFeatureLevel

ID3D11DeviceContext VTable (d3d11.dll ID3D11DeviceContext)

Index: 0 | QueryInterface
Index: 1 | Addref
Index: 2 | Release
Index: 3 | GetDevice
Index: 4 | GetPrivateData
Index: 5 | SetPrivateData
Index: 6 | SetPrivateDataInterface
Index: 7 | VSSetConstantBuffers
Index: 8 | PSSetShaderResources
Index: 9 | PSSetShader
Index: 10 | SetSamplers
Index: 11 | SetShader
Index: 12 | DrawIndexed
Index: 13 | Draw
Index: 14 | Map
Index: 15 | Unmap
Index: 16 | PSSetConstantBuffer
Index: 17 | IASetInputLayout
Index: 18 | IASetVertexBuffers
Index: 19 | IASetIndexBuffer
Index: 20 | DrawIndexedInstanced
Index: 21 | DrawInstanced
Index: 22 | GSSetConstantBuffers
Index: 23 | GSSetShader
Index: 24 | IASetPrimitiveTopology
Index: 25 | VSSetShaderResources
Index: 26 | VSSetSamplers
Index: 27 | Begin
Index: 28 | End
Index: 29 | GetData
Index: 30 | GSSetPredication
Index: 31 | GSSetShaderResources
Index: 32 | GSSetSamplers
Index: 33 | OMSetRenderTargets
Index: 34 | OMSetRenderTargetsAndUnorderedAccessViews
Index: 35 | OMSetBlendState
Index: 36 | OMSetDepthStencilState
Index: 37 | SOSetTargets
Index: 38 | DrawAuto
Index: 39 | DrawIndexedInstancedIndirect
Index: 40 | DrawInstancedIndirect
Index: 41 | Dispatch
Index: 42 | DispatchIndirect
Index: 43 | RSSetState
Index: 44 | RSSetViewports
Index: 45 | RSSetScissorRects
Index: 46 | CopySubresourceRegion
Index: 47 | CopyResource
Index: 48 | UpdateSubresource
Index: 49 | CopyStructureCount
Index: 50 | ClearRenderTargetView
Index: 51 | ClearUnorderedAccessViewUint
Index: 52 | ClearUnorderedAccessViewFloat
Index: 53 | ClearDepthStencilView
Index: 54 | GenerateMips
Index: 55 | SetResourceMinLOD
Index: 56 | GetResourceMinLOD
Index: 57 | ResolveSubresource
Index: 58 | ExecuteCommandList
Index: 59 | HSSetShaderResources
Index: 60 | HSSetShader
Index: 61 | HSSetSamplers
Index: 62 | HSSetConstantBuffers
Index: 63 | DSSetShaderResources
Index: 64 | DSSetShader
Index: 65 | DSSetSamplers
Index: 66 | DSSetConstantBuffers
Index: 67 | DSSetShaderResources
Index: 68 | CSSetUnorderedAccessViews
Index: 69 | CSSetShader
Index: 70 | CSSetSamplers
Index: 71 | CSSetConstantBuffers
Index: 72 | VSGetConstantBuffers
Index: 73 | PSGetShaderResources
Index: 74 | PSGetShader
Index: 75 | PSGetSamplers
Index: 76 | VSGetShader
Index: 77 | PSGetConstantBuffers
Index: 78 | IAGetInputLayout
Index: 79 | IAGetVertexBuffers
Index: 80 | IAGetIndexBuffer
Index: 81 | GSGetConstantBuffers
Index: 82 | GSGetShader
Index: 83 | IAGetPrimitiveTopology
Index: 84 | VSGetShaderResources
Index: 85 | VSGetSamplers
Index: 86 | GetPredication
Index: 87 | GSGetShaderResources
Index: 88 | GSGetSamplers
Index: 89 | OMGetRenderTargets
Index: 90 | OMGetRenderTargetsAndUnorderedAccessViews
Index: 91 | OMGetBlendState
Index: 92 | OMGetDepthStencilState
Index: 93 | SOGetTargets
Index: 94 | RSGetState
Index: 95 | RSGetViewports
Index: 96 | RSGetScissorRects
Index: 97 | HSGetShaderResources
Index: 98 | HSGetShader
Index: 99 | HSGetSamplers
Index: 100 | HSGetConstantBuffers
Index: 101 | DSGetShaderResources
Index: 102 | DSGetShader
Index: 103 | DSGetSamplers
Index: 104 | DSGetConstantBuffers
Index: 105 | CSGetShaderResources
Index: 106 | CSGetUnorderedAccessViews
Index: 107 | CSGetShader
Index: 108 | CSGetSamplers
Index: 109 | CSGetConstantBuffers
Index: 110 | ClearState
Index: 111 | Flush
Index: 112 | GetType
Index: 113 | GetContextFlags
Index: 114 | FinishCommandList