Tuesday, October 28, 2008

Want to Be a Debugger of Windows

“If anything seems to be impossible in the Win32 world, just write a kernel-mode driver, and it will work out all right!”

It is important to keep in mind that ANSI characters of type CHAR are signed quantities, whereas the Unicode WCHAR is unsigned.

Saturday, September 27, 2008

EPMS BIRT

Monday, September 22, 2008

Some theses to read

A Rate Control Protocol for High Speed Streaming Video

Polar: an efficient finding nearest neighbor algorithm for overlay network

An Adaptive Mixing Audio Gateway in Heterogeneous Networks for ADMIRE System

Admire - A Prototype of Large Scale E-collaboration Platform

A Dynamic Optimal Selective Control Mechanism for Multi-Datastream Security in Video Conference System

Border Media Gateway: Extending Multimedia Multicast Gateway to Support Inter-AS Conferencing

Search "Admire" in IEEE

Sunday, September 21, 2008

Tuesday, September 16, 2008

Subclass and Superclass of Window

1. 子类化
通过GetWindowLongSetWindowLong改变一个窗口实例的窗口函数。子类化所要做的就是为一个窗口实例编写新的窗口函数。其操作是在实例级别上进行的。

2. 超类化
窗口超类化是在窗口类——WNDCLASS或WNDCLASSEX级别进行的改变窗口类特征的。
使用过程:首先获得一个已存在的窗口类,然后设置窗口类,最后注册该窗口类。

3. 总结
  • 子类化是实例级别上的,只要能获得窗口的实例,就可对其子类化。而超类化是在窗口类级别上的,不能用于由Windows创建的窗口。
    例如,对话框上的按钮就不能进行超类化,因为按钮类的名称为BUTTON,对应上述代码中的"Splash",是系统默认设计好的)。
  • 子类化修改窗口过程函数, 超类化修改窗口类。
参考

Inject Code into Another Process

1.将代码放入DLL中,通过windows hooks将DLL映射到远程进程。
在EXE中显式或隐式调用HookDll.dll中的InjectDllInjectDll函数调用SetWindowsHookEx。这时,HookDll.dll被映射到目标进程空间,并且通过HookProc监视并处理目标进程的消息。
由于HookDll.dll同时映射到了EXE和远程进程,所以可用通过共享数据区或其它方式进行通信。
以下为HookDll.dll源代码。

HookProc与窗口过程的区别?
DLL的物理地址相同?


2.将代码放入EXE中,通过使用CreateRemoteThread和LoadLibrary将DLL映射到远程进程。

The Execution of Switch and Case

switch和case语句只是选择入口,直至执行到switch结尾或遇到break.

MSDN:
Execution of the statement body begins at the selected statement and proceeds until the end of the body or until a break statement transfers control out of the body.

Monday, September 15, 2008

Create Dialog-based Win32 Application

1. 创建空win32工程
打开[File]--[New]--[Project...],单击[Next]后如图所示,选择Empty Project后单击[Finished].
2. 添加资源
打开[Project]--[Add New Items...].输入Name后,单击[Add].
在Resource View窗口中找到对应资源,右键单击,选择[Add Resources...]然后选择Dialog类型,并在ID属性中填入IDD_DIALOG
3. 添加代码

Use Syntax Highlighter in Blogspot

1. 下载Syntax Highlighter
SyntaxHighlighter_1.5.1.rar

2. 解压后,将Syntax Highlighter上传到网络空间
将Styles目录和Scripts目录下的所有文件上传到网络空间的同一目录下。

3. 在Layout--Edit HTML中添加如下内容
代码放在</body></html>前面。

Tuesday, August 26, 2008

Battlefront Tutorial Lesson

To follow along you'll need to download the Battlefront Tutorial Scenario from the SSG Scenario Download area.

Lesson #1 simply requires you to open the tutorial scenario. Subsequent Lessons will have save game files posted for use.

Let's start by looking at the two main unit displays. These are two basic examples. Examples of units will more capabilities (i.e. more stuff to explain) will be provided as a reference in a subsequent post.

Right click pop up on hex (21, 62)...

Next click on the unit icon to select the stack in hex (21, 62)...

Let's take a look at an elite quality tank unit.

-- Note how equipment type shows a heavy tank image and the movement type shows a tracked vehicle. Equipment type is a visual for the player; movement type affects movement costs based on the game's terrain values.

-- Also note in the replacement circle note that there is a tank symbol now (instead of a soldier). There are only these two types of regular replacements possible in the game.

Next let's do a 2-for-1... Engineer unit loaded into amphibious transport mode:

***********VICTORY POINT OBJECTIVES ***********

There are three ways to earn victory points (and the side with the most victory points wins the game!):

1. Destroy units
2. Capture Victory Point Objectives (Note: A side can only “capture” a VP objective that it does not control at the start of the game… capture only gives victory points once).
3. Control Victory Point Objectives

Finding the Victory Point Objectives.

There’s two easy ways to find the VP Objectives:

1. Use the “u” (units visible) hotkey to remove all units from view (they return to view by pressing “u” hotkey again).

Next use the “i” (VP indicator visible) hotkey to display the VP indicators. There are three settings to the “i” hotkey: all indicators, important indicators, no indicators.

Finally use the “c” (city name visible) hotkey to display the town names associated with the objectives. The town names are color coded to indicate side control (blue indicates Axis control, Orange is Allied control). Town names also have three hotkey settings: all, important, none.

Here’s a look at all the VP objectives in the tutorial.

Northern Map Area:
Central Map Area:

Southern Map Area:
Now let’s take a look at a specific VP Objective hex (5, 64), the Embassy Square. This is firmly in Blueland (Axis) Control so only the Axis side is gaining points for control at this point.

A right click pop up on the hex reveals that there is separate info on the VP Objective for the Axis and the Allies. Moving the mouse pointer over each side’s indicator provides details.
2. The second way (& quickest!) to identify the objectives is to use the F9 hotkey. The VP Objective hexes become shaded and display the points available to each side in the hexes.
***********SUPPLY SOURCES ***********

Knowing where your supply sources are located is critical to success in the game. Supply sources can be map edge, supply depot (dump) on the map, airdrop dump, or invasion beach source. Typically invasion beach sources don’t work for a turn or two after you control the hex they’re located in…

Here’s a quick look at the supply sources available to the Axis in the Southern map area.
Right clicking on hex (1, 59) shows that there is an Axis supply source located there.
Ending the Axis turn brings up the Allied turn 1. The picture below shows where the Allies have four invasion beach supply sources that are inactive (waiting for the Allies to land and take control of the hexes).
The Allies have 8 standard on map supply depots.
Finally, the Allies start in control of two special supply depots… the Oilwell Fields. These supply depots will operate for both sides (provides supply to the side controlling the VP Objective hex that they’re located in).
To follow along here, start up a game of the tutorial scenario. It will open to turn 1 on the Axis side (player 1 turn).

***********Unit Arrivals ***********

There are three ways units arrive during a game.
1. Arrival Hexes
2. Off Map Area (OMA) Placement (Note: Reborn destroyed units return to game via this method.)
3. Airborne Dropzones This method will be covered in a subsequent lesson.

Arrival Hexes

This are easy to locate. Here’s a quick overview:

1. Use the “u” (units visible) hotkey to remove all units from view (they return to view by pressing “u” hotkey again).

2. Here’s a look at a couple of arrival hex locations.

Right click on Axis hex (21, 62)…
Move the mouse curser over the arrival hex indicator as shown here:
This reveals that there is one unit arriving on the next turn (units arrive automatically at the beginning of your turn).
Note the green highlight around the indicator square. That tells you the hex is due to have arrivals next turn. The only ways that the unit will not arrive next turn is if the enemy gets control of hexes near (or captures!) the arrival hex OR if you leave too many units stacked in the hex… an arriving unit is subject to hex stacking limits… too many units present and arrivals will be delayed until the hex is not stacked to the limit at the beginning of a turn.

You also can (sometimes) see enemy arrival hex schedule. Right click on hex (40, 28). You get similar info to what you saw on the Axis unit above.
***********OFF MAP AREA (OMA) ***********

The second way units can arrive is via the Off Map Area (OMA) arrival process. Here the player specifies which of several possible arrival locations a unit shows up at.

The Allied player in the tutorial has active OMA arrivals so let’s end the Axis turn and start up Allied turn 1. Note you get a reminder that some actions were still available to the Axis player. Click OK and go to Allied player turn. Make sure you have Redland as the active Allied country (Neutral Red Islands is the other Allied country).
Along the right hand side of the map you should see nine small green hexagons. These indicate OMA arrival locations (seven of them are shown below).
Click on the open OMA screen button.

You can see there are three types of OMA arrivals: Alert, standard, & reinforcements. Click on Alert (there are no units listed under standard & reinforcements). OMA boxes 2, 3, & 4 are active for the Allies (box 11 is inactive in this scenario so disregard). Axis has OMA boxes 7, 8, & 9 active (but you cannot gain any info on the enemy side here…besides the location of their OMA arrival hexes).

Click anywhere in box 4… and you see the three possible OMA arrival hexes for this box. All OMA boxes should have three possible OMA arrival hexes associated with them.
Note how boxes 2 & 3 have the Amphibious Transport Mode symbol in the three hexes next to them. All units arriving in these OMA arrival hexes will be in amphibious transport movement mode. Now click on box 2 or 3. You see the possible locations for arrivals. Note how the possible landing beaches are also highlighted in red!
No units can be arrived now so let’s end this view and return to the main game screen.

***********STRONGPOINTS AND MINEFIELDS ***********

The final section of lesson one is on strongpoints and minefields.

Strongpoints

These are static, non-unit, items on the battlefield.

- They must always be attacked and cleared before any units in the same hex can be attacked.
- They stop enemy movement into the hex until they are destroyed. This also means they maintain control of the hex in question until destroyed by enemy.
- They do not return when destroyed (permanent destruction).
- They can be worth destroyed unit VPs.
- They do NOT count toward the hex stacking limit.
- They can independently provide supply to units in the hex.
- They always require double dice to clear with indirect fire.
- They are always sited by the enemy (distance away from enemy and terrain they are located in don’t apply for siting of strongpoints).
- When attacked they use their own CRT to resolve combat odds (independent of the terrain they are located in).
- They cannot receive regular replacements to rebuild (although some use auto-timed replacements to rebuild).
- Only one strongpoint can be in a hex. No double & triple stacking these.
- Some are in place at start of game, some can be placed by a player as the game progresses (if they are available to place).
- When available to player to place, they are use-or-lose. No building up a backlog. Must be placed during turn available.

To see some strongpoints, have all units not visible (u hotkey) and all VP Objective indicators turned off (i hotkey).

You should see something like the following (Axis strongpoints are highlighted by red squares):
Right click on hex (12, 55). Move mouse over the strongpoint icon shown.
Here you can see a two step strongpoint.

- Defense value of 5 with two steps… defense value drops to 3 when only one of the two steps is present.
- This strongpoint provides supply to the hex. It does not allow regular replacements to be used based on this supply.
- This strongpoint only takes 1 turn to auto-repair the second step.

Minefields

Minefields are conditions imposed on a given hex. They are not units, nor an item that can be attacked like a strongpoint. They are more akin to river hex sides or bridges.

- You can clear enemy minefields by controlling the hex.
- Some are present at the start of a game, some are placed by player. Like strongpoints they are use-or-lose assets when available.
- Minefields inhibit enemy movement and supply distribution.
- They also inhibit attacks (unit attacking out of an enemy minefield loses an important tactical combat shift opportunity.)
- They also making defending in an enemy minefield a very dangerous situation (enemy attack will be more effective).

Here’s the process for placing them:

1. Select available asset. Note how legal placement hexes are clear and illegal placement hexes are shaded.
2. To place simply move to desired hex and click the minefield into place.
Lesson #2 Part 1: Move out!

To follow along here, start up a new game of the tutorial scenario. It will open to turn 1 on the Axis side (player 1 turn).

***********Amphibious Invasion ***********

No messing around here. Let’s get to the good part!

Amphibious Movement & Landings

Select I battalion of 6 Marine Regiment in hex (13, 53) by clicking on the stack of units in that hex. I/6 Marine Regiment starts the game in amphibious movement mode. Once landed ashore, the unit reverts to its normal leg movement type.

Notice how the sea lanes become highlighted when the unit is selected. This shows where the unit can move to this turn.
Let’s move 6 Marine Regiment to a landing beach. In Battlefront only one unit can move at a time. So we’ll start with I/6 Marines.

Move the mouse cursor. It will show a green running man when over a possible movement location and a red slashed circle when the cursor is over a hex the unit cannot move to.
Move the mouse cursor to hex (19, 31).
Click and hold on hex (19, 31). Note how a path of green arrows shows the auto path from starting location to hex (19, 31). If you move the cursor (while still holding the click) you can see how many movement points will remain after moving to hex (19, 31).
Now, with the cursor over hex (19, 31) release the click. The unit will auto move. Note that it still has movement capability left (we won’t use it as we’ve reached the landing spot).
Now move the other two units of 6 Marine Regiment to the same beach as I/6 Marines.
Here’s a quick rundown on regimental integrity. Notice that we’ve left the supporting engineer unit behind…
Let’s find the engineers! Too easy. Click on the engineer icon in the regimental integrity display.
There they are…
Let’s get them to the beach and begin the amphibious landings. They are already selected so move the mouse cursor to hex (19, 31) and click there to move the engineers. Notice how the display changes after moving the units.
You can see that the engineers are now receiving the regimental integrity bonus and that there are now two units of the regimental integrity group in hex (19, 31). What about that black die? Looks a little ominous… means that there is a 33% chance that one step of the unit will be a casualty on landing. There can be up to four black dice present for a four step unit trying to come ashore. Each die is rolled independently for a landing.

Time to land the regiment. Click on the anchor to land the unit.
Results may be different for you, but my engineers took it on the chin… landing craft overturned, well aimed machine gun fire, and Marines disembarking too soon and sinking in deep water…
In the image above, note how one of the four green dots below the engineer symbol in the regimental integrity display turned red… more instant info on how strong the regimental group is!. The dotted bar below the units shows the number steps for the unit... green means step in place and red means the step has been lost.

You can see that the unit now has 8 leg movement OP’s… but cannot use extended movement (double arrows made less distinct). In the main map area you can see which hexes the engineers can reach this turn with the 8 available movement OP’s.

Repeat the landing process for the three naval infantry battalions. Note how the unit in hex (19, 30)… closest to visible enemy has to undergo two black dice to land, while the unit furthest away from enemy in hex (19, 32) doesn’t have to mess around with any black dice! Landing attrition is based on how many enemy steps are within the landing area. The purple 4 tells you how many hexes away enemy units can be present to cause the dreaded black die… more enemy present, more black dice that must be dealt with… one good thing is that the max number of black dice equals the units number of steps present (only one black die per step).
Let’s leave those four units on the beach for now. We’ll come back to them in a little bit.

Select the 1st Special Service Regiment in hex (6, 46). We’ll use it to take the Oilwell Field 3 (VP Objective).
Move each battalion so that three sides of the VP Objective have 1st Special Service Regiment units next to them. Land the three battalions.
Close Combat!

Close combat takes place by attacking from adjacent hexsides. The more hexsides you attack from, generally speaking, the better. Select one of the battalions and move it over the defending unit. You’ll see opposing arrows. Close combat is possible!
Click on the defending unit to open the close combat screen.
Wow. Lotta stuff going on here… Let’s break it down.
One battalion attacking alone won’t get the job done here. Let’s throw in the other two. You can select the other attacking hexes by clicking on the stack visible on the map or by clicking on the colored rosette at the bottom right of screen.

With all three units attacking things look pretty good. 67% chance of taking out the defending two step unit (4 of 6 CRT lines have a D2 result). Hmmm, 1/3 chance of the defenders surviving and likely retreating to another area of the oilwell field (DR means the defending stack will retreat).
Not what we want here. So our choices are throw more units and attack from another hexside OR since we have 4 special attacks available let’s see what one of these does…click on the button below Attack!. This will get the job done right the first time.
Now click on the execute close combat button to resolve combat.
Results will be different based on random die generator result. Mine was a 1 die for combat (green die) and a 5 die for retreat (red die).
Defenders are now gone. Notice that none of the three units of 1 Special Service Regiment has enough movement Ops available to move into the VP Objective hex. Now that we’ve taken it, let’s secure it properly. Move III battalion of 2 Special Service Regiment into the VP Objective and conduct amphibious landing there. I & II battalions of 2 Special Service Regiment can be moved into attack position next to the other Oilwell objective.
Your game should look something like this now. Note that I & II battalions of 2 Special Service Regiment are receiving the regimental integrity bonus even though III battalion is outside the radius (very different concept from the Decisive Battles series).
That’s enough for this part. Let’s save your progress now. Click on the save game button.
This brings up the save game menu. Click in the file name box as shown below and type in the save game file name you wish to use.
Once you’ve typed the file name, hit Enter on your keyboard to bring up the save file option and save the game.